diff options
-rw-r--r-- | src/regress/lib/libcrypto/Makefile | 3 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/engine/Makefile | 9 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/engine/enginetest.c | 253 |
3 files changed, 1 insertions, 264 deletions
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile index 01ffd29227..0e279cca1d 100644 --- a/src/regress/lib/libcrypto/Makefile +++ b/src/regress/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.52 2023/04/25 15:18:59 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.53 2023/12/27 12:26:17 jsing Exp $ |
2 | 2 | ||
3 | SUBDIR += aead | 3 | SUBDIR += aead |
4 | SUBDIR += aes | 4 | SUBDIR += aes |
@@ -22,7 +22,6 @@ SUBDIR += dsa | |||
22 | SUBDIR += ec | 22 | SUBDIR += ec |
23 | SUBDIR += ecdh | 23 | SUBDIR += ecdh |
24 | SUBDIR += ecdsa | 24 | SUBDIR += ecdsa |
25 | SUBDIR += engine | ||
26 | SUBDIR += evp | 25 | SUBDIR += evp |
27 | SUBDIR += free | 26 | SUBDIR += free |
28 | SUBDIR += gcm128 | 27 | SUBDIR += gcm128 |
diff --git a/src/regress/lib/libcrypto/engine/Makefile b/src/regress/lib/libcrypto/engine/Makefile deleted file mode 100644 index 7f11b0d382..0000000000 --- a/src/regress/lib/libcrypto/engine/Makefile +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | # $OpenBSD: Makefile,v 1.3 2014/07/08 15:53:52 jsing Exp $ | ||
2 | |||
3 | PROG= enginetest | ||
4 | LDADD= -lcrypto | ||
5 | DPADD= ${LIBCRYPTO} | ||
6 | WARNINGS= Yes | ||
7 | CFLAGS+= -DLIBRESSL_INTERNAL -Werror | ||
8 | |||
9 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/engine/enginetest.c b/src/regress/lib/libcrypto/engine/enginetest.c deleted file mode 100644 index 9afae39190..0000000000 --- a/src/regress/lib/libcrypto/engine/enginetest.c +++ /dev/null | |||
@@ -1,253 +0,0 @@ | |||
1 | /* $OpenBSD: enginetest.c,v 1.10 2023/06/19 18:52:29 tb Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <string.h> | ||
61 | |||
62 | #include <openssl/buffer.h> | ||
63 | #include <openssl/crypto.h> | ||
64 | #ifndef OPENSSL_NO_ENGINE | ||
65 | #include <openssl/engine.h> | ||
66 | #include <openssl/err.h> | ||
67 | |||
68 | static void display_engine_list(void) | ||
69 | { | ||
70 | ENGINE *h; | ||
71 | int loop; | ||
72 | |||
73 | h = ENGINE_get_first(); | ||
74 | loop = 0; | ||
75 | printf("listing available engine types\n"); | ||
76 | while (h) { | ||
77 | printf("engine %d, id = \"%s\", name = \"%s\"\n", | ||
78 | loop++, ENGINE_get_id(h), ENGINE_get_name(h)); | ||
79 | h = ENGINE_get_next(h); | ||
80 | } | ||
81 | |||
82 | printf("end of list\n"); | ||
83 | /* | ||
84 | * ENGINE_get_first() increases the struct_ref counter, so we must call | ||
85 | * ENGINE_free() to decrease it again | ||
86 | */ | ||
87 | ENGINE_free(h); | ||
88 | } | ||
89 | |||
90 | int main(int argc, char *argv[]) | ||
91 | { | ||
92 | ENGINE *block[512]; | ||
93 | char *id, *name; | ||
94 | ENGINE *ptr; | ||
95 | int loop; | ||
96 | int to_return = 1; | ||
97 | ENGINE *new_h1 = NULL; | ||
98 | ENGINE *new_h2 = NULL; | ||
99 | ENGINE *new_h3 = NULL; | ||
100 | ENGINE *new_h4 = NULL; | ||
101 | |||
102 | ERR_load_crypto_strings(); | ||
103 | |||
104 | memset(block, 0, 512 * sizeof(ENGINE *)); | ||
105 | if (((new_h1 = ENGINE_new()) == NULL) || | ||
106 | !ENGINE_set_id(new_h1, "test_id0") || | ||
107 | !ENGINE_set_name(new_h1, "First test item") || | ||
108 | ((new_h2 = ENGINE_new()) == NULL) || | ||
109 | !ENGINE_set_id(new_h2, "test_id1") || | ||
110 | !ENGINE_set_name(new_h2, "Second test item") || | ||
111 | ((new_h3 = ENGINE_new()) == NULL) || | ||
112 | !ENGINE_set_id(new_h3, "test_id2") || | ||
113 | !ENGINE_set_name(new_h3, "Third test item") || | ||
114 | ((new_h4 = ENGINE_new()) == NULL) || | ||
115 | !ENGINE_set_id(new_h4, "test_id3") || | ||
116 | !ENGINE_set_name(new_h4, "Fourth test item")) { | ||
117 | printf("Couldn't set up test ENGINE structures\n"); | ||
118 | goto end; | ||
119 | } | ||
120 | |||
121 | printf("\nenginetest beginning\n\n"); | ||
122 | display_engine_list(); | ||
123 | if (!ENGINE_add(new_h1)) { | ||
124 | printf("Add failed!\n"); | ||
125 | goto end; | ||
126 | } | ||
127 | display_engine_list(); | ||
128 | ptr = ENGINE_get_first(); | ||
129 | if (!ENGINE_remove(ptr)) { | ||
130 | printf("Remove failed!\n"); | ||
131 | goto end; | ||
132 | } | ||
133 | ENGINE_free(ptr); | ||
134 | display_engine_list(); | ||
135 | if (!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) { | ||
136 | printf("Add failed!\n"); | ||
137 | goto end; | ||
138 | } | ||
139 | display_engine_list(); | ||
140 | if (!ENGINE_remove(new_h2)) { | ||
141 | printf("Remove failed!\n"); | ||
142 | goto end; | ||
143 | } | ||
144 | display_engine_list(); | ||
145 | if (!ENGINE_add(new_h4)) { | ||
146 | printf("Add failed!\n"); | ||
147 | goto end; | ||
148 | } | ||
149 | display_engine_list(); | ||
150 | if (ENGINE_add(new_h3)) { | ||
151 | printf("Add *should* have failed but didn't!\n"); | ||
152 | goto end; | ||
153 | } else | ||
154 | printf("Add that should fail did.\n"); | ||
155 | ERR_clear_error(); | ||
156 | if (ENGINE_remove(new_h2)) { | ||
157 | printf("Remove *should* have failed but didn't!\n"); | ||
158 | goto end; | ||
159 | } else | ||
160 | printf("Remove that should fail did.\n"); | ||
161 | ERR_clear_error(); | ||
162 | if (!ENGINE_remove(new_h3)) { | ||
163 | printf("Remove failed!\n"); | ||
164 | goto end; | ||
165 | } | ||
166 | display_engine_list(); | ||
167 | if (!ENGINE_remove(new_h4)) { | ||
168 | printf("Remove failed!\n"); | ||
169 | goto end; | ||
170 | } | ||
171 | display_engine_list(); | ||
172 | /* | ||
173 | * Depending on whether there's any hardware support compiled | ||
174 | * in, this remove may be destined to fail. | ||
175 | */ | ||
176 | ptr = ENGINE_get_first(); | ||
177 | if (ptr) | ||
178 | if (!ENGINE_remove(ptr)) | ||
179 | printf("Remove failed!i - probably no hardware " | ||
180 | "support present.\n"); | ||
181 | ENGINE_free(ptr); | ||
182 | display_engine_list(); | ||
183 | |||
184 | if (!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) { | ||
185 | printf("Couldn't add and remove to an empty list!\n"); | ||
186 | goto end; | ||
187 | } else | ||
188 | printf("Successfully added and removed to an empty list!\n"); | ||
189 | |||
190 | printf("About to beef up the engine-type list\n"); | ||
191 | for (loop = 0; loop < 512; loop++) { | ||
192 | if (asprintf(&id, "id%d", loop) == -1) | ||
193 | goto end; | ||
194 | if (asprintf(&name, "Fake engine type %d", loop) == -1) | ||
195 | goto end; | ||
196 | |||
197 | if (((block[loop] = ENGINE_new()) == NULL) || | ||
198 | !id || !ENGINE_set_id(block[loop], id) || | ||
199 | !name || !ENGINE_set_name(block[loop], name)) { | ||
200 | printf("Couldn't create block of ENGINE structures.\n"); | ||
201 | goto end; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | for (loop = 0; loop < 512; loop++) { | ||
206 | if (!ENGINE_add(block[loop])) { | ||
207 | printf("\nAdding stopped at %d, (%s,%s)\n", | ||
208 | loop, ENGINE_get_id(block[loop]), | ||
209 | ENGINE_get_name(block[loop])); | ||
210 | break; | ||
211 | } | ||
212 | printf("."); | ||
213 | fflush(stdout); | ||
214 | } | ||
215 | printf("\nAbout to empty the engine-type list\n"); | ||
216 | while ((ptr = ENGINE_get_first()) != NULL) { | ||
217 | if (!ENGINE_remove(ptr)) { | ||
218 | printf("\nRemove failed!\n"); | ||
219 | goto end; | ||
220 | } | ||
221 | ENGINE_free(ptr); | ||
222 | printf("."); fflush(stdout); | ||
223 | } | ||
224 | for (loop = 0; loop < 512; loop++) { | ||
225 | free((void *)ENGINE_get_id(block[loop])); | ||
226 | free((void *)ENGINE_get_name(block[loop])); | ||
227 | } | ||
228 | printf("\nTests completed happily\n"); | ||
229 | to_return = 0; | ||
230 | end: | ||
231 | if (to_return) | ||
232 | ERR_print_errors_fp(stderr); | ||
233 | ENGINE_free(new_h1); | ||
234 | ENGINE_free(new_h2); | ||
235 | ENGINE_free(new_h3); | ||
236 | ENGINE_free(new_h4); | ||
237 | for (loop = 0; loop < 512; loop++) | ||
238 | ENGINE_free(block[loop]); | ||
239 | ENGINE_cleanup(); | ||
240 | CRYPTO_cleanup_all_ex_data(); | ||
241 | ERR_free_strings(); | ||
242 | ERR_remove_thread_state(NULL); | ||
243 | CRYPTO_mem_leaks_fp(stderr); | ||
244 | return to_return; | ||
245 | } | ||
246 | #else | ||
247 | int | ||
248 | main(void) | ||
249 | { | ||
250 | printf("ENGINE support is disabled\n"); | ||
251 | return 0; | ||
252 | } | ||
253 | #endif | ||