test: update ssl_new tests in line with pedantic FIPS policy
[openssl.git] / test / ssl_test.c
1 /*
2  * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (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 <stdio.h>
11 #include <string.h>
12
13 #include <openssl/conf.h>
14 #include <openssl/err.h>
15 #include <openssl/ssl.h>
16 #include <openssl/provider.h>
17 #ifndef OPENSSL_NO_QUIC
18 #include <openssl/quic.h>
19 #endif
20
21 #include "helpers/handshake.h"
22 #include "helpers/ssl_test_ctx.h"
23 #include "testutil.h"
24
25 static CONF *conf = NULL;
26 static OSSL_PROVIDER *defctxnull = NULL, *thisprov = NULL;
27 static OSSL_LIB_CTX *libctx = NULL;
28
29 /* Currently the section names are of the form test-<number>, e.g. test-15. */
30 #define MAX_TESTCASE_NAME_LENGTH 100
31
32 static const char *print_alert(int alert)
33 {
34     return alert ? SSL_alert_desc_string_long(alert) : "no alert";
35 }
36
37 static int check_result(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
38 {
39     if (!TEST_int_eq(result->result, test_ctx->expected_result)) {
40         TEST_info("ExpectedResult mismatch: expected %s, got %s.",
41                   ssl_test_result_name(test_ctx->expected_result),
42                   ssl_test_result_name(result->result));
43         return 0;
44     }
45     return 1;
46 }
47
48 static int check_alerts(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
49 {
50     if (!TEST_int_eq(result->client_alert_sent,
51                      result->client_alert_received)) {
52         TEST_info("Client sent alert %s but server received %s.",
53                   print_alert(result->client_alert_sent),
54                   print_alert(result->client_alert_received));
55         /*
56          * We can't bail here because the peer doesn't always get far enough
57          * to process a received alert. Specifically, in protocol version
58          * negotiation tests, we have the following scenario.
59          * Client supports TLS v1.2 only; Server supports TLS v1.1.
60          * Client proposes TLS v1.2; server responds with 1.1;
61          * Client now sends a protocol alert, using TLS v1.2 in the header.
62          * The server, however, rejects the alert because of version mismatch
63          * in the record layer; therefore, the server appears to never
64          * receive the alert.
65          */
66         /* return 0; */
67     }
68
69     if (!TEST_int_eq(result->server_alert_sent,
70                      result->server_alert_received)) {
71         TEST_info("Server sent alert %s but client received %s.",
72                   print_alert(result->server_alert_sent),
73                   print_alert(result->server_alert_received));
74         /* return 0; */
75     }
76
77     /* Tolerate an alert if one wasn't explicitly specified in the test. */
78     if (test_ctx->expected_client_alert
79         /*
80          * The info callback alert value is computed as
81          * (s->s3->send_alert[0] << 8) | s->s3->send_alert[1]
82          * where the low byte is the alert code and the high byte is other stuff.
83          */
84         && (result->client_alert_sent & 0xff) != test_ctx->expected_client_alert) {
85         TEST_error("ClientAlert mismatch: expected %s, got %s.",
86                    print_alert(test_ctx->expected_client_alert),
87                    print_alert(result->client_alert_sent));
88         return 0;
89     }
90
91     if (test_ctx->expected_server_alert
92         && (result->server_alert_sent & 0xff) != test_ctx->expected_server_alert) {
93         TEST_error("ServerAlert mismatch: expected %s, got %s.",
94                    print_alert(test_ctx->expected_server_alert),
95                    print_alert(result->server_alert_sent));
96         return 0;
97     }
98
99     if (!TEST_int_le(result->client_num_fatal_alerts_sent, 1))
100         return 0;
101     if (!TEST_int_le(result->server_num_fatal_alerts_sent, 1))
102         return 0;
103     return 1;
104 }
105
106 static int check_protocol(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
107 {
108     if (!TEST_int_eq(result->client_protocol, result->server_protocol)) {
109         TEST_info("Client has protocol %s but server has %s.",
110                   ssl_protocol_name(result->client_protocol),
111                   ssl_protocol_name(result->server_protocol));
112         return 0;
113     }
114
115     if (test_ctx->expected_protocol) {
116         if (!TEST_int_eq(result->client_protocol,
117                          test_ctx->expected_protocol)) {
118             TEST_info("Protocol mismatch: expected %s, got %s.\n",
119                       ssl_protocol_name(test_ctx->expected_protocol),
120                       ssl_protocol_name(result->client_protocol));
121             return 0;
122         }
123     }
124     return 1;
125 }
126
127 static int check_servername(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
128 {
129     if (!TEST_int_eq(result->servername, test_ctx->expected_servername)) {
130       TEST_info("Client ServerName mismatch, expected %s, got %s.",
131                 ssl_servername_name(test_ctx->expected_servername),
132                 ssl_servername_name(result->servername));
133       return 0;
134     }
135   return 1;
136 }
137
138 static int check_session_ticket(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
139 {
140     if (test_ctx->session_ticket_expected == SSL_TEST_SESSION_TICKET_IGNORE)
141         return 1;
142     if (!TEST_int_eq(result->session_ticket,
143                      test_ctx->session_ticket_expected)) {
144         TEST_info("Client SessionTicketExpected mismatch, expected %s, got %s.",
145                   ssl_session_ticket_name(test_ctx->session_ticket_expected),
146                   ssl_session_ticket_name(result->session_ticket));
147         return 0;
148     }
149     return 1;
150 }
151
152 static int check_session_id(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
153 {
154     if (test_ctx->session_id_expected == SSL_TEST_SESSION_ID_IGNORE)
155         return 1;
156     if (!TEST_int_eq(result->session_id, test_ctx->session_id_expected)) {
157         TEST_info("Client SessionIdExpected mismatch, expected %s, got %s\n.",
158                 ssl_session_id_name(test_ctx->session_id_expected),
159                 ssl_session_id_name(result->session_id));
160         return 0;
161     }
162     return 1;
163 }
164
165 static int check_compression(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
166 {
167     if (!TEST_int_eq(result->compression, test_ctx->compression_expected))
168         return 0;
169     return 1;
170 }
171 #ifndef OPENSSL_NO_NEXTPROTONEG
172 static int check_npn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
173 {
174     int ret = 1;
175     if (!TEST_str_eq(result->client_npn_negotiated,
176                      result->server_npn_negotiated))
177         ret = 0;
178     if (!TEST_str_eq(test_ctx->expected_npn_protocol,
179                      result->client_npn_negotiated))
180         ret = 0;
181     return ret;
182 }
183 #endif
184
185 static int check_alpn(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
186 {
187     int ret = 1;
188     if (!TEST_str_eq(result->client_alpn_negotiated,
189                      result->server_alpn_negotiated))
190         ret = 0;
191     if (!TEST_str_eq(test_ctx->expected_alpn_protocol,
192                      result->client_alpn_negotiated))
193         ret = 0;
194     return ret;
195 }
196
197 static int check_session_ticket_app_data(HANDSHAKE_RESULT *result,
198                                          SSL_TEST_CTX *test_ctx)
199 {
200     size_t result_len = 0;
201     size_t expected_len = 0;
202
203     /* consider empty and NULL strings to be the same */
204     if (result->result_session_ticket_app_data != NULL)
205         result_len = strlen(result->result_session_ticket_app_data);
206     if (test_ctx->expected_session_ticket_app_data != NULL)
207         expected_len = strlen(test_ctx->expected_session_ticket_app_data);
208     if (result_len == 0 && expected_len == 0)
209         return 1;
210
211     if (!TEST_str_eq(result->result_session_ticket_app_data,
212                      test_ctx->expected_session_ticket_app_data))
213         return 0;
214
215     return 1;
216 }
217
218 static int check_resumption(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
219 {
220     if (!TEST_int_eq(result->client_resumed, result->server_resumed))
221         return 0;
222     if (!TEST_int_eq(result->client_resumed, test_ctx->resumption_expected))
223         return 0;
224     return 1;
225 }
226
227 static int check_nid(const char *name, int expected_nid, int nid)
228 {
229     if (expected_nid == 0 || expected_nid == nid)
230         return 1;
231     TEST_error("%s type mismatch, %s vs %s\n",
232                name, OBJ_nid2ln(expected_nid),
233                nid == NID_undef ? "absent" : OBJ_nid2ln(nid));
234     return 0;
235 }
236
237 static void print_ca_names(STACK_OF(X509_NAME) *names)
238 {
239     int i;
240
241     if (names == NULL || sk_X509_NAME_num(names) == 0) {
242         TEST_note("    <empty>");
243         return;
244     }
245     for (i = 0; i < sk_X509_NAME_num(names); i++) {
246         X509_NAME_print_ex(bio_err, sk_X509_NAME_value(names, i), 4,
247                            XN_FLAG_ONELINE);
248         BIO_puts(bio_err, "\n");
249     }
250 }
251
252 static int check_ca_names(const char *name,
253                           STACK_OF(X509_NAME) *expected_names,
254                           STACK_OF(X509_NAME) *names)
255 {
256     int i;
257
258     if (expected_names == NULL)
259         return 1;
260     if (names == NULL || sk_X509_NAME_num(names) == 0) {
261         if (TEST_int_eq(sk_X509_NAME_num(expected_names), 0))
262             return 1;
263         goto err;
264     }
265     if (sk_X509_NAME_num(names) != sk_X509_NAME_num(expected_names))
266         goto err;
267     for (i = 0; i < sk_X509_NAME_num(names); i++) {
268         if (!TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(names, i),
269                                        sk_X509_NAME_value(expected_names, i)),
270                          0)) {
271             goto err;
272         }
273     }
274     return 1;
275 err:
276     TEST_info("%s: list mismatch", name);
277     TEST_note("Expected Names:");
278     print_ca_names(expected_names);
279     TEST_note("Received Names:");
280     print_ca_names(names);
281     return 0;
282 }
283
284 static int check_tmp_key(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
285 {
286     return check_nid("Tmp key", test_ctx->expected_tmp_key_type,
287                      result->tmp_key_type);
288 }
289
290 static int check_server_cert_type(HANDSHAKE_RESULT *result,
291                                   SSL_TEST_CTX *test_ctx)
292 {
293     return check_nid("Server certificate", test_ctx->expected_server_cert_type,
294                      result->server_cert_type);
295 }
296
297 static int check_server_sign_hash(HANDSHAKE_RESULT *result,
298                                   SSL_TEST_CTX *test_ctx)
299 {
300     return check_nid("Server signing hash", test_ctx->expected_server_sign_hash,
301                      result->server_sign_hash);
302 }
303
304 static int check_server_sign_type(HANDSHAKE_RESULT *result,
305                                   SSL_TEST_CTX *test_ctx)
306 {
307     return check_nid("Server signing", test_ctx->expected_server_sign_type,
308                      result->server_sign_type);
309 }
310
311 static int check_server_ca_names(HANDSHAKE_RESULT *result,
312                                  SSL_TEST_CTX *test_ctx)
313 {
314     return check_ca_names("Server CA names",
315                           test_ctx->expected_server_ca_names,
316                           result->server_ca_names);
317 }
318
319 static int check_client_cert_type(HANDSHAKE_RESULT *result,
320                                   SSL_TEST_CTX *test_ctx)
321 {
322     return check_nid("Client certificate", test_ctx->expected_client_cert_type,
323                      result->client_cert_type);
324 }
325
326 static int check_client_sign_hash(HANDSHAKE_RESULT *result,
327                                   SSL_TEST_CTX *test_ctx)
328 {
329     return check_nid("Client signing hash", test_ctx->expected_client_sign_hash,
330                      result->client_sign_hash);
331 }
332
333 static int check_client_sign_type(HANDSHAKE_RESULT *result,
334                                   SSL_TEST_CTX *test_ctx)
335 {
336     return check_nid("Client signing", test_ctx->expected_client_sign_type,
337                      result->client_sign_type);
338 }
339
340 static int check_client_ca_names(HANDSHAKE_RESULT *result,
341                                  SSL_TEST_CTX *test_ctx)
342 {
343     return check_ca_names("Client CA names",
344                           test_ctx->expected_client_ca_names,
345                           result->client_ca_names);
346 }
347
348 static int check_cipher(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
349 {
350     if (test_ctx->expected_cipher == NULL)
351         return 1;
352     if (!TEST_ptr(result->cipher))
353         return 0;
354     if (!TEST_str_eq(test_ctx->expected_cipher,
355                      result->cipher))
356         return 0;
357     return 1;
358 }
359
360 /*
361  * This could be further simplified by constructing an expected
362  * HANDSHAKE_RESULT, and implementing comparison methods for
363  * its fields.
364  */
365 static int check_test(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
366 {
367     int ret = 1;
368     ret &= check_result(result, test_ctx);
369     ret &= check_alerts(result, test_ctx);
370     if (result->result == SSL_TEST_SUCCESS) {
371         ret &= check_protocol(result, test_ctx);
372         ret &= check_servername(result, test_ctx);
373         ret &= check_session_ticket(result, test_ctx);
374         ret &= check_compression(result, test_ctx);
375         ret &= check_session_id(result, test_ctx);
376         ret &= (result->session_ticket_do_not_call == 0);
377 #ifndef OPENSSL_NO_NEXTPROTONEG
378         ret &= check_npn(result, test_ctx);
379 #endif
380         ret &= check_cipher(result, test_ctx);
381         ret &= check_alpn(result, test_ctx);
382         ret &= check_session_ticket_app_data(result, test_ctx);
383         ret &= check_resumption(result, test_ctx);
384         ret &= check_tmp_key(result, test_ctx);
385         ret &= check_server_cert_type(result, test_ctx);
386         ret &= check_server_sign_hash(result, test_ctx);
387         ret &= check_server_sign_type(result, test_ctx);
388         ret &= check_server_ca_names(result, test_ctx);
389         ret &= check_client_cert_type(result, test_ctx);
390         ret &= check_client_sign_hash(result, test_ctx);
391         ret &= check_client_sign_type(result, test_ctx);
392         ret &= check_client_ca_names(result, test_ctx);
393     }
394     return ret;
395 }
396
397 static int test_handshake(int idx)
398 {
399     int ret = 0;
400     SSL_CTX *server_ctx = NULL, *server2_ctx = NULL, *client_ctx = NULL,
401         *resume_server_ctx = NULL, *resume_client_ctx = NULL;
402     SSL_TEST_CTX *test_ctx = NULL;
403     HANDSHAKE_RESULT *result = NULL;
404     char test_app[MAX_TESTCASE_NAME_LENGTH];
405
406     BIO_snprintf(test_app, sizeof(test_app), "test-%d", idx);
407
408     test_ctx = SSL_TEST_CTX_create(conf, test_app, libctx);
409     if (!TEST_ptr(test_ctx))
410         goto err;
411
412     /* Verify that the FIPS provider supports this test */
413     if (test_ctx->fips_version != NULL
414                 && !fips_provider_version_match(libctx, test_ctx->fips_version)) {
415             ret = TEST_skip("FIPS provider unable to run this test");
416             goto err;
417     }
418
419 #ifndef OPENSSL_NO_DTLS
420     if (test_ctx->method == SSL_TEST_METHOD_DTLS) {
421         server_ctx = SSL_CTX_new_ex(libctx, NULL, DTLS_server_method());
422         if (!TEST_true(SSL_CTX_set_options(server_ctx,
423                         SSL_OP_ALLOW_CLIENT_RENEGOTIATION))
424                 || !TEST_true(SSL_CTX_set_max_proto_version(server_ctx, 0)))
425             goto err;
426         if (test_ctx->extra.server.servername_callback !=
427             SSL_TEST_SERVERNAME_CB_NONE) {
428             if (!TEST_ptr(server2_ctx =
429                             SSL_CTX_new_ex(libctx, NULL, DTLS_server_method()))
430                     || !TEST_true(SSL_CTX_set_options(server2_ctx,
431                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
432                 goto err;
433         }
434         client_ctx = SSL_CTX_new_ex(libctx, NULL, DTLS_client_method());
435         if (!TEST_true(SSL_CTX_set_max_proto_version(client_ctx, 0)))
436             goto err;
437         if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {
438             resume_server_ctx = SSL_CTX_new_ex(libctx, NULL,
439                                                DTLS_server_method());
440             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_server_ctx, 0))
441                     || !TEST_true(SSL_CTX_set_options(resume_server_ctx,
442                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
443                 goto err;
444             resume_client_ctx = SSL_CTX_new_ex(libctx, NULL,
445                                                DTLS_client_method());
446             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_client_ctx, 0)))
447                 goto err;
448             if (!TEST_ptr(resume_server_ctx)
449                     || !TEST_ptr(resume_client_ctx))
450                 goto err;
451         }
452     }
453 #endif
454     if (test_ctx->method == SSL_TEST_METHOD_TLS) {
455 #if !defined(OPENSSL_NO_TLS1_3) \
456     && defined(OPENSSL_NO_EC) \
457     && defined(OPENSSL_NO_DH)
458         /* Without ec or dh there are no built-in groups for TLSv1.3 */
459         int maxversion = TLS1_2_VERSION;
460 #else
461         int maxversion = 0;
462 #endif
463
464         server_ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
465         if (!TEST_true(SSL_CTX_set_max_proto_version(server_ctx, maxversion))
466                 || !TEST_true(SSL_CTX_set_options(server_ctx,
467                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
468             goto err;
469         /* SNI on resumption isn't supported/tested yet. */
470         if (test_ctx->extra.server.servername_callback !=
471             SSL_TEST_SERVERNAME_CB_NONE) {
472             if (!TEST_ptr(server2_ctx =
473                             SSL_CTX_new_ex(libctx, NULL, TLS_server_method()))
474                     || !TEST_true(SSL_CTX_set_options(server2_ctx,
475                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
476                 goto err;
477             if (!TEST_true(SSL_CTX_set_max_proto_version(server2_ctx,
478                                                          maxversion)))
479                 goto err;
480         }
481         client_ctx = SSL_CTX_new_ex(libctx, NULL, TLS_client_method());
482         if (!TEST_true(SSL_CTX_set_max_proto_version(client_ctx, maxversion)))
483             goto err;
484
485         if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {
486             resume_server_ctx = SSL_CTX_new_ex(libctx, NULL,
487                                                TLS_server_method());
488             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_server_ctx,
489                                                          maxversion))
490                     || !TEST_true(SSL_CTX_set_options(resume_server_ctx,
491                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
492                 goto err;
493             resume_client_ctx = SSL_CTX_new_ex(libctx, NULL,
494                                                TLS_client_method());
495             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_client_ctx,
496                                                          maxversion)))
497                 goto err;
498             if (!TEST_ptr(resume_server_ctx)
499                     || !TEST_ptr(resume_client_ctx))
500                 goto err;
501         }
502     }
503 #ifndef OPENSSL_NO_QUIC
504     if (test_ctx->method == SSL_TEST_METHOD_QUIC) {
505         server_ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_server_method());
506         if (test_ctx->extra.server.servername_callback !=
507             SSL_TEST_SERVERNAME_CB_NONE) {
508             if (!TEST_ptr(server2_ctx =
509                             SSL_CTX_new_ex(libctx, NULL,
510                                            OSSL_QUIC_server_method())))
511                 goto err;
512         }
513         client_ctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
514         if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {
515             resume_server_ctx = SSL_CTX_new_ex(libctx, NULL,
516                                                OSSL_QUIC_server_method());
517             resume_client_ctx = SSL_CTX_new_ex(libctx, NULL,
518                                                OSSL_QUIC_client_method());
519             if (!TEST_ptr(resume_server_ctx)
520                     || !TEST_ptr(resume_client_ctx))
521                 goto err;
522         }
523     }
524 #endif
525
526 #ifdef OPENSSL_NO_AUTOLOAD_CONFIG
527     if (!TEST_true(OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL)))
528         goto err;
529 #endif
530
531     if (!TEST_ptr(server_ctx)
532             || !TEST_ptr(client_ctx)
533             || !TEST_int_gt(CONF_modules_load(conf, test_app, 0),  0))
534         goto err;
535
536     if (!SSL_CTX_config(server_ctx, "server")
537         || !SSL_CTX_config(client_ctx, "client")) {
538         goto err;
539     }
540
541     if (server2_ctx != NULL && !SSL_CTX_config(server2_ctx, "server2"))
542         goto err;
543     if (resume_server_ctx != NULL
544         && !SSL_CTX_config(resume_server_ctx, "resume-server"))
545         goto err;
546     if (resume_client_ctx != NULL
547         && !SSL_CTX_config(resume_client_ctx, "resume-client"))
548         goto err;
549
550     result = do_handshake(server_ctx, server2_ctx, client_ctx,
551                           resume_server_ctx, resume_client_ctx, test_ctx);
552
553     if (result != NULL)
554         ret = check_test(result, test_ctx);
555
556 err:
557     CONF_modules_unload(0);
558     SSL_CTX_free(server_ctx);
559     SSL_CTX_free(server2_ctx);
560     SSL_CTX_free(client_ctx);
561     SSL_CTX_free(resume_server_ctx);
562     SSL_CTX_free(resume_client_ctx);
563     SSL_TEST_CTX_free(test_ctx);
564     HANDSHAKE_RESULT_free(result);
565     return ret;
566 }
567
568 #define USAGE "conf_file module_name [module_conf_file]\n"
569 OPT_TEST_DECLARE_USAGE(USAGE)
570
571 int setup_tests(void)
572 {
573     long num_tests;
574
575     if (!test_skip_common_options()) {
576         TEST_error("Error parsing test options\n");
577         return 0;
578     }
579
580     if (!TEST_ptr(conf = NCONF_new(NULL))
581             /* argv[1] should point to the test conf file */
582             || !TEST_int_gt(NCONF_load(conf, test_get_argument(0), NULL), 0)
583             || !TEST_int_ne(NCONF_get_number_e(conf, NULL, "num_tests",
584                                                &num_tests), 0)) {
585         TEST_error("usage: ssl_test %s", USAGE);
586         return 0;
587     }
588
589     if (!test_arg_libctx(&libctx, &defctxnull, &thisprov, 1, USAGE))
590         return 0;
591
592     ADD_ALL_TESTS(test_handshake, (int)num_tests);
593     return 1;
594 }
595
596 void cleanup_tests(void)
597 {
598     NCONF_free(conf);
599     OSSL_PROVIDER_unload(defctxnull);
600     OSSL_PROVIDER_unload(thisprov);
601     OSSL_LIB_CTX_free(libctx);
602 }