diff options
Diffstat (limited to 'src/lib/libcrypto/dsa')
-rw-r--r-- | src/lib/libcrypto/dsa/Makefile.ssl | 127 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_asn1.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_key.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 74 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_sign.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_vrf.c | 3 |
8 files changed, 186 insertions, 75 deletions
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl index b0bcf974fb..dac582be00 100644 --- a/src/lib/libcrypto/dsa/Makefile.ssl +++ b/src/lib/libcrypto/dsa/Makefile.ssl | |||
@@ -85,62 +85,105 @@ dsa_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | |||
85 | dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 85 | dsa_asn1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
86 | dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 86 | dsa_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
87 | dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 87 | dsa_asn1.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
88 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h | 88 | dsa_asn1.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
89 | dsa_asn1.o: ../../include/openssl/opensslconf.h | ||
89 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 90 | dsa_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h |
90 | dsa_asn1.o: ../../include/openssl/stack.h ../cryptlib.h | 91 | dsa_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
91 | dsa_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | 92 | dsa_asn1.o: ../cryptlib.h |
92 | dsa_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 93 | dsa_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
93 | dsa_err.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h | 94 | dsa_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h |
95 | dsa_err.o: ../../include/openssl/dsa.h ../../include/openssl/err.h | ||
96 | dsa_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
94 | dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | 97 | dsa_err.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h |
95 | dsa_err.o: ../../include/openssl/stack.h | 98 | dsa_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
96 | dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 99 | dsa_gen.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
97 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 100 | dsa_gen.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
98 | dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 101 | dsa_gen.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
99 | dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 102 | dsa_gen.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
100 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h | 103 | dsa_gen.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
101 | dsa_gen.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 104 | dsa_gen.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
102 | dsa_gen.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 105 | dsa_gen.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
103 | dsa_gen.o: ../../include/openssl/stack.h ../cryptlib.h | 106 | dsa_gen.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
107 | dsa_gen.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
104 | dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 108 | dsa_key.o: ../../include/openssl/bio.h ../../include/openssl/bn.h |
105 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 109 | dsa_key.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h |
106 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 110 | dsa_key.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
107 | dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 111 | dsa_key.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
108 | dsa_key.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h | 112 | dsa_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h |
109 | dsa_key.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 113 | dsa_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
110 | dsa_key.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 114 | dsa_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
111 | dsa_key.o: ../../include/openssl/stack.h ../cryptlib.h | 115 | dsa_key.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
116 | dsa_key.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
112 | dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 117 | dsa_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
113 | dsa_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | 118 | dsa_lib.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
114 | dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | 119 | dsa_lib.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
115 | dsa_lib.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 120 | dsa_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
116 | dsa_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 121 | dsa_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
117 | dsa_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 122 | dsa_lib.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
118 | dsa_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 123 | dsa_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h |
119 | dsa_lib.o: ../cryptlib.h | 124 | dsa_lib.o: ../../include/openssl/evp.h ../../include/openssl/idea.h |
125 | dsa_lib.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
126 | dsa_lib.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
127 | dsa_lib.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
128 | dsa_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
129 | dsa_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | ||
130 | dsa_lib.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
131 | dsa_lib.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
132 | dsa_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
133 | dsa_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
134 | dsa_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
120 | dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 135 | dsa_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
121 | dsa_ossl.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | 136 | dsa_ossl.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
122 | dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | 137 | dsa_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
123 | dsa_ossl.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 138 | dsa_ossl.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
124 | dsa_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 139 | dsa_ossl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
125 | dsa_ossl.o: ../../include/openssl/opensslconf.h | 140 | dsa_ossl.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
141 | dsa_ossl.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
142 | dsa_ossl.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
143 | dsa_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
144 | dsa_ossl.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
145 | dsa_ossl.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
146 | dsa_ossl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
126 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 147 | dsa_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h |
127 | dsa_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 148 | dsa_ossl.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h |
128 | dsa_ossl.o: ../cryptlib.h | 149 | dsa_ossl.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h |
150 | dsa_ossl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
151 | dsa_ossl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
152 | dsa_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
129 | dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | 153 | dsa_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h |
130 | dsa_sign.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h | 154 | dsa_sign.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h |
131 | dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | 155 | dsa_sign.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h |
132 | dsa_sign.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h | 156 | dsa_sign.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
133 | dsa_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 157 | dsa_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h |
134 | dsa_sign.o: ../../include/openssl/opensslconf.h | 158 | dsa_sign.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h |
159 | dsa_sign.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
160 | dsa_sign.o: ../../include/openssl/evp.h ../../include/openssl/idea.h | ||
161 | dsa_sign.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h | ||
162 | dsa_sign.o: ../../include/openssl/md4.h ../../include/openssl/md5.h | ||
163 | dsa_sign.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h | ||
164 | dsa_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
135 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 165 | dsa_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h |
136 | dsa_sign.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 166 | dsa_sign.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h |
137 | dsa_sign.o: ../cryptlib.h | 167 | dsa_sign.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h |
168 | dsa_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
169 | dsa_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
170 | dsa_sign.o: ../../include/openssl/symhacks.h ../cryptlib.h | ||
138 | dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h | 171 | dsa_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/asn1_mac.h |
139 | dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | 172 | dsa_vrf.o: ../../include/openssl/bio.h ../../include/openssl/blowfish.h |
140 | dsa_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 173 | dsa_vrf.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h |
141 | dsa_vrf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | 174 | dsa_vrf.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h |
142 | dsa_vrf.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | 175 | dsa_vrf.o: ../../include/openssl/des.h ../../include/openssl/dh.h |
143 | dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h | 176 | dsa_vrf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os.h |
144 | dsa_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | 177 | dsa_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h |
145 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | 178 | dsa_vrf.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
179 | dsa_vrf.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h | ||
180 | dsa_vrf.o: ../../include/openssl/md2.h ../../include/openssl/md4.h | ||
181 | dsa_vrf.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
182 | dsa_vrf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
183 | dsa_vrf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
184 | dsa_vrf.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h | ||
185 | dsa_vrf.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
186 | dsa_vrf.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
187 | dsa_vrf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
188 | dsa_vrf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
146 | dsa_vrf.o: ../cryptlib.h | 189 | dsa_vrf.o: ../cryptlib.h |
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index 68d9912cbc..65689a3426 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
@@ -65,14 +65,13 @@ | |||
65 | #ifndef HEADER_DSA_H | 65 | #ifndef HEADER_DSA_H |
66 | #define HEADER_DSA_H | 66 | #define HEADER_DSA_H |
67 | 67 | ||
68 | #ifdef __cplusplus | ||
69 | extern "C" { | ||
70 | #endif | ||
71 | |||
72 | #ifdef NO_DSA | 68 | #ifdef NO_DSA |
73 | #error DSA is disabled. | 69 | #error DSA is disabled. |
74 | #endif | 70 | #endif |
75 | 71 | ||
72 | #ifndef NO_BIO | ||
73 | #include <openssl/bio.h> | ||
74 | #endif | ||
76 | #include <openssl/bn.h> | 75 | #include <openssl/bn.h> |
77 | #include <openssl/crypto.h> | 76 | #include <openssl/crypto.h> |
78 | #ifndef NO_DH | 77 | #ifndef NO_DH |
@@ -81,6 +80,10 @@ extern "C" { | |||
81 | 80 | ||
82 | #define DSA_FLAG_CACHE_MONT_P 0x01 | 81 | #define DSA_FLAG_CACHE_MONT_P 0x01 |
83 | 82 | ||
83 | #ifdef __cplusplus | ||
84 | extern "C" { | ||
85 | #endif | ||
86 | |||
84 | typedef struct dsa_st DSA; | 87 | typedef struct dsa_st DSA; |
85 | 88 | ||
86 | typedef struct DSA_SIG_st | 89 | typedef struct DSA_SIG_st |
@@ -130,7 +133,11 @@ struct dsa_st | |||
130 | char *method_mont_p; | 133 | char *method_mont_p; |
131 | int references; | 134 | int references; |
132 | CRYPTO_EX_DATA ex_data; | 135 | CRYPTO_EX_DATA ex_data; |
136 | #if 0 | ||
133 | DSA_METHOD *meth; | 137 | DSA_METHOD *meth; |
138 | #else | ||
139 | struct engine_st *engine; | ||
140 | #endif | ||
134 | }; | 141 | }; |
135 | 142 | ||
136 | #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ | 143 | #define DSAparams_dup(x) (DSA *)ASN1_dup((int (*)())i2d_DSAparams, \ |
@@ -156,12 +163,20 @@ int DSA_do_verify(const unsigned char *dgst,int dgst_len, | |||
156 | 163 | ||
157 | DSA_METHOD *DSA_OpenSSL(void); | 164 | DSA_METHOD *DSA_OpenSSL(void); |
158 | 165 | ||
159 | void DSA_set_default_method(DSA_METHOD *); | 166 | void DSA_set_default_openssl_method(DSA_METHOD *); |
160 | DSA_METHOD *DSA_get_default_method(void); | 167 | DSA_METHOD *DSA_get_default_openssl_method(void); |
168 | #if 0 | ||
161 | DSA_METHOD *DSA_set_method(DSA *dsa, 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 | ||
162 | 173 | ||
163 | DSA * DSA_new(void); | 174 | DSA * DSA_new(void); |
175 | #if 0 | ||
164 | DSA * DSA_new_method(DSA_METHOD *meth); | 176 | DSA * DSA_new_method(DSA_METHOD *meth); |
177 | #else | ||
178 | DSA * DSA_new_method(struct engine_st *engine); | ||
179 | #endif | ||
165 | int DSA_size(DSA *); | 180 | int DSA_size(DSA *); |
166 | /* next 4 return -1 on error */ | 181 | /* next 4 return -1 on error */ |
167 | int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); | 182 | int DSA_sign_setup( DSA *dsa,BN_CTX *ctx_in,BIGNUM **kinvp,BIGNUM **rp); |
@@ -188,7 +203,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp); | |||
188 | int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); | 203 | int i2d_DSAPrivateKey(DSA *a, unsigned char **pp); |
189 | int i2d_DSAparams(DSA *a,unsigned char **pp); | 204 | int i2d_DSAparams(DSA *a,unsigned char **pp); |
190 | 205 | ||
191 | #ifdef HEADER_BIO_H | 206 | #ifndef NO_BIO |
192 | int DSAparams_print(BIO *bp, DSA *x); | 207 | int DSAparams_print(BIO *bp, DSA *x); |
193 | int DSA_print(BIO *bp, DSA *x, int off); | 208 | int DSA_print(BIO *bp, DSA *x, int off); |
194 | #endif | 209 | #endif |
diff --git a/src/lib/libcrypto/dsa/dsa_asn1.c b/src/lib/libcrypto/dsa/dsa_asn1.c index c9b32b4db7..a76c8f7c7e 100644 --- a/src/lib/libcrypto/dsa/dsa_asn1.c +++ b/src/lib/libcrypto/dsa/dsa_asn1.c | |||
@@ -10,7 +10,7 @@ DSA_SIG *DSA_SIG_new(void) | |||
10 | { | 10 | { |
11 | DSA_SIG *ret; | 11 | DSA_SIG *ret; |
12 | 12 | ||
13 | ret = Malloc(sizeof(DSA_SIG)); | 13 | ret = OPENSSL_malloc(sizeof(DSA_SIG)); |
14 | if (ret == NULL) | 14 | if (ret == NULL) |
15 | { | 15 | { |
16 | DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); | 16 | DSAerr(DSA_F_DSA_SIG_NEW,ERR_R_MALLOC_FAILURE); |
@@ -26,7 +26,7 @@ void DSA_SIG_free(DSA_SIG *r) | |||
26 | if (r == NULL) return; | 26 | if (r == NULL) return; |
27 | if (r->r) BN_clear_free(r->r); | 27 | if (r->r) BN_clear_free(r->r); |
28 | if (r->s) BN_clear_free(r->s); | 28 | if (r->s) BN_clear_free(r->s); |
29 | Free(r); | 29 | OPENSSL_free(r); |
30 | } | 30 | } |
31 | 31 | ||
32 | int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) | 32 | int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) |
@@ -35,7 +35,7 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) | |||
35 | ASN1_INTEGER rbs,sbs; | 35 | ASN1_INTEGER rbs,sbs; |
36 | unsigned char *p; | 36 | unsigned char *p; |
37 | 37 | ||
38 | rbs.data=Malloc(BN_num_bits(v->r)/8+1); | 38 | rbs.data=OPENSSL_malloc(BN_num_bits(v->r)/8+1); |
39 | if (rbs.data == NULL) | 39 | if (rbs.data == NULL) |
40 | { | 40 | { |
41 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); | 41 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); |
@@ -43,10 +43,10 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) | |||
43 | } | 43 | } |
44 | rbs.type=V_ASN1_INTEGER; | 44 | rbs.type=V_ASN1_INTEGER; |
45 | rbs.length=BN_bn2bin(v->r,rbs.data); | 45 | rbs.length=BN_bn2bin(v->r,rbs.data); |
46 | sbs.data=Malloc(BN_num_bits(v->s)/8+1); | 46 | sbs.data=OPENSSL_malloc(BN_num_bits(v->s)/8+1); |
47 | if (sbs.data == NULL) | 47 | if (sbs.data == NULL) |
48 | { | 48 | { |
49 | Free(rbs.data); | 49 | OPENSSL_free(rbs.data); |
50 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); | 50 | DSAerr(DSA_F_I2D_DSA_SIG, ERR_R_MALLOC_FAILURE); |
51 | return(0); | 51 | return(0); |
52 | } | 52 | } |
@@ -64,8 +64,8 @@ int i2d_DSA_SIG(DSA_SIG *v, unsigned char **pp) | |||
64 | i2d_ASN1_INTEGER(&sbs,&p); | 64 | i2d_ASN1_INTEGER(&sbs,&p); |
65 | } | 65 | } |
66 | t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); | 66 | t=ASN1_object_size(1,len,V_ASN1_SEQUENCE); |
67 | Free(rbs.data); | 67 | OPENSSL_free(rbs.data); |
68 | Free(sbs.data); | 68 | OPENSSL_free(sbs.data); |
69 | return(t); | 69 | return(t); |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_key.c b/src/lib/libcrypto/dsa/dsa_key.c index 5aef2d5fcf..af3c56d770 100644 --- a/src/lib/libcrypto/dsa/dsa_key.c +++ b/src/lib/libcrypto/dsa/dsa_key.c | |||
@@ -84,7 +84,7 @@ int DSA_generate_key(DSA *dsa) | |||
84 | i=BN_num_bits(dsa->q); | 84 | i=BN_num_bits(dsa->q); |
85 | for (;;) | 85 | for (;;) |
86 | { | 86 | { |
87 | if (!BN_rand(priv_key,i,1,0)) | 87 | if (!BN_rand(priv_key,i,0,0)) |
88 | goto err; | 88 | goto err; |
89 | if (BN_cmp(priv_key,dsa->q) >= 0) | 89 | if (BN_cmp(priv_key,dsa->q) >= 0) |
90 | BN_sub(priv_key,priv_key,dsa->q); | 90 | BN_sub(priv_key,priv_key,dsa->q); |
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 224e412afc..b31b946ad3 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -63,6 +63,7 @@ | |||
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 | #include <openssl/engine.h> | ||
66 | 67 | ||
67 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; | 68 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; |
68 | 69 | ||
@@ -70,12 +71,26 @@ static DSA_METHOD *default_DSA_method; | |||
70 | static int dsa_meth_num = 0; | 71 | static int dsa_meth_num = 0; |
71 | static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL; | 72 | static STACK_OF(CRYPTO_EX_DATA_FUNCS) *dsa_meth = NULL; |
72 | 73 | ||
73 | void DSA_set_default_method(DSA_METHOD *meth) | 74 | void DSA_set_default_openssl_method(DSA_METHOD *meth) |
74 | { | 75 | { |
75 | default_DSA_method = meth; | 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 | } | ||
76 | } | 91 | } |
77 | 92 | ||
78 | DSA_METHOD *DSA_get_default_method(void) | 93 | DSA_METHOD *DSA_get_default_openssl_method(void) |
79 | { | 94 | { |
80 | if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); | 95 | if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); |
81 | return default_DSA_method; | 96 | return default_DSA_method; |
@@ -86,6 +101,7 @@ DSA *DSA_new(void) | |||
86 | return DSA_new_method(NULL); | 101 | return DSA_new_method(NULL); |
87 | } | 102 | } |
88 | 103 | ||
104 | #if 0 | ||
89 | DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) | 105 | DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) |
90 | { | 106 | { |
91 | DSA_METHOD *mtmp; | 107 | DSA_METHOD *mtmp; |
@@ -95,21 +111,52 @@ DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth) | |||
95 | if (meth->init) meth->init(dsa); | 111 | if (meth->init) meth->init(dsa); |
96 | return mtmp; | 112 | return mtmp; |
97 | } | 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 | } | ||
131 | #endif | ||
98 | 132 | ||
99 | 133 | ||
134 | #if 0 | ||
100 | DSA *DSA_new_method(DSA_METHOD *meth) | 135 | DSA *DSA_new_method(DSA_METHOD *meth) |
136 | #else | ||
137 | DSA *DSA_new_method(ENGINE *engine) | ||
138 | #endif | ||
101 | { | 139 | { |
140 | DSA_METHOD *meth; | ||
102 | DSA *ret; | 141 | DSA *ret; |
103 | 142 | ||
104 | ret=(DSA *)Malloc(sizeof(DSA)); | 143 | ret=(DSA *)OPENSSL_malloc(sizeof(DSA)); |
105 | if (ret == NULL) | 144 | if (ret == NULL) |
106 | { | 145 | { |
107 | DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); | 146 | DSAerr(DSA_F_DSA_NEW,ERR_R_MALLOC_FAILURE); |
108 | return(NULL); | 147 | return(NULL); |
109 | } | 148 | } |
110 | if(!default_DSA_method) default_DSA_method = DSA_OpenSSL(); | 149 | if(engine) |
111 | if(meth) ret->meth = meth; | 150 | ret->engine = engine; |
112 | else ret->meth = default_DSA_method; | 151 | else |
152 | { | ||
153 | if((ret->engine=ENGINE_get_default_DSA()) == NULL) | ||
154 | { | ||
155 | OPENSSL_free(ret); | ||
156 | return NULL; | ||
157 | } | ||
158 | } | ||
159 | meth = ENGINE_get_DSA(ret->engine); | ||
113 | ret->pad=0; | 160 | ret->pad=0; |
114 | ret->version=0; | 161 | ret->version=0; |
115 | ret->write_params=1; | 162 | ret->write_params=1; |
@@ -125,10 +172,10 @@ DSA *DSA_new_method(DSA_METHOD *meth) | |||
125 | ret->method_mont_p=NULL; | 172 | ret->method_mont_p=NULL; |
126 | 173 | ||
127 | ret->references=1; | 174 | ret->references=1; |
128 | ret->flags=ret->meth->flags; | 175 | ret->flags=meth->flags; |
129 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | 176 | if ((meth->init != NULL) && !meth->init(ret)) |
130 | { | 177 | { |
131 | Free(ret); | 178 | OPENSSL_free(ret); |
132 | ret=NULL; | 179 | ret=NULL; |
133 | } | 180 | } |
134 | else | 181 | else |
@@ -139,6 +186,7 @@ DSA *DSA_new_method(DSA_METHOD *meth) | |||
139 | 186 | ||
140 | void DSA_free(DSA *r) | 187 | void DSA_free(DSA *r) |
141 | { | 188 | { |
189 | DSA_METHOD *meth; | ||
142 | int i; | 190 | int i; |
143 | 191 | ||
144 | if (r == NULL) return; | 192 | if (r == NULL) return; |
@@ -158,7 +206,9 @@ void DSA_free(DSA *r) | |||
158 | 206 | ||
159 | CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data); | 207 | CRYPTO_free_ex_data(dsa_meth, r, &r->ex_data); |
160 | 208 | ||
161 | if(r->meth->finish) r->meth->finish(r); | 209 | meth = ENGINE_get_DSA(r->engine); |
210 | if(meth->finish) meth->finish(r); | ||
211 | ENGINE_finish(r->engine); | ||
162 | 212 | ||
163 | if (r->p != NULL) BN_clear_free(r->p); | 213 | if (r->p != NULL) BN_clear_free(r->p); |
164 | if (r->q != NULL) BN_clear_free(r->q); | 214 | if (r->q != NULL) BN_clear_free(r->q); |
@@ -167,7 +217,7 @@ void DSA_free(DSA *r) | |||
167 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); | 217 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); |
168 | if (r->kinv != NULL) BN_clear_free(r->kinv); | 218 | if (r->kinv != NULL) BN_clear_free(r->kinv); |
169 | if (r->r != NULL) BN_clear_free(r->r); | 219 | if (r->r != NULL) BN_clear_free(r->r); |
170 | Free(r); | 220 | OPENSSL_free(r); |
171 | } | 221 | } |
172 | 222 | ||
173 | int DSA_size(DSA *r) | 223 | int DSA_size(DSA *r) |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index b51cf6ad8d..96295dc24f 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
@@ -64,6 +64,7 @@ | |||
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> | ||
67 | 68 | ||
68 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); | 69 | static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); |
69 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); | 70 | static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); |
@@ -181,7 +182,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
181 | /* Get random k */ | 182 | /* Get random k */ |
182 | for (;;) | 183 | for (;;) |
183 | { | 184 | { |
184 | if (!BN_rand(&k, BN_num_bits(dsa->q), 1, 0)) goto err; | 185 | if (!BN_rand(&k, BN_num_bits(dsa->q), 0, 0)) goto err; |
185 | if (BN_cmp(&k,dsa->q) >= 0) | 186 | if (BN_cmp(&k,dsa->q) >= 0) |
186 | BN_sub(&k,&k,dsa->q); | 187 | BN_sub(&k,&k,dsa->q); |
187 | if (!BN_is_zero(&k)) break; | 188 | if (!BN_is_zero(&k)) break; |
@@ -195,7 +196,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
195 | } | 196 | } |
196 | 197 | ||
197 | /* Compute r = (g^k mod p) mod q */ | 198 | /* Compute r = (g^k mod p) mod q */ |
198 | if (!dsa->meth->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, | 199 | if (!ENGINE_get_DSA(dsa->engine)->bn_mod_exp(dsa, r,dsa->g,&k,dsa->p,ctx, |
199 | (BN_MONT_CTX *)dsa->method_mont_p)) goto err; | 200 | (BN_MONT_CTX *)dsa->method_mont_p)) goto err; |
200 | if (!BN_mod(r,r,dsa->q,ctx)) goto err; | 201 | if (!BN_mod(r,r,dsa->q,ctx)) goto err; |
201 | 202 | ||
@@ -273,7 +274,7 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
273 | if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; | 274 | if (!BN_mod(&u1,&u1,dsa->q,ctx)) goto err; |
274 | #else | 275 | #else |
275 | { | 276 | { |
276 | if (!dsa->meth->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, | 277 | if (!ENGINE_get_DSA(dsa->engine)->dsa_mod_exp(dsa, &t1,dsa->g,&u1,dsa->pub_key,&u2, |
277 | dsa->p,ctx,mont)) goto err; | 278 | dsa->p,ctx,mont)) goto err; |
278 | /* BN_copy(&u1,&t1); */ | 279 | /* BN_copy(&u1,&t1); */ |
279 | /* let u1 = u1 mod q */ | 280 | /* let u1 = u1 mod q */ |
diff --git a/src/lib/libcrypto/dsa/dsa_sign.c b/src/lib/libcrypto/dsa/dsa_sign.c index 89205026f0..dfe27bae47 100644 --- a/src/lib/libcrypto/dsa/dsa_sign.c +++ b/src/lib/libcrypto/dsa/dsa_sign.c | |||
@@ -64,10 +64,11 @@ | |||
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> | ||
67 | 68 | ||
68 | 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) |
69 | { | 70 | { |
70 | return dsa->meth->dsa_do_sign(dgst, dlen, dsa); | 71 | return ENGINE_get_DSA(dsa->engine)->dsa_do_sign(dgst, dlen, dsa); |
71 | } | 72 | } |
72 | 73 | ||
73 | 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, |
@@ -87,6 +88,6 @@ int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, | |||
87 | 88 | ||
88 | 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) |
89 | { | 90 | { |
90 | return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); | 91 | return ENGINE_get_DSA(dsa->engine)->dsa_sign_setup(dsa, ctx_in, kinvp, rp); |
91 | } | 92 | } |
92 | 93 | ||
diff --git a/src/lib/libcrypto/dsa/dsa_vrf.c b/src/lib/libcrypto/dsa/dsa_vrf.c index 03277f80fd..2e891ae491 100644 --- a/src/lib/libcrypto/dsa/dsa_vrf.c +++ b/src/lib/libcrypto/dsa/dsa_vrf.c | |||
@@ -65,11 +65,12 @@ | |||
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> | ||
68 | 69 | ||
69 | 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, |
70 | DSA *dsa) | 71 | DSA *dsa) |
71 | { | 72 | { |
72 | return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); | 73 | return ENGINE_get_DSA(dsa->engine)->dsa_do_verify(dgst, dgst_len, sig, dsa); |
73 | } | 74 | } |
74 | 75 | ||
75 | /* data has already been hashed (probably with SHA or SHA-1). */ | 76 | /* data has already been hashed (probably with SHA or SHA-1). */ |