summaryrefslogtreecommitdiff
path: root/CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2018-10-08 13:31:30 -0400
committerPeter Jones <pjones@redhat.com>2018-10-09 17:50:01 -0400
commitb86e8e7e9c4d4191d556a52fbd2c3e614ddb246e (patch)
treeca28062a443b69ba44c28ad01c31f522c0e12992 /CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c
parent6dfae5e78b327f4671f10e85a42c94cad9064bd6 (diff)
downloadefi-boot-shim-openssl-rebase-helper-start.tar.gz
efi-boot-shim-openssl-rebase-helper-start.zip
Add CryptoPkg/Library/BaseCryptLib/ and CryptoPkg/Library/OpensslLib/openssl-rebase-helper-start
Diffstat (limited to 'CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c')
-rw-r--r--CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c b/CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c
new file mode 100644
index 00000000..e226d43f
--- /dev/null
+++ b/CryptoPkg/Library/OpensslLib/openssl/test/pbelutest.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/evp.h>
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * Password based encryption (PBE) table ordering test.
+ * Attempt to look up all supported algorithms.
+ */
+
+int main(int argc, char **argv)
+{
+ size_t i;
+ int rv = 0;
+ int pbe_type, pbe_nid;
+ int last_type = -1, last_nid = -1;
+ for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
+ if (EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0) == 0) {
+ rv = 1;
+ break;
+ }
+ }
+ if (rv == 0)
+ return 0;
+ /* Error: print out whole table */
+ for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) {
+ if (pbe_type > last_type)
+ rv = 0;
+ else if (pbe_type < last_type || pbe_nid < last_nid)
+ rv = 1;
+ else
+ rv = 0;
+ fprintf(stderr, "PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid,
+ OBJ_nid2sn(pbe_nid), rv ? "ERROR" : "OK");
+ last_type = pbe_type;
+ last_nid = pbe_nid;
+ }
+ return 1;
+}