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 */
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 */
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 */
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); }
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 */
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 */
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 */
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; }
void HASH_put_bool(hash_t *hash, const char *key, bool val){ put_bool(hash, key, 0, val); }