Lines Matching refs:t
57 PROV_TEST_RNG *t; in test_rng_new() local
59 t = OPENSSL_zalloc(sizeof(*t)); in test_rng_new()
60 if (t == NULL) in test_rng_new()
63 t->max_request = INT_MAX; in test_rng_new()
64 t->provctx = provctx; in test_rng_new()
65 t->state = EVP_RAND_STATE_UNINITIALISED; in test_rng_new()
66 return t; in test_rng_new()
71 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_free() local
73 if (t == NULL) in test_rng_free()
75 OPENSSL_free(t->entropy); in test_rng_free()
76 OPENSSL_free(t->nonce); in test_rng_free()
77 CRYPTO_THREAD_lock_free(t->lock); in test_rng_free()
78 OPENSSL_free(t); in test_rng_free()
86 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_instantiate() local
88 if (!test_rng_set_ctx_params(t, params) || strength > t->strength) in test_rng_instantiate()
91 t->state = EVP_RAND_STATE_READY; in test_rng_instantiate()
92 t->entropy_pos = 0; in test_rng_instantiate()
93 t->seed = 221953166; /* Value doesn't matter, so long as it isn't zero */ in test_rng_instantiate()
100 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_uninstantiate() local
102 t->entropy_pos = 0; in test_rng_uninstantiate()
103 t->state = EVP_RAND_STATE_UNINITIALISED; in test_rng_uninstantiate()
107 static unsigned char gen_byte(PROV_TEST_RNG *t) in gen_byte() argument
118 n = t->seed; in gen_byte()
122 t->seed = n; in gen_byte()
131 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_generate() local
134 if (strength > t->strength) in test_rng_generate()
136 if (t->generate) { in test_rng_generate()
138 out[i] = gen_byte(t); in test_rng_generate()
140 if (t->entropy_len - t->entropy_pos < outlen) in test_rng_generate()
143 memcpy(out, t->entropy + t->entropy_pos, outlen); in test_rng_generate()
144 t->entropy_pos += outlen; in test_rng_generate()
163 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_nonce() local
166 if (strength > t->strength) in test_rng_nonce()
169 if (t->generate) { in test_rng_nonce()
171 out[i] = gen_byte(t); in test_rng_nonce()
175 if (t->nonce == NULL) in test_rng_nonce()
178 memcpy(out, t->nonce, t->nonce_len); in test_rng_nonce()
179 return t->nonce_len; in test_rng_nonce()
184 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_get_ctx_params() local
188 if (p != NULL && !OSSL_PARAM_set_int(p, t->state)) in test_rng_get_ctx_params()
192 if (p != NULL && !OSSL_PARAM_set_int(p, t->strength)) in test_rng_get_ctx_params()
196 if (p != NULL && !OSSL_PARAM_set_size_t(p, t->max_request)) in test_rng_get_ctx_params()
200 if (p != NULL && !OSSL_PARAM_set_uint(p, t->generate)) in test_rng_get_ctx_params()
227 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_set_ctx_params() local
236 if (p != NULL && !OSSL_PARAM_get_uint(p, &t->strength)) in test_rng_set_ctx_params()
243 OPENSSL_free(t->entropy); in test_rng_set_ctx_params()
244 t->entropy = ptr; in test_rng_set_ctx_params()
245 t->entropy_len = size; in test_rng_set_ctx_params()
246 t->entropy_pos = 0; in test_rng_set_ctx_params()
254 OPENSSL_free(t->nonce); in test_rng_set_ctx_params()
255 t->nonce = ptr; in test_rng_set_ctx_params()
256 t->nonce_len = size; in test_rng_set_ctx_params()
260 if (p != NULL && !OSSL_PARAM_get_size_t(p, &t->max_request)) in test_rng_set_ctx_params()
264 if (p != NULL && !OSSL_PARAM_get_uint(p, &t->generate)) in test_rng_set_ctx_params()
294 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_get_seed() local
296 *pout = t->entropy; in test_rng_get_seed()
297 return t->entropy_len > max_len ? max_len : t->entropy_len; in test_rng_get_seed()
302 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_enable_locking() local
304 if (t != NULL && t->lock == NULL) { in test_rng_enable_locking()
305 t->lock = CRYPTO_THREAD_lock_new(); in test_rng_enable_locking()
306 if (t->lock == NULL) { in test_rng_enable_locking()
316 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_lock() local
318 if (t == NULL || t->lock == NULL) in test_rng_lock()
320 return CRYPTO_THREAD_write_lock(t->lock); in test_rng_lock()
325 PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; in test_rng_unlock() local
327 if (t != NULL && t->lock != NULL) in test_rng_unlock()
328 CRYPTO_THREAD_unlock(t->lock); in test_rng_unlock()