]>
Commit | Line | Data |
---|---|---|
2c166171 | 1 | /* |
8fe3127c | 2 | * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved. |
2c166171 RL |
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 the asn1 module */ | |
11 | ||
12 | #include <stdio.h> | |
13 | #include <string.h> | |
14 | ||
15 | #include <openssl/asn1.h> | |
16 | #include <openssl/evp.h> | |
17 | #include <openssl/objects.h> | |
18 | #include "testutil.h" | |
19 | #include "e_os.h" | |
20 | ||
2c166171 RL |
21 | /********************************************************************** |
22 | * | |
23 | * Test of a_strnid's tbl_standard | |
24 | * | |
25 | ***/ | |
26 | ||
2c166171 RL |
27 | #include "../crypto/asn1/tbl_standard.h" |
28 | ||
308b876d | 29 | static int test_tbl_standard() |
2c166171 RL |
30 | { |
31 | const ASN1_STRING_TABLE *tmp; | |
32 | int last_nid = -1; | |
33 | size_t i; | |
34 | ||
35 | for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) { | |
36 | if (tmp->nid < last_nid) { | |
37 | last_nid = 0; | |
38 | break; | |
39 | } | |
40 | last_nid = tmp->nid; | |
41 | } | |
42 | ||
8fe3127c P |
43 | if (TEST_int_ne(last_nid, 0)) { |
44 | TEST_info("asn1 tbl_standard: Table order OK"); | |
2c166171 RL |
45 | return 1; |
46 | } | |
47 | ||
8fe3127c | 48 | TEST_error("asn1 tbl_standard: out of order"); |
2c166171 | 49 | for (tmp = tbl_standard, i = 0; i < OSSL_NELEM(tbl_standard); i++, tmp++) |
8fe3127c P |
50 | TEST_note("asn1 tbl_standard: Index %" OSSLzu ", NID %d, Name=%s", |
51 | i, tmp->nid, OBJ_nid2ln(tmp->nid)); | |
2c166171 RL |
52 | |
53 | return 0; | |
54 | } | |
55 | ||
2c166171 RL |
56 | /********************************************************************** |
57 | * | |
58 | * Test of ameth_lib's standard_methods | |
59 | * | |
60 | ***/ | |
61 | ||
2c166171 RL |
62 | #include "internal/asn1_int.h" |
63 | #include "../crypto/asn1/standard_methods.h" | |
64 | ||
308b876d | 65 | static int test_standard_methods() |
2c166171 RL |
66 | { |
67 | const EVP_PKEY_ASN1_METHOD **tmp; | |
68 | int last_pkey_id = -1; | |
69 | size_t i; | |
70 | ||
71 | for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods); | |
72 | i++, tmp++) { | |
73 | if ((*tmp)->pkey_id < last_pkey_id) { | |
74 | last_pkey_id = 0; | |
75 | break; | |
76 | } | |
77 | last_pkey_id = (*tmp)->pkey_id; | |
78 | } | |
79 | ||
8fe3127c P |
80 | if (TEST_int_ne(last_pkey_id, 0)) { |
81 | TEST_info("asn1 standard methods: Table order OK"); | |
2c166171 RL |
82 | return 1; |
83 | } | |
84 | ||
8fe3127c | 85 | TEST_error("asn1 standard methods: out of order"); |
2c166171 RL |
86 | for (tmp = standard_methods, i = 0; i < OSSL_NELEM(standard_methods); |
87 | i++, tmp++) | |
8fe3127c P |
88 | TEST_note("asn1 standard methods: Index %" OSSLzu |
89 | ", pkey ID %d, Name=%s", i, (*tmp)->pkey_id, | |
90 | OBJ_nid2sn((*tmp)->pkey_id)); | |
2c166171 RL |
91 | |
92 | return 0; | |
93 | } | |
94 | ||
e364c3b2 | 95 | void register_tests(void) |
2c166171 | 96 | { |
308b876d EK |
97 | ADD_TEST(test_tbl_standard); |
98 | ADD_TEST(test_standard_methods); | |
2c166171 | 99 | } |