]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/internal/param_build.h
762d7b11c9c8c7b145a8971e0c82c101ff2ed0f7
[thirdparty/openssl.git] / include / internal / param_build.h
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 <openssl/params.h>
12 #include <openssl/ossl_typ.h>
13
14 #define OSSL_PARAM_BLD_MAX 10
15
16 typedef struct {
17 const char *key;
18 int type;
19 int secure;
20 size_t size;
21 size_t alloc_blocks;
22 const BIGNUM *bn;
23 void *string;
24 union {
25 /*
26 * These fields are never directly addressed, but their sizes are
27 * imporant so that all native types can be copied here without overrun.
28 */
29 ossl_intmax_t i;
30 ossl_uintmax_t u;
31 double d;
32 } num;
33 } OSSL_PARAM_BLD_DEF;
34
35 typedef struct {
36 size_t curr;
37 size_t total_blocks;
38 size_t secure_blocks;
39 OSSL_PARAM_BLD_DEF params[OSSL_PARAM_BLD_MAX];
40 } OSSL_PARAM_BLD;
41
42 void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
43 OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld, void **secure);
44 OSSL_PARAM *ossl_param_bld_to_param_ex(OSSL_PARAM_BLD *bld,
45 OSSL_PARAM *params, size_t param_n,
46 void *data, size_t data_n,
47 void *secure, size_t secure_n);
48
49 int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
50 int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key,
51 unsigned int val);
52 int ossl_param_bld_push_long(OSSL_PARAM_BLD *bld, const char *key,
53 long int val);
54 int ossl_param_bld_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
55 unsigned long int val);
56 int ossl_param_bld_push_int32(OSSL_PARAM_BLD *bld, const char *key,
57 int32_t val);
58 int ossl_param_bld_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
59 uint32_t val);
60 int ossl_param_bld_push_int64(OSSL_PARAM_BLD *bld, const char *key,
61 int64_t val);
62 int ossl_param_bld_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
63 uint64_t val);
64 int ossl_param_bld_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
65 size_t val);
66 int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key,
67 double val);
68 int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
69 const BIGNUM *bn);
70 int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
71 char *buf, size_t bsize);
72 int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
73 char *buf, size_t bsize);
74 int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
75 void *buf, size_t bsize);
76 int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
77 void *buf, size_t bsize);