1 /* 2 * Copyright 2015-2016 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 #include <openssl/evp.h> 11 #include <stdio.h> 12 #include <string.h> 13 14 /* 15 * Password based encryption (PBE) table ordering test. 16 * Attempt to look up all supported algorithms. 17 */ 18 19 int main(int argc, char **argv) 20 { 21 size_t i; 22 int rv = 0; 23 int pbe_type, pbe_nid; 24 int last_type = -1, last_nid = -1; 25 for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { 26 if (EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0) == 0) { 27 rv = 1; 28 break; 29 } 30 } 31 if (rv == 0) 32 return 0; 33 /* Error: print out whole table */ 34 for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { 35 if (pbe_type > last_type) 36 rv = 0; 37 else if (pbe_type < last_type || pbe_nid < last_nid) 38 rv = 1; 39 else 40 rv = 0; 41 fprintf(stderr, "PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid, 42 OBJ_nid2sn(pbe_nid), rv ? "ERROR" : "OK"); 43 last_type = pbe_type; 44 last_nid = pbe_nid; 45 } 46 return 1; 47 } 48