summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl32
-rw-r--r--src/lib/libcrypto/dsa/dsa_lib.c15
-rw-r--r--src/lib/libcrypto/dsa/dsa_ossl.c14
-rw-r--r--src/lib/libcrypto/dsa/dsa_sign.c1
-rw-r--r--src/lib/libcrypto/dsa/dsa_vrf.c1
-rw-r--r--src/lib/libcrypto/dsa/dsagen.c2
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c17
7 files changed, 48 insertions, 34 deletions
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
index d308caafca..e5f8a8cf51 100644
--- a/src/lib/libcrypto/dsa/Makefile.ssl
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -70,7 +70,7 @@ lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff 70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71 71
72depend: 72depend:
73 $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) 73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74 74
75dclean: 75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
@@ -143,35 +143,29 @@ dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
143dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 143dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
144dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 144dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
145dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 145dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
146dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 146dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
147dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 147dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
148dsa_ossl.o: ../../include/openssl/opensslconf.h
149dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 148dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
150dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 149dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
151dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 150dsa_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
152dsa_ossl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
153dsa_ossl.o: ../cryptlib.h dsa_ossl.c 151dsa_ossl.o: ../cryptlib.h dsa_ossl.c
154dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h 152dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h
155dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 153dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
156dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 154dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
157dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h 155dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
158dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h 156dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
159dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 157dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
160dsa_sign.o: ../../include/openssl/opensslconf.h
161dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 158dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h 159dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
163dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 160dsa_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
164dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
165dsa_sign.o: ../cryptlib.h dsa_sign.c 161dsa_sign.o: ../cryptlib.h dsa_sign.c
166dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h 162dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h
167dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h 163dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h
168dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h 164dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
169dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h 165dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
170dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h 166dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
171dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h 167dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
172dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 168dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
173dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 169dsa_vrf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
174dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
175dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 170dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
176dsa_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h 171dsa_vrf.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_vrf.c
177dsa_vrf.o: ../cryptlib.h dsa_vrf.c
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c
index da2cdfa3d6..4171af24c6 100644
--- a/src/lib/libcrypto/dsa/dsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_lib.c
@@ -63,7 +63,9 @@
63#include <openssl/bn.h> 63#include <openssl/bn.h>
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/asn1.h> 65#include <openssl/asn1.h>
66#ifndef OPENSSL_NO_ENGINE
66#include <openssl/engine.h> 67#include <openssl/engine.h>
68#endif
67 69
68const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; 70const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT;
69 71
@@ -93,11 +95,13 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth)
93 const DSA_METHOD *mtmp; 95 const DSA_METHOD *mtmp;
94 mtmp = dsa->meth; 96 mtmp = dsa->meth;
95 if (mtmp->finish) mtmp->finish(dsa); 97 if (mtmp->finish) mtmp->finish(dsa);
98#ifndef OPENSSL_NO_ENGINE
96 if (dsa->engine) 99 if (dsa->engine)
97 { 100 {
98 ENGINE_finish(dsa->engine); 101 ENGINE_finish(dsa->engine);
99 dsa->engine = NULL; 102 dsa->engine = NULL;
100 } 103 }
104#endif
101 dsa->meth = meth; 105 dsa->meth = meth;
102 if (meth->init) meth->init(dsa); 106 if (meth->init) meth->init(dsa);
103 return 1; 107 return 1;
@@ -114,6 +118,7 @@ DSA *DSA_new_method(ENGINE *engine)
114 return(NULL); 118 return(NULL);
115 } 119 }
116 ret->meth = DSA_get_default_method(); 120 ret->meth = DSA_get_default_method();
121#ifndef OPENSSL_NO_ENGINE
117 if (engine) 122 if (engine)
118 { 123 {
119 if (!ENGINE_init(engine)) 124 if (!ENGINE_init(engine))
@@ -138,6 +143,7 @@ DSA *DSA_new_method(ENGINE *engine)
138 return NULL; 143 return NULL;
139 } 144 }
140 } 145 }
146#endif
141 147
142 ret->pad=0; 148 ret->pad=0;
143 ret->version=0; 149 ret->version=0;
@@ -158,8 +164,10 @@ DSA *DSA_new_method(ENGINE *engine)
158 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 164 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
159 if ((ret->meth->init != NULL) && !ret->meth->init(ret)) 165 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
160 { 166 {
167#ifndef OPENSSL_NO_ENGINE
161 if (ret->engine) 168 if (ret->engine)
162 ENGINE_finish(ret->engine); 169 ENGINE_finish(ret->engine);
170#endif
163 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); 171 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);
164 OPENSSL_free(ret); 172 OPENSSL_free(ret);
165 ret=NULL; 173 ret=NULL;
@@ -189,8 +197,10 @@ void DSA_free(DSA *r)
189 197
190 if(r->meth->finish) 198 if(r->meth->finish)
191 r->meth->finish(r); 199 r->meth->finish(r);
200#ifndef OPENSSL_NO_ENGINE
192 if(r->engine) 201 if(r->engine)
193 ENGINE_finish(r->engine); 202 ENGINE_finish(r->engine);
203#endif
194 204
195 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); 205 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data);
196 206
@@ -224,7 +234,10 @@ int DSA_size(const DSA *r)
224 { 234 {
225 int ret,i; 235 int ret,i;
226 ASN1_INTEGER bs; 236 ASN1_INTEGER bs;
227 unsigned char buf[4]; 237 unsigned char buf[4]; /* 4 bytes looks really small.
238 However, i2d_ASN1_INTEGER() will not look
239 beyond the first byte, as long as the second
240 parameter is NULL. */
228 241
229 i=BN_num_bits(r->q); 242 i=BN_num_bits(r->q);
230 bs.length=(i+7)/8; 243 bs.length=(i+7)/8;
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c
index 37dd5fc994..b9e7f3ea5c 100644
--- a/src/lib/libcrypto/dsa/dsa_ossl.c
+++ b/src/lib/libcrypto/dsa/dsa_ossl.c
@@ -64,7 +64,6 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/engine.h>
68 67
69static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); 68static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
70static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); 69static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp);
@@ -106,13 +105,15 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
106 int i,reason=ERR_R_BN_LIB; 105 int i,reason=ERR_R_BN_LIB;
107 DSA_SIG *ret=NULL; 106 DSA_SIG *ret=NULL;
108 107
108 BN_init(&m);
109 BN_init(&xr);
110
109 if (!dsa->p || !dsa->q || !dsa->g) 111 if (!dsa->p || !dsa->q || !dsa->g)
110 { 112 {
111 reason=DSA_R_MISSING_PARAMETERS; 113 reason=DSA_R_MISSING_PARAMETERS;
112 goto err; 114 goto err;
113 } 115 }
114 BN_init(&m); 116
115 BN_init(&xr);
116 s=BN_new(); 117 s=BN_new();
117 if (s == NULL) goto err; 118 if (s == NULL) goto err;
118 119
@@ -178,6 +179,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
178 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS); 179 DSAerr(DSA_F_DSA_SIGN_SETUP,DSA_R_MISSING_PARAMETERS);
179 return 0; 180 return 0;
180 } 181 }
182
183 BN_init(&k);
184
181 if (ctx_in == NULL) 185 if (ctx_in == NULL)
182 { 186 {
183 if ((ctx=BN_CTX_new()) == NULL) goto err; 187 if ((ctx=BN_CTX_new()) == NULL) goto err;
@@ -185,7 +189,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
185 else 189 else
186 ctx=ctx_in; 190 ctx=ctx_in;
187 191
188 BN_init(&k);
189 if ((r=BN_new()) == NULL) goto err; 192 if ((r=BN_new()) == NULL) goto err;
190 kinv=NULL; 193 kinv=NULL;
191 194
@@ -241,11 +244,12 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
241 return -1; 244 return -1;
242 } 245 }
243 246
244 if ((ctx=BN_CTX_new()) == NULL) goto err;
245 BN_init(&u1); 247 BN_init(&u1);
246 BN_init(&u2); 248 BN_init(&u2);
247 BN_init(&t1); 249 BN_init(&t1);
248 250
251 if ((ctx=BN_CTX_new()) == NULL) goto err;
252
249 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0) 253 if (BN_is_zero(sig->r) || sig->r->neg || BN_ucmp(sig->r, dsa->q) >= 0)
250 { 254 {
251 ret = 0; 255 ret = 0;
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c
index e9469ca62f..89205026f0 100644
--- a/src/lib/libcrypto/dsa/dsa_sign.c
+++ b/src/lib/libcrypto/dsa/dsa_sign.c
@@ -64,7 +64,6 @@
64#include <openssl/dsa.h> 64#include <openssl/dsa.h>
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/engine.h>
68 67
69DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) 68DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
70 { 69 {
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c
index 066c6b5b28..c4aeddd056 100644
--- a/src/lib/libcrypto/dsa/dsa_vrf.c
+++ b/src/lib/libcrypto/dsa/dsa_vrf.c
@@ -65,7 +65,6 @@
65#include <openssl/rand.h> 65#include <openssl/rand.h>
66#include <openssl/asn1.h> 66#include <openssl/asn1.h>
67#include <openssl/asn1_mac.h> 67#include <openssl/asn1_mac.h>
68#include <openssl/engine.h>
69 68
70int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, 69int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
71 DSA *dsa) 70 DSA *dsa)
diff --git a/src/lib/libcrypto/dsa/dsagen.c b/src/lib/libcrypto/dsa/dsagen.c
index a0b0976640..1b6a1cca0f 100644
--- a/src/lib/libcrypto/dsa/dsagen.c
+++ b/src/lib/libcrypto/dsa/dsagen.c
@@ -103,7 +103,7 @@ main()
103 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); 103 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
104 104
105 memcpy(seed_buf,seed,20); 105 memcpy(seed_buf,seed,20);
106 dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb); 106 dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb,bio_err);
107 107
108 if (dsa == NULL) 108 if (dsa == NULL)
109 DSA_print(bio_err,dsa,0); 109 DSA_print(bio_err,dsa,0);
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index 12da64f9f4..4734ce4af8 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -61,14 +61,13 @@
61#include <string.h> 61#include <string.h>
62#include <sys/types.h> 62#include <sys/types.h>
63#include <sys/stat.h> 63#include <sys/stat.h>
64
65#include "../e_os.h"
66
64#include <openssl/crypto.h> 67#include <openssl/crypto.h>
65#include <openssl/rand.h> 68#include <openssl/rand.h>
66#include <openssl/bio.h> 69#include <openssl/bio.h>
67#include <openssl/err.h> 70#include <openssl/err.h>
68#include <openssl/engine.h>
69#ifdef OPENSSL_SYS_WINDOWS
70#include "../bio/bss_file.c"
71#endif
72 71
73#ifdef OPENSSL_NO_DSA 72#ifdef OPENSSL_NO_DSA
74int main(int argc, char *argv[]) 73int main(int argc, char *argv[])
@@ -212,10 +211,16 @@ end:
212 BIO_free(bio_err); 211 BIO_free(bio_err);
213 bio_err = NULL; 212 bio_err = NULL;
214 } 213 }
215 exit(!ret); 214 EXIT(!ret);
216 return(0); 215 return(0);
217 } 216 }
218 217
218static int cb_exit(int ec)
219 {
220 EXIT(ec);
221 return(0); /* To keep some compilers quiet */
222 }
223
219static void MS_CALLBACK dsa_cb(int p, int n, void *arg) 224static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
220 { 225 {
221 char c='*'; 226 char c='*';
@@ -231,7 +236,7 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
231 if (!ok && (p == 0) && (num > 1)) 236 if (!ok && (p == 0) && (num > 1))
232 { 237 {
233 BIO_printf((BIO *)arg,"error in dsatest\n"); 238 BIO_printf((BIO *)arg,"error in dsatest\n");
234 exit(1); 239 cb_exit(1);
235 } 240 }
236 } 241 }
237#endif 242#endif