-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathwp_wolfprov.c
More file actions
1519 lines (1379 loc) · 46.7 KB
/
Copy pathwp_wolfprov.c
File metadata and controls
1519 lines (1379 loc) · 46.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* wolfprov.c
*
* Copyright (C) 2006-2025 wolfSSL Inc.
*
* This file is part of wolfProvider.
*
* wolfProvider is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfProvider is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wolfProvider. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
#include <openssl/core.h>
#include <openssl/core_dispatch.h>
#include <openssl/core_names.h>
#include <openssl/params.h>
#include <openssl/prov_ssl.h>
#include <openssl/bio.h>
#include "wolfprovider/version.h"
#include "wolfprovider/settings.h"
#include "wolfprovider/wp_wolfprov.h"
#include "wolfprovider/alg_funcs.h"
#include "wolfssl/wolfcrypt/logging.h"
#ifdef HAVE_FIPS
#include <wolfssl/wolfcrypt/fips_test.h>
#endif
const char* wolfprovider_id = "libwolfprov";
/* Core function that gets the table of parameters. */
static OSSL_FUNC_core_gettable_params_fn* c_gettable_params = NULL;
/* Core function that gets the parameters. */
static OSSL_FUNC_core_get_params_fn* c_get_params = NULL;
/* Parameters provided to the core */
static const OSSL_PARAM wolfssl_param_types[] = {
OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0),
OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0),
OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0),
OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0),
OSSL_PARAM_END
};
#ifdef WP_CHECK_FORCE_FAIL
static int forceFail = 0;
#endif
/*
* Get he table of parameters supported by wolfProv.
*
* @param [in] provCtx Unused.
* @return Table of supported parameters.
*/
static const OSSL_PARAM* wolfprov_gettable_params(void* provCtx)
{
(void)provCtx;
return wolfssl_param_types;
}
/*
* Returns whether the provider is running/usable.
*
* In FIPS builds the live wolfCrypt FIPS status is queried; a non-zero status
* (integrity/POST or continuous-test failure) returns 0 so a status-polling
* caller can observe the failure.
*
* @return 1 indicating provider is running, 0 otherwise.
*/
int wolfssl_prov_is_running(void)
{
WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "wolfssl_prov_is_running");
#ifdef WP_CHECK_FORCE_FAIL
if (forceFail) {
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 0);
return 0;
}
#endif
#ifdef HAVE_FIPS
if (wolfCrypt_GetStatus_fips() != 0) {
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 0);
return 0;
}
#endif
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 1);
return 1;
}
WC_RNG* wolfssl_prov_get_rng(WOLFPROV_CTX* provCtx)
{
return &provCtx->rng;
}
static OSSL_FUNC_BIO_read_ex_fn *c_bio_read_ex = NULL;
static OSSL_FUNC_BIO_write_ex_fn *c_bio_write_ex = NULL;
static OSSL_FUNC_BIO_gets_fn *c_bio_gets = NULL;
static OSSL_FUNC_BIO_puts_fn *c_bio_puts = NULL;
static OSSL_FUNC_BIO_ctrl_fn *c_bio_ctrl = NULL;
static OSSL_FUNC_BIO_free_fn *c_bio_free = NULL;
static OSSL_FUNC_BIO_up_ref_fn *c_bio_up_ref = NULL;
static int wolfssl_prov_bio_read_ex(OSSL_CORE_BIO *bio, void *data, size_t data_len,
size_t *bytes_read)
{
if (c_bio_read_ex == NULL)
return 0;
return c_bio_read_ex(bio, data, data_len, bytes_read);
}
static int wolfssl_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len,
size_t *written)
{
if (c_bio_write_ex == NULL)
return 0;
return c_bio_write_ex(bio, data, data_len, written);
}
static int wolfssl_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size)
{
if (c_bio_gets == NULL)
return -1;
return c_bio_gets(bio, buf, size);
}
static int wolfssl_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str)
{
if (c_bio_puts == NULL)
return -1;
return c_bio_puts(bio, str);
}
static int wolfssl_prov_bio_ctrl(OSSL_CORE_BIO *bio, int cmd, long num, void *ptr)
{
if (c_bio_ctrl == NULL)
return -1;
return c_bio_ctrl(bio, cmd, num, ptr);
}
static int wolfssl_prov_bio_free(OSSL_CORE_BIO *bio)
{
if (c_bio_free == NULL)
return 0;
return c_bio_free(bio);
}
int wolfssl_prov_bio_up_ref(OSSL_CORE_BIO *bio)
{
if (c_bio_up_ref == NULL)
return 0;
return c_bio_up_ref(bio);
}
static int bio_core_read_ex(BIO *bio, char *data, size_t data_len,
size_t *bytes_read)
{
return wolfssl_prov_bio_read_ex(BIO_get_data(bio), data, data_len, bytes_read);
}
static int bio_core_write_ex(BIO *bio, const char *data, size_t data_len,
size_t *written)
{
return wolfssl_prov_bio_write_ex(BIO_get_data(bio), data, data_len, written);
}
static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
return wolfssl_prov_bio_ctrl(BIO_get_data(bio), cmd, num, ptr);
}
static int bio_core_gets(BIO *bio, char *buf, int size)
{
return wolfssl_prov_bio_gets(BIO_get_data(bio), buf, size);
}
static int bio_core_puts(BIO *bio, const char *str)
{
return wolfssl_prov_bio_puts(BIO_get_data(bio), str);
}
static int bio_core_new(BIO *bio)
{
WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "bio_core_new");
BIO_set_init(bio, 1);
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 1);
return 1;
}
static int bio_core_free(BIO *bio)
{
WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "bio_core_free");
BIO_set_init(bio, 0);
wolfssl_prov_bio_free(BIO_get_data(bio));
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 1);
return 1;
}
/*
* Creates a new provider context object.
*
* @return NULL on memory allocation failure.
* @return On success, provider context object.
*/
static WOLFPROV_CTX* wolfssl_prov_ctx_new(void)
{
WOLFPROV_CTX* ctx;
WP_CHECK_FIPS_ALGO_PTR(WP_CAST_ALGO_DRBG);
ctx = (WOLFPROV_CTX*)OPENSSL_zalloc(sizeof(*ctx));
if ((ctx != NULL) && (wc_InitRng(&ctx->rng) != 0)) {
OPENSSL_free(ctx);
ctx = NULL;
}
#ifndef WP_SINGLE_THREADED
if ((ctx != NULL) && (wc_InitMutex(&ctx->rng_mutex) != 0)) {
wc_FreeRng(&ctx->rng);
OPENSSL_free(ctx);
ctx = NULL;
}
#endif
if (ctx != NULL) {
ctx->coreBioMethod = BIO_meth_new(BIO_TYPE_CORE_TO_PROV, "BIO to Core filter");
if (ctx->coreBioMethod == NULL
|| !BIO_meth_set_write_ex(ctx->coreBioMethod, bio_core_write_ex)
|| !BIO_meth_set_read_ex(ctx->coreBioMethod, bio_core_read_ex)
|| !BIO_meth_set_puts(ctx->coreBioMethod, bio_core_puts)
|| !BIO_meth_set_gets(ctx->coreBioMethod, bio_core_gets)
|| !BIO_meth_set_ctrl(ctx->coreBioMethod, bio_core_ctrl)
|| !BIO_meth_set_create(ctx->coreBioMethod, bio_core_new)
|| !BIO_meth_set_destroy(ctx->coreBioMethod, bio_core_free)) {
BIO_meth_free(ctx->coreBioMethod);
#ifndef WP_SINGLE_THREADED
wc_FreeMutex(&ctx->rng_mutex);
#endif
wc_FreeRng(&ctx->rng);
OPENSSL_free(ctx);
ctx = NULL;
}
}
#if defined(WP_HAVE_SEED_SRC) && defined(WP_HAVE_RANDOM)
/* Initialize urandom subsystem (registers seed callback, lazy file open) */
if (ctx != NULL) {
if (wp_urandom_init() != 0) {
/* Non-fatal - fall back to normal RNG on platforms without urandom */
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_LEVEL_DEBUG,
"wp_urandom_init failed, will use WC_RNG instead", 0);
}
}
#endif
return ctx;
}
/*
* Disposes of provider context object.
*
* @param [in] ctx wolfSSL provider context object to dispose of.
*/
static void wolfssl_prov_ctx_free(WOLFPROV_CTX* ctx)
{
#if defined(WP_HAVE_SEED_SRC) && defined(WP_HAVE_RANDOM)
/* Clean up urandom subsystem */
wp_urandom_cleanup();
#endif
BIO_meth_free(ctx->coreBioMethod);
#ifndef WP_SINGLE_THREADED
wc_FreeMutex(&ctx->rng_mutex);
#endif
wc_FreeRng(&ctx->rng);
OPENSSL_free(ctx);
}
/*
* Stores the library context object in the wolfSSL provider object.
*
* @param [in] ctx wolfSSL provider context object.
* @param [in] libCtx Library context object.
*/
static void wolfssl_prov_ctx_set0_lib_ctx(WOLFPROV_CTX* ctx,
OSSL_LIB_CTX* libCtx)
{
if (ctx != NULL) {
ctx->libCtx = libCtx;
}
}
/*
* Stores the handle in the wolfSSL provider object.
*
* @param [in] ctx wolfSSL provider context object.
* @param [in] handle Handle to the core.
*/
static void wolfssl_prov_ctx_set0_handle(WOLFPROV_CTX* ctx,
const OSSL_CORE_HANDLE* handle)
{
if (ctx != NULL) {
ctx->handle = handle;
}
}
/*
* Gets the parameters of the provider.
*
* @param [in] provCtx Provider context to get parameters for.
* @param [in, out] params Parameter id and space for value.
* @return 1 on success.
* @return 0 on failure.
*/
static int wolfprov_get_params(void* provCtx, OSSL_PARAM params[])
{
int ok = 1;
OSSL_PARAM* p;
#ifdef HAVE_FIPS
static const char* provider_name = "wolfSSL Provider FIPS";
#else
static const char* provider_name = "wolfSSL Provider";
#endif
WOLFPROV_ENTER(WP_LOG_COMP_PROVIDER, "wolfprov_get_params");
(void)provCtx;
/* Look for provider name as a parameter to return. */
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
/* Set the string if name requested. */
if ((p != NULL) && (!OSSL_PARAM_set_utf8_ptr(p, provider_name))) {
ok = 0;
}
if (ok) {
/* Look for provider version as a parameter to return. */
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION);
/* Set the string if version requested. */
if ((p != NULL) &&
(!OSSL_PARAM_set_utf8_ptr(p, LIBWOLFPROV_VERSION_STRING))) {
ok = 0;
}
}
if (ok) {
/* Look for provider build info as a parameter to return. */
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO);
/* Set the string if build info requested - wolfSSL version. */
if ((p != NULL) && (!OSSL_PARAM_set_utf8_ptr(p,
"wolfSSL " LIBWOLFSSL_VERSION_STRING))) {
ok = 0;
}
}
if (ok) {
/* Look for provider status as a parameter to return. */
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS);
/* Set the value if status requested - is running?. */
if ((p != NULL) &&
(!OSSL_PARAM_set_int(p, wolfssl_prov_is_running()))) {
ok = 0;
}
}
WOLFPROV_LEAVE(WP_LOG_COMP_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
return ok;
}
#ifdef HAVE_FIPS
/* Properties of wolfSSL provider: name and FIPS wolfSSL. */
#define WOLFPROV_PROPERTIES "provider=wolfprov,fips=yes"
#else
/* Properties of wolfSSL provider: name only. */
#define WOLFPROV_PROPERTIES "provider=wolfprov"
#endif
/* List of digest algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_digests[] = {
#ifdef WP_HAVE_MD5
/* MD5 */
{ WP_NAMES_MD5, WOLFPROV_PROPERTIES, wp_md5_functions,
"" },
#endif
#ifdef WP_HAVE_MD5_SHA1
/* MD5-SHA1 */
{ WP_NAMES_MD5_SHA1, WOLFPROV_PROPERTIES, wp_md5_sha1_functions,
"" },
#endif
#ifdef WP_HAVE_SHA1
/* SHA-1 */
{ WP_NAMES_SHA1, WOLFPROV_PROPERTIES, wp_sha1_functions,
"" },
#endif
/* SHA-2 */
#ifdef WP_HAVE_SHA224
{ WP_NAMES_SHA2_224, WOLFPROV_PROPERTIES, wp_sha224_functions,
"" },
#endif
#ifdef WP_HAVE_SHA256
{ WP_NAMES_SHA2_256, WOLFPROV_PROPERTIES, wp_sha256_functions,
"" },
#endif
#ifdef WP_HAVE_SHA384
{ WP_NAMES_SHA2_384, WOLFPROV_PROPERTIES, wp_sha384_functions,
"" },
#endif
#ifdef WP_HAVE_SHA512
{ WP_NAMES_SHA2_512, WOLFPROV_PROPERTIES, wp_sha512_functions,
"" },
#if LIBWOLFSSL_VERSION_HEX >= 0x05000000
#ifndef WOLFSSL_NOSHA512_224
{ WP_NAMES_SHA2_512_224, WOLFPROV_PROPERTIES,
wp_sha512_224_functions,
"" },
#endif /* !WOLFSSL_NOSHA512_224 */
#ifndef WOLFSSL_NOSHA512_256
{ WP_NAMES_SHA2_512_256, WOLFPROV_PROPERTIES,
wp_sha512_256_functions,
"" },
#endif /* !WOLFSSL_NOSHA512_256 */
#endif
#endif /* WP_HAVE_SHA512 */
/* SHA-3 */
#ifdef WP_HAVE_SHA3
{ WP_NAMES_SHA3_224, WOLFPROV_PROPERTIES, wp_sha3_224_functions,
"" },
{ WP_NAMES_SHA3_256, WOLFPROV_PROPERTIES, wp_sha3_256_functions,
"" },
{ WP_NAMES_SHA3_384, WOLFPROV_PROPERTIES, wp_sha3_384_functions,
"" },
{ WP_NAMES_SHA3_512, WOLFPROV_PROPERTIES, wp_sha3_512_functions,
"" },
#endif
#ifdef WP_HAVE_SHAKE_256
/* SHAKE */
{ WP_NAMES_SHAKE_256, WOLFPROV_PROPERTIES, wp_shake_256_functions,
"" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of cipher algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_ciphers[] = {
#ifdef WP_HAVE_AESGCM
/* AES-GCM */
{ WP_NAMES_AES_256_GCM, WOLFPROV_PROPERTIES, wp_aes256gcm_functions,
"" },
{ WP_NAMES_AES_192_GCM, WOLFPROV_PROPERTIES, wp_aes192gcm_functions,
"" },
{ WP_NAMES_AES_128_GCM, WOLFPROV_PROPERTIES, wp_aes128gcm_functions,
"" },
#endif
#ifdef WP_HAVE_AESCCM
/* AES-CCM */
{ WP_NAMES_AES_256_CCM, WOLFPROV_PROPERTIES, wp_aes256ccm_functions,
"" },
{ WP_NAMES_AES_192_CCM, WOLFPROV_PROPERTIES, wp_aes192ccm_functions,
"" },
{ WP_NAMES_AES_128_CCM, WOLFPROV_PROPERTIES, wp_aes128ccm_functions,
"" },
#endif
#ifdef WP_HAVE_AESCBC
/* AES-CBC */
{ WP_NAMES_AES_256_CBC, WOLFPROV_PROPERTIES, wp_aes256cbc_functions,
"" },
{ WP_NAMES_AES_192_CBC, WOLFPROV_PROPERTIES, wp_aes192cbc_functions,
"" },
{ WP_NAMES_AES_128_CBC, WOLFPROV_PROPERTIES, wp_aes128cbc_functions,
"" },
#endif
#ifdef WP_HAVE_AESECB
/* AES-ECB */
{ WP_NAMES_AES_256_ECB, WOLFPROV_PROPERTIES, wp_aes256ecb_functions,
"" },
{ WP_NAMES_AES_192_ECB, WOLFPROV_PROPERTIES, wp_aes192ecb_functions,
"" },
{ WP_NAMES_AES_128_ECB, WOLFPROV_PROPERTIES, wp_aes128ecb_functions,
"" },
#endif
#ifdef WP_HAVE_AESCTR
/* AES-CTR */
{ WP_NAMES_AES_256_CTR, WOLFPROV_PROPERTIES, wp_aes256ctr_functions,
"" },
{ WP_NAMES_AES_192_CTR, WOLFPROV_PROPERTIES, wp_aes192ctr_functions,
"" },
{ WP_NAMES_AES_128_CTR, WOLFPROV_PROPERTIES, wp_aes128ctr_functions,
"" },
#endif
#ifdef WP_HAVE_AESCFB
/* AES-CFB */
{ WP_NAMES_AES_256_CFB, WOLFPROV_PROPERTIES, wp_aes256cfb_functions,
"" },
{ WP_NAMES_AES_192_CFB, WOLFPROV_PROPERTIES, wp_aes192cfb_functions,
"" },
{ WP_NAMES_AES_128_CFB, WOLFPROV_PROPERTIES, wp_aes128cfb_functions,
"" },
#endif
#ifdef WP_HAVE_AESCTS
/* AES-CTS */
{ WP_NAMES_AES_256_CTS, WOLFPROV_PROPERTIES, wp_aes256cts_functions,
"" },
{ WP_NAMES_AES_192_CTS, WOLFPROV_PROPERTIES, wp_aes192cts_functions,
"" },
{ WP_NAMES_AES_128_CTS, WOLFPROV_PROPERTIES, wp_aes128cts_functions,
"" },
#endif
#ifdef HAVE_AES_KEYWRAP
/* AES Kwy Wrap - unpadded */
{ WP_NAMES_AES_256_WRAP, WOLFPROV_PROPERTIES, wp_aes256wrap_functions,
"" },
{ WP_NAMES_AES_192_WRAP, WOLFPROV_PROPERTIES, wp_aes192wrap_functions,
"" },
{ WP_NAMES_AES_128_WRAP, WOLFPROV_PROPERTIES, wp_aes128wrap_functions,
"" },
#endif
#ifdef WP_HAVE_DES3CBC
{ WP_NAMES_DES_EDE3_CBC, WOLFPROV_PROPERTIES, wp_des3cbc_functions,
"" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of MAC algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_macs[] = {
#ifdef WP_HAVE_HMAC
{ WP_NAMES_HMAC, WOLFPROV_PROPERTIES, wp_hmac_functions,
"" },
#endif
#ifdef WP_HAVE_CMAC
{ WP_NAMES_CMAC, WOLFPROV_PROPERTIES, wp_cmac_functions,
"" },
#endif
#ifdef WP_HAVE_AESGCM
{ WP_NAMES_GMAC, WOLFPROV_PROPERTIES, wp_gmac_functions,
"" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of KDF algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_kdfs[] = {
{ WP_NAMES_HKDF, WOLFPROV_PROPERTIES, wp_kdf_hkdf_functions,
"" },
#ifndef NO_PWDBASED
{ WP_NAMES_PBKDF2, WOLFPROV_PROPERTIES, wp_kdf_pbkdf2_functions,
"" },
#endif
#ifndef NO_PWDBASED
{ WP_NAMES_PKCS12KDF, WOLFPROV_PROPERTIES, wp_kdf_pkcs12_functions,
"" },
#endif
{ WP_NAMES_TLS1_3_KDF, WOLFPROV_PROPERTIES, wp_kdf_tls1_3_kdf_functions,
"" },
#ifdef WP_HAVE_TLS1_PRF
{ WP_NAMES_TLS1_PRF, WOLFPROV_PROPERTIES, wp_kdf_tls1_prf_functions,
"" },
#endif
#ifdef WP_HAVE_KBKDF
{ WP_NAMES_KBKDF, WOLFPROV_PROPERTIES, wp_kdf_kbkdf_functions,
"" },
#endif
#ifdef WP_HAVE_KRB5KDF
{ WP_NAMES_KRB5KDF, WOLFPROV_PROPERTIES, wp_kdf_krb5kdf_functions,
"" },
#endif
#ifdef WP_HAVE_SSHKDF
{ WP_NAMES_SSHKDF, WOLFPROV_PROPERTIES, wp_kdf_sshkdf_functions,
"" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of RNG algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_rands[] = {
#if defined(WP_HAVE_SEED_SRC) && defined(WP_HAVE_RANDOM)
{ WP_NAMES_SEED_SRC, WOLFPROV_PROPERTIES, wp_seed_src_functions,
"" },
#endif
{ WP_NAMES_CTR_DRBG, WOLFPROV_PROPERTIES, wp_drbg_functions,
"" },
{ WP_NAMES_HASH_DRBG, WOLFPROV_PROPERTIES, wp_drbg_functions,
"" },
{ NULL, NULL, NULL, NULL }
};
/* List of key gen/import/export implementations available in wolfSSL provider.
*/
static const OSSL_ALGORITHM wolfprov_keymgmt[] = {
#ifdef WP_HAVE_RSA
{ WP_NAMES_RSA, WOLFPROV_PROPERTIES, wp_rsa_keymgmt_functions,
"RSA" },
{ WP_NAMES_RSA_PSS, WOLFPROV_PROPERTIES, wp_rsapss_keymgmt_functions,
"RSA_PSS" },
#endif
#ifdef WP_HAVE_ECC
{ WP_NAMES_EC, WOLFPROV_PROPERTIES, wp_ecc_keymgmt_functions,
"ECC" },
#endif
#ifdef WP_HAVE_X25519
{ WP_NAMES_X25519, WOLFPROV_PROPERTIES, wp_x25519_keymgmt_functions,
"X25519" },
#endif
#ifdef WP_HAVE_X448
{ WP_NAMES_X448, WOLFPROV_PROPERTIES, wp_x448_keymgmt_functions,
"X448" },
#endif
#ifdef WP_HAVE_ED25519
{ WP_NAMES_ED25519, WOLFPROV_PROPERTIES, wp_ed25519_keymgmt_functions,
"X25519" },
#endif
#ifdef WP_HAVE_ED448
{ WP_NAMES_ED448, WOLFPROV_PROPERTIES, wp_ed448_keymgmt_functions,
"X448" },
#endif
#ifdef WP_HAVE_DH
{ WP_NAMES_DH, WOLFPROV_PROPERTIES, wp_dh_keymgmt_functions,
"DH" },
{ WP_NAMES_DHX, WOLFPROV_PROPERTIES, wp_dh_keymgmt_functions,
"DHX" },
#endif
#ifdef WP_HAVE_HMAC
{ WP_NAMES_HMAC, WOLFPROV_PROPERTIES, wp_hmac_keymgmt_functions,
"HMAC" },
#endif
#ifdef WP_HAVE_CMAC
{ WP_NAMES_CMAC, WOLFPROV_PROPERTIES, wp_cmac_keymgmt_functions,
"CMAC" },
#endif
#ifdef WP_HAVE_HKDF
{ WP_NAMES_HKDF, WOLFPROV_PROPERTIES, wp_kdf_keymgmt_functions,
"HKDF" },
#endif
{ WP_NAMES_TLS1_PRF, WOLFPROV_PROPERTIES, wp_kdf_keymgmt_functions,
"HKDF" },
{ WP_NAMES_TLS1_3_KDF, WOLFPROV_PROPERTIES, wp_kdf_keymgmt_functions,
"HKDF" },
#ifdef WP_HAVE_MLKEM
{ WP_NAMES_ML_KEM_512, WOLFPROV_PROPERTIES,
wp_mlkem512_keymgmt_functions, "" },
{ WP_NAMES_ML_KEM_768, WOLFPROV_PROPERTIES,
wp_mlkem768_keymgmt_functions, "" },
{ WP_NAMES_ML_KEM_1024, WOLFPROV_PROPERTIES,
wp_mlkem1024_keymgmt_functions, "" },
{ WP_NAMES_X25519MLKEM768, WOLFPROV_PROPERTIES,
wp_mlx_x25519_keymgmt_functions, "" },
{ WP_NAMES_SECP256R1MLKEM768, WOLFPROV_PROPERTIES,
wp_mlx_p256_keymgmt_functions, "" },
{ WP_NAMES_SECP384R1MLKEM1024, WOLFPROV_PROPERTIES,
wp_mlx_p384_keymgmt_functions, "" },
#endif
#ifdef WP_HAVE_MLDSA
{ WP_NAMES_ML_DSA_44, WOLFPROV_PROPERTIES,
wp_mldsa44_keymgmt_functions, "" },
{ WP_NAMES_ML_DSA_65, WOLFPROV_PROPERTIES,
wp_mldsa65_keymgmt_functions, "" },
{ WP_NAMES_ML_DSA_87, WOLFPROV_PROPERTIES,
wp_mldsa87_keymgmt_functions, "" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of key exchange algorithm implementations available in wolfSSL provider.
*/
static const OSSL_ALGORITHM wolfprov_keyexch[] = {
#ifdef WP_HAVE_ECDH
{ WP_NAMES_ECDH, WOLFPROV_PROPERTIES, wp_ecdh_keyexch_functions,
"" },
#endif
#ifdef WP_HAVE_X25519
{ WP_NAMES_X25519, WOLFPROV_PROPERTIES, wp_x25519_keyexch_functions,
"" },
#endif
#ifdef WP_HAVE_X448
{ WP_NAMES_X448, WOLFPROV_PROPERTIES, wp_x448_keyexch_functions,
"" },
#endif
#ifdef WP_HAVE_DH
{ WP_NAMES_DH, WOLFPROV_PROPERTIES, wp_dh_keyexch_functions,
"" },
#endif
{ WP_NAMES_HKDF, WOLFPROV_PROPERTIES, wp_hkdf_keyexch_functions,
"" },
{ WP_NAMES_TLS1_PRF, WOLFPROV_PROPERTIES, wp_tls1_prf_keyexch_functions,
"" },
{ NULL, NULL, NULL, NULL }
};
/* List of signature algorithm implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_signature[] = {
#ifdef WP_HAVE_RSA
{ WP_NAMES_RSA, WOLFPROV_PROPERTIES, wp_rsa_signature_functions,
"" },
#endif
#ifdef WP_HAVE_ECDSA
{ WP_NAMES_ECDSA, WOLFPROV_PROPERTIES, wp_ecdsa_signature_functions,
"" },
#endif
#ifdef WP_HAVE_ED25519
{ WP_NAMES_ED25519, WOLFPROV_PROPERTIES, wp_ed25519_signature_functions,
"" },
#endif
#ifdef WP_HAVE_ED448
{ WP_NAMES_ED448, WOLFPROV_PROPERTIES, wp_ed448_signature_functions,
"" },
#endif
#ifdef WP_HAVE_HMAC
{ WP_NAMES_HMAC, WOLFPROV_PROPERTIES, wp_hmac_signature_functions,
"" },
#endif
#ifdef WP_HAVE_CMAC
{ WP_NAMES_CMAC, WOLFPROV_PROPERTIES, wp_cmac_signature_functions,
"" },
#endif
#ifdef WP_HAVE_MLDSA
{ WP_NAMES_ML_DSA_44, WOLFPROV_PROPERTIES,
wp_mldsa_signature_functions, "" },
{ WP_NAMES_ML_DSA_65, WOLFPROV_PROPERTIES,
wp_mldsa_signature_functions, "" },
{ WP_NAMES_ML_DSA_87, WOLFPROV_PROPERTIES,
wp_mldsa_signature_functions, "" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of asymmetric encryption/decryption algorithm implementations available
* in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_asym_cipher[] = {
#ifdef WP_HAVE_RSA
{ WP_NAMES_RSA, WOLFPROV_PROPERTIES, wp_rsa_asym_cipher_functions,
"" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* List of asymmetric key encryption mechanism algorithm implementations
* available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_asym_kem[] = {
#ifdef WP_HAVE_RSA
{ WP_NAMES_RSA, WOLFPROV_PROPERTIES, wp_rsa_asym_kem_functions,
"" },
#endif
#ifdef WP_HAVE_MLKEM
{ WP_NAMES_ML_KEM_512, WOLFPROV_PROPERTIES,
wp_mlkem_asym_kem_functions, "" },
{ WP_NAMES_ML_KEM_768, WOLFPROV_PROPERTIES,
wp_mlkem_asym_kem_functions, "" },
{ WP_NAMES_ML_KEM_1024, WOLFPROV_PROPERTIES,
wp_mlkem_asym_kem_functions, "" },
{ WP_NAMES_X25519MLKEM768, WOLFPROV_PROPERTIES,
wp_mlx_asym_kem_functions, "" },
{ WP_NAMES_SECP256R1MLKEM768, WOLFPROV_PROPERTIES,
wp_mlx_asym_kem_functions, "" },
{ WP_NAMES_SECP384R1MLKEM1024, WOLFPROV_PROPERTIES,
wp_mlx_asym_kem_functions, "" },
#endif
{ NULL, NULL, NULL, NULL }
};
/* The properties to indicate the supported DER format. */
#define WP_ENCODER_PROPERTIES(format, encoding) \
WOLFPROV_PROPERTIES ",output=" #encoding ",structure=" #format
/* List of ASN.1 encoding implementations available in wolfSSL provider. */
static const OSSL_ALGORITHM wolfprov_encoder[] = {
#ifdef WP_HAVE_RSA
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_rsa_spki_der_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_rsa_spki_pem_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_rsa_pki_der_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_rsa_pki_pem_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_rsa_epki_der_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_rsa_epki_pem_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(type-specific, der),
wp_rsa_kp_der_encoder_functions,
"" },
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(type-specific, pem),
wp_rsa_kp_pem_encoder_functions,
"" },
#ifdef WP_RSA_PSS_ENCODING
{ WP_NAMES_RSA_PSS, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_rsapss_spki_der_encoder_functions,
"" },
{ WP_NAMES_RSA_PSS, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_rsapss_spki_pem_encoder_functions,
"" },
{ WP_NAMES_RSA_PSS, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_rsapss_pki_der_encoder_functions,
"" },
{ WP_NAMES_RSA_PSS, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_rsapss_pki_pem_encoder_functions,
"" },
/*{ WP_NAMES_RSA, WOLFPROV_PROPERTIES ",output=text", \*/
{ WP_NAMES_RSA, WP_ENCODER_PROPERTIES(type-specific, text), \
wp_rsa_text_encoder_functions,
"" },
#endif
#endif /* WP_HAVE_RSA */
#ifdef WP_HAVE_DH
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(type-specific, der),
wp_dh_type_specific_der_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(type-specific, pem),
wp_dh_type_specific_pem_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_dh_spki_der_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_dh_spki_pem_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_dh_pki_der_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_dh_pki_pem_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_dh_epki_der_encoder_functions,
"" },
{ WP_NAMES_DH, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_dh_epki_pem_encoder_functions,
"" },
#endif
#ifdef WP_HAVE_ECC
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(type-specific, der),
wp_ecc_type_specific_der_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(type-specific, pem),
wp_ecc_type_specific_pem_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_ecc_spki_der_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_ecc_spki_pem_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_ecc_pki_der_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_ecc_pki_pem_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_ecc_epki_der_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_ecc_epki_pem_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(X9_62, der),
wp_ecc_x9_62_der_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(X9_62, pem),
wp_ecc_x9_62_pem_encoder_functions,
"" },
{ WP_NAMES_EC, WP_ENCODER_PROPERTIES(type-specific, text),
wp_ecc_text_encoder_functions,
"" },
#endif
#ifdef WP_HAVE_X25519
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_x25519_spki_der_encoder_functions,
"" },
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_x25519_spki_pem_encoder_functions,
"" },
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_x25519_pki_der_encoder_functions,
"" },
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_x25519_pki_pem_encoder_functions,
"" },
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_x25519_epki_der_encoder_functions,
"" },
{ WP_NAMES_X25519, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_x25519_epki_pem_encoder_functions,
"" },
#endif
#ifdef WP_HAVE_ED25519
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_ed25519_spki_der_encoder_functions,
"" },
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_ed25519_spki_pem_encoder_functions,
"" },
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_ed25519_pki_der_encoder_functions,
"" },
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_ed25519_pki_pem_encoder_functions,
"" },
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_ed25519_epki_der_encoder_functions,
"" },
{ WP_NAMES_ED25519, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_ed25519_epki_pem_encoder_functions,
"" },
#endif
#ifdef WP_HAVE_X448
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_x448_spki_der_encoder_functions,
"" },
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_x448_spki_pem_encoder_functions,
"" },
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_x448_pki_der_encoder_functions,
"" },
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_x448_pki_pem_encoder_functions,
"" },
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_x448_epki_der_encoder_functions,
"" },
{ WP_NAMES_X448, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_x448_epki_pem_encoder_functions,
"" },
#endif
#ifdef WP_HAVE_ED448
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
wp_ed448_spki_der_encoder_functions,
"" },
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, pem),
wp_ed448_spki_pem_encoder_functions,
"" },
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(PrivateKeyInfo, der),
wp_ed448_pki_der_encoder_functions,
"" },
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(PrivateKeyInfo, pem),
wp_ed448_pki_pem_encoder_functions,
"" },
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, der),
wp_ed448_epki_der_encoder_functions,
"" },
{ WP_NAMES_ED448, WP_ENCODER_PROPERTIES(EncryptedPrivateKeyInfo, pem),
wp_ed448_epki_pem_encoder_functions,
"" },
#endif