]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/dh/dh_rfc5114.c
Deprecate the low level Diffie-Hellman functions.
[thirdparty/openssl.git] / crypto / dh / dh_rfc5114.c
CommitLineData
0f113f3e 1/*
aa6bb135 2 * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
20bee968 3 *
e38873f5 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
aa6bb135
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
20bee968
DSH
8 */
9
ada66e78
P
10/*
11 * DH low level APIs are deprecated for public use, but still ok for
12 * internal use.
13 */
14#include "internal/deprecated.h"
15
20bee968 16#include <stdio.h>
b39fc560 17#include "internal/cryptlib.h"
706457b7 18#include "dh_local.h"
20bee968 19#include <openssl/bn.h>
25f2138b 20#include "crypto/bn_dh.h"
20bee968 21
0f113f3e
MC
22/*
23 * Macro to make a DH structure from BIGNUM data. NB: although just copying
75f648aa
RS
24 * the BIGNUM static pointers would be more efficient, we can't do that
25 * because they get wiped using BN_clear_free() when DH_free() is called.
20bee968
DSH
26 */
27
28#define make_dh(x) \
75f648aa
RS
29DH *DH_get_##x(void) \
30{ \
31 DH *dh = DH_new(); \
32\
33 if (dh == NULL) \
34 return NULL; \
dc8de3e6
SL
35 dh->params.p = BN_dup(&_bignum_dh##x##_p); \
36 dh->params.g = BN_dup(&_bignum_dh##x##_g); \
37 dh->params.q = BN_dup(&_bignum_dh##x##_q); \
38 if (dh->params.p == NULL || dh->params.q == NULL || dh->params.g == NULL) {\
75f648aa
RS
39 DH_free(dh); \
40 return NULL; \
41 } \
42 return dh; \
43}
20bee968
DSH
44
45make_dh(1024_160)
46make_dh(2048_224)
47make_dh(2048_256)