]>
Commit | Line | Data |
---|---|---|
7ffbd7ca P |
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 | #ifndef HEADER_PARAMS_H | |
12 | # define HEADER_PARAMS_H | |
13 | ||
14 | # include <openssl/core.h> | |
15 | # include <openssl/bn.h> | |
16 | ||
17 | # ifdef __cplusplus | |
18 | extern "C" { | |
19 | # endif | |
20 | ||
21 | # define OSSL_PARAM_END \ | |
22 | { NULL, 0, NULL, 0, NULL } | |
23 | ||
24 | # define OSSL_PARAM_DEFN(key, type, addr, sz, rsz) \ | |
25 | { (key), (type), (addr), (sz), (rsz) } | |
26 | ||
27 | /* Basic parameter types without return sizes */ | |
28 | # define OSSL_PARAM_int(key, addr) \ | |
29 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), NULL) | |
30 | # define OSSL_PARAM_uint(key, addr) \ | |
31 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
32 | sizeof(unsigned int), NULL) | |
33 | # define OSSL_PARAM_long(key, addr) \ | |
34 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \ | |
35 | NULL) | |
36 | # define OSSL_PARAM_ulong(key, addr) \ | |
37 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
38 | sizeof(unsigned long int), NULL) | |
39 | # define OSSL_PARAM_int32(key, addr) \ | |
40 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), NULL) | |
41 | # define OSSL_PARAM_uint32(key, addr) \ | |
42 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
43 | sizeof(uint32_t), NULL) | |
44 | # define OSSL_PARAM_int64(key, addr) \ | |
45 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), NULL) | |
46 | # define OSSL_PARAM_uint64(key, addr) \ | |
47 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
48 | sizeof(uint64_t), NULL) | |
49 | # define OSSL_PARAM_size_t(key, addr) \ | |
50 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t), \ | |
51 | NULL) | |
52 | # define OSSL_PARAM_double(key, addr) \ | |
53 | OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), NULL) | |
54 | ||
55 | # define OSSL_PARAM_utf8_string(key, addr, sz) \ | |
56 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, NULL) | |
57 | # define OSSL_PARAM_octet_string(key, addr, sz) \ | |
58 | OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, NULL) | |
59 | ||
60 | # define OSSL_PARAM_utf8_ptr(key, addr, sz) \ | |
61 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, NULL) | |
62 | # define OSSL_PARAM_octet_ptr(key, addr, sz) \ | |
63 | OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, NULL) | |
64 | ||
65 | /* Basic parameter types including return sizes */ | |
66 | # define OSSL_PARAM_SIZED_int(key, addr, r_sz) \ | |
67 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), &(r_sz)) | |
68 | # define OSSL_PARAM_SIZED_uint(key, addr, r_sz) \ | |
69 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
70 | sizeof(unsigned int), &(r_sz)) | |
71 | # define OSSL_PARAM_SIZED_long(key, addr, r_sz) \ | |
72 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \ | |
73 | &(r_sz)) | |
74 | # define OSSL_PARAM_SIZED_ulong(key, addr, r_sz) \ | |
75 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
76 | sizeof(unsigned long int), &(r_sz)) | |
77 | # define OSSL_PARAM_SIZED_int32(key, addr, r_sz) \ | |
78 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), &(r_sz)) | |
79 | # define OSSL_PARAM_SIZED_uint32(key, addr, r_sz) \ | |
80 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
81 | sizeof(uint32_t), &(r_sz)) | |
82 | # define OSSL_PARAM_SIZED_int64(key, addr, r_sz) \ | |
83 | OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), &(r_sz)) | |
84 | # define OSSL_PARAM_SIZED_uint64(key, addr, r_sz) \ | |
85 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
86 | sizeof(uint64_t), &(r_sz)) | |
87 | # define OSSL_PARAM_SIZED_size_t(key, addr, r_sz) \ | |
88 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ | |
89 | sizeof(size_t), &(r_sz)) | |
90 | # define OSSL_PARAM_SIZED_double(key, addr, r_sz) \ | |
91 | OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), &(r_sz)) | |
92 | ||
93 | # define OSSL_PARAM_SIZED_BN(key, addr, sz, r_sz) \ | |
94 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sz, \ | |
95 | &(r_sz)) | |
96 | ||
97 | # define OSSL_PARAM_SIZED_utf8_string(key, addr, sz, r_sz) \ | |
98 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, &(r_sz)) | |
99 | # define OSSL_PARAM_SIZED_octet_string(key, addr, sz, r_sz) \ | |
100 | OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, &(r_sz)) | |
101 | ||
102 | # define OSSL_PARAM_SIZED_utf8_ptr(key, addr, sz, r_sz) \ | |
103 | OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, &(r_sz)) | |
104 | # define OSSL_PARAM_SIZED_octet_ptr(key, addr, sz, r_sz) \ | |
105 | OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, &(r_sz)) | |
106 | ||
107 | /* Search an OSSL_PARAM array for a matching name */ | |
108 | const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key); | |
109 | ||
110 | /* Basic parameter type run-time construction */ | |
111 | OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *ret); | |
112 | OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf, | |
113 | size_t *ret); | |
114 | OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf, | |
115 | size_t *ret); | |
116 | OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf, | |
117 | size_t *ret); | |
118 | OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf, | |
119 | size_t *ret); | |
120 | OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf, | |
121 | size_t *ret); | |
122 | OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf, | |
123 | size_t *ret); | |
124 | OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf, | |
125 | size_t *ret); | |
126 | OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf, | |
127 | size_t *ret); | |
128 | OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, | |
129 | size_t bsize, size_t *rsize); | |
130 | OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf, | |
131 | size_t *rsize); | |
132 | OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, | |
133 | size_t bsize, size_t *rsize); | |
134 | OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, | |
135 | size_t *rsize); | |
136 | OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, | |
137 | size_t bsize, size_t *rsize); | |
138 | OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, | |
139 | size_t *rsize); | |
195852fe | 140 | OSSL_PARAM OSSL_PARAM_construct_end(void); |
7ffbd7ca P |
141 | |
142 | int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val); | |
143 | int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val); | |
144 | int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val); | |
145 | int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val); | |
146 | int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val); | |
147 | int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val); | |
148 | int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val); | |
149 | int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val); | |
150 | int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val); | |
151 | ||
152 | int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val); | |
153 | int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val); | |
154 | int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val); | |
155 | int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val); | |
156 | int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val); | |
157 | int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val); | |
158 | int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val); | |
159 | int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val); | |
160 | int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val); | |
161 | ||
162 | int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val); | |
163 | int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val); | |
164 | ||
165 | int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val); | |
166 | int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val); | |
167 | ||
168 | int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); | |
169 | int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val); | |
170 | ||
171 | int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, | |
172 | size_t *used_len); | |
173 | int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val, | |
174 | size_t len); | |
175 | ||
176 | int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); | |
177 | int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val); | |
178 | ||
179 | int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, | |
180 | size_t *used_len); | |
181 | int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val, | |
182 | size_t used_len); | |
183 | ||
184 | # ifdef __cplusplus | |
185 | } | |
186 | # endif | |
187 | #endif |