diff options
| author | djm <> | 2012-10-13 21:23:50 +0000 |
|---|---|---|
| committer | djm <> | 2012-10-13 21:23:50 +0000 |
| commit | 228cae30b117c2493f69ad3c195341cd6ec8d430 (patch) | |
| tree | 29ff00b10d52c0978077c4fd83c33b065bade73e /src/lib/libcrypto/dsa/dsa_lib.c | |
| parent | 731838c66b52c0ae5888333005b74115a620aa96 (diff) | |
| download | openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.tar.gz openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.tar.bz2 openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.zip | |
import OpenSSL-1.0.1c
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_lib.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index e9b75902db..96d8d0c4b4 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
| @@ -70,6 +70,10 @@ | |||
| 70 | #include <openssl/dh.h> | 70 | #include <openssl/dh.h> |
| 71 | #endif | 71 | #endif |
| 72 | 72 | ||
| 73 | #ifdef OPENSSL_FIPS | ||
| 74 | #include <openssl/fips.h> | ||
| 75 | #endif | ||
| 76 | |||
| 73 | const char DSA_version[]="DSA" OPENSSL_VERSION_PTEXT; | 77 | const char DSA_version[]="DSA" OPENSSL_VERSION_PTEXT; |
| 74 | 78 | ||
| 75 | static const DSA_METHOD *default_DSA_method = NULL; | 79 | static const DSA_METHOD *default_DSA_method = NULL; |
| @@ -82,7 +86,16 @@ void DSA_set_default_method(const DSA_METHOD *meth) | |||
| 82 | const DSA_METHOD *DSA_get_default_method(void) | 86 | const DSA_METHOD *DSA_get_default_method(void) |
| 83 | { | 87 | { |
| 84 | if(!default_DSA_method) | 88 | if(!default_DSA_method) |
| 89 | { | ||
| 90 | #ifdef OPENSSL_FIPS | ||
| 91 | if (FIPS_mode()) | ||
| 92 | return FIPS_dsa_openssl(); | ||
| 93 | else | ||
| 94 | return DSA_OpenSSL(); | ||
| 95 | #else | ||
| 85 | default_DSA_method = DSA_OpenSSL(); | 96 | default_DSA_method = DSA_OpenSSL(); |
| 97 | #endif | ||
| 98 | } | ||
| 86 | return default_DSA_method; | 99 | return default_DSA_method; |
| 87 | } | 100 | } |
| 88 | 101 | ||
| @@ -163,7 +176,7 @@ DSA *DSA_new_method(ENGINE *engine) | |||
| 163 | ret->method_mont_p=NULL; | 176 | ret->method_mont_p=NULL; |
| 164 | 177 | ||
| 165 | ret->references=1; | 178 | ret->references=1; |
| 166 | ret->flags=ret->meth->flags; | 179 | ret->flags=ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; |
| 167 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | 180 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
| 168 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | 181 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) |
| 169 | { | 182 | { |
| @@ -276,7 +289,8 @@ void *DSA_get_ex_data(DSA *d, int idx) | |||
| 276 | DH *DSA_dup_DH(const DSA *r) | 289 | DH *DSA_dup_DH(const DSA *r) |
| 277 | { | 290 | { |
| 278 | /* DSA has p, q, g, optional pub_key, optional priv_key. | 291 | /* DSA has p, q, g, optional pub_key, optional priv_key. |
| 279 | * DH has p, optional length, g, optional pub_key, optional priv_key. | 292 | * DH has p, optional length, g, optional pub_key, optional priv_key, |
| 293 | * optional q. | ||
| 280 | */ | 294 | */ |
| 281 | 295 | ||
| 282 | DH *ret = NULL; | 296 | DH *ret = NULL; |
| @@ -290,7 +304,11 @@ DH *DSA_dup_DH(const DSA *r) | |||
| 290 | if ((ret->p = BN_dup(r->p)) == NULL) | 304 | if ((ret->p = BN_dup(r->p)) == NULL) |
| 291 | goto err; | 305 | goto err; |
| 292 | if (r->q != NULL) | 306 | if (r->q != NULL) |
| 307 | { | ||
| 293 | ret->length = BN_num_bits(r->q); | 308 | ret->length = BN_num_bits(r->q); |
| 309 | if ((ret->q = BN_dup(r->q)) == NULL) | ||
| 310 | goto err; | ||
| 311 | } | ||
| 294 | if (r->g != NULL) | 312 | if (r->g != NULL) |
| 295 | if ((ret->g = BN_dup(r->g)) == NULL) | 313 | if ((ret->g = BN_dup(r->g)) == NULL) |
| 296 | goto err; | 314 | goto err; |
