]>
Commit | Line | Data |
---|---|---|
21dcbebc | 1 | /* |
feeb7ecd | 2 | * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. |
d02b48c6 | 3 | * |
48f4ad77 | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
21dcbebc RS |
5 | * this file except in compliance with the License. You can obtain a copy |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
d02b48c6 RE |
8 | */ |
9 | ||
ae4186b0 DMSP |
10 | #ifndef OPENSSL_DH_H |
11 | # define OPENSSL_DH_H | |
d86167ec DMSP |
12 | # pragma once |
13 | ||
14 | # include <openssl/macros.h> | |
936c2b9e | 15 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
d86167ec DMSP |
16 | # define HEADER_DH_H |
17 | # endif | |
d02b48c6 | 18 | |
98186eb4 | 19 | # include <openssl/opensslconf.h> |
d3ae5b1c | 20 | |
3c27208f | 21 | # ifndef OPENSSL_NO_DH |
2c64df66 P |
22 | # include <openssl/e_os2.h> |
23 | # include <openssl/bio.h> | |
24 | # include <openssl/asn1.h> | |
25 | # include <openssl/types.h> | |
26 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 | |
27 | # include <openssl/bn.h> | |
28 | # endif | |
29 | # include <openssl/dherr.h> | |
5e3225cc | 30 | |
2c64df66 | 31 | # ifdef __cplusplus |
3c27208f | 32 | extern "C" { |
2c64df66 | 33 | # endif |
3c27208f | 34 | |
2c64df66 P |
35 | # ifndef OPENSSL_DH_MAX_MODULUS_BITS |
36 | # define OPENSSL_DH_MAX_MODULUS_BITS 10000 | |
37 | # endif | |
83c3410b | 38 | |
2c64df66 | 39 | # define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 |
0f113f3e | 40 | |
2c64df66 | 41 | # define DH_FLAG_CACHE_MONT_P 0x01 |
5584f65a | 42 | |
2c64df66 | 43 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
5584f65a MC |
44 | /* |
45 | * Does nothing. Previously this switched off constant time behaviour. | |
46 | */ | |
2c64df66 P |
47 | # define DH_FLAG_NO_EXP_CONSTTIME 0x00 |
48 | # endif | |
dfeab068 | 49 | |
ada66e78 | 50 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
0f113f3e MC |
51 | /* |
52 | * If this flag is set the DH method is FIPS compliant and can be used in | |
53 | * FIPS mode. This is set in the validated module method. If an application | |
8483a003 | 54 | * sets this flag in its own methods it is its responsibility to ensure the |
0f113f3e | 55 | * result is compliant. |
4960411e DSH |
56 | */ |
57 | ||
ada66e78 | 58 | # define DH_FLAG_FIPS_METHOD 0x0400 |
4960411e | 59 | |
0f113f3e MC |
60 | /* |
61 | * If this flag is set the operations normally disabled in FIPS mode are | |
4960411e DSH |
62 | * permitted it is then the applications responsibility to ensure that the |
63 | * usage is compliant. | |
64 | */ | |
65 | ||
ada66e78 P |
66 | # define DH_FLAG_NON_FIPS_ALLOW 0x0400 |
67 | # endif | |
4960411e | 68 | |
3a87a9b9 GT |
69 | /* Already defined in ossl_typ.h */ |
70 | /* typedef struct dh_st DH; */ | |
71 | /* typedef struct dh_method DH_METHOD; */ | |
13066cee | 72 | |
599eccfc RS |
73 | DECLARE_ASN1_ITEM(DHparams) |
74 | ||
ada66e78 P |
75 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
76 | # define DH_GENERATOR_2 2 | |
77 | # define DH_GENERATOR_3 3 | |
78 | # define DH_GENERATOR_5 5 | |
d02b48c6 RE |
79 | |
80 | /* DH_check error codes */ | |
92dcfb79 MC |
81 | /* |
82 | * NB: These values must align with the equivalently named macros in | |
83 | * internal/ffc.h. | |
84 | */ | |
ada66e78 P |
85 | # define DH_CHECK_P_NOT_PRIME 0x01 |
86 | # define DH_CHECK_P_NOT_SAFE_PRIME 0x02 | |
87 | # define DH_UNABLE_TO_CHECK_GENERATOR 0x04 | |
88 | # define DH_NOT_SUITABLE_GENERATOR 0x08 | |
89 | # define DH_CHECK_Q_NOT_PRIME 0x10 | |
90 | # define DH_CHECK_INVALID_Q_VALUE 0x20 | |
91 | # define DH_CHECK_INVALID_J_VALUE 0x40 | |
92 | # define DH_MODULUS_TOO_SMALL 0x80 | |
93 | # define DH_MODULUS_TOO_LARGE 0x100 | |
d02b48c6 | 94 | |
bf3d6c0c | 95 | /* DH_check_pub_key error codes */ |
ada66e78 P |
96 | # define DH_CHECK_PUBKEY_TOO_SMALL 0x01 |
97 | # define DH_CHECK_PUBKEY_TOO_LARGE 0x02 | |
98 | # define DH_CHECK_PUBKEY_INVALID 0x04 | |
bf3d6c0c | 99 | |
0f113f3e MC |
100 | /* |
101 | * primes p where (p-1)/2 is prime too are called "safe"; we define this for | |
102 | * backward compatibility: | |
103 | */ | |
2c64df66 | 104 | # define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME |
4486d0cd | 105 | |
f11f86f6 | 106 | /* DH parameter generation types used by EVP_PKEY_CTX_set_dh_paramgen_type() */ |
ada66e78 P |
107 | # define DH_PARAMGEN_TYPE_GENERATOR 0 /* Use a generator g */ |
108 | # define DH_PARAMGEN_TYPE_FIPS_186_2 1 /* Use legacy FIPS186-2 standard */ | |
109 | # define DH_PARAMGEN_TYPE_FIPS_186_4 2 /* Use FIPS186-4 standard */ | |
110 | ||
111 | # define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME | |
112 | ||
113 | # define d2i_DHparams_fp(fp, x) \ | |
114 | (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ | |
115 | (char *(*)())d2i_DHparams, \ | |
116 | (fp), \ | |
117 | (unsigned char **)(x)) | |
118 | # define i2d_DHparams_fp(fp, x) \ | |
119 | ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x)) | |
120 | # define d2i_DHparams_bio(bp, x) \ | |
121 | ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x) | |
122 | # define i2d_DHparams_bio(bp, x) \ | |
123 | ASN1_i2d_bio_of(DH, i2d_DHparams, bp, x) | |
124 | ||
125 | # define d2i_DHxparams_fp(fp,x) \ | |
126 | (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ | |
127 | (char *(*)())d2i_DHxparams, \ | |
128 | (fp), \ | |
129 | (unsigned char **)(x)) | |
130 | # define i2d_DHxparams_fp(fp, x) \ | |
131 | ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x)) | |
132 | # define d2i_DHxparams_bio(bp, x) \ | |
133 | ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x) | |
134 | # define i2d_DHxparams_bio(bp, x) \ | |
135 | ASN1_i2d_bio_of(DH, i2d_DHxparams, bp, x) | |
136 | # endif | |
d02b48c6 | 137 | |
9fdcc21f | 138 | DECLARE_ASN1_DUP_FUNCTION_name(DH, DHparams) |
f4274da1 | 139 | |
ada66e78 | 140 | DEPRECATEDIN_3_0(const DH_METHOD *DH_OpenSSL(void)) |
13066cee | 141 | |
ada66e78 P |
142 | DEPRECATEDIN_3_0(void DH_set_default_method(const DH_METHOD *meth)) |
143 | DEPRECATEDIN_3_0(const DH_METHOD *DH_get_default_method(void)) | |
144 | DEPRECATEDIN_3_0(int DH_set_method(DH *dh, const DH_METHOD *meth)) | |
145 | DEPRECATEDIN_3_0(DH *DH_new_method(ENGINE *engine)) | |
13066cee | 146 | |
0f113f3e MC |
147 | DH *DH_new(void); |
148 | void DH_free(DH *dh); | |
149 | int DH_up_ref(DH *dh); | |
ada66e78 P |
150 | DEPRECATEDIN_3_0(int DH_bits(const DH *dh)) |
151 | DEPRECATEDIN_3_0(int DH_size(const DH *dh)) | |
152 | DEPRECATEDIN_3_0(int DH_security_bits(const DH *dh)) | |
153 | # ifndef OPENSSL_NO_DEPRECATED_3_0 | |
154 | # define DH_get_ex_new_index(l, p, newf, dupf, freef) \ | |
155 | CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) | |
156 | # endif | |
157 | DEPRECATEDIN_3_0(int DH_set_ex_data(DH *d, int idx, void *arg)) | |
158 | DEPRECATEDIN_3_0(void *DH_get_ex_data(DH *d, int idx)) | |
e9224c71 GT |
159 | |
160 | /* Deprecated version */ | |
98186eb4 | 161 | DEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator, |
0f113f3e MC |
162 | void (*callback) (int, int, |
163 | void *), | |
98186eb4 | 164 | void *cb_arg)) |
e9224c71 GT |
165 | |
166 | /* New version */ | |
ada66e78 P |
167 | DEPRECATEDIN_3_0(int DH_generate_parameters_ex(DH *dh, int prime_len, |
168 | int generator, BN_GENCB *cb)) | |
0f113f3e | 169 | |
ada66e78 P |
170 | DEPRECATEDIN_3_0(int DH_check_params_ex(const DH *dh)) |
171 | DEPRECATEDIN_3_0(int DH_check_ex(const DH *dh)) | |
172 | DEPRECATEDIN_3_0(int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key)) | |
173 | /* | |
174 | * TODO(3.0): deprecate DH_check_params once ssl/statem/statem_clnt.c is fixed. | |
175 | */ | |
26505153 | 176 | int DH_check_params(const DH *dh, int *ret); |
ada66e78 P |
177 | DEPRECATEDIN_3_0(int DH_check(const DH *dh, int *codes)) |
178 | DEPRECATEDIN_3_0(int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, | |
179 | int *codes)) | |
180 | DEPRECATEDIN_3_0(int DH_generate_key(DH *dh)) | |
181 | DEPRECATEDIN_3_0(int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, | |
182 | DH *dh)) | |
183 | DEPRECATEDIN_3_0(int DH_compute_key_padded(unsigned char *key, | |
184 | const BIGNUM *pub_key, DH *dh)) | |
9fdcc21f DO |
185 | DECLARE_ASN1_ENCODE_FUNCTIONS_only(DH, DHparams) |
186 | DECLARE_ASN1_ENCODE_FUNCTIONS_only(DH, DHxparams) | |
2c64df66 | 187 | # ifndef OPENSSL_NO_STDIO |
ada66e78 | 188 | DEPRECATEDIN_3_0(int DHparams_print_fp(FILE *fp, const DH *x)) |
2c64df66 | 189 | # endif |
ada66e78 | 190 | DEPRECATEDIN_3_0(int DHparams_print(BIO *bp, const DH *x)) |
d02b48c6 | 191 | |
20bee968 DSH |
192 | /* RFC 5114 parameters */ |
193 | DH *DH_get_1024_160(void); | |
194 | DH *DH_get_2048_224(void); | |
195 | DH *DH_get_2048_256(void); | |
196 | ||
ca2bf555 | 197 | /* Named parameters, currently RFC7919 and RFC3526 */ |
ada66e78 | 198 | /* TODO(3.0): deprecate DH_new_by_nid() after converting ssl/s3_lib.c */ |
7806a782 | 199 | DH *DH_new_by_nid(int nid); |
ada66e78 | 200 | DEPRECATEDIN_3_0(int DH_get_nid(DH *dh)) |
7806a782 | 201 | |
2c64df66 | 202 | # ifndef OPENSSL_NO_CMS |
dc1ce3bc | 203 | /* RFC2631 KDF */ |
ada66e78 P |
204 | DEPRECATEDIN_3_0(int DH_KDF_X9_42(unsigned char *out, size_t outlen, |
205 | const unsigned char *Z, size_t Zlen, | |
206 | ASN1_OBJECT *key_oid, | |
207 | const unsigned char *ukm, | |
208 | size_t ukmlen, const EVP_MD *md)) | |
2c64df66 | 209 | # endif |
0f113f3e | 210 | |
fd809cfd RL |
211 | void DH_get0_pqg(const DH *dh, |
212 | const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); | |
0aeddcfa | 213 | int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); |
fd809cfd RL |
214 | void DH_get0_key(const DH *dh, |
215 | const BIGNUM **pub_key, const BIGNUM **priv_key); | |
0aeddcfa | 216 | int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); |
6db7fadf DMSP |
217 | const BIGNUM *DH_get0_p(const DH *dh); |
218 | const BIGNUM *DH_get0_q(const DH *dh); | |
219 | const BIGNUM *DH_get0_g(const DH *dh); | |
220 | const BIGNUM *DH_get0_priv_key(const DH *dh); | |
221 | const BIGNUM *DH_get0_pub_key(const DH *dh); | |
0aeddcfa MC |
222 | void DH_clear_flags(DH *dh, int flags); |
223 | int DH_test_flags(const DH *dh, int flags); | |
224 | void DH_set_flags(DH *dh, int flags); | |
ada66e78 P |
225 | DEPRECATEDIN_3_0(ENGINE *DH_get0_engine(DH *d)) |
226 | DEPRECATEDIN_3_0(long DH_get_length(const DH *dh)) | |
227 | DEPRECATEDIN_3_0(int DH_set_length(DH *dh, long length)) | |
228 | ||
229 | DEPRECATEDIN_3_0(DH_METHOD *DH_meth_new(const char *name, int flags)) | |
230 | DEPRECATEDIN_3_0(void DH_meth_free(DH_METHOD *dhm)) | |
231 | DEPRECATEDIN_3_0(DH_METHOD *DH_meth_dup(const DH_METHOD *dhm)) | |
232 | DEPRECATEDIN_3_0(const char *DH_meth_get0_name(const DH_METHOD *dhm)) | |
233 | DEPRECATEDIN_3_0(int DH_meth_set1_name(DH_METHOD *dhm, const char *name)) | |
234 | DEPRECATEDIN_3_0(int DH_meth_get_flags(const DH_METHOD *dhm)) | |
235 | DEPRECATEDIN_3_0(int DH_meth_set_flags(DH_METHOD *dhm, int flags)) | |
236 | DEPRECATEDIN_3_0(void *DH_meth_get0_app_data(const DH_METHOD *dhm)) | |
237 | DEPRECATEDIN_3_0(int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data)) | |
238 | DEPRECATEDIN_3_0(int (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *)) | |
239 | DEPRECATEDIN_3_0(int DH_meth_set_generate_key(DH_METHOD *dhm, | |
240 | int (*generate_key) (DH *))) | |
241 | DEPRECATEDIN_3_0(int (*DH_meth_get_compute_key(const DH_METHOD *dhm)) | |
242 | (unsigned char *key, | |
243 | const BIGNUM *pub_key, DH *dh)) | |
244 | DEPRECATEDIN_3_0(int DH_meth_set_compute_key(DH_METHOD *dhm, | |
245 | int (*compute_key) | |
246 | (unsigned char *key, | |
247 | const BIGNUM *pub_key, | |
248 | DH *dh))) | |
249 | DEPRECATEDIN_3_0(int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm)) | |
250 | (const DH *, BIGNUM *, | |
251 | const BIGNUM *, | |
252 | const BIGNUM *, | |
253 | const BIGNUM *, BN_CTX *, | |
254 | BN_MONT_CTX *)) | |
255 | DEPRECATEDIN_3_0(int DH_meth_set_bn_mod_exp(DH_METHOD *dhm, | |
256 | int (*bn_mod_exp) | |
257 | (const DH *, BIGNUM *, | |
258 | const BIGNUM *, const BIGNUM *, | |
259 | const BIGNUM *, BN_CTX *, | |
260 | BN_MONT_CTX *))) | |
261 | DEPRECATEDIN_3_0(int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *)) | |
262 | DEPRECATEDIN_3_0(int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *))) | |
263 | DEPRECATEDIN_3_0(int (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *)) | |
264 | DEPRECATEDIN_3_0(int DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *))) | |
265 | DEPRECATEDIN_3_0(int (*DH_meth_get_generate_params(const DH_METHOD *dhm)) | |
266 | (DH *, int, int, | |
267 | BN_GENCB *)) | |
268 | DEPRECATEDIN_3_0(int DH_meth_set_generate_params(DH_METHOD *dhm, | |
269 | int (*generate_params) | |
270 | (DH *, int, int, | |
271 | BN_GENCB *))) | |
0aeddcfa | 272 | |
2c64df66 | 273 | # define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \ |
0f113f3e | 274 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 275 | EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL) |
0f113f3e | 276 | |
2c64df66 | 277 | # define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \ |
0f113f3e | 278 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 279 | EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL) |
0f113f3e | 280 | |
2c64df66 | 281 | # define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \ |
0f113f3e | 282 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 283 | EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL) |
0f113f3e | 284 | |
2c64df66 | 285 | # define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \ |
0f113f3e | 286 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 287 | EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL) |
0f113f3e | 288 | |
2c64df66 | 289 | # define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \ |
0f113f3e | 290 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 291 | EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) |
0f113f3e | 292 | |
2c64df66 | 293 | # define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \ |
0f113f3e | 294 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ |
2c64df66 | 295 | EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) |
0f113f3e | 296 | |
2c64df66 | 297 | # define EVP_PKEY_CTX_set_dh_nid(ctx, nid) \ |
d59d853a DSH |
298 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, \ |
299 | EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \ | |
300 | EVP_PKEY_CTRL_DH_NID, nid, NULL) | |
301 | ||
35aca9ec | 302 | int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad); |
f4403a1f | 303 | |
2c64df66 P |
304 | # define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \ |
305 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
306 | EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL) | |
307 | ||
308 | # define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \ | |
309 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
310 | EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL) | |
311 | ||
312 | # define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \ | |
313 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
314 | EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)(oid)) | |
315 | ||
316 | # define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \ | |
317 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
318 | EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)(poid)) | |
319 | ||
320 | # define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \ | |
321 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
322 | EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)(md)) | |
323 | ||
324 | # define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \ | |
325 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
326 | EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)(pmd)) | |
327 | ||
328 | # define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \ | |
329 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
330 | EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL) | |
331 | ||
332 | # define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \ | |
333 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
334 | EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)(plen)) | |
335 | ||
336 | # define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \ | |
337 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
338 | EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)(p)) | |
339 | ||
340 | # define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \ | |
341 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_DERIVE, \ | |
342 | EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)(p)) | |
343 | ||
344 | # define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1) | |
345 | # define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2) | |
346 | # define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3) | |
347 | # define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4) | |
348 | # define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5) | |
349 | # define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6) | |
350 | # define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7) | |
351 | # define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8) | |
352 | # define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9) | |
353 | # define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10) | |
354 | # define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11) | |
355 | # define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12) | |
356 | # define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) | |
357 | # define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) | |
358 | # define EVP_PKEY_CTRL_DH_NID (EVP_PKEY_ALG_CTRL + 15) | |
359 | # define EVP_PKEY_CTRL_DH_PAD (EVP_PKEY_ALG_CTRL + 16) | |
bd59f2b9 DSH |
360 | |
361 | /* KDF types */ | |
2c64df66 P |
362 | # define EVP_PKEY_DH_KDF_NONE 1 |
363 | # ifndef OPENSSL_NO_CMS | |
364 | # define EVP_PKEY_DH_KDF_X9_42 2 | |
365 | # endif | |
3ba0885a | 366 | |
0cd0a820 | 367 | # ifdef __cplusplus |
d02b48c6 | 368 | } |
0cd0a820 | 369 | # endif |
3c27208f | 370 | # endif |
d02b48c6 | 371 | #endif |