]>
Commit | Line | Data |
---|---|---|
440e5d80 | 1 | /* |
ad887416 | 2 | * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved. |
d9546693 | 3 | * |
440e5d80 RS |
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 | |
d9546693 DSH |
8 | */ |
9 | ||
10 | #include <openssl/evp.h> | |
b66411f6 | 11 | #include "testutil.h" |
d9546693 DSH |
12 | |
13 | /* | |
14 | * Password based encryption (PBE) table ordering test. | |
15 | * Attempt to look up all supported algorithms. | |
16 | */ | |
17 | ||
b66411f6 | 18 | static int test_pbelu(void) |
d9546693 | 19 | { |
9e206ce5 | 20 | int i, failed = 0; |
b66411f6 RS |
21 | int pbe_type, pbe_nid, last_type = -1, last_nid = -1; |
22 | ||
d9546693 | 23 | for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { |
b66411f6 | 24 | if (!TEST_true(EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0))) { |
9e206ce5 | 25 | TEST_note("i=%d, pbe_type=%d, pbe_nid=%d", i, pbe_type, pbe_nid); |
b66411f6 | 26 | failed = 1; |
d9546693 DSH |
27 | break; |
28 | } | |
29 | } | |
b66411f6 RS |
30 | |
31 | if (!failed) | |
32 | return 1; | |
33 | ||
d9546693 DSH |
34 | /* Error: print out whole table */ |
35 | for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { | |
9e206ce5 P |
36 | failed = pbe_type < last_type |
37 | || (pbe_type == last_type && pbe_nid < last_nid); | |
38 | TEST_note("PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid, | |
39 | OBJ_nid2sn(pbe_nid), failed ? "ERROR" : "OK"); | |
d9546693 DSH |
40 | last_type = pbe_type; |
41 | last_nid = pbe_nid; | |
42 | } | |
9e206ce5 | 43 | return 0; |
b66411f6 RS |
44 | } |
45 | ||
ad887416 | 46 | int setup_tests(void) |
b66411f6 RS |
47 | { |
48 | ADD_TEST(test_pbelu); | |
ad887416 | 49 | return 1; |
d9546693 | 50 | } |