summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa/dsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa.h')
-rw-r--r--src/lib/libcrypto/dsa/dsa.h180
1 files changed, 118 insertions, 62 deletions
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h
index 1ca87c1cbe..9b3baadf2c 100644
--- a/src/lib/libcrypto/dsa/dsa.h
+++ b/src/lib/libcrypto/dsa/dsa.h
@@ -65,18 +65,59 @@
65#ifndef HEADER_DSA_H 65#ifndef HEADER_DSA_H
66#define HEADER_DSA_H 66#define HEADER_DSA_H
67 67
68#ifdef OPENSSL_NO_DSA
69#error DSA is disabled.
70#endif
71
72#ifndef OPENSSL_NO_BIO
73#include <openssl/bio.h>
74#endif
75#include <openssl/bn.h>
76#include <openssl/crypto.h>
77#include <openssl/ossl_typ.h>
78#ifndef OPENSSL_NO_DH
79# include <openssl/dh.h>
80#endif
81
82#define DSA_FLAG_CACHE_MONT_P 0x01
83
68#ifdef __cplusplus 84#ifdef __cplusplus
69extern "C" { 85extern "C" {
70#endif 86#endif
71 87
72#include "bn.h" 88typedef struct dsa_st DSA;
73 89
74typedef struct dsa_st 90typedef struct DSA_SIG_st
91 {
92 BIGNUM *r;
93 BIGNUM *s;
94 } DSA_SIG;
95
96typedef struct dsa_method {
97 const char *name;
98 DSA_SIG * (*dsa_do_sign)(const unsigned char *dgst, int dlen, DSA *dsa);
99 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
100 BIGNUM **rp);
101 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
102 DSA_SIG *sig, DSA *dsa);
103 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
104 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
105 BN_MONT_CTX *in_mont);
106 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
107 const BIGNUM *m, BN_CTX *ctx,
108 BN_MONT_CTX *m_ctx); /* Can be null */
109 int (*init)(DSA *dsa);
110 int (*finish)(DSA *dsa);
111 int flags;
112 char *app_data;
113} DSA_METHOD;
114
115struct dsa_st
75 { 116 {
76 /* This first variable is used to pick up errors where 117 /* This first variable is used to pick up errors where
77 * a DSA is passed instead of of a EVP_PKEY */ 118 * a DSA is passed instead of of a EVP_PKEY */
78 int pad; 119 int pad;
79 int version; 120 long version;
80 int write_params; 121 int write_params;
81 BIGNUM *p; 122 BIGNUM *p;
82 BIGNUM *q; /* == 20 */ 123 BIGNUM *q; /* == 20 */
@@ -88,8 +129,15 @@ typedef struct dsa_st
88 BIGNUM *kinv; /* Signing pre-calc */ 129 BIGNUM *kinv; /* Signing pre-calc */
89 BIGNUM *r; /* Signing pre-calc */ 130 BIGNUM *r; /* Signing pre-calc */
90 131
132 int flags;
133 /* Normally used to cache montgomery values */
134 char *method_mont_p;
91 int references; 135 int references;
92 } DSA; 136 CRYPTO_EX_DATA ex_data;
137 const DSA_METHOD *meth;
138 /* functional reference if 'meth' is ENGINE-provided */
139 ENGINE *engine;
140 };
93 141
94#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ 142#define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \
95 (char *(*)())d2i_DSAparams,(char *)(x)) 143 (char *(*)())d2i_DSAparams,(char *)(x))
@@ -102,93 +150,101 @@ typedef struct dsa_st
102#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio(i2d_DSAparams,(bp), \ 150#define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio(i2d_DSAparams,(bp), \
103 (unsigned char *)(x)) 151 (unsigned char *)(x))
104 152
105#ifndef NOPROTO 153
154DSA_SIG * DSA_SIG_new(void);
155void DSA_SIG_free(DSA_SIG *a);
156int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);
157DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);
158
159DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa);
160int DSA_do_verify(const unsigned char *dgst,int dgst_len,
161 DSA_SIG *sig,DSA *dsa);
162
163const DSA_METHOD *DSA_OpenSSL(void);
164
165void DSA_set_default_method(const DSA_METHOD *);
166const DSA_METHOD *DSA_get_default_method(void);
167int DSA_set_method(DSA *dsa, const DSA_METHOD *);
106 168
107DSA * DSA_new(void); 169DSA * DSA_new(void);
108int DSA_size(DSA *); 170DSA * DSA_new_method(ENGINE *engine);
171void DSA_free (DSA *r);
172/* "up" the DSA object's reference count */
173int DSA_up_ref(DSA *r);
174int DSA_size(const DSA *);
109 /* next 4 return -1 on error */ 175 /* next 4 return -1 on error */
110int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); 176int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp);
111int DSA_sign(int type,unsigned char *dgst,int dlen, 177int DSA_sign(int type,const unsigned char *dgst,int dlen,
112 unsigned char *sig, unsigned int *siglen, DSA *dsa); 178 unsigned char *sig, unsigned int *siglen, DSA *dsa);
113int DSA_verify(int type,unsigned char *dgst,int dgst_len, 179int DSA_verify(int type,const unsigned char *dgst,int dgst_len,
114 unsigned char *sigbuf, int siglen, DSA *dsa); 180 const unsigned char *sigbuf, int siglen, DSA *dsa);
115void DSA_free (DSA *r); 181int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
116 182 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
117void ERR_load_DSA_strings(void ); 183int DSA_set_ex_data(DSA *d, int idx, void *arg);
118 184void *DSA_get_ex_data(DSA *d, int idx);
119DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); 185
120DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); 186DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);
121DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); 187DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);
122DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len, 188DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length);
189DSA * DSA_generate_parameters(int bits,
190 unsigned char *seed,int seed_len,
123 int *counter_ret, unsigned long *h_ret,void 191 int *counter_ret, unsigned long *h_ret,void
124 (*callback)(),char *cb_arg); 192 (*callback)(int, int, void *),void *cb_arg);
125int DSA_generate_key(DSA *a); 193int DSA_generate_key(DSA *a);
126int i2d_DSAPublicKey(DSA *a, unsigned char **pp); 194int i2d_DSAPublicKey(const DSA *a, unsigned char **pp);
127int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); 195int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);
128int i2d_DSAparams(DSA *a,unsigned char **pp); 196int i2d_DSAparams(const DSA *a,unsigned char **pp);
129 197
130#ifdef HEADER_BIO_H 198#ifndef OPENSSL_NO_BIO
131int DSAparams_print(BIO *bp, DSA *x); 199int DSAparams_print(BIO *bp, const DSA *x);
132int DSA_print(BIO *bp, DSA *x, int off); 200int DSA_print(BIO *bp, const DSA *x, int off);
133#endif 201#endif
134#ifndef NO_FP_API 202#ifndef OPENSSL_NO_FP_API
135int DSAparams_print_fp(FILE *fp, DSA *x); 203int DSAparams_print_fp(FILE *fp, const DSA *x);
136int DSA_print_fp(FILE *bp, DSA *x, int off); 204int DSA_print_fp(FILE *bp, const DSA *x, int off);
137#endif 205#endif
138 206
139int DSA_is_prime(BIGNUM *q,void (*callback)(),char *cb_arg); 207#define DSS_prime_checks 50
140 208/* Primality test according to FIPS PUB 186[-1], Appendix 2.1:
141#else 209 * 50 rounds of Rabin-Miller */
142 210#define DSA_is_prime(n, callback, cb_arg) \
143DSA * DSA_new(); 211 BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
144int DSA_size();
145int DSA_sign_setup();
146int DSA_sign();
147int DSA_verify();
148void DSA_free ();
149
150void ERR_load_DSA_strings();
151
152DSA * d2i_DSAPublicKey();
153DSA * d2i_DSAPrivateKey();
154DSA * d2i_DSAparams();
155DSA * DSA_generate_parameters();
156int DSA_generate_key();
157int i2d_DSAPublicKey();
158int i2d_DSAPrivateKey();
159int i2d_DSAparams();
160
161int DSA_is_prime();
162
163int DSAparams_print();
164int DSA_print();
165
166#ifndef NO_FP_API
167int DSAparams_print_fp();
168int DSA_print_fp();
169#endif
170 212
213#ifndef OPENSSL_NO_DH
214/* Convert DSA structure (key or just parameters) into DH structure
215 * (be careful to avoid small subgroup attacks when using this!) */
216DH *DSA_dup_DH(const DSA *r);
171#endif 217#endif
172 218
173/* BEGIN ERROR CODES */ 219/* BEGIN ERROR CODES */
220/* The following lines are auto generated by the script mkerr.pl. Any changes
221 * made after this point may be overwritten when the script is next run.
222 */
223void ERR_load_DSA_strings(void);
224
174/* Error codes for the DSA functions. */ 225/* Error codes for the DSA functions. */
175 226
176/* Function codes. */ 227/* Function codes. */
228#define DSA_F_D2I_DSA_SIG 110
177#define DSA_F_DSAPARAMS_PRINT 100 229#define DSA_F_DSAPARAMS_PRINT 100
178#define DSA_F_DSAPARAMS_PRINT_FP 101 230#define DSA_F_DSAPARAMS_PRINT_FP 101
179#define DSA_F_DSA_IS_PRIME 102 231#define DSA_F_DSA_DO_SIGN 112
180#define DSA_F_DSA_NEW 103 232#define DSA_F_DSA_DO_VERIFY 113
233#define DSA_F_DSA_NEW_METHOD 103
181#define DSA_F_DSA_PRINT 104 234#define DSA_F_DSA_PRINT 104
182#define DSA_F_DSA_PRINT_FP 105 235#define DSA_F_DSA_PRINT_FP 105
183#define DSA_F_DSA_SIGN 106 236#define DSA_F_DSA_SIGN 106
184#define DSA_F_DSA_SIGN_SETUP 107 237#define DSA_F_DSA_SIGN_SETUP 107
238#define DSA_F_DSA_SIG_NEW 109
185#define DSA_F_DSA_VERIFY 108 239#define DSA_F_DSA_VERIFY 108
240#define DSA_F_I2D_DSA_SIG 111
241#define DSA_F_SIG_CB 114
186 242
187/* Reason codes. */ 243/* Reason codes. */
188#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 244#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
189 245#define DSA_R_MISSING_PARAMETERS 101
246
190#ifdef __cplusplus 247#ifdef __cplusplus
191} 248}
192#endif 249#endif
193#endif 250#endif
194