/src/openssl/crypto/dh/dh_rfc5114.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2011-2021 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
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 |
8 | | */ |
9 | | |
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 | | |
16 | | #include <stdio.h> |
17 | | #include "internal/cryptlib.h" |
18 | | #include "dh_local.h" |
19 | | #include <openssl/bn.h> |
20 | | #include "crypto/bn_dh.h" |
21 | | |
22 | | /* |
23 | | * Macro to make a DH structure from BIGNUM data. NB: although just copying |
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. |
26 | | */ |
27 | | |
28 | | #define make_dh(x) \ |
29 | 0 | DH *DH_get_##x(void) \ |
30 | 0 | { \ |
31 | 0 | DH *dh = DH_new(); \ |
32 | 0 | \ |
33 | 0 | if (dh == NULL) \ |
34 | 0 | return NULL; \ |
35 | 0 | dh->params.p = BN_dup(&ossl_bignum_dh##x##_p); \ |
36 | 0 | dh->params.g = BN_dup(&ossl_bignum_dh##x##_g); \ |
37 | 0 | dh->params.q = BN_dup(&ossl_bignum_dh##x##_q); \ |
38 | 0 | if (dh->params.p == NULL || dh->params.q == NULL || dh->params.g == NULL) {\ |
39 | 0 | DH_free(dh); \ |
40 | 0 | return NULL; \ |
41 | 0 | } \ |
42 | 0 | return dh; \ |
43 | 0 | } Unexecuted instantiation: DH_get_1024_160 Unexecuted instantiation: DH_get_2048_224 Unexecuted instantiation: DH_get_2048_256 |
44 | | |
45 | | make_dh(1024_160) |
46 | | make_dh(2048_224) |
47 | | make_dh(2048_256) |