コード例 #1
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t verifyWeight(hasp_handle_t handle, byte tagNo, boolean isActive, const byte *signedWeight, unsigned char signedWeightLen, bool *result)
{
  hasp_status_t status;
  unsigned char iobuffer[256];
  VM_IO_BUFFER_T iobuffer_cxt;
  hasp_size_t iolength = 0;
  hasp_u32_t vm_returncode = 0;

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the verification fails */
  *result = false;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_byte_array(&iobuffer_cxt, (byte *)signedWeight, signedWeightLen);

  iolength = iobuffer_cxt.cmdSize;

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_verifyWeight, iobuffer, &iolength, &vm_returncode);
  if (status != HASP_STATUS_OK) return status;

  *result = (vm_returncode != 0);

  return HASP_STATUS_OK;

} /* verifyWeight */
コード例 #2
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t updateConsumption(hasp_handle_t handle, uint8_t tagNo, int isActive, int consumption, uint8_t *random, int *result)
{
  hasp_status_t status;
  unsigned char iobuffer[256];
  VM_IO_BUFFER_T iobuffer_cxt;
  hasp_size_t iolength = 0;
  hasp_u32_t vm_returncode = 0;
  int returnValue = 0; /* false */

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the consumption update fails */
  *result = 0 /* false */;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_int(&iobuffer_cxt, consumption);
  put_byte_array(&iobuffer_cxt, random, 8);

  /* iolength = iobuffer_cxt.cmdSize; */
  iolength = sizeof(iobuffer);

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_updateConsumption, iobuffer, &iolength, &vm_returncode);

  if (status != HASP_STATUS_OK)
  {
#ifdef DEBUG
    printf("hasp_vm_invoke(updateConsumption) failed with status: %d\n", status);

    if (status == HASP_VM_METHOD_EXCEPTION_OCCUR)
      printf("exception code is %d, exception info is: %s\n", vm_returncode, iobuffer);
#endif

    return status;
  }

  returnValue = (vm_returncode != 0);

  if (returnValue)
  {
    /* fetch random output parameter */
    get_byte_array(&iobuffer_cxt, random, 8);
  }

  *result = returnValue;

  return status;

} /* updateConsumption */
コード例 #3
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t verifyTag(hasp_handle_t handle, uint8_t tagNo, int isActive, const uint8_t *certificate, unsigned char certificateLen, uint8_t *random, int *result)
{
  hasp_status_t status;              /* AoC API return code */
  unsigned char iobuffer[256];       /* AoC API input/output buffer */
  VM_IO_BUFFER_T iobuffer_cxt;       /* AoC API input/output structure */
  hasp_size_t iolength = 0;          /* AoC API input/output buffer length */
  hasp_u32_t vm_returncode = 0;      /* AoC API return value */

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the verification fails */
  *result = 0 /* false */;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_byte_array(&iobuffer_cxt, (uint8_t *)certificate, certificateLen);
  put_byte_array(&iobuffer_cxt, random, 8);

  /* iolength = iobuffer_cxt.cmdSize; */
  iolength = sizeof(iobuffer);

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_verifyTag, iobuffer, &iolength, &vm_returncode);
  if (status != HASP_STATUS_OK)
  {
#ifdef DEBUG
    printf("hasp_vm_invoke(verifyTag) failed with status: %d\n", status);

    if (status == HASP_VM_METHOD_EXCEPTION_OCCUR)
      printf("exception code is %d, exception info is: %s\n", vm_returncode, iobuffer);
#endif

    return status;
  }

  if (vm_returncode == 1)
  {
    /* fetch random output parameter */
    get_byte_array(&iobuffer_cxt, random, 8);
  }

  *result = vm_returncode;

  return status;

} /* verifyTag */
コード例 #4
0
ファイル: ssh2connection-server.c プロジェクト: gdh1995/putty
void ssh2channel_send_exit_signal_numeric(
    SshChannel *sc, int signum, bool core_dumped, ptrlen msg)
{
    struct ssh2_channel *c = container_of(sc, struct ssh2_channel, sc);
    struct ssh2_connection_state *s = c->connlayer;

    PktOut *pktout = ssh2_chanreq_init(c, "exit-signal", NULL, NULL);
    put_uint32(pktout, signum);
    put_bool(pktout, core_dumped);
    put_stringpl(pktout, msg);
    put_stringz(pktout, "");           /* language tag */

    pq_push(s->ppl.out_pq, pktout);
}
コード例 #5
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t verifyWeight(hasp_handle_t handle, uint8_t tagNo, int isActive, const uint8_t *signedWeight, unsigned char signedWeightLen, int *result)
{
  hasp_status_t status;
  unsigned char iobuffer[256];
  VM_IO_BUFFER_T iobuffer_cxt;
  hasp_size_t iolength = 0;
  hasp_u32_t vm_returncode = 0;

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the verification fails */
  *result = 0 /* false */;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_byte_array(&iobuffer_cxt, (uint8_t *)signedWeight, signedWeightLen);

  /* iolength = iobuffer_cxt.cmdSize; */
  iolength = sizeof(iobuffer);

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_verifyWeight, iobuffer, &iolength, &vm_returncode);
  if (status != HASP_STATUS_OK)
  {
#ifdef DEBUG
    printf("hasp_vm_invoke(verifyWeight) failed with status: %d\n", status);

    if (status == HASP_VM_METHOD_EXCEPTION_OCCUR)
      printf("exception code is %d, exception info is: %s\n", vm_returncode, iobuffer);
#endif

    return status;
  }

  *result = vm_returncode; // (vm_returncode != 0);

  return status;

} /* verifyWeight */
コード例 #6
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t verifyTag(hasp_handle_t handle, byte tagNo, bool isActive, const byte *certificate, unsigned char certificateLen, byte *random, bool *result)
{
  hasp_status_t status;              /* AoC API return code */
  unsigned char iobuffer[256];       /* AoC API input/output buffer */
  VM_IO_BUFFER_T iobuffer_cxt;       /* AoC API input/output structure */
  hasp_size_t iolength = 0;          /* AoC API input/output buffer length */
  hasp_u32_t vm_returncode = 0;      /* AoC API return value */
  bool returnValue = false;          /* bool return value */

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the verification fails */
  *result = false;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_byte_array(&iobuffer_cxt, (byte *)certificate, certificateLen);
  put_byte_array(&iobuffer_cxt, random, 8);

  iolength = iobuffer_cxt.cmdSize;

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_verifyTag, iobuffer, &iolength, &vm_returncode);
  if (status != HASP_STATUS_OK) return status;

  returnValue = (vm_returncode != 0);

  if (returnValue)
  {
    /* fetch random output parameter */
    get_byte_array(&iobuffer_cxt, random, 8);
  }

  *result = returnValue;

  return HASP_STATUS_OK;

} /* verifyTag */
コード例 #7
0
ファイル: REDApp_utils.c プロジェクト: SlavaC1/ControlSW
hasp_status_t updateConsumption(hasp_handle_t handle, byte tagNo, bool isActive, int consumption, byte *random, bool *result)
{
  hasp_status_t status;
  unsigned char iobuffer[256];
  VM_IO_BUFFER_T iobuffer_cxt;
  hasp_size_t iolength = 0;
  hasp_u32_t vm_returncode = 0;
  bool returnValue = false;

  /* initialize arrays and structs */
  memset(iobuffer, 0, sizeof(iobuffer));
  memset(&iobuffer_cxt, 0, sizeof(iobuffer_cxt));

  /* assume that the consumption update fails */
  *result = false;

  /* prepare Aoc API input buffer */
  iobuffer_cxt.cmdBuff = iobuffer;
  iobuffer_cxt.rspBuff = iobuffer;

  put_byte(&iobuffer_cxt, tagNo);
  put_bool(&iobuffer_cxt, isActive);
  put_int(&iobuffer_cxt, consumption);
  put_byte_array(&iobuffer_cxt, random, 8);

  iolength = iobuffer_cxt.cmdSize;

  /* invoke the method of VM resource */
  status = hasp_vm_invoke(handle, REDAppMethodId_updateConsumption, iobuffer, &iolength, &vm_returncode);
  if (status != HASP_STATUS_OK) return status;

  returnValue = (vm_returncode != 0);

  if (returnValue)
  {
    /* fetch random output parameter */
    get_byte_array(&iobuffer_cxt, random, 8);
  }

  *result = returnValue;

  return HASP_STATUS_OK;

} /* updateConsumption */
コード例 #8
0
ファイル: hashmap.c プロジェクト: kmatheussen/radium
void HASH_put_bool_at(hash_t *hash, const char *key, int i, bool val){
  put_bool(hash, key, i, val);
  int new_size = i+1;
  if(new_size>hash->num_array_elements)
    hash->num_array_elements = new_size;
}
コード例 #9
0
ファイル: hashmap.c プロジェクト: kmatheussen/radium
void HASH_put_bool(hash_t *hash, const char *key, bool val){
  put_bool(hash, key, 0, val);
}