2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* Internal tests for EVP_PKEY method ordering */
12 /* We need to use some deprecated APIs */
13 #define OPENSSL_SUPPRESS_DEPRECATED
18 #include <openssl/evp.h>
21 /* Test of EVP_PKEY_ASN1_METHOD ordering */
22 static int test_asn1_meths(void)
28 const EVP_PKEY_ASN1_METHOD *ameth;
30 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
31 ameth = EVP_PKEY_asn1_get0(i);
32 EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
39 TEST_error("EVP_PKEY_ASN1_METHOD table out of order");
40 for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
43 ameth = EVP_PKEY_asn1_get0(i);
44 EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, &info, NULL, ameth);
47 TEST_note("%d : %s : %s", pkey_id, OBJ_nid2ln(pkey_id), info);
53 #ifndef OPENSSL_NO_DEPRECATED_3_0
54 /* Test of EVP_PKEY_METHOD ordering */
55 static int test_pkey_meths(void)
61 const EVP_PKEY_METHOD *pmeth;
63 for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
64 pmeth = EVP_PKEY_meth_get0(i);
65 EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
72 TEST_error("EVP_PKEY_METHOD table out of order");
73 for (i = 0; i < EVP_PKEY_meth_get_count(); i++) {
74 pmeth = EVP_PKEY_meth_get0(i);
75 EVP_PKEY_meth_get0_info(&pkey_id, NULL, pmeth);
76 TEST_note("%d : %s", pkey_id, OBJ_nid2ln(pkey_id));
85 ADD_TEST(test_asn1_meths);
86 #ifndef OPENSSL_NO_DEPRECATED_3_0
87 ADD_TEST(test_pkey_meths);