summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2022-11-09 17:15:59 +0000
committerjsing <>2022-11-09 17:15:59 +0000
commitba67559fec418c6b97834e077e96f2392244261d (patch)
tree419745e35d30316044acb9926492fe983429f7ae
parent43e1084850b7fe1150ba2bd0e010673e66bc63df (diff)
downloadopenbsd-ba67559fec418c6b97834e077e96f2392244261d.tar.gz
openbsd-ba67559fec418c6b97834e077e96f2392244261d.tar.bz2
openbsd-ba67559fec418c6b97834e077e96f2392244261d.zip
Add some regress coverage for EVP_PKEY_METHOD.
-rw-r--r--src/regress/lib/libcrypto/evp/evp_test.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/regress/lib/libcrypto/evp/evp_test.c b/src/regress/lib/libcrypto/evp/evp_test.c
index bf43d7a5ab..c4721cc365 100644
--- a/src/regress/lib/libcrypto/evp/evp_test.c
+++ b/src/regress/lib/libcrypto/evp/evp_test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_test.c,v 1.1 2022/11/09 16:13:39 jsing Exp $ */ 1/* $OpenBSD: evp_test.c,v 1.2 2022/11/09 17:15:59 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -21,7 +21,7 @@
21#include "evp_locl.h" 21#include "evp_locl.h"
22 22
23static int 23static int
24evp_meth_find_test(void) 24evp_asn1_method_test(void)
25{ 25{
26 const EVP_PKEY_ASN1_METHOD *method; 26 const EVP_PKEY_ASN1_METHOD *method;
27 int count, pkey_id, i; 27 int count, pkey_id, i;
@@ -101,12 +101,49 @@ evp_meth_find_test(void)
101 return failed; 101 return failed;
102} 102}
103 103
104static int
105evp_pkey_method_test(void)
106{
107 const EVP_PKEY_METHOD *method;
108 int pkey_id;
109 int failed = 1;
110
111 if ((method = EVP_PKEY_meth_find(EVP_PKEY_RSA)) == NULL) {
112 fprintf(stderr, "FAIL: failed to find RSA method\n");
113 goto failure;
114 }
115 EVP_PKEY_meth_get0_info(&pkey_id, NULL, method);
116 if (pkey_id != EVP_PKEY_RSA) {
117 fprintf(stderr, "FAIL: method ID mismatch (%d != %d)\n",
118 pkey_id, EVP_PKEY_RSA);
119 goto failure;
120 }
121
122 if ((method = EVP_PKEY_meth_find(EVP_PKEY_RSA_PSS)) == NULL) {
123 fprintf(stderr, "FAIL: failed to find RSA-PSS method\n");
124 goto failure;
125 }
126 EVP_PKEY_meth_get0_info(&pkey_id, NULL, method);
127 if (pkey_id != EVP_PKEY_RSA_PSS) {
128 fprintf(stderr, "FAIL: method ID mismatch (%d != %d)\n",
129 pkey_id, EVP_PKEY_RSA_PSS);
130 goto failure;
131 }
132
133 failed = 0;
134
135 failure:
136
137 return failed;
138}
139
104int 140int
105main(int argc, char **argv) 141main(int argc, char **argv)
106{ 142{
107 int failed = 0; 143 int failed = 0;
108 144
109 failed |= evp_meth_find_test(); 145 failed |= evp_asn1_method_test();
146 failed |= evp_pkey_method_test();
110 147
111 return failed; 148 return failed;
112} 149}