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/types.h> |
13 | |
14 | #define OSSL_PARAM_BLD_MAX 25 |
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 | const 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); |
44 | void ossl_param_bld_free(OSSL_PARAM *params); |
45 | OSSL_PARAM *ossl_param_bld_to_param_ex(OSSL_PARAM_BLD *bld, |
46 | OSSL_PARAM *params, size_t param_n, |
47 | void *data, size_t data_n, |
48 | void *secure, size_t secure_n); |
49 | |
50 | int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int val); |
51 | int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key, |
52 | unsigned int val); |
53 | int ossl_param_bld_push_long(OSSL_PARAM_BLD *bld, const char *key, |
54 | long int val); |
55 | int ossl_param_bld_push_ulong(OSSL_PARAM_BLD *bld, const char *key, |
56 | unsigned long int val); |
57 | int ossl_param_bld_push_int32(OSSL_PARAM_BLD *bld, const char *key, |
58 | int32_t val); |
59 | int ossl_param_bld_push_uint32(OSSL_PARAM_BLD *bld, const char *key, |
60 | uint32_t val); |
61 | int ossl_param_bld_push_int64(OSSL_PARAM_BLD *bld, const char *key, |
62 | int64_t val); |
63 | int ossl_param_bld_push_uint64(OSSL_PARAM_BLD *bld, const char *key, |
64 | uint64_t val); |
65 | int ossl_param_bld_push_size_t(OSSL_PARAM_BLD *bld, const char *key, |
66 | size_t val); |
67 | int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key, |
68 | double val); |
69 | int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key, |
70 | const BIGNUM *bn); |
71 | int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key, |
72 | const char *buf, size_t bsize); |
73 | int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key, |
74 | char *buf, size_t bsize); |
75 | int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key, |
76 | const void *buf, size_t bsize); |
77 | int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key, |
78 | void *buf, size_t bsize); |
79 | |