/* Reseed a generator. */ static int drbg_reseed(struct drbg_aes_ctx *ctx) { uint8_t buffer[DRBG_AES_SEED_SIZE]; int ret; /* The other two generators are seeded from /dev/random. */ ret = _rnd_get_system_entropy(buffer, sizeof(buffer)); if (ret < 0) return gnutls_assert_val(ret); drbg_aes_reseed(ctx, sizeof(buffer), buffer, 0, NULL); return 0; }
int drbg_aes_init(struct drbg_aes_ctx *ctx, unsigned entropy_size, const uint8_t * entropy, unsigned pstring_size, const uint8_t * pstring) { uint8_t tmp[DRBG_AES_KEY_SIZE]; memset(ctx, 0, sizeof(*ctx)); memset(tmp, 0, sizeof(tmp)); aes_set_encrypt_key(&ctx->key, DRBG_AES_KEY_SIZE, tmp); return drbg_aes_reseed(ctx, entropy_size, entropy, pstring_size, pstring); }