diff options
author | markus <> | 2002-09-05 12:51:50 +0000 |
---|---|---|
committer | markus <> | 2002-09-05 12:51:50 +0000 |
commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/dsa/dsa.h | |
parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa.h')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 180 |
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 |
69 | extern "C" { | 85 | extern "C" { |
70 | #endif | 86 | #endif |
71 | 87 | ||
72 | #include "bn.h" | 88 | typedef struct dsa_st DSA; |
73 | 89 | ||
74 | typedef struct dsa_st | 90 | typedef struct DSA_SIG_st |
91 | { | ||
92 | BIGNUM *r; | ||
93 | BIGNUM *s; | ||
94 | } DSA_SIG; | ||
95 | |||
96 | typedef 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 | |||
115 | struct 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 | |
154 | DSA_SIG * DSA_SIG_new(void); | ||
155 | void DSA_SIG_free(DSA_SIG *a); | ||
156 | int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); | ||
157 | DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); | ||
158 | |||
159 | DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); | ||
160 | int DSA_do_verify(const unsigned char *dgst,int dgst_len, | ||
161 | DSA_SIG *sig,DSA *dsa); | ||
162 | |||
163 | const DSA_METHOD *DSA_OpenSSL(void); | ||
164 | |||
165 | void DSA_set_default_method(const DSA_METHOD *); | ||
166 | const DSA_METHOD *DSA_get_default_method(void); | ||
167 | int DSA_set_method(DSA *dsa, const DSA_METHOD *); | ||
106 | 168 | ||
107 | DSA * DSA_new(void); | 169 | DSA * DSA_new(void); |
108 | int DSA_size(DSA *); | 170 | DSA * DSA_new_method(ENGINE *engine); |
171 | void DSA_free (DSA *r); | ||
172 | /* "up" the DSA object's reference count */ | ||
173 | int DSA_up_ref(DSA *r); | ||
174 | int DSA_size(const DSA *); | ||
109 | /* next 4 return -1 on error */ | 175 | /* next 4 return -1 on error */ |
110 | int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); | 176 | int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); |
111 | int DSA_sign(int type,unsigned char *dgst,int dlen, | 177 | int 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); |
113 | int DSA_verify(int type,unsigned char *dgst,int dgst_len, | 179 | int 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); |
115 | void DSA_free (DSA *r); | 181 | int 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); | |
117 | void ERR_load_DSA_strings(void ); | 183 | int DSA_set_ex_data(DSA *d, int idx, void *arg); |
118 | 184 | void *DSA_get_ex_data(DSA *d, int idx); | |
119 | DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); | 185 | |
120 | DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); | 186 | DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); |
121 | DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); | 187 | DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); |
122 | DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len, | 188 | DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); |
189 | DSA * 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); |
125 | int DSA_generate_key(DSA *a); | 193 | int DSA_generate_key(DSA *a); |
126 | int i2d_DSAPublicKey(DSA *a, unsigned char **pp); | 194 | int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); |
127 | int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); | 195 | int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); |
128 | int i2d_DSAparams(DSA *a,unsigned char **pp); | 196 | int i2d_DSAparams(const DSA *a,unsigned char **pp); |
129 | 197 | ||
130 | #ifdef HEADER_BIO_H | 198 | #ifndef OPENSSL_NO_BIO |
131 | int DSAparams_print(BIO *bp, DSA *x); | 199 | int DSAparams_print(BIO *bp, const DSA *x); |
132 | int DSA_print(BIO *bp, DSA *x, int off); | 200 | int DSA_print(BIO *bp, const DSA *x, int off); |
133 | #endif | 201 | #endif |
134 | #ifndef NO_FP_API | 202 | #ifndef OPENSSL_NO_FP_API |
135 | int DSAparams_print_fp(FILE *fp, DSA *x); | 203 | int DSAparams_print_fp(FILE *fp, const DSA *x); |
136 | int DSA_print_fp(FILE *bp, DSA *x, int off); | 204 | int DSA_print_fp(FILE *bp, const DSA *x, int off); |
137 | #endif | 205 | #endif |
138 | 206 | ||
139 | int 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) \ | |
143 | DSA * DSA_new(); | 211 | BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) |
144 | int DSA_size(); | ||
145 | int DSA_sign_setup(); | ||
146 | int DSA_sign(); | ||
147 | int DSA_verify(); | ||
148 | void DSA_free (); | ||
149 | |||
150 | void ERR_load_DSA_strings(); | ||
151 | |||
152 | DSA * d2i_DSAPublicKey(); | ||
153 | DSA * d2i_DSAPrivateKey(); | ||
154 | DSA * d2i_DSAparams(); | ||
155 | DSA * DSA_generate_parameters(); | ||
156 | int DSA_generate_key(); | ||
157 | int i2d_DSAPublicKey(); | ||
158 | int i2d_DSAPrivateKey(); | ||
159 | int i2d_DSAparams(); | ||
160 | |||
161 | int DSA_is_prime(); | ||
162 | |||
163 | int DSAparams_print(); | ||
164 | int DSA_print(); | ||
165 | |||
166 | #ifndef NO_FP_API | ||
167 | int DSAparams_print_fp(); | ||
168 | int 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!) */ | ||
216 | DH *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 | */ | ||
223 | void 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 | |||