summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dh/dh.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dh/dh.h')
-rw-r--r--src/lib/libcrypto/dh/dh.h60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 92c7481e10..ccdf35ae1c 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -59,6 +59,8 @@
59#ifndef HEADER_DH_H 59#ifndef HEADER_DH_H
60#define HEADER_DH_H 60#define HEADER_DH_H
61 61
62#include <openssl/e_os2.h>
63
62#ifdef OPENSSL_NO_DH 64#ifdef OPENSSL_NO_DH
63#error DH is disabled. 65#error DH is disabled.
64#endif 66#endif
@@ -66,10 +68,15 @@
66#ifndef OPENSSL_NO_BIO 68#ifndef OPENSSL_NO_BIO
67#include <openssl/bio.h> 69#include <openssl/bio.h>
68#endif 70#endif
69#include <openssl/bn.h>
70#include <openssl/crypto.h>
71#include <openssl/ossl_typ.h> 71#include <openssl/ossl_typ.h>
72#ifndef OPENSSL_NO_DEPRECATED
73#include <openssl/bn.h>
74#endif
72 75
76#ifndef OPENSSL_DH_MAX_MODULUS_BITS
77# define OPENSSL_DH_MAX_MODULUS_BITS 10000
78#endif
79
73#define DH_FLAG_CACHE_MONT_P 0x01 80#define DH_FLAG_CACHE_MONT_P 0x01
74#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH 81#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
75 * implementation now uses constant time 82 * implementation now uses constant time
@@ -83,9 +90,12 @@
83extern "C" { 90extern "C" {
84#endif 91#endif
85 92
86typedef struct dh_st DH; 93/* Already defined in ossl_typ.h */
94/* typedef struct dh_st DH; */
95/* typedef struct dh_method DH_METHOD; */
87 96
88typedef struct dh_method { 97struct dh_method
98 {
89 const char *name; 99 const char *name;
90 /* Methods here */ 100 /* Methods here */
91 int (*generate_key)(DH *dh); 101 int (*generate_key)(DH *dh);
@@ -98,7 +108,9 @@ typedef struct dh_method {
98 int (*finish)(DH *dh); 108 int (*finish)(DH *dh);
99 int flags; 109 int flags;
100 char *app_data; 110 char *app_data;
101} DH_METHOD; 111 /* If this is non-NULL, it will be used to generate parameters */
112 int (*generate_params)(DH *dh, int prime_len, int generator, BN_GENCB *cb);
113 };
102 114
103struct dh_st 115struct dh_st
104 { 116 {
@@ -113,7 +125,7 @@ struct dh_st
113 BIGNUM *priv_key; /* x */ 125 BIGNUM *priv_key; /* x */
114 126
115 int flags; 127 int flags;
116 char *method_mont_p; 128 BN_MONT_CTX *method_mont_p;
117 /* Place holders if we want to do X9.42 DH */ 129 /* Place holders if we want to do X9.42 DH */
118 BIGNUM *q; 130 BIGNUM *q;
119 BIGNUM *j; 131 BIGNUM *j;
@@ -137,25 +149,21 @@ struct dh_st
137#define DH_UNABLE_TO_CHECK_GENERATOR 0x04 149#define DH_UNABLE_TO_CHECK_GENERATOR 0x04
138#define DH_NOT_SUITABLE_GENERATOR 0x08 150#define DH_NOT_SUITABLE_GENERATOR 0x08
139 151
152/* DH_check_pub_key error codes */
153#define DH_CHECK_PUBKEY_TOO_SMALL 0x01
154#define DH_CHECK_PUBKEY_TOO_LARGE 0x02
155
140/* primes p where (p-1)/2 is prime too are called "safe"; we define 156/* primes p where (p-1)/2 is prime too are called "safe"; we define
141 this for backward compatibility: */ 157 this for backward compatibility: */
142#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME 158#define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
143 159
144#define DHparams_dup(x) (DH *)ASN1_dup((int (*)())i2d_DHparams, \ 160#define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x)
145 (char *(*)())d2i_DHparams,(char *)(x))
146#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ 161#define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
147 (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) 162 (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x))
148#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ 163#define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \
149 (unsigned char *)(x)) 164 (unsigned char *)(x))
150#define d2i_DHparams_bio(bp,x) (DH *)ASN1_d2i_bio((char *(*)())DH_new, \ 165#define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x)
151 (char *(*)())d2i_DHparams,(bp),(unsigned char **)(x)) 166#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)
152#ifdef __cplusplus
153#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio((int (*)())i2d_DHparams,(bp), \
154 (unsigned char *)(x))
155#else
156#define i2d_DHparams_bio(bp,x) ASN1_i2d_bio(i2d_DHparams,(bp), \
157 (unsigned char *)(x))
158#endif
159 167
160const DH_METHOD *DH_OpenSSL(void); 168const DH_METHOD *DH_OpenSSL(void);
161 169
@@ -172,9 +180,18 @@ int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
172 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); 180 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
173int DH_set_ex_data(DH *d, int idx, void *arg); 181int DH_set_ex_data(DH *d, int idx, void *arg);
174void *DH_get_ex_data(DH *d, int idx); 182void *DH_get_ex_data(DH *d, int idx);
183
184/* Deprecated version */
185#ifndef OPENSSL_NO_DEPRECATED
175DH * DH_generate_parameters(int prime_len,int generator, 186DH * DH_generate_parameters(int prime_len,int generator,
176 void (*callback)(int,int,void *),void *cb_arg); 187 void (*callback)(int,int,void *),void *cb_arg);
188#endif /* !defined(OPENSSL_NO_DEPRECATED) */
189
190/* New version */
191int DH_generate_parameters_ex(DH *dh, int prime_len,int generator, BN_GENCB *cb);
192
177int DH_check(const DH *dh,int *codes); 193int DH_check(const DH *dh,int *codes);
194int DH_check_pub_key(const DH *dh,const BIGNUM *pub_key, int *codes);
178int DH_generate_key(DH *dh); 195int DH_generate_key(DH *dh);
179int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh); 196int DH_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
180DH * d2i_DHparams(DH **a,const unsigned char **pp, long length); 197DH * d2i_DHparams(DH **a,const unsigned char **pp, long length);
@@ -197,15 +214,18 @@ void ERR_load_DH_strings(void);
197/* Error codes for the DH functions. */ 214/* Error codes for the DH functions. */
198 215
199/* Function codes. */ 216/* Function codes. */
217#define DH_F_COMPUTE_KEY 102
200#define DH_F_DHPARAMS_PRINT 100 218#define DH_F_DHPARAMS_PRINT 100
201#define DH_F_DHPARAMS_PRINT_FP 101 219#define DH_F_DHPARAMS_PRINT_FP 101
202#define DH_F_DH_COMPUTE_KEY 102 220#define DH_F_DH_BUILTIN_GENPARAMS 106
203#define DH_F_DH_GENERATE_KEY 103
204#define DH_F_DH_GENERATE_PARAMETERS 104
205#define DH_F_DH_NEW_METHOD 105 221#define DH_F_DH_NEW_METHOD 105
222#define DH_F_GENERATE_KEY 103
223#define DH_F_GENERATE_PARAMETERS 104
206 224
207/* Reason codes. */ 225/* Reason codes. */
208#define DH_R_BAD_GENERATOR 101 226#define DH_R_BAD_GENERATOR 101
227#define DH_R_INVALID_PUBKEY 102
228#define DH_R_MODULUS_TOO_LARGE 103
209#define DH_R_NO_PRIVATE_VALUE 100 229#define DH_R_NO_PRIVATE_VALUE 100
210 230
211#ifdef __cplusplus 231#ifdef __cplusplus