Lines Matching refs:t
57 int (*init) (EVP_TEST *t, const char *alg);
59 void (*cleanup) (EVP_TEST *t);
61 int (*parse) (EVP_TEST *t, const char *name, const char *value);
63 int (*run_test) (EVP_TEST *t);
112 static int check_fips_approved(EVP_TEST *t, int approved) in check_fips_approved() argument
120 if (t->expect_unapproved) { in check_fips_approved()
134 static int mac_check_fips_approved(EVP_MAC_CTX *ctx, EVP_TEST *t) in mac_check_fips_approved() argument
150 return check_fips_approved(t, approved); in mac_check_fips_approved()
153 static int pkey_check_fips_approved(EVP_PKEY_CTX *ctx, EVP_TEST *t) in pkey_check_fips_approved() argument
177 return check_fips_approved(t, approved); in pkey_check_fips_approved()
180 static int rand_check_fips_approved(EVP_RAND_CTX *ctx, EVP_TEST *t) in rand_check_fips_approved() argument
196 return check_fips_approved(t, approved); in rand_check_fips_approved()
237 static int ctrl2params(EVP_TEST *t, STACK_OF(OPENSSL_STRING) *controls, in ctrl2params() argument
247 t->err = "ERR_TOO_MANY_PARAMETERS"; in ctrl2params()
255 t->err = "ERR_PARAM_ERROR"; in ctrl2params()
268 t->err = "ERR_PARAM_ERROR"; in ctrl2params()
288 static int kdf_check_fips_approved(EVP_KDF_CTX *ctx, EVP_TEST *t) in kdf_check_fips_approved() argument
297 return check_fips_approved(t, approved); in kdf_check_fips_approved()
300 static int cipher_check_fips_approved(EVP_CIPHER_CTX *ctx, EVP_TEST *t) in cipher_check_fips_approved() argument
309 return check_fips_approved(t, approved); in cipher_check_fips_approved()
318 static int memory_err_compare(EVP_TEST *t, const char *err, in memory_err_compare() argument
324 if (t->expected_err != NULL && strcmp(t->expected_err, err) == 0) in memory_err_compare()
329 t->err = err; in memory_err_compare()
657 static int digest_test_init(EVP_TEST *t, const char *alg) in digest_test_init() argument
665 t->skip = 1; in digest_test_init()
674 t->data = mdat; in digest_test_init()
684 static void digest_test_cleanup(EVP_TEST *t) in digest_test_cleanup() argument
686 DIGEST_DATA *mdat = t->data; in digest_test_cleanup()
693 static int digest_test_parse(EVP_TEST *t, in digest_test_parse() argument
696 DIGEST_DATA *mdata = t->data; in digest_test_parse()
727 static int test_duplicate_md_ctx(EVP_TEST *t, EVP_MD_CTX *mctx) in test_duplicate_md_ctx() argument
735 t->err = "DIGESTFINALXOF_ERROR"; in test_duplicate_md_ctx()
740 t->err = "DIGESTFINALXOF_ERROR"; in test_duplicate_md_ctx()
747 static int digest_test_run(EVP_TEST *t) in digest_test_run() argument
749 DIGEST_DATA *expected = t->data; in digest_test_run()
758 t->err = "TEST_FAILURE"; in digest_test_run()
782 t->err = "DIGESTINIT_ERROR"; in digest_test_run()
787 t->err = "DIGESTUPDATE_ERROR"; in digest_test_run()
801 } else if (!test_duplicate_md_ctx(t, mctx_cpy)) { in digest_test_run()
805 if (!test_duplicate_md_ctx(t, EVP_MD_CTX_dup(mctx))) in digest_test_run()
810 t->err = "DIGESTFINALXOF_ERROR"; in digest_test_run()
815 t->err = "DIGESTFINAL_ERROR"; in digest_test_run()
820 t->err = "DIGEST_LENGTH_MISMATCH"; in digest_test_run()
823 if (!memory_err_compare(t, "DIGEST_MISMATCH", in digest_test_run()
828 t->err = NULL; in digest_test_run()
843 t->err = "EVP_Q_digest failed"; in digest_test_run()
916 static int cipher_test_init(EVP_TEST *t, const char *alg) in cipher_test_init() argument
924 t->skip = 1; in cipher_test_init()
935 t->skip = 1; in cipher_test_init()
961 t->skip = 1; in cipher_test_init()
966 t->data = cdat; in cipher_test_init()
972 static void cipher_test_cleanup(EVP_TEST *t) in cipher_test_cleanup() argument
975 CIPHER_DATA *cdat = t->data; in cipher_test_cleanup()
990 static int cipher_test_parse(EVP_TEST *t, const char *keyword, in cipher_test_parse() argument
993 CIPHER_DATA *cdat = t->data; in cipher_test_parse()
1075 static int cipher_test_enc(EVP_TEST *t, int enc, size_t out_misalign, in cipher_test_enc() argument
1079 CIPHER_DATA *expected = t->data; in cipher_test_enc()
1087 t->err = "TEST_FAILURE"; in cipher_test_enc()
1129 t->err = "CIPHERINIT_ERROR"; in cipher_test_enc()
1140 t->err = "INVALID_CTS_MODE"; in cipher_test_enc()
1148 t->err = "INVALID_IV_LENGTH"; in cipher_test_enc()
1152 t->err = "INVALID_IV_LENGTH"; in cipher_test_enc()
1163 t->err = "TAG_LENGTH_SET_ERROR"; in cipher_test_enc()
1166 t->err = "TAG_SET_ERROR"; in cipher_test_enc()
1180 t->err = "INVALID_ROUNDS"; in cipher_test_enc()
1186 t->err = "INVALID_KEY_LENGTH"; in cipher_test_enc()
1193 t->err = "INVALID KEY BITS"; in cipher_test_enc()
1198 t->err = "KEY_SET_ERROR"; in cipher_test_enc()
1210 t->err = "INVALID_IV"; in cipher_test_enc()
1253 t->err = "SET_MAC_KEY_ERROR"; in cipher_test_enc()
1264 t->err = "SET_TLS_VERSION_ERROR"; in cipher_test_enc()
1271 t->err = "CCM_PLAINTEXT_LENGTH_SET_ERROR"; in cipher_test_enc()
1276 t->err = "AAD_SET_ERROR"; in cipher_test_enc()
1333 t->err = "TLS1_AAD_ERROR"; in cipher_test_enc()
1341 t->err = "TAG_SET_ERROR"; in cipher_test_enc()
1353 t->err = "SET_XTS_STANDARD_ERROR"; in cipher_test_enc()
1358 t->err = "CIPHERUPDATE_ERROR"; in cipher_test_enc()
1399 t->err = "CIPHERFINAL_ERROR"; in cipher_test_enc()
1402 if (!cipher_check_fips_approved(ctx, t)) { in cipher_test_enc()
1403 t->err = "FIPSAPPROVED_ERROR"; in cipher_test_enc()
1418 if (!memory_err_compare(t, "VALUE_MISMATCH", expected_out, out_len, in cipher_test_enc()
1425 t->err = "TAG_LENGTH_INTERNAL_ERROR"; in cipher_test_enc()
1430 t->err = "TAG_RETRIEVE_ERROR"; in cipher_test_enc()
1433 if (!memory_err_compare(t, "TAG_VALUE_MISMATCH", in cipher_test_enc()
1446 t->err = "INVALID_NEXT_IV"; in cipher_test_enc()
1451 t->err = NULL; in cipher_test_enc()
1461 static int cipher_test_run(EVP_TEST *t) in cipher_test_run() argument
1463 CIPHER_DATA *cdat = t->data; in cipher_test_run()
1471 t->err = "NO_KEY"; in cipher_test_run()
1477 t->err = "NO_IV"; in cipher_test_run()
1482 t->err = "NO_TAG"; in cipher_test_run()
1487 if (!ctrl2params(t, cdat->init_controls, NULL, in cipher_test_run()
1496 t->aux_err = aux_err; in cipher_test_run()
1522 rv = cipher_test_enc(t, 1, out_misalign, inp_misalign, in cipher_test_run()
1528 rv = cipher_test_enc(t, 0, out_misalign, inp_misalign, in cipher_test_run()
1538 t->aux_err = NULL; in cipher_test_run()
1594 static int mac_test_init(EVP_TEST *t, const char *alg) in mac_test_init() argument
1602 t->skip = 1; in mac_test_init()
1647 t->data = mdat; in mac_test_init()
1651 static void mac_test_cleanup(EVP_TEST *t) in mac_test_cleanup() argument
1653 MAC_DATA *mdat = t->data; in mac_test_cleanup()
1667 static int mac_test_parse(EVP_TEST *t, in mac_test_parse() argument
1670 MAC_DATA *mdata = t->data; in mac_test_parse()
1711 static int mac_test_ctrl_pkey(EVP_TEST *t, EVP_PKEY_CTX *pctx, in mac_test_ctrl_pkey() argument
1725 t->err = "PKEY_CTRL_INVALID"; in mac_test_ctrl_pkey()
1727 t->err = "PKEY_CTRL_ERROR"; in mac_test_ctrl_pkey()
1734 static int mac_test_run_pkey(EVP_TEST *t) in mac_test_run_pkey() argument
1736 MAC_DATA *expected = t->data; in mac_test_run_pkey()
1760 t->skip = 1; in mac_test_run_pkey()
1761 t->err = NULL; in mac_test_run_pkey()
1768 t->skip = 1; in mac_test_run_pkey()
1769 t->err = NULL; in mac_test_run_pkey()
1773 t->err = "MAC_KEY_CREATE_ERROR"; in mac_test_run_pkey()
1787 t->err = "MAC_KEY_CREATE_ERROR"; in mac_test_run_pkey()
1794 t->skip = 1; in mac_test_run_pkey()
1795 t->err = NULL; in mac_test_run_pkey()
1801 t->err = "INTERNAL_ERROR"; in mac_test_run_pkey()
1805 t->err = "DIGESTSIGNINIT_ERROR"; in mac_test_run_pkey()
1809 if (!mac_test_ctrl_pkey(t, pctx, in mac_test_run_pkey()
1812 t->err = "EVPPKEYCTXCTRL_ERROR"; in mac_test_run_pkey()
1823 t->err = "DIGESTSIGNUPDATE_ERROR"; in mac_test_run_pkey()
1831 t->err = "DIGESTSIGNFINAL_LENGTH_ERROR"; in mac_test_run_pkey()
1835 t->err = "TEST_FAILURE"; in mac_test_run_pkey()
1839 || !memory_err_compare(t, "TEST_MAC_ERR", in mac_test_run_pkey()
1842 t->err = "TEST_MAC_ERR"; in mac_test_run_pkey()
1845 t->err = NULL; in mac_test_run_pkey()
1855 static int mac_test_run_mac(EVP_TEST *t) in mac_test_run_mac() argument
1857 MAC_DATA *expected = t->data; in mac_test_run_mac()
1903 t->err = "MAC_BAD_PARAMS"; in mac_test_run_mac()
1908 t->skip = 1; in mac_test_run_mac()
1909 t->err = NULL; in mac_test_run_mac()
1930 if (!ctrl2params(t, expected->controls, defined_params, in mac_test_run_mac()
1941 t->err = "MAC_CREATE_ERROR"; in mac_test_run_mac()
1951 t->err = "MAC_INIT_ERROR"; in mac_test_run_mac()
1956 t->err = "MAC SIZE not set"; in mac_test_run_mac()
1962 t->err = "MAC SIZE check failed"; in mac_test_run_mac()
1967 t->err = "MAC SIZE check failed"; in mac_test_run_mac()
1980 t->err = "INTERNAL_ERROR"; in mac_test_run_mac()
1985 t->err = "TEST_FAILURE"; in mac_test_run_mac()
1990 t->err = "TEST_FAILURE"; in mac_test_run_mac()
2003 t->err = "MAC_UPDATE_ERROR"; in mac_test_run_mac()
2013 t->err = "TEST_FAILURE"; in mac_test_run_mac()
2017 || !memory_err_compare(t, "TEST_MAC_ERR", in mac_test_run_mac()
2020 t->err = "MAC_FINAL_ERROR"; in mac_test_run_mac()
2025 t->err = "MAC_FINAL_LENGTH_ERROR"; in mac_test_run_mac()
2029 t->err = "TEST_FAILURE"; in mac_test_run_mac()
2033 || !memory_err_compare(t, "TEST_MAC_ERR", in mac_test_run_mac()
2036 t->err = "TEST_MAC_ERR"; in mac_test_run_mac()
2039 if (!mac_check_fips_approved(ctx, t)) in mac_test_run_mac()
2060 t->err = "MAC_REINIT_SHOULD_FAIL"; in mac_test_run_mac()
2070 t->err = "MAC_REINIT_ERROR"; in mac_test_run_mac()
2076 t->err = NULL; in mac_test_run_mac()
2088 t->err = "EVP_Q_mac failed"; in mac_test_run_mac()
2099 static int mac_test_run(EVP_TEST *t) in mac_test_run() argument
2101 MAC_DATA *expected = t->data; in mac_test_run()
2104 return mac_test_run_mac(t); in mac_test_run()
2105 return mac_test_run_pkey(t); in mac_test_run()
2129 static int kem_test_init(EVP_TEST *t, const char *name) in kem_test_init() argument
2138 t->skip = 1; in kem_test_init()
2147 t->data = kdata; in kem_test_init()
2156 static void kem_test_cleanup(EVP_TEST *t) in kem_test_cleanup() argument
2158 KEM_DATA *kdata = t->data; in kem_test_cleanup()
2166 static int kem_test_parse(EVP_TEST *t, const char *keyword, const char *value) in kem_test_parse() argument
2168 KEM_DATA *kdata = t->data; in kem_test_parse()
2183 static int encapsulate(EVP_TEST *t, EVP_PKEY_CTX *ctx, const char *op, in encapsulate() argument
2188 KEM_DATA *kdata = t->data; in encapsulate()
2196 if (ctrl2params(t, kdata->init_ctrls, NULL, in encapsulate()
2202 t->err = "TEST_ENCAPSULATE_INIT_ERROR"; in encapsulate()
2207 t->err = "TEST_SET_KEM_OP_ERROR"; in encapsulate()
2211 t->err = "TEST_ENCAPSULATE_LEN_ERROR"; in encapsulate()
2221 t->err = "TEST_ENCAPSULATE_ERROR"; in encapsulate()
2224 ret = pkey_check_fips_approved(ctx, t); in encapsulate()
2228 t->err = NULL; in encapsulate()
2243 static int decapsulate(EVP_TEST *t, EVP_PKEY_CTX *ctx, const char *op, in decapsulate() argument
2248 KEM_DATA *kdata = t->data; in decapsulate()
2256 if (!ctrl2params(t, kdata->init_ctrls, NULL, in decapsulate()
2262 t->err = "TEST_DECAPSULATE_INIT_ERROR"; in decapsulate()
2267 t->err = "TEST_SET_KEM_OP_ERROR"; in decapsulate()
2271 t->err = "TEST_DECAPSULATE_LEN_ERROR"; in decapsulate()
2280 t->err = "TEST_DECAPSULATE_ERROR"; in decapsulate()
2284 t->err = "TEST_SECRET_MISMATCH"; in decapsulate()
2287 t->err = NULL; in decapsulate()
2295 static int kem_test_run(EVP_TEST *t) in kem_test_run() argument
2298 KEM_DATA *kdata = t->data; in kem_test_run()
2304 ret = encapsulate(t, kdata->ctx, kdata->op, &wrapped, &wrappedlen, in kem_test_run()
2306 if (ret == 0 || t->err != NULL) in kem_test_run()
2308 ret = decapsulate(t, kdata->ctx, kdata->op, wrapped, wrappedlen, in kem_test_run()
2311 ret = decapsulate(t, kdata->ctx, kdata->op, kdata->input, kdata->inputlen, in kem_test_run()
2361 static int pkey_test_init_keyctx(EVP_TEST *t, const char *keyname, in pkey_test_init_keyctx() argument
2374 t->skip = 1; in pkey_test_init_keyctx()
2387 t->data = kdata; in pkey_test_init_keyctx()
2391 static int pkey_test_init(EVP_TEST *t, const char *name, in pkey_test_init() argument
2403 rv = pkey_test_init_keyctx(t, name, use_public); in pkey_test_init()
2404 if (t->skip || !rv) in pkey_test_init()
2406 kdata = t->data; in pkey_test_init()
2414 static int pkey_test_init_ex2(EVP_TEST *t, const char *name, in pkey_test_init_ex2() argument
2438 t->skip = 1; in pkey_test_init_ex2()
2442 rv = pkey_test_init_keyctx(t, /* keyname */ p + 1, use_public); in pkey_test_init_ex2()
2443 if (t->skip || !rv) in pkey_test_init_ex2()
2445 kdata = t->data; in pkey_test_init_ex2()
2458 static void pkey_test_cleanup(EVP_TEST *t) in pkey_test_cleanup() argument
2460 PKEY_DATA *kdata = t->data; in pkey_test_cleanup()
2470 static int pkey_test_ctrl(EVP_TEST *t, EVP_PKEY_CTX *pctx, in pkey_test_ctrl() argument
2484 t->err = "PKEY_CTRL_INVALID"; in pkey_test_ctrl()
2489 t->skip = 1; in pkey_test_ctrl()
2492 t->err = "PKEY_CTRL_ERROR"; in pkey_test_ctrl()
2500 static int pkey_add_control(EVP_TEST *t, STACK_OF(OPENSSL_STRING) *controls, in pkey_add_control() argument
2514 t->skip = 1; in pkey_add_control()
2521 static int pkey_test_parse(EVP_TEST *t, in pkey_test_parse() argument
2524 PKEY_DATA *kdata = t->data; in pkey_test_parse()
2532 return pkey_add_control(t, kdata->controls, value); in pkey_test_parse()
2536 static int pkey_test_run_init(EVP_TEST *t) in pkey_test_run_init() argument
2538 PKEY_DATA *data = t->data; in pkey_test_run_init()
2545 if (!ctrl2params(t, data->init_controls, in pkey_test_run_init()
2553 t->err = "KEYOP_INIT_ERROR"; in pkey_test_run_init()
2558 t->err = "KEYOP_INIT_ERROR"; in pkey_test_run_init()
2562 t->err = "KEYOP_INIT_ERROR"; in pkey_test_run_init()
2569 if (!pkey_test_ctrl(t, data->ctx, value) || t->err != NULL) in pkey_test_run_init()
2578 static int pkey_test_run(EVP_TEST *t) in pkey_test_run() argument
2580 PKEY_DATA *expected = t->data; in pkey_test_run()
2585 if (!pkey_test_run_init(t)) in pkey_test_run()
2590 t->err = "INTERNAL_ERROR"; in pkey_test_run()
2597 t->err = "KEYOP_LENGTH_ERROR"; in pkey_test_run()
2602 t->err = "KEYOP_ERROR"; in pkey_test_run()
2605 if (!memory_err_compare(t, "KEYOP_MISMATCH", in pkey_test_run()
2610 t->err = NULL; in pkey_test_run()
2618 t->err = "KEYOP_LENGTH_ERROR"; in pkey_test_run()
2623 t->err = "KEYOP_ERROR"; in pkey_test_run()
2626 if (!memory_err_compare(t, "KEYOP_MISMATCH", in pkey_test_run()
2631 if (pkey_check_fips_approved(expected->ctx, t) <= 0) in pkey_test_run()
2644 static int sign_test_init(EVP_TEST *t, const char *name) in sign_test_init() argument
2647 return pkey_test_init_ex2(t, name, 0, in sign_test_init()
2649 return pkey_test_init(t, name, 0, EVP_PKEY_sign_init_ex, EVP_PKEY_sign); in sign_test_init()
2664 static int sign_test_message_init(EVP_TEST *t, const char *name) in sign_test_message_init() argument
2666 return pkey_test_init_ex2(t, name, 0, in sign_test_message_init()
2683 static int verify_recover_test_init(EVP_TEST *t, const char *name) in verify_recover_test_init() argument
2686 return pkey_test_init_ex2(t, name, 1, in verify_recover_test_init()
2689 return pkey_test_init(t, name, 1, EVP_PKEY_verify_recover_init_ex, in verify_recover_test_init()
2701 static int decrypt_test_init(EVP_TEST *t, const char *name) in decrypt_test_init() argument
2703 return pkey_test_init(t, name, 0, EVP_PKEY_decrypt_init_ex, in decrypt_test_init()
2720 static int verify_test_init(EVP_TEST *t, const char *name) in verify_test_init() argument
2723 return pkey_test_init_ex2(t, name, 1, in verify_test_init()
2725 return pkey_test_init(t, name, 1, EVP_PKEY_verify_init_ex, NULL); in verify_test_init()
2728 static int verify_test_run(EVP_TEST *t) in verify_test_run() argument
2731 PKEY_DATA *kdata = t->data; in verify_test_run()
2733 if (!pkey_test_run_init(t)) in verify_test_run()
2737 t->err = "VERIFY_ERROR"; in verify_test_run()
2740 if (!pkey_check_fips_approved(kdata->ctx, t)) in verify_test_run()
2758 static int verify_message_test_init(EVP_TEST *t, const char *name) in verify_message_test_init() argument
2760 return pkey_test_init_ex2(t, name, 0, in verify_message_test_init()
2772 static int pderive_test_init(EVP_TEST *t, const char *name) in pderive_test_init() argument
2774 return pkey_test_init(t, name, 0, EVP_PKEY_derive_init_ex, 0); in pderive_test_init()
2777 static int pderive_test_parse(EVP_TEST *t, in pderive_test_parse() argument
2780 PKEY_DATA *kdata = t->data; in pderive_test_parse()
2798 return pkey_add_control(t, kdata->controls, value); in pderive_test_parse()
2804 static int pderive_test_run(EVP_TEST *t) in pderive_test_run() argument
2807 PKEY_DATA *expected = t->data; in pderive_test_run()
2812 if (!pkey_test_run_init(t)) in pderive_test_run()
2815 t->err = NULL; in pderive_test_run()
2818 t->err = "DERIVE_SET_PEER_ERROR"; in pderive_test_run()
2823 t->err = "DERIVE_ERROR"; in pderive_test_run()
2829 t->err = "DERIVE_ERROR"; in pderive_test_run()
2833 t->err = "DERIVE_ERROR"; in pderive_test_run()
2837 t->err = "DERIVE_ERROR"; in pderive_test_run()
2840 if (!memory_err_compare(t, "SHARED_SECRET_MISMATCH", in pderive_test_run()
2845 if (!pkey_check_fips_approved(dctx, t)) { in pderive_test_run()
2849 t->err = NULL; in pderive_test_run()
2917 static int scrypt_test_parse(EVP_TEST *t, in scrypt_test_parse() argument
2920 PBE_DATA *pdata = t->data; in scrypt_test_parse()
2934 static int pbkdf2_test_parse(EVP_TEST *t, in pbkdf2_test_parse() argument
2937 PBE_DATA *pdata = t->data; in pbkdf2_test_parse()
2954 static int pkcs12_test_parse(EVP_TEST *t, in pkcs12_test_parse() argument
2957 PBE_DATA *pdata = t->data; in pkcs12_test_parse()
2965 return pbkdf2_test_parse(t, keyword, value); in pkcs12_test_parse()
2968 static int pbe_test_init(EVP_TEST *t, const char *alg) in pbe_test_init() argument
2975 t->skip = 1; in pbe_test_init()
2991 t->data = pdat; in pbe_test_init()
2995 static void pbe_test_cleanup(EVP_TEST *t) in pbe_test_cleanup() argument
2997 PBE_DATA *pdat = t->data; in pbe_test_cleanup()
3004 static int pbe_test_parse(EVP_TEST *t, in pbe_test_parse() argument
3007 PBE_DATA *pdata = t->data; in pbe_test_parse()
3016 return pbkdf2_test_parse(t, keyword, value); in pbe_test_parse()
3018 return pkcs12_test_parse(t, keyword, value); in pbe_test_parse()
3021 return scrypt_test_parse(t, keyword, value); in pbe_test_parse()
3026 static int pbe_test_run(EVP_TEST *t) in pbe_test_run() argument
3028 PBE_DATA *expected = t->data; in pbe_test_run()
3036 t->err = "INTERNAL_ERROR"; in pbe_test_run()
3044 t->err = "PBKDF2_ERROR"; in pbe_test_run()
3053 t->err = "SCRYPT_ERROR"; in pbe_test_run()
3061 t->err = "PKCS12_ERROR"; in pbe_test_run()
3068 t->err = "PKCS12_ERROR"; in pbe_test_run()
3072 if (!memory_err_compare(t, "KEY_MISMATCH", expected->key, expected->key_len, in pbe_test_run()
3076 t->err = NULL; in pbe_test_run()
3113 static int encode_test_init(EVP_TEST *t, const char *encoding) in encode_test_init() argument
3125 if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR"))) in encode_test_init()
3133 t->data = edata; in encode_test_init()
3140 static void encode_test_cleanup(EVP_TEST *t) in encode_test_cleanup() argument
3142 ENCODE_DATA *edata = t->data; in encode_test_cleanup()
3149 static int encode_test_parse(EVP_TEST *t, in encode_test_parse() argument
3152 ENCODE_DATA *edata = t->data; in encode_test_parse()
3161 static int encode_test_run(EVP_TEST *t) in encode_test_run() argument
3163 ENCODE_DATA *expected = t->data; in encode_test_run()
3170 t->err = "INTERNAL_ERROR"; in encode_test_run()
3203 if (!memory_err_compare(t, "BAD_ENCODING", in encode_test_run()
3225 t->err = "DECODE_ERROR"; in encode_test_run()
3234 t->err = "DECODE_ERROR"; in encode_test_run()
3240 && !memory_err_compare(t, "BAD_DECODING", in encode_test_run()
3243 t->err = "BAD_DECODING"; in encode_test_run()
3247 t->err = NULL; in encode_test_run()
3302 static int rand_test_init(EVP_TEST *t, const char *name) in rand_test_init() argument
3335 t->data = rdata; in rand_test_init()
3343 static void rand_test_cleanup(EVP_TEST *t) in rand_test_cleanup() argument
3345 RAND_DATA *rdata = t->data; in rand_test_cleanup()
3368 static int rand_test_parse(EVP_TEST *t, in rand_test_parse() argument
3371 RAND_DATA *rdata = t->data; in rand_test_parse()
3430 static int rand_test_run(EVP_TEST *t) in rand_test_run() argument
3432 RAND_DATA *expected = t->data; in rand_test_run()
3446 if (!ctrl2params(t, expected->init_controls, in rand_test_run()
3463 if (t->expect_unapproved == 0) { in rand_test_run()
3464 t->err = "EVP_RAND_CTX_set_params"; in rand_test_run()
3538 if (!rand_check_fips_approved(expected->ctx, t)) in rand_test_run()
3547 t->err = NULL; in rand_test_run()
3584 static int kdf_test_init(EVP_TEST *t, const char *name) in kdf_test_init() argument
3591 t->skip = 1; in kdf_test_init()
3611 t->data = kdata; in kdf_test_init()
3616 static void kdf_test_cleanup(EVP_TEST *t) in kdf_test_cleanup() argument
3618 KDF_DATA *kdata = t->data; in kdf_test_cleanup()
3628 static int kdf_test_ctrl(EVP_TEST *t, EVP_KDF_CTX *kctx, in kdf_test_ctrl() argument
3631 KDF_DATA *kdata = t->data; in kdf_test_ctrl()
3647 t->skip = 1; in kdf_test_ctrl()
3654 t->skip = 1; in kdf_test_ctrl()
3661 t->skip = 1; in kdf_test_ctrl()
3668 t->skip = 1; in kdf_test_ctrl()
3675 t->skip = 1; in kdf_test_ctrl()
3682 t->skip = 1; in kdf_test_ctrl()
3689 t->skip = 1; in kdf_test_ctrl()
3697 t->err = "KDF_PARAM_ERROR"; in kdf_test_ctrl()
3704 t->skip = 1; in kdf_test_ctrl()
3713 t->skip = 1; in kdf_test_ctrl()
3719 t->skip = 1; in kdf_test_ctrl()
3726 static int kdf_test_parse(EVP_TEST *t, in kdf_test_parse() argument
3729 KDF_DATA *kdata = t->data; in kdf_test_parse()
3736 return kdf_test_ctrl(t, kdata->ctx, value); in kdf_test_parse()
3740 static int kdf_test_run(EVP_TEST *t) in kdf_test_run() argument
3743 KDF_DATA *expected = t->data; in kdf_test_run()
3751 if (!ctrl2params(t, expected->init_controls, in kdf_test_run()
3756 t->err = "KDF_CTRL_ERROR"; in kdf_test_run()
3762 t->err = "KDF_CTRL_ERROR"; in kdf_test_run()
3766 t->err = "INTERNAL_ERROR"; in kdf_test_run()
3776 t->err = "KDF_DERIVE_ERROR"; in kdf_test_run()
3779 if (!kdf_check_fips_approved(expected->ctx, t)) { in kdf_test_run()
3783 if (!memory_err_compare(t, "KDF_MISMATCH", in kdf_test_run()
3788 t->err = NULL; in kdf_test_run()
3820 static int pkey_kdf_test_init(EVP_TEST *t, const char *name) in pkey_kdf_test_init() argument
3826 t->skip = 1; in pkey_kdf_test_init()
3838 t->data = kdata; in pkey_kdf_test_init()
3846 static void pkey_kdf_test_cleanup(EVP_TEST *t) in pkey_kdf_test_cleanup() argument
3848 PKEY_KDF_DATA *kdata = t->data; in pkey_kdf_test_cleanup()
3854 static int pkey_kdf_test_parse(EVP_TEST *t, in pkey_kdf_test_parse() argument
3857 PKEY_KDF_DATA *kdata = t->data; in pkey_kdf_test_parse()
3862 return pkey_test_ctrl(t, kdata->ctx, value); in pkey_kdf_test_parse()
3866 static int pkey_kdf_test_run(EVP_TEST *t) in pkey_kdf_test_run() argument
3869 PKEY_KDF_DATA *expected = t->data; in pkey_kdf_test_run()
3879 t->err = "INTERNAL_ERROR"; in pkey_kdf_test_run()
3895 t->err = "INTERNAL_ERROR"; in pkey_kdf_test_run()
3899 t->err = "KDF_DERIVE_ERROR"; in pkey_kdf_test_run()
3902 if (!pkey_check_fips_approved(expected->ctx, t)) { in pkey_kdf_test_run()
3907 t->err = "KDF_MISMATCH"; in pkey_kdf_test_run()
3910 t->err = NULL; in pkey_kdf_test_run()
3934 static int keypair_test_init(EVP_TEST *t, const char *pair) in keypair_test_init() argument
3944 t->err = "PARSING_ERROR"; in keypair_test_init()
3951 t->err = "MISSING_PRIVATE_KEY"; in keypair_test_init()
3956 t->err = "MISSING_PUBLIC_KEY"; in keypair_test_init()
3962 t->skip = 1; in keypair_test_init()
3971 t->data = data; in keypair_test_init()
3973 t->err = NULL; in keypair_test_init()
3980 static void keypair_test_cleanup(EVP_TEST *t) in keypair_test_cleanup() argument
3982 OPENSSL_free(t->data); in keypair_test_cleanup()
3983 t->data = NULL; in keypair_test_cleanup()
3989 static int void_test_parse(EVP_TEST *t, const char *keyword, const char *value) in void_test_parse() argument
3994 static int keypair_test_run(EVP_TEST *t) in keypair_test_run() argument
3997 const KEYPAIR_TEST_DATA *pair = t->data; in keypair_test_run()
4005 t->err = "KEYPAIR_TYPE_MISMATCH"; in keypair_test_run()
4012 t->err = "KEYPAIR_MISMATCH"; in keypair_test_run()
4014 t->err = "KEYPAIR_TYPE_MISMATCH"; in keypair_test_run()
4016 t->err = "UNSUPPORTED_KEY_COMPARISON"; in keypair_test_run()
4027 t->err = NULL; in keypair_test_run()
4052 static int keygen_test_init(EVP_TEST *t, const char *alg) in keygen_test_init() argument
4057 t->skip = 1; in keygen_test_init()
4067 t->data = data; in keygen_test_init()
4068 t->err = NULL; in keygen_test_init()
4072 static void keygen_test_cleanup(EVP_TEST *t) in keygen_test_cleanup() argument
4074 KEYGEN_TEST_DATA *keygen = t->data; in keygen_test_cleanup()
4080 OPENSSL_free(t->data); in keygen_test_cleanup()
4081 t->data = NULL; in keygen_test_cleanup()
4084 static int keygen_test_parse(EVP_TEST *t, in keygen_test_parse() argument
4087 KEYGEN_TEST_DATA *keygen = t->data; in keygen_test_parse()
4098 static int keygen_test_run(EVP_TEST *t) in keygen_test_run() argument
4100 KEYGEN_TEST_DATA *keygen = t->data; in keygen_test_run()
4111 t->skip = 1; in keygen_test_run()
4125 t->err = "KEYGEN_INIT_ERROR"; in keygen_test_run()
4130 if (!ctrl2params(t, keygen->controls, in keygen_test_run()
4135 t->err = "PKEY_CTRL_ERROR"; in keygen_test_run()
4143 t->err = "KEYGEN_GENERATE_ERROR"; in keygen_test_run()
4146 if (!pkey_check_fips_approved(genctx, t)) { in keygen_test_run()
4176 t->err = NULL; in keygen_test_run()
4212 static int digestsigver_test_init(EVP_TEST *t, const char *alg, int is_verify, in digestsigver_test_init() argument
4220 t->skip = 1; in digestsigver_test_init()
4238 t->data = mdat; in digestsigver_test_init()
4242 static int digestsign_test_init(EVP_TEST *t, const char *alg) in digestsign_test_init() argument
4244 return digestsigver_test_init(t, alg, 0, 0); in digestsign_test_init()
4247 static void digestsigver_test_cleanup(EVP_TEST *t) in digestsigver_test_cleanup() argument
4249 DIGESTSIGN_DATA *mdata = t->data; in digestsigver_test_cleanup()
4258 t->data = NULL; in digestsigver_test_cleanup()
4261 static int digestsigver_test_parse(EVP_TEST *t, in digestsigver_test_parse() argument
4264 DIGESTSIGN_DATA *mdata = t->data; in digestsigver_test_parse()
4275 t->skip = 1; in digestsigver_test_parse()
4297 return pkey_add_control(t, mdata->controls, value); in digestsigver_test_parse()
4308 static int check_deterministic_noncetype(EVP_TEST *t, in check_deterministic_noncetype() argument
4320 t->err = "EVP_PKEY_CTX_set_params_ERROR"; in check_deterministic_noncetype()
4322 t->err = "EVP_PKEY_CTX_get_params_ERROR"; in check_deterministic_noncetype()
4324 t->err = "nonce_type_not_modified_ERROR"; in check_deterministic_noncetype()
4326 t->err = "nonce_type_value_ERROR"; in check_deterministic_noncetype()
4328 return t->err == NULL; in check_deterministic_noncetype()
4331 static int signverify_init(EVP_TEST *t, DIGESTSIGN_DATA *data) in signverify_init() argument
4340 if (!ctrl2params(t, data->init_controls, in signverify_init()
4350 t->err = "DIGESTVERIFYINIT_ERROR"; in signverify_init()
4356 t->err = "DIGESTSIGNINIT_ERROR"; in signverify_init()
4364 if (!pkey_test_ctrl(t, data->pctx, value) || t->err != NULL) in signverify_init()
4379 static int digestsign_test_run(EVP_TEST *t) in digestsign_test_run() argument
4382 DIGESTSIGN_DATA *expected = t->data; in digestsign_test_run()
4386 if (!signverify_init(t, expected)) in digestsign_test_run()
4388 if (!check_deterministic_noncetype(t, expected)) in digestsign_test_run()
4393 if (!pkey_test_ctrl(t, expected->pctx, value) || t->err != NULL) in digestsign_test_run()
4399 t->err = "DIGESTUPDATE_ERROR"; in digestsign_test_run()
4404 t->err = "DIGESTSIGNFINAL_LENGTH_ERROR"; in digestsign_test_run()
4408 t->err = "MALLOC_FAILURE"; in digestsign_test_run()
4413 t->err = "DIGESTSIGNFINAL_ERROR"; in digestsign_test_run()
4416 if (!memory_err_compare(t, "SIGNATURE_MISMATCH", in digestsign_test_run()
4421 t->err = NULL; in digestsign_test_run()
4435 static int digestverify_test_init(EVP_TEST *t, const char *alg) in digestverify_test_init() argument
4437 return digestsigver_test_init(t, alg, 1, 0); in digestverify_test_init()
4446 static int digestverify_test_run(EVP_TEST *t) in digestverify_test_run() argument
4448 DIGESTSIGN_DATA *mdata = t->data; in digestverify_test_run()
4450 if (!signverify_init(t, mdata)) in digestverify_test_run()
4454 t->err = "DIGESTUPDATE_ERROR"; in digestverify_test_run()
4460 t->err = "VERIFY_ERROR"; in digestverify_test_run()
4472 static int oneshot_digestsign_test_init(EVP_TEST *t, const char *alg) in oneshot_digestsign_test_init() argument
4474 return digestsigver_test_init(t, alg, 0, 1); in oneshot_digestsign_test_init()
4477 static int oneshot_digestsign_test_run(EVP_TEST *t) in oneshot_digestsign_test_run() argument
4479 DIGESTSIGN_DATA *expected = t->data; in oneshot_digestsign_test_run()
4483 if (!signverify_init(t, expected)) in oneshot_digestsign_test_run()
4488 t->err = "DIGESTSIGN_LENGTH_ERROR"; in oneshot_digestsign_test_run()
4492 t->err = "MALLOC_FAILURE"; in oneshot_digestsign_test_run()
4498 t->err = "DIGESTSIGN_ERROR"; in oneshot_digestsign_test_run()
4501 if (!memory_err_compare(t, "SIGNATURE_MISMATCH", in oneshot_digestsign_test_run()
4506 t->err = NULL; in oneshot_digestsign_test_run()
4520 static int oneshot_digestverify_test_init(EVP_TEST *t, const char *alg) in oneshot_digestverify_test_init() argument
4522 return digestsigver_test_init(t, alg, 1, 1); in oneshot_digestverify_test_init()
4525 static int oneshot_digestverify_test_run(EVP_TEST *t) in oneshot_digestverify_test_run() argument
4527 DIGESTSIGN_DATA *mdata = t->data; in oneshot_digestverify_test_run()
4529 if (!signverify_init(t, mdata)) in oneshot_digestverify_test_run()
4534 t->err = "VERIFY_ERROR"; in oneshot_digestverify_test_run()
4588 static void clear_test(EVP_TEST *t) in clear_test() argument
4590 test_clearstanza(&t->s); in clear_test()
4592 if (t->data != NULL) { in clear_test()
4593 if (t->meth != NULL) in clear_test()
4594 t->meth->cleanup(t); in clear_test()
4595 OPENSSL_free(t->data); in clear_test()
4596 t->data = NULL; in clear_test()
4598 OPENSSL_free(t->expected_err); in clear_test()
4599 t->expected_err = NULL; in clear_test()
4600 OPENSSL_free(t->reason); in clear_test()
4601 t->reason = NULL; in clear_test()
4604 t->err = NULL; in clear_test()
4605 t->skip = 0; in clear_test()
4606 t->meth = NULL; in clear_test()
4607 t->expect_unapproved = 0; in clear_test()
4615 static int check_test_error(EVP_TEST *t) in check_test_error() argument
4620 if (t->err == NULL && t->expected_err == NULL) in check_test_error()
4622 if (t->err != NULL && t->expected_err == NULL) { in check_test_error()
4623 if (t->aux_err != NULL) { in check_test_error()
4625 t->s.test_file, t->s.start, t->aux_err, t->err); in check_test_error()
4628 t->s.test_file, t->s.start, t->err); in check_test_error()
4632 if (t->err == NULL && t->expected_err != NULL) { in check_test_error()
4634 t->s.test_file, t->s.start, t->expected_err); in check_test_error()
4638 if (strcmp(t->err, t->expected_err) != 0) { in check_test_error()
4640 t->s.test_file, t->s.start, t->expected_err, t->err); in check_test_error()
4644 if (t->reason == NULL) in check_test_error()
4647 if (t->reason == NULL) { in check_test_error()
4649 t->s.test_file, t->s.start); in check_test_error()
4656 t->s.test_file, t->s.start, t->reason); in check_test_error()
4664 t->s.test_file, t->s.start, t->reason); in check_test_error()
4668 if (strcmp(reason, t->reason) == 0) in check_test_error()
4672 t->s.test_file, t->s.start, t->reason, reason); in check_test_error()
4678 static int run_test(EVP_TEST *t) in run_test() argument
4680 if (t->meth == NULL) in run_test()
4682 t->s.numtests++; in run_test()
4683 if (t->skip) { in run_test()
4684 t->s.numskip++; in run_test()
4687 if (t->err == NULL && t->meth->run_test(t) != 1) { in run_test()
4689 t->s.test_file, t->s.start, t->meth->name); in run_test()
4692 if (!check_test_error(t)) { in run_test()
4694 t->s.errors++; in run_test()
4823 static int parse(EVP_TEST *t) in parse() argument
4833 if (BIO_eof(t->s.fp)) in parse()
4835 clear_test(t); in parse()
4836 if (!test_readstanza(&t->s)) in parse()
4838 } while (t->s.numpairs == 0); in parse()
4839 pp = &t->s.pairs[0]; in parse()
4846 pkey = PEM_read_bio_PrivateKey_ex(t->s.key, NULL, 0, NULL, libctx, NULL); in parse()
4855 pkey = PEM_read_bio_PUBKEY_ex(t->s.key, NULL, 0, NULL, libctx, NULL); in parse()
4864 pkey = PEM_read_bio_Parameters_ex(t->s.key, NULL, libctx, NULL); in parse()
4921 pp->value, t->s.test_file, t->s.start); in parse()
4922 t->skip = 1; in parse()
4932 TEST_info("Line %d: error matching FIPS versions\n", t->s.curr); in parse()
4936 t->s.test_file, t->s.start); in parse()
4937 t->skip = 1; in parse()
4960 if ((t->s.numpairs - skipped) != 1) in parse()
4961 TEST_info("Line %d: missing blank line\n", t->s.curr); in parse()
4966 if (!TEST_ptr(t->meth = find_test(pp->key))) in parse()
4968 if (!t->meth->init(t, pp->value)) { in parse()
4972 if (t->skip == 1) { in parse()
4977 for (pp++, i = 1; i < (t->s.numpairs - skipped); pp++, i++) { in parse()
4985 t->s.test_file, t->s.start); in parse()
4986 t->skip = 1; in parse()
4991 t->s.curr); in parse()
4994 if (t->expected_err != NULL) { in parse()
4995 TEST_info("Line %d: multiple result lines", t->s.curr); in parse()
4998 t->expected_err = take_value(pp); in parse()
5002 if (t->reason != NULL) { in parse()
5003 TEST_info("Line %d: multiple reason lines", t->s.curr); in parse()
5006 t->reason = take_value(pp); in parse()
5010 pp->value, t->s.test_file, t->s.start); in parse()
5011 t->skip = 1; in parse()
5014 t->expect_unapproved = 1; in parse()
5017 int rv = t->meth->parse(t, pp->key, pp->value); in parse()
5020 TEST_info("Line %d: unknown keyword %s", t->s.curr, pp->key); in parse()
5025 t->s.curr, pp->key, pp->value); in parse()
5028 if (t->skip) in parse()
5038 EVP_TEST *t; in run_file_tests() local
5042 if (!TEST_ptr(t = OPENSSL_zalloc(sizeof(*t)))) in run_file_tests()
5044 if (!test_start_file(&t->s, testfile)) { in run_file_tests()
5045 OPENSSL_free(t); in run_file_tests()
5050 while (!BIO_eof(t->s.fp)) { in run_file_tests()
5051 c = parse(t); in run_file_tests()
5052 if (t->skip) { in run_file_tests()
5053 t->s.numskip++; in run_file_tests()
5056 if (c == 0 || !run_test(t)) { in run_file_tests()
5057 t->s.errors++; in run_file_tests()
5061 test_end_file(&t->s); in run_file_tests()
5062 clear_test(t); in run_file_tests()
5066 BIO_free(t->s.key); in run_file_tests()
5067 c = t->s.errors; in run_file_tests()
5068 OPENSSL_free(t); in run_file_tests()