void mbedtls_sha1_hw_free(crypto_sha_context *ctx) { if (ctx == NULL) { return; } crypto_zeroize(ctx, sizeof(crypto_sha_context)); }
void mbedtls_des3_free( mbedtls_des3_context *ctx ) { if (ctx == NULL) { return; } crypto_zeroize(ctx, sizeof (mbedtls_des3_context)); }
int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length) { (void)obj; unsigned char tmpBuff[PRNG_KEY_SIZE]; size_t cur_length = 0; while (length >= sizeof(tmpBuff)) { trng_get(output); output += sizeof(tmpBuff); cur_length += sizeof(tmpBuff); length -= sizeof(tmpBuff); } if (length > 0) { trng_get(tmpBuff); memcpy(output, tmpBuff, length); cur_length += length; crypto_zeroize(tmpBuff, sizeof(tmpBuff)); } *output_length = cur_length; return 0; }