diff options
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r-- | src/lib/libcrypto/dsa/Makefile.ssl | 167 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 85 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_asn1.c | 200 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_err.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 151 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_sign.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_vrf.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsatest.c | 17 |
11 files changed, 347 insertions, 320 deletions
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl index d88f596364..32ecf6ee01 100644 --- a/src/lib/libcrypto/dsa/Makefile.ssl +++ b/src/lib/libcrypto/dsa/Makefile.ssl | |||
@@ -5,13 +5,14 @@ | |||
5 | DIR= dsa | 5 | DIR= dsa |
6 | TOP= ../.. | 6 | TOP= ../.. |
7 | CC= cc | 7 | CC= cc |
8 | INCLUDES= -I.. -I../../include | 8 | INCLUDES= -I.. -I$(TOP) -I../../include |
9 | CFLAG=-g | 9 | CFLAG=-g |
10 | INSTALL_PREFIX= | 10 | INSTALL_PREFIX= |
11 | OPENSSLDIR= /usr/local/ssl | 11 | OPENSSLDIR= /usr/local/ssl |
12 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
13 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) | 14 | MAKEDEPPROG= makedepend |
15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
15 | MAKEFILE= Makefile.ssl | 16 | MAKEFILE= Makefile.ssl |
16 | AR= ar r | 17 | AR= ar r |
17 | 18 | ||
@@ -41,8 +42,7 @@ all: lib | |||
41 | 42 | ||
42 | lib: $(LIBOBJ) | 43 | lib: $(LIBOBJ) |
43 | $(AR) $(LIB) $(LIBOBJ) | 44 | $(AR) $(LIB) $(LIBOBJ) |
44 | @echo You may get an error following this line. Please ignore. | 45 | $(RANLIB) $(LIB) || echo Never mind. |
45 | - $(RANLIB) $(LIB) | ||
46 | @touch lib | 46 | @touch lib |
47 | 47 | ||
48 | files: | 48 | files: |
@@ -81,110 +81,89 @@ clean: | |||
81 | 81 | ||
82 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 82 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
83 | 83 | ||
84 | dsa_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h | 84 | dsa_asn1.o: ../../e_os.h ../../include/openssl/asn1.h |
85 | dsa_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 85 | dsa_asn1.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h |
86 | dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 86 | dsa_asn1.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
87 | dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 87 | dsa_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h |
88 | dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 88 | dsa_asn1.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
89 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 89 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
90 | dsa_asn1.o: ../../include/openssl/opensslconf.h | 90 | dsa_asn1.o: ../../include/openssl/opensslconf.h |
91 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 91 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
92 | dsa_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 92 | dsa_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
93 | dsa_asn1.o: ../cryptlib.h | 93 | dsa_asn1.o: ../../include/openssl/symhacks.h ../cryptlib.h dsa_asn1.c |
94 | dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 94 | dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
95 | dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | 95 | dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h |
96 | dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h | 96 | dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
97 | dsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 97 | dsa_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
98 | dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 98 | dsa_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
99 | dsa_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
99 | dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 100 | dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
101 | dsa_err.o: dsa_err.c | ||
102 | dsa_gen.o: ../../e_os.h ../../include/openssl/asn1.h | ||
100 | dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 103 | dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
101 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 104 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
102 | dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 105 | dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
103 | dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 106 | dsa_gen.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
104 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 107 | dsa_gen.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
108 | dsa_gen.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
105 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 109 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
106 | dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 110 | dsa_gen.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
107 | dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 111 | dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
108 | dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h | 112 | dsa_gen.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
109 | dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 113 | dsa_gen.o: ../cryptlib.h dsa_gen.c |
114 | dsa_key.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
110 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 115 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
111 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 116 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
112 | dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 117 | dsa_key.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
113 | dsa_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 118 | dsa_key.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
114 | dsa_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 119 | dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
115 | dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 120 | dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
116 | dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 121 | dsa_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
117 | dsa_key.o: ../../include/openssl/symhacks.h ../cryptlib.h | 122 | dsa_key.o: ../cryptlib.h dsa_key.c |
118 | dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 123 | dsa_lib.o: ../../e_os.h ../../include/openssl/asn1.h |
119 | dsa_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 124 | dsa_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
120 | dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 125 | dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
121 | dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
122 | dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 126 | dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
123 | dsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 127 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h |
124 | dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 128 | dsa_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
125 | dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 129 | dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
126 | dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 130 | dsa_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
127 | dsa_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
128 | dsa_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
129 | dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
130 | dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | ||
131 | dsa_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
132 | dsa_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
133 | dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 131 | dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h |
134 | dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 132 | dsa_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
135 | dsa_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h | 133 | dsa_lib.o: ../../include/openssl/ui.h ../cryptlib.h dsa_lib.c |
136 | dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 134 | dsa_ossl.o: ../../e_os.h ../../include/openssl/asn1.h |
137 | dsa_ossl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | 135 | dsa_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
138 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | 136 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
139 | dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
140 | dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 137 | dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
141 | dsa_ossl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 138 | dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h |
142 | dsa_ossl.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 139 | dsa_ossl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
143 | dsa_ossl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 140 | dsa_ossl.o: ../../include/openssl/opensslconf.h |
144 | dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 141 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
145 | dsa_ossl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | 142 | dsa_ossl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h |
146 | dsa_ossl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | 143 | dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
147 | dsa_ossl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 144 | dsa_ossl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h |
148 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 145 | dsa_ossl.o: ../cryptlib.h dsa_ossl.c |
149 | dsa_ossl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 146 | dsa_sign.o: ../../e_os.h ../../include/openssl/asn1.h |
150 | dsa_ossl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 147 | dsa_sign.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
151 | dsa_ossl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | 148 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
152 | dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
153 | dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
154 | dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
155 | dsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
156 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
157 | dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
158 | dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 149 | dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
159 | dsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 150 | dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h |
160 | dsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h | 151 | dsa_sign.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
161 | dsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | 152 | dsa_sign.o: ../../include/openssl/opensslconf.h |
162 | dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | 153 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
163 | dsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | 154 | dsa_sign.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h |
164 | dsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | 155 | dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
165 | dsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 156 | dsa_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h |
166 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 157 | dsa_sign.o: ../cryptlib.h dsa_sign.c |
167 | dsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | 158 | dsa_vrf.o: ../../e_os.h ../../include/openssl/asn1.h |
168 | dsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | 159 | dsa_vrf.o: ../../include/openssl/asn1_mac.h ../../include/openssl/bio.h |
169 | dsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
170 | dsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
171 | dsa_sign.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
172 | dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h | ||
173 | dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h | ||
174 | dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | 160 | dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
175 | dsa_vrf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h | 161 | dsa_vrf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h |
176 | dsa_vrf.o: ../../include/openssl/des.h ../../include/openssl/dh.h | 162 | dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h |
177 | dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 163 | dsa_vrf.o: ../../include/openssl/engine.h ../../include/openssl/err.h |
178 | dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | 164 | dsa_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
179 | dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 165 | dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
180 | dsa_vrf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | 166 | dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h |
181 | dsa_vrf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | 167 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h |
182 | dsa_vrf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | 168 | dsa_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h |
183 | dsa_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 169 | dsa_vrf.o: ../cryptlib.h dsa_vrf.c |
184 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
185 | dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
186 | dsa_vrf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
187 | dsa_vrf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
188 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
189 | dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
190 | dsa_vrf.o: ../cryptlib.h | ||
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index 12b60a8faa..9b3baadf2c 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
@@ -65,16 +65,17 @@ | |||
65 | #ifndef HEADER_DSA_H | 65 | #ifndef HEADER_DSA_H |
66 | #define HEADER_DSA_H | 66 | #define HEADER_DSA_H |
67 | 67 | ||
68 | #ifdef NO_DSA | 68 | #ifdef OPENSSL_NO_DSA |
69 | #error DSA is disabled. | 69 | #error DSA is disabled. |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #ifndef NO_BIO | 72 | #ifndef OPENSSL_NO_BIO |
73 | #include <openssl/bio.h> | 73 | #include <openssl/bio.h> |
74 | #endif | 74 | #endif |
75 | #include <openssl/bn.h> | 75 | #include <openssl/bn.h> |
76 | #include <openssl/crypto.h> | 76 | #include <openssl/crypto.h> |
77 | #ifndef NO_DH | 77 | #include <openssl/ossl_typ.h> |
78 | #ifndef OPENSSL_NO_DH | ||
78 | # include <openssl/dh.h> | 79 | # include <openssl/dh.h> |
79 | #endif | 80 | #endif |
80 | 81 | ||
@@ -116,7 +117,7 @@ struct dsa_st | |||
116 | /* This first variable is used to pick up errors where | 117 | /* This first variable is used to pick up errors where |
117 | * a DSA is passed instead of of a EVP_PKEY */ | 118 | * a DSA is passed instead of of a EVP_PKEY */ |
118 | int pad; | 119 | int pad; |
119 | int version; | 120 | long version; |
120 | int write_params; | 121 | int write_params; |
121 | BIGNUM *p; | 122 | BIGNUM *p; |
122 | BIGNUM *q; /* == 20 */ | 123 | BIGNUM *q; /* == 20 */ |
@@ -133,11 +134,9 @@ struct dsa_st | |||
133 | char *method_mont_p; | 134 | char *method_mont_p; |
134 | int references; | 135 | int references; |
135 | CRYPTO_EX_DATA ex_data; | 136 | CRYPTO_EX_DATA ex_data; |
136 | #if 0 | 137 | const DSA_METHOD *meth; |
137 | DSA_METHOD *meth; | 138 | /* functional reference if 'meth' is ENGINE-provided */ |
138 | #else | 139 | ENGINE *engine; |
139 | struct engine_st *engine; | ||
140 | #endif | ||
141 | }; | 140 | }; |
142 | 141 | ||
143 | #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ | 142 | #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ |
@@ -154,62 +153,55 @@ struct dsa_st | |||
154 | 153 | ||
155 | DSA_SIG * DSA_SIG_new(void); | 154 | DSA_SIG * DSA_SIG_new(void); |
156 | void DSA_SIG_free(DSA_SIG *a); | 155 | void DSA_SIG_free(DSA_SIG *a); |
157 | int i2d_DSA_SIG(DSA_SIG *a, unsigned char **pp); | 156 | int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); |
158 | DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, unsigned char **pp, long length); | 157 | DSA_SIG * d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); |
159 | 158 | ||
160 | DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); | 159 | DSA_SIG * DSA_do_sign(const unsigned char *dgst,int dlen,DSA *dsa); |
161 | int DSA_do_verify(const unsigned char *dgst,int dgst_len, | 160 | int DSA_do_verify(const unsigned char *dgst,int dgst_len, |
162 | DSA_SIG *sig,DSA *dsa); | 161 | DSA_SIG *sig,DSA *dsa); |
163 | 162 | ||
164 | DSA_METHOD *DSA_OpenSSL(void); | 163 | const DSA_METHOD *DSA_OpenSSL(void); |
165 | 164 | ||
166 | void DSA_set_default_openssl_method(DSA_METHOD *); | 165 | void DSA_set_default_method(const DSA_METHOD *); |
167 | DSA_METHOD *DSA_get_default_openssl_method(void); | 166 | const DSA_METHOD *DSA_get_default_method(void); |
168 | #if 0 | 167 | int DSA_set_method(DSA *dsa, const DSA_METHOD *); |
169 | DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *); | ||
170 | #else | ||
171 | int DSA_set_method(DSA *dsa, struct engine_st *engine); | ||
172 | #endif | ||
173 | 168 | ||
174 | DSA * DSA_new(void); | 169 | DSA * DSA_new(void); |
175 | #if 0 | 170 | DSA * DSA_new_method(ENGINE *engine); |
176 | DSA * DSA_new_method(DSA_METHOD *meth); | 171 | void DSA_free (DSA *r); |
177 | #else | 172 | /* "up" the DSA object's reference count */ |
178 | DSA * DSA_new_method(struct engine_st *engine); | 173 | int DSA_up_ref(DSA *r); |
179 | #endif | 174 | int DSA_size(const DSA *); |
180 | int DSA_size(DSA *); | ||
181 | /* next 4 return -1 on error */ | 175 | /* next 4 return -1 on error */ |
182 | 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); |
183 | int DSA_sign(int type,const unsigned char *dgst,int dlen, | 177 | int DSA_sign(int type,const unsigned char *dgst,int dlen, |
184 | unsigned char *sig, unsigned int *siglen, DSA *dsa); | 178 | unsigned char *sig, unsigned int *siglen, DSA *dsa); |
185 | int DSA_verify(int type,const unsigned char *dgst,int dgst_len, | 179 | int DSA_verify(int type,const unsigned char *dgst,int dgst_len, |
186 | unsigned char *sigbuf, int siglen, DSA *dsa); | 180 | const unsigned char *sigbuf, int siglen, DSA *dsa); |
187 | void DSA_free (DSA *r); | ||
188 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 181 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
189 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 182 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
190 | int DSA_set_ex_data(DSA *d, int idx, void *arg); | 183 | int DSA_set_ex_data(DSA *d, int idx, void *arg); |
191 | void *DSA_get_ex_data(DSA *d, int idx); | 184 | void *DSA_get_ex_data(DSA *d, int idx); |
192 | 185 | ||
193 | void ERR_load_DSA_strings(void ); | 186 | DSA * d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); |
194 | 187 | DSA * d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); | |
195 | DSA * d2i_DSAPublicKey(DSA **a, unsigned char **pp, long length); | 188 | DSA * d2i_DSAparams(DSA **a, const unsigned char **pp, long length); |
196 | DSA * d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length); | 189 | DSA * DSA_generate_parameters(int bits, |
197 | DSA * d2i_DSAparams(DSA **a, unsigned char **pp, long length); | 190 | unsigned char *seed,int seed_len, |
198 | DSA * DSA_generate_parameters(int bits, unsigned char *seed,int seed_len, | ||
199 | int *counter_ret, unsigned long *h_ret,void | 191 | int *counter_ret, unsigned long *h_ret,void |
200 | (*callback)(int, int, void *),void *cb_arg); | 192 | (*callback)(int, int, void *),void *cb_arg); |
201 | int DSA_generate_key(DSA *a); | 193 | int DSA_generate_key(DSA *a); |
202 | int i2d_DSAPublicKey(DSA *a, unsigned char **pp); | 194 | int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); |
203 | int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); | 195 | int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); |
204 | int i2d_DSAparams(DSA *a,unsigned char **pp); | 196 | int i2d_DSAparams(const DSA *a,unsigned char **pp); |
205 | 197 | ||
206 | #ifndef NO_BIO | 198 | #ifndef OPENSSL_NO_BIO |
207 | int DSAparams_print(BIO *bp, DSA *x); | 199 | int DSAparams_print(BIO *bp, const DSA *x); |
208 | int DSA_print(BIO *bp, DSA *x, int off); | 200 | int DSA_print(BIO *bp, const DSA *x, int off); |
209 | #endif | 201 | #endif |
210 | #ifndef NO_FP_API | 202 | #ifndef OPENSSL_NO_FP_API |
211 | int DSAparams_print_fp(FILE *fp, DSA *x); | 203 | int DSAparams_print_fp(FILE *fp, const DSA *x); |
212 | int DSA_print_fp(FILE *bp, DSA *x, int off); | 204 | int DSA_print_fp(FILE *bp, const DSA *x, int off); |
213 | #endif | 205 | #endif |
214 | 206 | ||
215 | #define DSS_prime_checks 50 | 207 | #define DSS_prime_checks 50 |
@@ -218,16 +210,17 @@ int DSA_print_fp(FILE *bp, DSA *x, int off); | |||
218 | #define DSA_is_prime(n, callback, cb_arg) \ | 210 | #define DSA_is_prime(n, callback, cb_arg) \ |
219 | BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) | 211 | BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) |
220 | 212 | ||
221 | #ifndef NO_DH | 213 | #ifndef OPENSSL_NO_DH |
222 | /* Convert DSA structure (key or just parameters) into DH structure | 214 | /* Convert DSA structure (key or just parameters) into DH structure |
223 | * (be careful to avoid small subgroup attacks when using this!) */ | 215 | * (be careful to avoid small subgroup attacks when using this!) */ |
224 | DH *DSA_dup_DH(DSA *r); | 216 | DH *DSA_dup_DH(const DSA *r); |
225 | #endif | 217 | #endif |
226 | 218 | ||
227 | /* BEGIN ERROR CODES */ | 219 | /* BEGIN ERROR CODES */ |
228 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 220 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
229 | * made after this point may be overwritten when the script is next run. | 221 | * made after this point may be overwritten when the script is next run. |
230 | */ | 222 | */ |
223 | void ERR_load_DSA_strings(void); | ||
231 | 224 | ||
232 | /* Error codes for the DSA functions. */ | 225 | /* Error codes for the DSA functions. */ |
233 | 226 | ||
@@ -237,7 +230,7 @@ DH *DSA_dup_DH(DSA *r); | |||
237 | #define DSA_F_DSAPARAMS_PRINT_FP 101 | 230 | #define DSA_F_DSAPARAMS_PRINT_FP 101 |
238 | #define DSA_F_DSA_DO_SIGN 112 | 231 | #define DSA_F_DSA_DO_SIGN 112 |
239 | #define DSA_F_DSA_DO_VERIFY 113 | 232 | #define DSA_F_DSA_DO_VERIFY 113 |
240 | #define DSA_F_DSA_NEW 103 | 233 | #define DSA_F_DSA_NEW_METHOD 103 |
241 | #define DSA_F_DSA_PRINT 104 | 234 | #define DSA_F_DSA_PRINT 104 |
242 | #define DSA_F_DSA_PRINT_FP 105 | 235 | #define DSA_F_DSA_PRINT_FP 105 |
243 | #define DSA_F_DSA_SIGN 106 | 236 | #define DSA_F_DSA_SIGN 106 |
@@ -245,6 +238,7 @@ DH *DSA_dup_DH(DSA *r); | |||
245 | #define DSA_F_DSA_SIG_NEW 109 | 238 | #define DSA_F_DSA_SIG_NEW 109 |
246 | #define DSA_F_DSA_VERIFY 108 | 239 | #define DSA_F_DSA_VERIFY 108 |
247 | #define DSA_F_I2D_DSA_SIG 111 | 240 | #define DSA_F_I2D_DSA_SIG 111 |
241 | #define DSA_F_SIG_CB 114 | ||
248 | 242 | ||
249 | /* Reason codes. */ | 243 | /* Reason codes. */ |
250 | #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 | 244 | #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 |
@@ -254,4 +248,3 @@ DH *DSA_dup_DH(DSA *r); | |||
254 | } | 248 | } |
255 | #endif | 249 | #endif |
256 | #endif | 250 | #endif |
257 | |||
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c index a76c8f7c7e..23fce555aa 100644 --- a/src/lib/libcrypto/dsa/dsa_asn1.c +++ b/src/lib/libcrypto/dsa/dsa_asn1.c | |||
@@ -1,96 +1,140 @@ | |||
1 | /* crypto/dsa/dsa_asn1.c */ | 1 | /* dsa_asn1.c */ |
2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
2 | 58 | ||
3 | #include <stdio.h> | 59 | #include <stdio.h> |
4 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
5 | #include <openssl/dsa.h> | 61 | #include <openssl/dsa.h> |
6 | #include <openssl/asn1.h> | 62 | #include <openssl/asn1.h> |
7 | #include <openssl/asn1_mac.h> | 63 | #include <openssl/asn1t.h> |
8 | 64 | ||
9 | DSA_SIG *DSA_SIG_new(void) | 65 | /* Override the default new methods */ |
66 | static int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | ||
10 | { | 67 | { |
11 | DSA_SIG *ret; | 68 | if(operation == ASN1_OP_NEW_PRE) { |
12 | 69 | DSA_SIG *sig; | |
13 | ret = OPENSSL_malloc(sizeof(DSA_SIG)); | 70 | sig = OPENSSL_malloc(sizeof(DSA_SIG)); |
14 | if (ret == NULL) | 71 | sig->r = NULL; |
15 | { | 72 | sig->s = NULL; |
16 | DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); | 73 | *pval = (ASN1_VALUE *)sig; |
17 | return(NULL); | 74 | if(sig) return 2; |
18 | } | 75 | DSAerr(DSA_F_SIG_CB, ERR_R_MALLOC_FAILURE); |
19 | ret->r = NULL; | 76 | return 0; |
20 | ret->s = NULL; | 77 | } |
21 | return(ret); | 78 | return 1; |
22 | } | 79 | } |
23 | 80 | ||
24 | void DSA_SIG_free(DSA_SIG *r) | 81 | ASN1_SEQUENCE_cb(DSA_SIG, sig_cb) = { |
82 | ASN1_SIMPLE(DSA_SIG, r, CBIGNUM), | ||
83 | ASN1_SIMPLE(DSA_SIG, s, CBIGNUM) | ||
84 | } ASN1_SEQUENCE_END_cb(DSA_SIG, DSA_SIG) | ||
85 | |||
86 | IMPLEMENT_ASN1_FUNCTIONS_const(DSA_SIG) | ||
87 | |||
88 | /* Override the default free and new methods */ | ||
89 | static int dsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | ||
25 | { | 90 | { |
26 | if (r == NULL) return; | 91 | if(operation == ASN1_OP_NEW_PRE) { |
27 | if (r->r) BN_clear_free(r->r); | 92 | *pval = (ASN1_VALUE *)DSA_new(); |
28 | if (r->s) BN_clear_free(r->s); | 93 | if(*pval) return 2; |
29 | OPENSSL_free(r); | 94 | return 0; |
95 | } else if(operation == ASN1_OP_FREE_PRE) { | ||
96 | DSA_free((DSA *)*pval); | ||
97 | *pval = NULL; | ||
98 | return 2; | ||
99 | } | ||
100 | return 1; | ||
30 | } | 101 | } |
31 | 102 | ||
32 | int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) | 103 | ASN1_SEQUENCE_cb(DSAPrivateKey, dsa_cb) = { |
33 | { | 104 | ASN1_SIMPLE(DSA, version, LONG), |
34 | int t=0,len; | 105 | ASN1_SIMPLE(DSA, p, BIGNUM), |
35 | ASN1_INTEGER rbs,sbs; | 106 | ASN1_SIMPLE(DSA, q, BIGNUM), |
36 | unsigned char *p; | 107 | ASN1_SIMPLE(DSA, g, BIGNUM), |
108 | ASN1_SIMPLE(DSA, pub_key, BIGNUM), | ||
109 | ASN1_SIMPLE(DSA, priv_key, BIGNUM) | ||
110 | } ASN1_SEQUENCE_END_cb(DSA, DSAPrivateKey) | ||
37 | 111 | ||
38 | rbs.data=OPENSSL_malloc(BN_num_bits(v->r)/8+1); | 112 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPrivateKey, DSAPrivateKey) |
39 | if (rbs.data == NULL) | ||
40 | { | ||
41 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); | ||
42 | return(0); | ||
43 | } | ||
44 | rbs.type=V_ASN1_INTEGER; | ||
45 | rbs.length=BN_bn2bin(v->r,rbs.data); | ||
46 | sbs.data=OPENSSL_malloc(BN_num_bits(v->s)/8+1); | ||
47 | if (sbs.data == NULL) | ||
48 | { | ||
49 | OPENSSL_free(rbs.data); | ||
50 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); | ||
51 | return(0); | ||
52 | } | ||
53 | sbs.type=V_ASN1_INTEGER; | ||
54 | sbs.length=BN_bn2bin(v->s,sbs.data); | ||
55 | 113 | ||
56 | len=i2d_ASN1_INTEGER(&rbs,NULL); | 114 | ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = { |
57 | len+=i2d_ASN1_INTEGER(&sbs,NULL); | 115 | ASN1_SIMPLE(DSA, p, BIGNUM), |
116 | ASN1_SIMPLE(DSA, q, BIGNUM), | ||
117 | ASN1_SIMPLE(DSA, g, BIGNUM), | ||
118 | } ASN1_SEQUENCE_END_cb(DSA, DSAparams) | ||
58 | 119 | ||
59 | if (pp) | 120 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams) |
60 | { | ||
61 | p=*pp; | ||
62 | ASN1_put_object(&p,1,len,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL); | ||
63 | i2d_ASN1_INTEGER(&rbs,&p); | ||
64 | i2d_ASN1_INTEGER(&sbs,&p); | ||
65 | } | ||
66 | t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); | ||
67 | OPENSSL_free(rbs.data); | ||
68 | OPENSSL_free(sbs.data); | ||
69 | return(t); | ||
70 | } | ||
71 | 121 | ||
72 | DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, unsigned char **pp, long length) | 122 | /* DSA public key is a bit trickier... its effectively a CHOICE type |
73 | { | 123 | * decided by a field called write_params which can either write out |
74 | int i=ERR_R_NESTED_ASN1_ERROR; | 124 | * just the public key as an INTEGER or the parameters and public key |
75 | ASN1_INTEGER *bs=NULL; | 125 | * in a SEQUENCE |
76 | M_ASN1_D2I_vars(a,DSA_SIG *,DSA_SIG_new); | 126 | */ |
77 | 127 | ||
78 | M_ASN1_D2I_Init(); | 128 | ASN1_SEQUENCE(dsa_pub_internal) = { |
79 | M_ASN1_D2I_start_sequence(); | 129 | ASN1_SIMPLE(DSA, pub_key, BIGNUM), |
80 | M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); | 130 | ASN1_SIMPLE(DSA, p, BIGNUM), |
81 | if ((ret->r=BN_bin2bn(bs->data,bs->length,ret->r)) == NULL) | 131 | ASN1_SIMPLE(DSA, q, BIGNUM), |
82 | goto err_bn; | 132 | ASN1_SIMPLE(DSA, g, BIGNUM) |
83 | M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER); | 133 | } ASN1_SEQUENCE_END_name(DSA, dsa_pub_internal) |
84 | if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL) | ||
85 | goto err_bn; | ||
86 | M_ASN1_BIT_STRING_free(bs); | ||
87 | M_ASN1_D2I_Finish_2(a); | ||
88 | 134 | ||
89 | err_bn: | 135 | ASN1_CHOICE_cb(DSAPublicKey, dsa_cb) = { |
90 | i=ERR_R_BN_LIB; | 136 | ASN1_SIMPLE(DSA, pub_key, BIGNUM), |
91 | err: | 137 | ASN1_EX_COMBINE(0, 0, dsa_pub_internal) |
92 | DSAerr(DSA_F_D2I_DSA_SIG,i); | 138 | } ASN1_CHOICE_END_cb(DSA, DSAPublicKey, write_params) |
93 | if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_SIG_free(ret); | 139 | |
94 | if (bs != NULL) M_ASN1_BIT_STRING_free(bs); | 140 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey) |
95 | return(NULL); | ||
96 | } | ||
diff --git a/src/lib/libcrypto/dsa/dsa_err.c b/src/lib/libcrypto/dsa/dsa_err.c index 736aeef7c4..79aa4ff526 100644 --- a/src/lib/libcrypto/dsa/dsa_err.c +++ b/src/lib/libcrypto/dsa/dsa_err.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include <openssl/dsa.h> | 63 | #include <openssl/dsa.h> |
64 | 64 | ||
65 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
66 | #ifndef NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
67 | static ERR_STRING_DATA DSA_str_functs[]= | 67 | static ERR_STRING_DATA DSA_str_functs[]= |
68 | { | 68 | { |
69 | {ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"}, | 69 | {ERR_PACK(0,DSA_F_D2I_DSA_SIG,0), "d2i_DSA_SIG"}, |
@@ -71,7 +71,7 @@ static ERR_STRING_DATA DSA_str_functs[]= | |||
71 | {ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"}, | 71 | {ERR_PACK(0,DSA_F_DSAPARAMS_PRINT_FP,0), "DSAparams_print_fp"}, |
72 | {ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, | 72 | {ERR_PACK(0,DSA_F_DSA_DO_SIGN,0), "DSA_do_sign"}, |
73 | {ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, | 73 | {ERR_PACK(0,DSA_F_DSA_DO_VERIFY,0), "DSA_do_verify"}, |
74 | {ERR_PACK(0,DSA_F_DSA_NEW,0), "DSA_new"}, | 74 | {ERR_PACK(0,DSA_F_DSA_NEW_METHOD,0), "DSA_new_method"}, |
75 | {ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"}, | 75 | {ERR_PACK(0,DSA_F_DSA_PRINT,0), "DSA_print"}, |
76 | {ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"}, | 76 | {ERR_PACK(0,DSA_F_DSA_PRINT_FP,0), "DSA_print_fp"}, |
77 | {ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"}, | 77 | {ERR_PACK(0,DSA_F_DSA_SIGN,0), "DSA_sign"}, |
@@ -79,6 +79,7 @@ static ERR_STRING_DATA DSA_str_functs[]= | |||
79 | {ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"}, | 79 | {ERR_PACK(0,DSA_F_DSA_SIG_NEW,0), "DSA_SIG_new"}, |
80 | {ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"}, | 80 | {ERR_PACK(0,DSA_F_DSA_VERIFY,0), "DSA_verify"}, |
81 | {ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"}, | 81 | {ERR_PACK(0,DSA_F_I2D_DSA_SIG,0), "i2d_DSA_SIG"}, |
82 | {ERR_PACK(0,DSA_F_SIG_CB,0), "SIG_CB"}, | ||
82 | {0,NULL} | 83 | {0,NULL} |
83 | }; | 84 | }; |
84 | 85 | ||
@@ -98,7 +99,7 @@ void ERR_load_DSA_strings(void) | |||
98 | if (init) | 99 | if (init) |
99 | { | 100 | { |
100 | init=0; | 101 | init=0; |
101 | #ifndef NO_ERR | 102 | #ifndef OPENSSL_NO_ERR |
102 | ERR_load_strings(ERR_LIB_DSA,DSA_str_functs); | 103 | ERR_load_strings(ERR_LIB_DSA,DSA_str_functs); |
103 | ERR_load_strings(ERR_LIB_DSA,DSA_str_reasons); | 104 | ERR_load_strings(ERR_LIB_DSA,DSA_str_reasons); |
104 | #endif | 105 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index 2294a362d9..dc9c249310 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
@@ -61,25 +61,27 @@ | |||
61 | #ifdef GENUINE_DSA | 61 | #ifdef GENUINE_DSA |
62 | /* Parameter generation follows the original release of FIPS PUB 186, | 62 | /* Parameter generation follows the original release of FIPS PUB 186, |
63 | * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */ | 63 | * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */ |
64 | #define HASH SHA | 64 | #define HASH EVP_sha() |
65 | #else | 65 | #else |
66 | /* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186, | 66 | /* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186, |
67 | * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in | 67 | * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in |
68 | * FIPS PUB 180-1) */ | 68 | * FIPS PUB 180-1) */ |
69 | #define HASH SHA1 | 69 | #define HASH EVP_sha1() |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #ifndef NO_SHA | 72 | #ifndef OPENSSL_NO_SHA |
73 | 73 | ||
74 | #include <stdio.h> | 74 | #include <stdio.h> |
75 | #include <time.h> | 75 | #include <time.h> |
76 | #include "cryptlib.h" | 76 | #include "cryptlib.h" |
77 | #include <openssl/sha.h> | 77 | #include <openssl/evp.h> |
78 | #include <openssl/bn.h> | 78 | #include <openssl/bn.h> |
79 | #include <openssl/dsa.h> | 79 | #include <openssl/dsa.h> |
80 | #include <openssl/rand.h> | 80 | #include <openssl/rand.h> |
81 | #include <openssl/sha.h> | ||
81 | 82 | ||
82 | DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, | 83 | DSA *DSA_generate_parameters(int bits, |
84 | unsigned char *seed_in, int seed_len, | ||
83 | int *counter_ret, unsigned long *h_ret, | 85 | int *counter_ret, unsigned long *h_ret, |
84 | void (*callback)(int, int, void *), | 86 | void (*callback)(int, int, void *), |
85 | void *cb_arg) | 87 | void *cb_arg) |
@@ -157,8 +159,8 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, | |||
157 | } | 159 | } |
158 | 160 | ||
159 | /* step 2 */ | 161 | /* step 2 */ |
160 | HASH(seed,SHA_DIGEST_LENGTH,md); | 162 | EVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); |
161 | HASH(buf,SHA_DIGEST_LENGTH,buf2); | 163 | EVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL); |
162 | for (i=0; i<SHA_DIGEST_LENGTH; i++) | 164 | for (i=0; i<SHA_DIGEST_LENGTH; i++) |
163 | md[i]^=buf2[i]; | 165 | md[i]^=buf2[i]; |
164 | 166 | ||
@@ -205,7 +207,7 @@ DSA *DSA_generate_parameters(int bits, unsigned char *seed_in, int seed_len, | |||
205 | if (buf[i] != 0) break; | 207 | if (buf[i] != 0) break; |
206 | } | 208 | } |
207 | 209 | ||
208 | HASH(buf,SHA_DIGEST_LENGTH,md); | 210 | EVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL); |
209 | 211 | ||
210 | /* step 8 */ | 212 | /* step 8 */ |
211 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) | 213 | if (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0)) |
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index a68d236e05..bf718c1c6d 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
@@ -56,11 +56,10 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef NO_SHA | 59 | #ifndef OPENSSL_NO_SHA |
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include <time.h> | 61 | #include <time.h> |
62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
63 | #include <openssl/sha.h> | ||
64 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
65 | #include <openssl/dsa.h> | 64 | #include <openssl/dsa.h> |
66 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 15f667a203..da2cdfa3d6 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -67,96 +67,78 @@ | |||
67 | 67 | ||
68 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; | 68 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; |
69 | 69 | ||
70 | static DSA_METHOD *default_DSA_method; | 70 | static const DSA_METHOD *default_DSA_method = NULL; |
71 | static int dsa_meth_num = 0; | ||
72 | static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL; | ||
73 | |||
74 | void DSA_set_default_openssl_method(DSA_METHOD *meth) | ||
75 | { | ||
76 | ENGINE *e; | ||
77 | /* We'll need to notify the "openssl" ENGINE of this | ||
78 | * change too. We won't bother locking things down at | ||
79 | * our end as there was never any locking in these | ||
80 | * functions! */ | ||
81 | if(default_DSA_method != meth) | ||
82 | { | ||
83 | default_DSA_method = meth; | ||
84 | e = ENGINE_by_id("openssl"); | ||
85 | if(e) | ||
86 | { | ||
87 | ENGINE_set_DSA(e, meth); | ||
88 | ENGINE_free(e); | ||
89 | } | ||
90 | } | ||
91 | } | ||
92 | 71 | ||
93 | DSA_METHOD *DSA_get_default_openssl_method(void) | 72 | void DSA_set_default_method(const DSA_METHOD *meth) |
94 | { | 73 | { |
95 | if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); | 74 | default_DSA_method = meth; |
75 | } | ||
76 | |||
77 | const DSA_METHOD *DSA_get_default_method(void) | ||
78 | { | ||
79 | if(!default_DSA_method) | ||
80 | default_DSA_method = DSA_OpenSSL(); | ||
96 | return default_DSA_method; | 81 | return default_DSA_method; |
97 | } | 82 | } |
98 | 83 | ||
99 | DSA *DSA_new(void) | 84 | DSA *DSA_new(void) |
100 | { | 85 | { |
101 | return DSA_new_method(NULL); | 86 | return DSA_new_method(NULL); |
102 | } | 87 | } |
103 | 88 | ||
104 | #if 0 | 89 | int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) |
105 | DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) | 90 | { |
106 | { | 91 | /* NB: The caller is specifically setting a method, so it's not up to us |
107 | DSA_METHOD *mtmp; | 92 | * to deal with which ENGINE it comes from. */ |
93 | const DSA_METHOD *mtmp; | ||
108 | mtmp = dsa->meth; | 94 | mtmp = dsa->meth; |
109 | if (mtmp->finish) mtmp->finish(dsa); | 95 | if (mtmp->finish) mtmp->finish(dsa); |
96 | if (dsa->engine) | ||
97 | { | ||
98 | ENGINE_finish(dsa->engine); | ||
99 | dsa->engine = NULL; | ||
100 | } | ||
110 | dsa->meth = meth; | 101 | dsa->meth = meth; |
111 | if (meth->init) meth->init(dsa); | 102 | if (meth->init) meth->init(dsa); |
112 | return mtmp; | 103 | return 1; |
113 | } | ||
114 | #else | ||
115 | int DSA_set_method(DSA *dsa, ENGINE *engine) | ||
116 | { | ||
117 | ENGINE *mtmp; | ||
118 | DSA_METHOD *meth; | ||
119 | mtmp = dsa->engine; | ||
120 | meth = ENGINE_get_DSA(mtmp); | ||
121 | if (!ENGINE_init(engine)) | ||
122 | return 0; | ||
123 | if (meth->finish) meth->finish(dsa); | ||
124 | dsa->engine = engine; | ||
125 | meth = ENGINE_get_DSA(engine); | ||
126 | if (meth->init) meth->init(dsa); | ||
127 | /* SHOULD ERROR CHECK THIS!!! */ | ||
128 | ENGINE_finish(mtmp); | ||
129 | return 1; | ||
130 | } | 104 | } |
131 | #endif | ||
132 | 105 | ||
133 | |||
134 | #if 0 | ||
135 | DSA *DSA_new_method(DSA_METHOD *meth) | ||
136 | #else | ||
137 | DSA *DSA_new_method(ENGINE *engine) | 106 | DSA *DSA_new_method(ENGINE *engine) |
138 | #endif | ||
139 | { | 107 | { |
140 | DSA_METHOD *meth; | ||
141 | DSA *ret; | 108 | DSA *ret; |
142 | 109 | ||
143 | ret=(DSA *)OPENSSL_malloc(sizeof(DSA)); | 110 | ret=(DSA *)OPENSSL_malloc(sizeof(DSA)); |
144 | if (ret == NULL) | 111 | if (ret == NULL) |
145 | { | 112 | { |
146 | DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); | 113 | DSAerr(DSA_F_DSA_NEW_METHOD,ERR_R_MALLOC_FAILURE); |
147 | return(NULL); | 114 | return(NULL); |
148 | } | 115 | } |
149 | if(engine) | 116 | ret->meth = DSA_get_default_method(); |
117 | if (engine) | ||
118 | { | ||
119 | if (!ENGINE_init(engine)) | ||
120 | { | ||
121 | DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB); | ||
122 | OPENSSL_free(ret); | ||
123 | return NULL; | ||
124 | } | ||
150 | ret->engine = engine; | 125 | ret->engine = engine; |
126 | } | ||
151 | else | 127 | else |
128 | ret->engine = ENGINE_get_default_DSA(); | ||
129 | if(ret->engine) | ||
152 | { | 130 | { |
153 | if((ret->engine=ENGINE_get_default_DSA()) == NULL) | 131 | ret->meth = ENGINE_get_DSA(ret->engine); |
132 | if(!ret->meth) | ||
154 | { | 133 | { |
134 | DSAerr(DSA_F_DSA_NEW_METHOD, | ||
135 | ERR_R_ENGINE_LIB); | ||
136 | ENGINE_finish(ret->engine); | ||
155 | OPENSSL_free(ret); | 137 | OPENSSL_free(ret); |
156 | return NULL; | 138 | return NULL; |
157 | } | 139 | } |
158 | } | 140 | } |
159 | meth = ENGINE_get_DSA(ret->engine); | 141 | |
160 | ret->pad=0; | 142 | ret->pad=0; |
161 | ret->version=0; | 143 | ret->version=0; |
162 | ret->write_params=1; | 144 | ret->write_params=1; |
@@ -172,11 +154,13 @@ DSA *DSA_new_method(ENGINE *engine) | |||
172 | ret->method_mont_p=NULL; | 154 | ret->method_mont_p=NULL; |
173 | 155 | ||
174 | ret->references=1; | 156 | ret->references=1; |
175 | ret->flags=meth->flags; | 157 | ret->flags=ret->meth->flags; |
176 | CRYPTO_new_ex_data(dsa_meth,ret,&ret->ex_data); | 158 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
177 | if ((meth->init != NULL) && !meth->init(ret)) | 159 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) |
178 | { | 160 | { |
179 | CRYPTO_free_ex_data(dsa_meth,ret,&ret->ex_data); | 161 | if (ret->engine) |
162 | ENGINE_finish(ret->engine); | ||
163 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | ||
180 | OPENSSL_free(ret); | 164 | OPENSSL_free(ret); |
181 | ret=NULL; | 165 | ret=NULL; |
182 | } | 166 | } |
@@ -186,7 +170,6 @@ DSA *DSA_new_method(ENGINE *engine) | |||
186 | 170 | ||
187 | void DSA_free(DSA *r) | 171 | void DSA_free(DSA *r) |
188 | { | 172 | { |
189 | DSA_METHOD *meth; | ||
190 | int i; | 173 | int i; |
191 | 174 | ||
192 | if (r == NULL) return; | 175 | if (r == NULL) return; |
@@ -204,11 +187,12 @@ void DSA_free(DSA *r) | |||
204 | } | 187 | } |
205 | #endif | 188 | #endif |
206 | 189 | ||
207 | meth = ENGINE_get_DSA(r->engine); | 190 | if(r->meth->finish) |
208 | if(meth->finish) meth->finish(r); | 191 | r->meth->finish(r); |
209 | ENGINE_finish(r->engine); | 192 | if(r->engine) |
193 | ENGINE_finish(r->engine); | ||
210 | 194 | ||
211 | CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data); | 195 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); |
212 | 196 | ||
213 | if (r->p != NULL) BN_clear_free(r->p); | 197 | if (r->p != NULL) BN_clear_free(r->p); |
214 | if (r->q != NULL) BN_clear_free(r->q); | 198 | if (r->q != NULL) BN_clear_free(r->q); |
@@ -220,7 +204,23 @@ void DSA_free(DSA *r) | |||
220 | OPENSSL_free(r); | 204 | OPENSSL_free(r); |
221 | } | 205 | } |
222 | 206 | ||
223 | int DSA_size(DSA *r) | 207 | int DSA_up_ref(DSA *r) |
208 | { | ||
209 | int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_DSA); | ||
210 | #ifdef REF_PRINT | ||
211 | REF_PRINT("DSA",r); | ||
212 | #endif | ||
213 | #ifdef REF_CHECK | ||
214 | if (i < 2) | ||
215 | { | ||
216 | fprintf(stderr, "DSA_up_ref, bad reference count\n"); | ||
217 | abort(); | ||
218 | } | ||
219 | #endif | ||
220 | return ((i > 1) ? 1 : 0); | ||
221 | } | ||
222 | |||
223 | int DSA_size(const DSA *r) | ||
224 | { | 224 | { |
225 | int ret,i; | 225 | int ret,i; |
226 | ASN1_INTEGER bs; | 226 | ASN1_INTEGER bs; |
@@ -242,9 +242,8 @@ int DSA_size(DSA *r) | |||
242 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 242 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
243 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 243 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
244 | { | 244 | { |
245 | dsa_meth_num++; | 245 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, argl, argp, |
246 | return(CRYPTO_get_ex_new_index(dsa_meth_num-1, | 246 | new_func, dup_func, free_func); |
247 | &dsa_meth,argl,argp,new_func,dup_func,free_func)); | ||
248 | } | 247 | } |
249 | 248 | ||
250 | int DSA_set_ex_data(DSA *d, int idx, void *arg) | 249 | int DSA_set_ex_data(DSA *d, int idx, void *arg) |
@@ -257,8 +256,8 @@ void *DSA_get_ex_data(DSA *d, int idx) | |||
257 | return(CRYPTO_get_ex_data(&d->ex_data,idx)); | 256 | return(CRYPTO_get_ex_data(&d->ex_data,idx)); |
258 | } | 257 | } |
259 | 258 | ||
260 | #ifndef NO_DH | 259 | #ifndef OPENSSL_NO_DH |
261 | DH *DSA_dup_DH(DSA *r) | 260 | DH *DSA_dup_DH(const DSA *r) |
262 | { | 261 | { |
263 | /* DSA has p, q, g, optional pub_key, optional priv_key. | 262 | /* DSA has p, q, g, optional pub_key, optional priv_key. |
264 | * DH has p, optional length, g, optional pub_key, optional priv_key. | 263 | * DH has p, optional length, g, optional pub_key, optional priv_key. |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index 34c6e9a141..07addc94d9 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
@@ -94,7 +94,7 @@ dsa_finish, | |||
94 | NULL | 94 | NULL |
95 | }; | 95 | }; |
96 | 96 | ||
97 | DSA_METHOD *DSA_OpenSSL(void) | 97 | const DSA_METHOD *DSA_OpenSSL(void) |
98 | { | 98 | { |
99 | return &openssl_dsa_meth; | 99 | return &openssl_dsa_meth; |
100 | } | 100 | } |
@@ -204,7 +204,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
204 | } | 204 | } |
205 | 205 | ||
206 | /* Compute r = (g^k mod p) mod q */ | 206 | /* Compute r = (g^k mod p) mod q */ |
207 | if (!ENGINE_get_DSA(dsa->engine)->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, | 207 | if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, |
208 | (BN_MONT_CTX *)dsa->method_mont_p)) goto err; | 208 | (BN_MONT_CTX *)dsa->method_mont_p)) goto err; |
209 | if (!BN_mod(r,r,dsa->q,ctx)) goto err; | 209 | if (!BN_mod(r,r,dsa->q,ctx)) goto err; |
210 | 210 | ||
@@ -237,6 +237,11 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
237 | BIGNUM u1,u2,t1; | 237 | BIGNUM u1,u2,t1; |
238 | BN_MONT_CTX *mont=NULL; | 238 | BN_MONT_CTX *mont=NULL; |
239 | int ret = -1; | 239 | int ret = -1; |
240 | if (!dsa->p || !dsa->q || !dsa->g) | ||
241 | { | ||
242 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MISSING_PARAMETERS); | ||
243 | return -1; | ||
244 | } | ||
240 | 245 | ||
241 | if ((ctx=BN_CTX_new()) == NULL) goto err; | 246 | if ((ctx=BN_CTX_new()) == NULL) goto err; |
242 | BN_init(&u1); | 247 | BN_init(&u1); |
@@ -293,7 +298,7 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
293 | if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; | 298 | if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; |
294 | #else | 299 | #else |
295 | { | 300 | { |
296 | if (!ENGINE_get_DSA(dsa->engine)->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, | 301 | if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, |
297 | dsa->p,ctx,mont)) goto err; | 302 | dsa->p,ctx,mont)) goto err; |
298 | /* BN_copy(&u1,&t1); */ | 303 | /* BN_copy(&u1,&t1); */ |
299 | /* let u1 = u1 mod q */ | 304 | /* let u1 = u1 mod q */ |
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c index dfe27bae47..e9469ca62f 100644 --- a/src/lib/libcrypto/dsa/dsa_sign.c +++ b/src/lib/libcrypto/dsa/dsa_sign.c | |||
@@ -68,7 +68,7 @@ | |||
68 | 68 | ||
69 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | 69 | DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) |
70 | { | 70 | { |
71 | return ENGINE_get_DSA(dsa->engine)->dsa_do_sign(dgst, dlen, dsa); | 71 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); |
72 | } | 72 | } |
73 | 73 | ||
74 | int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | 74 | int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, |
@@ -88,6 +88,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | |||
88 | 88 | ||
89 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | 89 | int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) |
90 | { | 90 | { |
91 | return ENGINE_get_DSA(dsa->engine)->dsa_sign_setup(dsa, ctx_in, kinvp, rp); | 91 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c index 2e891ae491..066c6b5b28 100644 --- a/src/lib/libcrypto/dsa/dsa_vrf.c +++ b/src/lib/libcrypto/dsa/dsa_vrf.c | |||
@@ -70,7 +70,7 @@ | |||
70 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | 70 | int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, |
71 | DSA *dsa) | 71 | DSA *dsa) |
72 | { | 72 | { |
73 | return ENGINE_get_DSA(dsa->engine)->dsa_do_verify(dgst, dgst_len, sig, dsa); | 73 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); |
74 | } | 74 | } |
75 | 75 | ||
76 | /* data has already been hashed (probably with SHA or SHA-1). */ | 76 | /* data has already been hashed (probably with SHA or SHA-1). */ |
@@ -80,7 +80,7 @@ int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
80 | * -1: error | 80 | * -1: error |
81 | */ | 81 | */ |
82 | int DSA_verify(int type, const unsigned char *dgst, int dgst_len, | 82 | int DSA_verify(int type, const unsigned char *dgst, int dgst_len, |
83 | unsigned char *sigbuf, int siglen, DSA *dsa) | 83 | const unsigned char *sigbuf, int siglen, DSA *dsa) |
84 | { | 84 | { |
85 | DSA_SIG *s; | 85 | DSA_SIG *s; |
86 | int ret=-1; | 86 | int ret=-1; |
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c index 309a7cda89..12da64f9f4 100644 --- a/src/lib/libcrypto/dsa/dsatest.c +++ b/src/lib/libcrypto/dsa/dsatest.c | |||
@@ -65,11 +65,12 @@ | |||
65 | #include <openssl/rand.h> | 65 | #include <openssl/rand.h> |
66 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
67 | #include <openssl/err.h> | 67 | #include <openssl/err.h> |
68 | #ifdef WINDOWS | 68 | #include <openssl/engine.h> |
69 | #ifdef OPENSSL_SYS_WINDOWS | ||
69 | #include "../bio/bss_file.c" | 70 | #include "../bio/bss_file.c" |
70 | #endif | 71 | #endif |
71 | 72 | ||
72 | #ifdef NO_DSA | 73 | #ifdef OPENSSL_NO_DSA |
73 | int main(int argc, char *argv[]) | 74 | int main(int argc, char *argv[]) |
74 | { | 75 | { |
75 | printf("No DSA support\n"); | 76 | printf("No DSA support\n"); |
@@ -78,7 +79,7 @@ int main(int argc, char *argv[]) | |||
78 | #else | 79 | #else |
79 | #include <openssl/dsa.h> | 80 | #include <openssl/dsa.h> |
80 | 81 | ||
81 | #ifdef WIN16 | 82 | #ifdef OPENSSL_SYS_WIN16 |
82 | #define MS_CALLBACK _far _loadds | 83 | #define MS_CALLBACK _far _loadds |
83 | #else | 84 | #else |
84 | #define MS_CALLBACK | 85 | #define MS_CALLBACK |
@@ -136,14 +137,16 @@ int main(int argc, char **argv) | |||
136 | unsigned char sig[256]; | 137 | unsigned char sig[256]; |
137 | unsigned int siglen; | 138 | unsigned int siglen; |
138 | 139 | ||
139 | ERR_load_crypto_strings(); | ||
140 | RAND_seed(rnd_seed, sizeof rnd_seed); | ||
141 | |||
142 | if (bio_err == NULL) | 140 | if (bio_err == NULL) |
143 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | 141 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); |
144 | 142 | ||
143 | CRYPTO_malloc_debug_init(); | ||
144 | CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL); | ||
145 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | 145 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); |
146 | 146 | ||
147 | ERR_load_crypto_strings(); | ||
148 | RAND_seed(rnd_seed, sizeof rnd_seed); | ||
149 | |||
147 | BIO_printf(bio_err,"test generation of DSA parameters\n"); | 150 | BIO_printf(bio_err,"test generation of DSA parameters\n"); |
148 | 151 | ||
149 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); | 152 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); |
@@ -200,7 +203,9 @@ end: | |||
200 | if (!ret) | 203 | if (!ret) |
201 | ERR_print_errors(bio_err); | 204 | ERR_print_errors(bio_err); |
202 | if (dsa != NULL) DSA_free(dsa); | 205 | if (dsa != NULL) DSA_free(dsa); |
206 | CRYPTO_cleanup_all_ex_data(); | ||
203 | ERR_remove_state(0); | 207 | ERR_remove_state(0); |
208 | ERR_free_strings(); | ||
204 | CRYPTO_mem_leaks(bio_err); | 209 | CRYPTO_mem_leaks(bio_err); |
205 | if (bio_err != NULL) | 210 | if (bio_err != NULL) |
206 | { | 211 | { |