Updated doc for BN_clear, BN_CTX_end when param is NULL
[openssl.git] / crypto / params.c
1 /*
2  * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3  * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
4  *
5  * Licensed under the Apache License 2.0 (the "License").  You may not use
6  * this file except in compliance with the License.  You can obtain a copy
7  * in the file LICENSE in the source distribution or at
8  * https://www.openssl.org/source/license.html
9  */
10
11 #include <string.h>
12 #include <openssl/params.h>
13 #include "internal/thread_once.h"
14
15 #define SET_RETURN_SIZE(p, sz) \
16     if ((p)->return_size != NULL) \
17         *(p)->return_size = (sz)
18
19 const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key)
20 {
21     if (p != NULL && key != NULL)
22         for (; p->key != NULL; p++)
23             if (strcmp(key, p->key) == 0)
24                 return p;
25     return NULL;
26 }
27
28 static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type,
29                                        void *data, size_t data_size,
30                                        size_t *return_size)
31 {
32     OSSL_PARAM res;
33
34     res.key = key;
35     res.data_type = data_type;
36     res.data = data;
37     res.data_size = data_size;
38     res.return_size = return_size;
39     return res;
40 }
41
42 int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val)
43 {
44     if (val == NULL || p == NULL || p->data_type != OSSL_PARAM_INTEGER)
45         return 0;
46
47     switch (p->data_size) {
48     case sizeof(int32_t):
49         if (sizeof(int) >= sizeof(int32_t)) {
50             *val = (int)*(const int32_t *)p->data;
51             return 1;
52         }
53         break;
54     case sizeof(int64_t):
55         if (sizeof(int) >= sizeof(int64_t)) {
56             *val = (int)*(const int64_t *)p->data;
57             return 1;
58         }
59         break;
60     }
61     return 0;
62 }
63
64 int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val)
65 {
66     if (p == NULL)
67         return 0;
68     SET_RETURN_SIZE(p, 0);
69     if (p->data_type != OSSL_PARAM_INTEGER)
70         return 0;
71
72     SET_RETURN_SIZE(p, sizeof(int)); /* Minimum expected size */
73     switch (p->data_size) {
74     case sizeof(int32_t):
75         if (sizeof(int32_t) >= sizeof(int)) {
76             SET_RETURN_SIZE(p, sizeof(int32_t));
77             *(int32_t *)p->data = (int32_t)val;
78             return 1;
79         }
80         break;
81     case sizeof(int64_t):
82         if (sizeof(int64_t) >= sizeof(int)) {
83             SET_RETURN_SIZE(p, sizeof(int64_t));
84             *(int64_t *)p->data = (int64_t)val;
85             return 1;
86         }
87         break;
88     }
89     return 0;
90 }
91
92 OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *rsize)
93 {
94     return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int),
95                                 rsize);
96 }
97
98 int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val)
99 {
100     if (val == NULL
101         || p == NULL
102         || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER))
103         return 0;
104
105     switch (p->data_size) {
106     case sizeof(uint32_t):
107         if (sizeof(unsigned int) >= sizeof(uint32_t)) {
108             *val = (unsigned int)*(const uint32_t *)p->data;
109             return 1;
110         }
111         break;
112     case sizeof(uint64_t):
113         if (sizeof(unsigned int) >= sizeof(uint64_t)) {
114             *val = (unsigned int)*(const uint64_t *)p->data;
115             return 1;
116         }
117         break;
118     }
119     return 0;
120 }
121
122 int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val)
123 {
124     if (p == NULL)
125         return 0;
126     SET_RETURN_SIZE(p, 0);
127     if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
128         return 0;
129
130     SET_RETURN_SIZE(p, sizeof(unsigned int)); /* Minimum expected size */
131     switch (p->data_size) {
132     case sizeof(uint32_t):
133         if (sizeof(uint32_t) >= sizeof(unsigned int)) {
134             SET_RETURN_SIZE(p, sizeof(uint32_t));
135             *(uint32_t *)p->data = (uint32_t)val;
136             return 1;
137         }
138         break;
139     case sizeof(uint64_t):
140         if (sizeof(uint64_t) >= sizeof(unsigned int)) {
141             SET_RETURN_SIZE(p, sizeof(uint64_t));
142             *(uint64_t *)p->data = (uint64_t)val;
143             return 1;
144         }
145         break;
146     }
147     return 0;
148 }
149
150 OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf,
151                                      size_t *rsize)
152 {
153     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
154                                 sizeof(unsigned int), rsize);
155 }
156
157 int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val)
158 {
159     if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER))
160         return 0;
161
162     switch (p->data_size) {
163     case sizeof(int32_t):
164         if (sizeof(long int) >= sizeof(int32_t)) {
165             *val = (long int)*(const int32_t *)p->data;
166             return 1;
167         } break;
168     case sizeof(int64_t):
169         if (sizeof(long int) >= sizeof(int64_t)) {
170             *val = (long int)*(const int64_t *)p->data;
171             return 1;
172         }
173         break;
174     }
175     return 0;
176 }
177
178 int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val)
179 {
180     if (p == NULL)
181         return 0;
182     SET_RETURN_SIZE(p, 0);
183     if (p->data_type != OSSL_PARAM_INTEGER)
184         return 0;
185
186     SET_RETURN_SIZE(p, sizeof(long int)); /* Minimum expected size */
187     switch (p->data_size) {
188     case sizeof(int32_t):
189         if (sizeof(int32_t) >= sizeof(long int)) {
190             SET_RETURN_SIZE(p, sizeof(int32_t));
191             *(int32_t *)p->data = (int32_t)val;
192             return 1;
193         }
194         break;
195     case sizeof(int64_t):
196         if (sizeof(int64_t) >= sizeof(long int)) {
197             SET_RETURN_SIZE(p, sizeof(int64_t));
198             *(int64_t *)p->data = (int64_t)val;
199             return 1;
200         }
201         break;
202     }
203     return 0;
204 }
205
206 OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf,
207                                      size_t *rsize)
208 {
209     return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int),
210                                 rsize);
211 }
212
213 int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val)
214 {
215     if (val == NULL
216         || p == NULL
217         || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER))
218         return 0;
219
220     switch (p->data_size) {
221     case sizeof(uint32_t):
222         if (sizeof(unsigned long int) >= sizeof(uint32_t)) {
223             *val = (unsigned long int)*(const uint32_t *)p->data;
224             return 1;
225         }
226         break;
227     case sizeof(uint64_t):
228         if (sizeof(unsigned long int) >= sizeof(uint64_t)) {
229             *val = (unsigned long int)*(const uint64_t *)p->data;
230             return 1;
231         }
232         break;
233     }
234     return 0;
235 }
236
237 int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val)
238 {
239     if (p == NULL)
240         return 0;
241     SET_RETURN_SIZE(p, 0);
242     if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
243         return 0;
244
245     SET_RETURN_SIZE(p, sizeof(unsigned long int)); /* Minimum exp size */
246     switch (p->data_size) {
247     case sizeof(uint32_t):
248         if (sizeof(uint32_t) >= sizeof(unsigned long int)) {
249             SET_RETURN_SIZE(p, sizeof(uint32_t));
250             *(uint32_t *)p->data = (uint32_t)val;
251             return 1;
252         }
253         break;
254     case sizeof(uint64_t):
255         if (sizeof(uint64_t) >= sizeof(unsigned long int)) {
256             SET_RETURN_SIZE(p, sizeof(uint64_t));
257             *(uint64_t *)p->data = (uint64_t)val;
258             return 1;
259         }
260         break;
261     }
262     return 0;
263 }
264
265 OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf,
266                                       size_t *rsize)
267 {
268     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
269                                 sizeof(unsigned long int), rsize);
270 }
271
272 int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val)
273 {
274     if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER))
275         return 0;
276
277     if (p->data_size == sizeof(int32_t)) {
278         *val = *(const int32_t *)p->data;
279         return 1;
280     }
281     return 0;
282 }
283
284 int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val)
285 {
286     if (p == NULL)
287         return 0;
288     SET_RETURN_SIZE(p, 0);
289     if (p->data_type != OSSL_PARAM_INTEGER)
290         return 0;
291
292     SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */
293     switch (p->data_size) {
294     case sizeof(int32_t):
295         SET_RETURN_SIZE(p, sizeof(int32_t));
296         *(int32_t *)p->data = val;
297         return 1;
298     case sizeof(int64_t):
299         SET_RETURN_SIZE(p, sizeof(int64_t));
300         *(int64_t *)p->data = (int64_t)val;
301         return 1;
302     }
303     return 0;
304 }
305
306 OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf,
307                                       size_t *rsize)
308 {
309     return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf,
310                                 sizeof(int32_t), rsize);
311 }
312
313 int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val)
314 {
315     if (val == NULL
316         || p == NULL
317         || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER))
318         return 0;
319
320     if (p->data_size == sizeof(uint32_t)) {
321         *val = *(const uint32_t *)p->data;
322         return 1;
323     }
324     return 0;
325 }
326
327 int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val)
328 {
329     if (p == NULL) return 0;
330     SET_RETURN_SIZE(p, 0);
331     if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
332         return 0;
333
334     SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */
335     switch (p->data_size) {
336     case sizeof(uint32_t):
337         SET_RETURN_SIZE(p, sizeof(uint32_t));
338         *(uint32_t *)p->data = val;
339         return 1;
340     case sizeof(uint64_t):
341         SET_RETURN_SIZE(p, sizeof(uint64_t));
342         *(uint64_t *)p->data = (uint64_t)val;
343         return 1;
344     }
345     return 0;
346 }
347
348 OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf,
349                                        size_t *rsize)
350 {
351     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
352                                 sizeof(uint32_t), rsize);
353 }
354
355 int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val)
356 {
357     if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER))
358         return 0;
359
360     switch (p->data_size) {
361     case sizeof(int32_t):
362         *val = (int64_t)*(const int32_t *)p->data;
363         return 1;
364     case sizeof(int64_t):
365         *val = *(const int64_t *)p->data;
366         return 1;
367     }
368     return 0;
369 }
370
371 int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val)
372 {
373     if (p == NULL)
374         return 0;
375     SET_RETURN_SIZE(p, 0);
376     if (p->data_type != OSSL_PARAM_INTEGER)
377         return 0;
378
379     SET_RETURN_SIZE(p, sizeof(int64_t)); /* Minimum expected size */
380     switch (p->data_size) {
381     case sizeof(int64_t):
382         SET_RETURN_SIZE(p, sizeof(int64_t));
383         *(int64_t *)p->data = val;
384         return 1;
385     }
386     return 0;
387 }
388
389 OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf,
390                                       size_t *rsize)
391 {
392     return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t),
393                                 rsize);
394 }
395
396 int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val)
397 {
398     if (val == NULL
399         || p == NULL
400         || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER))
401         return 0;
402
403     switch (p->data_size) {
404     case sizeof(uint32_t):
405         *val = (uint64_t)*(const uint32_t *)p->data;
406         return 1;
407     case sizeof(uint64_t):
408         *val = *(const uint64_t *)p->data;
409         return 1;
410     }
411     return 0;
412 }
413
414 int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val)
415 {
416     if (p == NULL)
417         return 0;
418     SET_RETURN_SIZE(p, 0);
419     if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
420         return 0;
421
422     SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Minimum expected size */
423     switch (p->data_size) {
424     case sizeof(uint64_t):
425         SET_RETURN_SIZE(p, sizeof(uint64_t));
426         *(uint64_t *)p->data = val;
427         return 1;
428     }
429     return 0;
430 }
431
432 OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf,
433                                        size_t *rsize) {
434     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
435                                 sizeof(uint64_t), rsize);
436 }
437
438 int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val)
439 {
440     if (val == NULL
441         || p == NULL
442         || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
443         return 0;
444
445     switch (p->data_size) {
446     case sizeof(uint32_t):
447         if (sizeof(size_t) >= sizeof(uint32_t)) {
448             *val = (size_t)*(const uint32_t *)p->data;
449             return 1;
450         }
451         break;
452     case sizeof(uint64_t):
453         if (sizeof(size_t) >= sizeof(uint64_t)) {
454             *val = (size_t)*(const uint64_t *)p->data;
455             return 1;
456         }
457         break;
458     }
459     return 0;
460 }
461
462 int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val)
463 {
464     if (p == NULL)
465         return 0;
466     SET_RETURN_SIZE(p, 0);
467     if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
468         return 0;
469
470     SET_RETURN_SIZE(p, sizeof(size_t)); /* Minimum expected size */
471     switch (p->data_size) {
472     case sizeof(uint32_t):
473         if (sizeof(uint32_t) >= sizeof(size_t)) {
474             SET_RETURN_SIZE(p, sizeof(uint32_t));
475             *(uint32_t *)p->data = (uint32_t)val;
476             return 1;
477         }
478         break;
479     case sizeof(uint64_t):
480         SET_RETURN_SIZE(p, sizeof(uint64_t));
481         if (sizeof(uint64_t) >= sizeof(size_t)) {
482             *(uint64_t *)p->data = (uint64_t)val;
483             return 1;
484         }
485         break;
486     }
487     return 0;
488 }
489
490 OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf,
491                                        size_t *rsize)
492 {
493     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
494                                 sizeof(size_t), rsize); }
495
496 int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val)
497 {
498     BIGNUM *b;
499
500     if (val == NULL
501         || p == NULL
502         || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
503         return 0;
504
505     b = BN_native2bn(p->data, (int)p->data_size, *val);
506     if (b != NULL) {
507         *val = b;
508         return 1;
509     }
510     return 0;
511 }
512
513 int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val)
514 {
515     size_t bytes;
516
517     if (p == NULL)
518         return 0;
519     SET_RETURN_SIZE(p, 0);
520     if (val == NULL || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
521         return 0;
522
523     bytes = (size_t)BN_num_bytes(val);
524     SET_RETURN_SIZE(p, bytes);
525     return p->data_size >= bytes
526         && BN_bn2nativepad(val, p->data, bytes) >= 0;
527 }
528
529 OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
530                                    size_t bsize, size_t *rsize)
531 {
532     return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER,
533                                 buf, bsize, rsize);
534 }
535
536 int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val)
537 {
538     if (val == NULL || p == NULL || p->data_type != OSSL_PARAM_REAL)
539         return 0;
540
541     switch (p->data_size) {
542     case sizeof(double):
543         *val = *(const double *)p->data;
544         return 1;
545     }
546     return 0;
547 }
548
549 int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val)
550 {
551     if (p == NULL)
552         return 0;
553     SET_RETURN_SIZE(p, 0);
554     if (p->data_type != OSSL_PARAM_REAL)
555         return 0;
556
557     switch (p->data_size) {
558     case sizeof(double):
559         SET_RETURN_SIZE(p, sizeof(double));
560         *(double *)p->data = val;
561         return 1;
562     }
563     return 0;
564 }
565
566 OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf,
567                                        size_t *rsize)
568 {
569     return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double),
570                                 rsize);
571 }
572
573 static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len,
574                                size_t *used_len, unsigned int type)
575 {
576     size_t sz;
577
578     if (val == NULL || p == NULL || p->data_type != type)
579         return 0;
580
581     sz = p->data_size;
582
583     if (used_len != NULL)
584         *used_len = sz;
585
586     if (*val == NULL) {
587         char *const q = OPENSSL_malloc(sz);
588
589         if (q == NULL)
590             return 0;
591         *val = q;
592         memcpy(q, p->data, sz);
593         return 1;
594     }
595     if (max_len < sz)
596         return 0;
597     memcpy(*val, p->data, sz);
598     return 1;
599 }
600
601 int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len)
602 {
603     return get_string_internal(p, (void **)val, max_len, NULL,
604                                OSSL_PARAM_UTF8_STRING);
605 }
606
607 int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len,
608                                 size_t *used_len)
609 {
610     return get_string_internal(p, val, max_len, used_len,
611                                OSSL_PARAM_OCTET_STRING);
612 }
613
614 static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len,
615                                unsigned int type)
616 {
617     SET_RETURN_SIZE(p, len);
618     if (p->data_type != type || p->data_size < len)
619         return 0;
620
621     memcpy(p->data, val, len);
622     return 1;
623 }
624
625 int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val)
626 {
627     if (p == NULL)
628         return 0;
629
630     SET_RETURN_SIZE(p, 0);
631     if (val == NULL)
632         return 0;
633     return set_string_internal(p, val, strlen(val) + 1, OSSL_PARAM_UTF8_STRING);
634 }
635
636 int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val,
637                                 size_t len)
638 {
639     if (p == NULL)
640         return 0;
641
642     SET_RETURN_SIZE(p, 0);
643     if (val == NULL)
644         return 0;
645     return set_string_internal(p, val, len, OSSL_PARAM_OCTET_STRING);
646 }
647
648 OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
649                                             size_t bsize, size_t *rsize)
650 {
651     return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize,
652                                 rsize);
653 }
654
655 OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
656                                              size_t bsize, size_t *rsize)
657 {
658     return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize,
659                                 rsize);
660 }
661
662 static int get_ptr_internal(const OSSL_PARAM *p, const void **val,
663                             size_t *used_len, unsigned int type)
664 {
665     if (val == NULL || p == NULL || p->data_type != type)
666         return 0;
667     if (used_len != NULL)
668         *used_len = p->data_size;
669     *val = *(const void **)p->data;
670     return 1;
671 }
672
673 int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val)
674 {
675     return get_ptr_internal(p, (const void **)val, NULL, OSSL_PARAM_UTF8_PTR);
676 }
677
678 int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
679                              size_t *used_len)
680 {
681     return get_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_PTR);
682 }
683
684 static int set_ptr_internal(const OSSL_PARAM *p, const void *val,
685                             unsigned int type, size_t len)
686 {
687     SET_RETURN_SIZE(p, len);
688     if (p->data_type != type)
689         return 0;
690     *(const void **)p->data = val;
691     return 1;
692 }
693
694 int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val)
695 {
696     if (p == NULL)
697         return 0;
698     SET_RETURN_SIZE(p, 0);
699     if (val == NULL)
700         return 0;
701     return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, strlen(val) + 1);
702 }
703
704 int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val,
705                              size_t used_len)
706 {
707     if (p == NULL)
708         return 0;
709     SET_RETURN_SIZE(p, 0);
710     if (val == NULL)
711         return 0;
712     return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len);
713 }
714
715 OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
716                                          size_t *rsize)
717 {
718     return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, 0, rsize);
719 }
720
721 OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
722                                           size_t *rsize)
723 {
724     return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, 0, rsize);
725 }