diff options
author | tedu <> | 2014-04-15 20:06:10 +0000 |
---|---|---|
committer | tedu <> | 2014-04-15 20:06:10 +0000 |
commit | 3c7d2178681a2741a8cc8a042cb2ea6ee28528b8 (patch) | |
tree | 11be20c8110348001494179db4f9b0b67ce149ba /src/lib/libcrypto/rsa/rsa_pmeth.c | |
parent | 4c8a9a73429ac4a1d79f4bab6a397df643934861 (diff) | |
download | openbsd-3c7d2178681a2741a8cc8a042cb2ea6ee28528b8.tar.gz openbsd-3c7d2178681a2741a8cc8a042cb2ea6ee28528b8.tar.bz2 openbsd-3c7d2178681a2741a8cc8a042cb2ea6ee28528b8.zip |
remove FIPS mode support. people who require FIPS can buy something that
meets their needs, but dumping it in here only penalizes the rest of us.
ok beck deraadt
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_pmeth.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_pmeth.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_pmeth.c b/src/lib/libcrypto/rsa/rsa_pmeth.c index 157aa5c41d..d706d35ff6 100644 --- a/src/lib/libcrypto/rsa/rsa_pmeth.c +++ b/src/lib/libcrypto/rsa/rsa_pmeth.c | |||
@@ -66,9 +66,6 @@ | |||
66 | #ifndef OPENSSL_NO_CMS | 66 | #ifndef OPENSSL_NO_CMS |
67 | #include <openssl/cms.h> | 67 | #include <openssl/cms.h> |
68 | #endif | 68 | #endif |
69 | #ifdef OPENSSL_FIPS | ||
70 | #include <openssl/fips.h> | ||
71 | #endif | ||
72 | #include "evp_locl.h" | 69 | #include "evp_locl.h" |
73 | #include "rsa_locl.h" | 70 | #include "rsa_locl.h" |
74 | 71 | ||
@@ -156,32 +153,6 @@ static void pkey_rsa_cleanup(EVP_PKEY_CTX *ctx) | |||
156 | OPENSSL_free(rctx); | 153 | OPENSSL_free(rctx); |
157 | } | 154 | } |
158 | } | 155 | } |
159 | #ifdef OPENSSL_FIPS | ||
160 | /* FIP checker. Return value indicates status of context parameters: | ||
161 | * 1 : redirect to FIPS. | ||
162 | * 0 : don't redirect to FIPS. | ||
163 | * -1 : illegal operation in FIPS mode. | ||
164 | */ | ||
165 | |||
166 | static int pkey_fips_check_ctx(EVP_PKEY_CTX *ctx) | ||
167 | { | ||
168 | RSA_PKEY_CTX *rctx = ctx->data; | ||
169 | RSA *rsa = ctx->pkey->pkey.rsa; | ||
170 | int rv = -1; | ||
171 | if (!FIPS_mode()) | ||
172 | return 0; | ||
173 | if (rsa->flags & RSA_FLAG_NON_FIPS_ALLOW) | ||
174 | rv = 0; | ||
175 | if (!(rsa->meth->flags & RSA_FLAG_FIPS_METHOD) && rv) | ||
176 | return -1; | ||
177 | if (rctx->md && !(rctx->md->flags & EVP_MD_FLAG_FIPS)) | ||
178 | return rv; | ||
179 | if (rctx->mgf1md && !(rctx->mgf1md->flags & EVP_MD_FLAG_FIPS)) | ||
180 | return rv; | ||
181 | return 1; | ||
182 | } | ||
183 | #endif | ||
184 | |||
185 | static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | 156 | static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
186 | const unsigned char *tbs, size_t tbslen) | 157 | const unsigned char *tbs, size_t tbslen) |
187 | { | 158 | { |
@@ -189,15 +160,6 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | |||
189 | RSA_PKEY_CTX *rctx = ctx->data; | 160 | RSA_PKEY_CTX *rctx = ctx->data; |
190 | RSA *rsa = ctx->pkey->pkey.rsa; | 161 | RSA *rsa = ctx->pkey->pkey.rsa; |
191 | 162 | ||
192 | #ifdef OPENSSL_FIPS | ||
193 | ret = pkey_fips_check_ctx(ctx); | ||
194 | if (ret < 0) | ||
195 | { | ||
196 | RSAerr(RSA_F_PKEY_RSA_SIGN, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
197 | return -1; | ||
198 | } | ||
199 | #endif | ||
200 | |||
201 | if (rctx->md) | 163 | if (rctx->md) |
202 | { | 164 | { |
203 | if (tbslen != (size_t)EVP_MD_size(rctx->md)) | 165 | if (tbslen != (size_t)EVP_MD_size(rctx->md)) |
@@ -206,22 +168,6 @@ static int pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | |||
206 | RSA_R_INVALID_DIGEST_LENGTH); | 168 | RSA_R_INVALID_DIGEST_LENGTH); |
207 | return -1; | 169 | return -1; |
208 | } | 170 | } |
209 | #ifdef OPENSSL_FIPS | ||
210 | if (ret > 0) | ||
211 | { | ||
212 | unsigned int slen; | ||
213 | ret = FIPS_rsa_sign_digest(rsa, tbs, tbslen, rctx->md, | ||
214 | rctx->pad_mode, | ||
215 | rctx->saltlen, | ||
216 | rctx->mgf1md, | ||
217 | sig, &slen); | ||
218 | if (ret > 0) | ||
219 | *siglen = slen; | ||
220 | else | ||
221 | *siglen = 0; | ||
222 | return ret; | ||
223 | } | ||
224 | #endif | ||
225 | 171 | ||
226 | if (EVP_MD_type(rctx->md) == NID_mdc2) | 172 | if (EVP_MD_type(rctx->md) == NID_mdc2) |
227 | { | 173 | { |
@@ -343,30 +289,8 @@ static int pkey_rsa_verify(EVP_PKEY_CTX *ctx, | |||
343 | RSA_PKEY_CTX *rctx = ctx->data; | 289 | RSA_PKEY_CTX *rctx = ctx->data; |
344 | RSA *rsa = ctx->pkey->pkey.rsa; | 290 | RSA *rsa = ctx->pkey->pkey.rsa; |
345 | size_t rslen; | 291 | size_t rslen; |
346 | #ifdef OPENSSL_FIPS | ||
347 | int rv; | ||
348 | rv = pkey_fips_check_ctx(ctx); | ||
349 | if (rv < 0) | ||
350 | { | ||
351 | RSAerr(RSA_F_PKEY_RSA_VERIFY, RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE); | ||
352 | return -1; | ||
353 | } | ||
354 | #endif | ||
355 | if (rctx->md) | 292 | if (rctx->md) |
356 | { | 293 | { |
357 | #ifdef OPENSSL_FIPS | ||
358 | if (rv > 0) | ||
359 | { | ||
360 | return FIPS_rsa_verify_digest(rsa, | ||
361 | tbs, tbslen, | ||
362 | rctx->md, | ||
363 | rctx->pad_mode, | ||
364 | rctx->saltlen, | ||
365 | rctx->mgf1md, | ||
366 | sig, siglen); | ||
367 | |||
368 | } | ||
369 | #endif | ||
370 | if (rctx->pad_mode == RSA_PKCS1_PADDING) | 294 | if (rctx->pad_mode == RSA_PKCS1_PADDING) |
371 | return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, | 295 | return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, |
372 | sig, siglen, rsa); | 296 | sig, siglen, rsa); |