diff options
author | djm <> | 2010-10-01 22:54:21 +0000 |
---|---|---|
committer | djm <> | 2010-10-01 22:54:21 +0000 |
commit | 829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (patch) | |
tree | e03b9f1bd051e844b971936729e9df549a209130 /src/lib/libcrypto/dsa/dsa_lib.c | |
parent | e6b755d2a53d3cac7a344dfdd6bf7c951cac754c (diff) | |
download | openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.gz openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.tar.bz2 openbsd-829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2.zip |
import OpenSSL-1.0.0a
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_lib.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 7ac9dc8c89..e9b75902db 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -76,14 +76,6 @@ static const DSA_METHOD *default_DSA_method = NULL; | |||
76 | 76 | ||
77 | void DSA_set_default_method(const DSA_METHOD *meth) | 77 | void DSA_set_default_method(const DSA_METHOD *meth) |
78 | { | 78 | { |
79 | #ifdef OPENSSL_FIPS | ||
80 | if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
81 | { | ||
82 | DSAerr(DSA_F_DSA_SET_DEFAULT_METHOD, DSA_R_NON_FIPS_METHOD); | ||
83 | return; | ||
84 | } | ||
85 | #endif | ||
86 | |||
87 | default_DSA_method = meth; | 79 | default_DSA_method = meth; |
88 | } | 80 | } |
89 | 81 | ||
@@ -104,13 +96,6 @@ int DSA_set_method(DSA *dsa, const DSA_METHOD *meth) | |||
104 | /* NB: The caller is specifically setting a method, so it's not up to us | 96 | /* NB: The caller is specifically setting a method, so it's not up to us |
105 | * to deal with which ENGINE it comes from. */ | 97 | * to deal with which ENGINE it comes from. */ |
106 | const DSA_METHOD *mtmp; | 98 | const DSA_METHOD *mtmp; |
107 | #ifdef OPENSSL_FIPS | ||
108 | if (FIPS_mode() && !(meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
109 | { | ||
110 | DSAerr(DSA_F_DSA_SET_METHOD, DSA_R_NON_FIPS_METHOD); | ||
111 | return 0; | ||
112 | } | ||
113 | #endif | ||
114 | mtmp = dsa->meth; | 99 | mtmp = dsa->meth; |
115 | if (mtmp->finish) mtmp->finish(dsa); | 100 | if (mtmp->finish) mtmp->finish(dsa); |
116 | #ifndef OPENSSL_NO_ENGINE | 101 | #ifndef OPENSSL_NO_ENGINE |
@@ -162,18 +147,6 @@ DSA *DSA_new_method(ENGINE *engine) | |||
162 | } | 147 | } |
163 | } | 148 | } |
164 | #endif | 149 | #endif |
165 | #ifdef OPENSSL_FIPS | ||
166 | if (FIPS_mode() && !(ret->meth->flags & DSA_FLAG_FIPS_METHOD)) | ||
167 | { | ||
168 | DSAerr(DSA_F_DSA_NEW_METHOD, DSA_R_NON_FIPS_METHOD); | ||
169 | #ifndef OPENSSL_NO_ENGINE | ||
170 | if (ret->engine) | ||
171 | ENGINE_finish(ret->engine); | ||
172 | #endif | ||
173 | OPENSSL_free(ret); | ||
174 | return NULL; | ||
175 | } | ||
176 | #endif | ||
177 | 150 | ||
178 | ret->pad=0; | 151 | ret->pad=0; |
179 | ret->version=0; | 152 | ret->version=0; |
@@ -260,6 +233,28 @@ int DSA_up_ref(DSA *r) | |||
260 | return ((i > 1) ? 1 : 0); | 233 | return ((i > 1) ? 1 : 0); |
261 | } | 234 | } |
262 | 235 | ||
236 | int DSA_size(const DSA *r) | ||
237 | { | ||
238 | int ret,i; | ||
239 | ASN1_INTEGER bs; | ||
240 | unsigned char buf[4]; /* 4 bytes looks really small. | ||
241 | However, i2d_ASN1_INTEGER() will not look | ||
242 | beyond the first byte, as long as the second | ||
243 | parameter is NULL. */ | ||
244 | |||
245 | i=BN_num_bits(r->q); | ||
246 | bs.length=(i+7)/8; | ||
247 | bs.data=buf; | ||
248 | bs.type=V_ASN1_INTEGER; | ||
249 | /* If the top bit is set the asn1 encoding is 1 larger. */ | ||
250 | buf[0]=0xff; | ||
251 | |||
252 | i=i2d_ASN1_INTEGER(&bs,NULL); | ||
253 | i+=i; /* r and s */ | ||
254 | ret=ASN1_object_size(1,i,V_ASN1_SEQUENCE); | ||
255 | return(ret); | ||
256 | } | ||
257 | |||
263 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 258 | int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
264 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) | 259 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
265 | { | 260 | { |