Lines Matching refs:t
28 static int self_test_digest(const ST_KAT_DIGEST *t, OSSL_SELF_TEST *st, in self_test_digest() argument
35 EVP_MD *md = EVP_MD_fetch(libctx, t->algorithm, NULL); in self_test_digest()
37 OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_DIGEST, t->desc); in self_test_digest()
42 || !EVP_DigestUpdate(ctx, t->pt, t->pt_len) in self_test_digest()
49 if (out_len != t->expected_len in self_test_digest()
50 || memcmp(out, t->expected, out_len) != 0) in self_test_digest()
65 const ST_KAT_CIPHER *t, int enc) in cipher_init() argument
72 if (t->tag == NULL) { in cipher_init()
74 return EVP_CipherInit_ex(ctx, cipher, NULL, t->key, t->iv, enc) in cipher_init()
80 in_tag = (unsigned char *)t->tag; in cipher_init()
83 && (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, t->iv_len, NULL) > 0) in cipher_init()
85 || EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, t->tag_len, in cipher_init()
87 && EVP_CipherInit_ex(ctx, NULL, NULL, t->key, t->iv, enc) in cipher_init()
89 && EVP_CipherUpdate(ctx, NULL, &tmp, t->aad, t->aad_len); in cipher_init()
93 static int self_test_cipher(const ST_KAT_CIPHER *t, OSSL_SELF_TEST *st, in self_test_cipher() argument
102 OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_CIPHER, t->base.desc); in self_test_cipher()
107 cipher = EVP_CIPHER_fetch(libctx, t->base.algorithm, NULL); in self_test_cipher()
112 if ((t->mode & CIPHER_MODE_ENCRYPT) != 0) { in self_test_cipher()
113 if (!cipher_init(ctx, cipher, t, encrypt) in self_test_cipher()
114 || !EVP_CipherUpdate(ctx, ct_buf, &len, t->base.pt, in self_test_cipher()
115 t->base.pt_len) in self_test_cipher()
121 if (ct_len != (int)t->base.expected_len in self_test_cipher()
122 || memcmp(t->base.expected, ct_buf, ct_len) != 0) in self_test_cipher()
125 if (t->tag != NULL) { in self_test_cipher()
128 if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, t->tag_len, in self_test_cipher()
130 || memcmp(tag, t->tag, t->tag_len) != 0) in self_test_cipher()
136 if ((t->mode & CIPHER_MODE_DECRYPT) != 0) { in self_test_cipher()
137 if (!(cipher_init(ctx, cipher, t, !encrypt) in self_test_cipher()
139 t->base.expected, t->base.expected_len) in self_test_cipher()
144 if (pt_len != (int)t->base.pt_len in self_test_cipher()
145 || memcmp(pt_buf, t->base.pt, pt_len) != 0) in self_test_cipher()
202 static int self_test_kdf(const ST_KAT_KDF *t, OSSL_SELF_TEST *st, in self_test_kdf() argument
213 OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_KDF, t->desc); in self_test_kdf()
219 kdf = EVP_KDF_fetch(libctx, t->algorithm, ""); in self_test_kdf()
230 if (!add_params(bld, t->params, bnctx)) in self_test_kdf()
236 if (t->expected_len > sizeof(out)) in self_test_kdf()
238 if (EVP_KDF_derive(ctx, out, t->expected_len, params) <= 0) in self_test_kdf()
243 if (memcmp(out, t->expected, t->expected_len) != 0) in self_test_kdf()
257 static int self_test_drbg(const ST_KAT_DRBG *t, OSSL_SELF_TEST *st, in self_test_drbg() argument
270 OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_DRBG, t->desc); in self_test_drbg()
286 rand = EVP_RAND_fetch(libctx, t->algorithm, NULL); in self_test_drbg()
297 drbg_params[0] = OSSL_PARAM_construct_utf8_string(t->param_name, in self_test_drbg()
298 t->param_value, 0); in self_test_drbg()
307 (void *)t->entropyin, in self_test_drbg()
308 t->entropyinlen); in self_test_drbg()
311 (void *)t->nonce, t->noncelen); in self_test_drbg()
314 if (!EVP_RAND_instantiate(drbg, strength, 0, t->persstr, t->persstrlen, in self_test_drbg()
320 (void *)t->entropyinpr1, in self_test_drbg()
321 t->entropyinpr1len); in self_test_drbg()
325 if (!EVP_RAND_generate(drbg, out, t->expectedlen, strength, in self_test_drbg()
327 t->entropyaddin1, t->entropyaddin1len)) in self_test_drbg()
332 (void *)t->entropyinpr2, in self_test_drbg()
333 t->entropyinpr2len); in self_test_drbg()
341 if (!EVP_RAND_generate(drbg, out, t->expectedlen, strength, in self_test_drbg()
343 t->entropyaddin2, t->entropyaddin2len)) in self_test_drbg()
348 if (memcmp(out, t->expected, t->expectedlen) != 0) in self_test_drbg()
369 static int self_test_ka(const ST_KAT_KAS *t, in self_test_ka() argument
378 size_t secret_len = t->expected_len; in self_test_ka()
382 OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_KA, t->desc); in self_test_ka()
395 if (!add_params(bld, t->key_group, bnctx) in self_test_ka()
396 || !add_params(bld, t->key_host_data, bnctx)) in self_test_ka()
400 if (!add_params(bld, t->key_group, bnctx) in self_test_ka()
401 || !add_params(bld, t->key_peer_data, bnctx)) in self_test_ka()
409 kactx = EVP_PKEY_CTX_new_from_name(libctx, t->algorithm, ""); in self_test_ka()
431 if (secret_len != t->expected_len in self_test_ka()
432 || memcmp(secret, t->expected, t->expected_len) != 0) in self_test_ka()
449 static int self_test_digest_sign(const ST_KAT_SIGN *t, in self_test_digest_sign() argument
465 if (t->sig_expected_len > sizeof(sig)) in self_test_digest_sign()
468 if (t->sig_expected == NULL) in self_test_digest_sign()
471 OSSL_SELF_TEST_onbegin(st, typ, t->desc); in self_test_digest_sign()
473 if (t->entropy != NULL) { in self_test_digest_sign()
474 if (!set_kat_drbg(libctx, t->entropy, t->entropy_len, in self_test_digest_sign()
475 t->nonce, t->nonce_len, t->persstr, t->persstr_len)) in self_test_digest_sign()
488 if (!add_params(bldkey, t->key, bnctx) in self_test_digest_sign()
489 || !add_params(bldinit, t->init, bnctx)) in self_test_digest_sign()
494 fromctx = EVP_PKEY_CTX_new_from_name(libctx, t->keytype, NULL); in self_test_digest_sign()
503 sigalg = EVP_SIGNATURE_fetch(libctx, t->sigalgorithm, NULL); in self_test_digest_sign()
510 digested = ((t->mode & SIGNATURE_MODE_DIGESTED) != 0); in self_test_digest_sign()
512 if ((t->mode & SIGNATURE_MODE_VERIFY_ONLY) != 0) { in self_test_digest_sign()
513 memcpy(sig, t->sig_expected, t->sig_expected_len); in self_test_digest_sign()
514 siglen = t->sig_expected_len; in self_test_digest_sign()
523 if (EVP_PKEY_sign(ctx, sig, &siglen, t->msg, t->msg_len) <= 0) in self_test_digest_sign()
526 if (t->sig_expected != NULL in self_test_digest_sign()
527 && (siglen != t->sig_expected_len in self_test_digest_sign()
528 || memcmp(sig, t->sig_expected, t->sig_expected_len) != 0)) in self_test_digest_sign()
532 if ((t->mode & SIGNATURE_MODE_SIGN_ONLY) == 0) { in self_test_digest_sign()
541 if (EVP_PKEY_verify(ctx, sig, siglen, t->msg, t->msg_len) <= 0) in self_test_digest_sign()
555 if (t->entropy != NULL) { in self_test_digest_sign()