]>
Commit | Line | Data |
---|---|---|
0aeddcfa MC |
1 | /* |
2 | * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. | |
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 | |
0aeddcfa | 7 | * https://www.openssl.org/source/license.html |
0aeddcfa MC |
8 | */ |
9 | ||
10 | #include <openssl/dh.h> | |
2f545ae4 | 11 | #include "internal/refcount.h" |
0aeddcfa MC |
12 | |
13 | struct dh_st { | |
14 | /* | |
15 | * This first argument is used to pick up errors when a DH is passed | |
16 | * instead of a EVP_PKEY | |
17 | */ | |
18 | int pad; | |
19 | int version; | |
20 | BIGNUM *p; | |
21 | BIGNUM *g; | |
6a32a3c0 | 22 | int32_t length; /* optional */ |
0aeddcfa MC |
23 | BIGNUM *pub_key; /* g^x % p */ |
24 | BIGNUM *priv_key; /* x */ | |
25 | int flags; | |
26 | BN_MONT_CTX *method_mont_p; | |
27 | /* Place holders if we want to do X9.42 DH */ | |
28 | BIGNUM *q; | |
29 | BIGNUM *j; | |
30 | unsigned char *seed; | |
31 | int seedlen; | |
32 | BIGNUM *counter; | |
2f545ae4 | 33 | CRYPTO_REF_COUNT references; |
0aeddcfa MC |
34 | CRYPTO_EX_DATA ex_data; |
35 | const DH_METHOD *meth; | |
36 | ENGINE *engine; | |
37 | CRYPTO_RWLOCK *lock; | |
38 | }; | |
17e01abb MC |
39 | |
40 | struct dh_method { | |
41 | char *name; | |
42 | /* Methods here */ | |
43 | int (*generate_key) (DH *dh); | |
44 | int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh); | |
0263b992 | 45 | |
17e01abb MC |
46 | /* Can be null */ |
47 | int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a, | |
48 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, | |
49 | BN_MONT_CTX *m_ctx); | |
50 | int (*init) (DH *dh); | |
51 | int (*finish) (DH *dh); | |
52 | int flags; | |
53 | char *app_data; | |
54 | /* If this is non-NULL, it will be used to generate parameters */ | |
55 | int (*generate_params) (DH *dh, int prime_len, int generator, | |
56 | BN_GENCB *cb); | |
57 | }; |