Fix the two new tests since approval.
[openssl.git] / test / pkey_meth_test.c
1 /*
2  * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (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
8  */
9
10 /* Internal tests for EVP_PKEY method ordering */
11
12 #include <stdio.h>
13 #include <string.h>
14
15 #include <openssl/evp.h>
16 #include "testutil.h"
17
18 /**********************************************************************
19  *
20  * Test of EVP_PKEY_ASN1 method ordering
21  *
22  ***/
23
24 static int test_asn1_meths()
25 {
26     int i;
27     int prev = -1;
28     int good = 1;
29     int pkey_id;
30     const EVP_PKEY_ASN1_METHOD *ameth;
31
32     for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
33         ameth = EVP_PKEY_asn1_get0(i);
34         EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
35         if (pkey_id < prev)
36             good = 0;
37         prev = pkey_id;
38
39     }
40     if (!good) {
41         TEST_error("EVP_PKEY_ASN1_METHOD table out of order");
42         for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
43             const char *info;
44
45             ameth = EVP_PKEY_asn1_get0(i);
46             EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, &info, NULL, ameth);
47             if (info == NULL)
48                 info = "<NO NAME>";
49             TEST_note("%d : %s : %s", pkey_id, OBJ_nid2ln(pkey_id), info);
50         }
51     }
52     return good;
53 }
54
55 int setup_tests()
56 {
57     ADD_TEST(test_asn1_meths);
58     return 1;
59 }