diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecdsa.h | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_err.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_lib.c | 21 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_locl.h | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 5 |
5 files changed, 37 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecdsa.h b/src/lib/libcrypto/ecdsa/ecdsa.h index e61c539812..7fb5254b62 100644 --- a/src/lib/libcrypto/ecdsa/ecdsa.h +++ b/src/lib/libcrypto/ecdsa/ecdsa.h | |||
| @@ -238,6 +238,7 @@ void ERR_load_ECDSA_strings(void); | |||
| 238 | /* Error codes for the ECDSA functions. */ | 238 | /* Error codes for the ECDSA functions. */ |
| 239 | 239 | ||
| 240 | /* Function codes. */ | 240 | /* Function codes. */ |
| 241 | #define ECDSA_F_ECDSA_CHECK 104 | ||
| 241 | #define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 | 242 | #define ECDSA_F_ECDSA_DATA_NEW_METHOD 100 |
| 242 | #define ECDSA_F_ECDSA_DO_SIGN 101 | 243 | #define ECDSA_F_ECDSA_DO_SIGN 101 |
| 243 | #define ECDSA_F_ECDSA_DO_VERIFY 102 | 244 | #define ECDSA_F_ECDSA_DO_VERIFY 102 |
| @@ -249,6 +250,7 @@ void ERR_load_ECDSA_strings(void); | |||
| 249 | #define ECDSA_R_ERR_EC_LIB 102 | 250 | #define ECDSA_R_ERR_EC_LIB 102 |
| 250 | #define ECDSA_R_MISSING_PARAMETERS 103 | 251 | #define ECDSA_R_MISSING_PARAMETERS 103 |
| 251 | #define ECDSA_R_NEED_NEW_SETUP_VALUES 106 | 252 | #define ECDSA_R_NEED_NEW_SETUP_VALUES 106 |
| 253 | #define ECDSA_R_NON_FIPS_METHOD 107 | ||
| 252 | #define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 | 254 | #define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED 104 |
| 253 | #define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 | 255 | #define ECDSA_R_SIGNATURE_MALLOC_FAILED 105 |
| 254 | 256 | ||
diff --git a/src/lib/libcrypto/ecdsa/ecs_err.c b/src/lib/libcrypto/ecdsa/ecs_err.c index 98e38d537f..81542e6d15 100644 --- a/src/lib/libcrypto/ecdsa/ecs_err.c +++ b/src/lib/libcrypto/ecdsa/ecs_err.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* crypto/ecdsa/ecs_err.c */ | 1 | /* crypto/ecdsa/ecs_err.c */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
| @@ -70,6 +70,7 @@ | |||
| 70 | 70 | ||
| 71 | static ERR_STRING_DATA ECDSA_str_functs[]= | 71 | static ERR_STRING_DATA ECDSA_str_functs[]= |
| 72 | { | 72 | { |
| 73 | {ERR_FUNC(ECDSA_F_ECDSA_CHECK), "ECDSA_CHECK"}, | ||
| 73 | {ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_NEW_METHOD"}, | 74 | {ERR_FUNC(ECDSA_F_ECDSA_DATA_NEW_METHOD), "ECDSA_DATA_NEW_METHOD"}, |
| 74 | {ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"}, | 75 | {ERR_FUNC(ECDSA_F_ECDSA_DO_SIGN), "ECDSA_do_sign"}, |
| 75 | {ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"}, | 76 | {ERR_FUNC(ECDSA_F_ECDSA_DO_VERIFY), "ECDSA_do_verify"}, |
| @@ -84,6 +85,7 @@ static ERR_STRING_DATA ECDSA_str_reasons[]= | |||
| 84 | {ERR_REASON(ECDSA_R_ERR_EC_LIB) ,"err ec lib"}, | 85 | {ERR_REASON(ECDSA_R_ERR_EC_LIB) ,"err ec lib"}, |
| 85 | {ERR_REASON(ECDSA_R_MISSING_PARAMETERS) ,"missing parameters"}, | 86 | {ERR_REASON(ECDSA_R_MISSING_PARAMETERS) ,"missing parameters"}, |
| 86 | {ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"}, | 87 | {ERR_REASON(ECDSA_R_NEED_NEW_SETUP_VALUES),"need new setup values"}, |
| 88 | {ERR_REASON(ECDSA_R_NON_FIPS_METHOD) ,"non fips method"}, | ||
| 87 | {ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"}, | 89 | {ERR_REASON(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED),"random number generation failed"}, |
| 88 | {ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"}, | 90 | {ERR_REASON(ECDSA_R_SIGNATURE_MALLOC_FAILED),"signature malloc failed"}, |
| 89 | {0,NULL} | 91 | {0,NULL} |
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c index 2ebae3aa27..e477da430b 100644 --- a/src/lib/libcrypto/ecdsa/ecs_lib.c +++ b/src/lib/libcrypto/ecdsa/ecs_lib.c | |||
| @@ -60,6 +60,9 @@ | |||
| 60 | #endif | 60 | #endif |
| 61 | #include <openssl/err.h> | 61 | #include <openssl/err.h> |
| 62 | #include <openssl/bn.h> | 62 | #include <openssl/bn.h> |
| 63 | #ifdef OPENSSL_FIPS | ||
| 64 | #include <openssl/fips.h> | ||
| 65 | #endif | ||
| 63 | 66 | ||
| 64 | const char ECDSA_version[]="ECDSA" OPENSSL_VERSION_PTEXT; | 67 | const char ECDSA_version[]="ECDSA" OPENSSL_VERSION_PTEXT; |
| 65 | 68 | ||
| @@ -77,7 +80,16 @@ void ECDSA_set_default_method(const ECDSA_METHOD *meth) | |||
| 77 | const ECDSA_METHOD *ECDSA_get_default_method(void) | 80 | const ECDSA_METHOD *ECDSA_get_default_method(void) |
| 78 | { | 81 | { |
| 79 | if(!default_ECDSA_method) | 82 | if(!default_ECDSA_method) |
| 83 | { | ||
| 84 | #ifdef OPENSSL_FIPS | ||
| 85 | if (FIPS_mode()) | ||
| 86 | return FIPS_ecdsa_openssl(); | ||
| 87 | else | ||
| 88 | return ECDSA_OpenSSL(); | ||
| 89 | #else | ||
| 80 | default_ECDSA_method = ECDSA_OpenSSL(); | 90 | default_ECDSA_method = ECDSA_OpenSSL(); |
| 91 | #endif | ||
| 92 | } | ||
| 81 | return default_ECDSA_method; | 93 | return default_ECDSA_method; |
| 82 | } | 94 | } |
| 83 | 95 | ||
| @@ -193,7 +205,14 @@ ECDSA_DATA *ecdsa_check(EC_KEY *key) | |||
| 193 | } | 205 | } |
| 194 | else | 206 | else |
| 195 | ecdsa_data = (ECDSA_DATA *)data; | 207 | ecdsa_data = (ECDSA_DATA *)data; |
| 196 | 208 | #ifdef OPENSSL_FIPS | |
| 209 | if (FIPS_mode() && !(ecdsa_data->flags & ECDSA_FLAG_FIPS_METHOD) | ||
| 210 | && !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) | ||
| 211 | { | ||
| 212 | ECDSAerr(ECDSA_F_ECDSA_CHECK, ECDSA_R_NON_FIPS_METHOD); | ||
| 213 | return NULL; | ||
| 214 | } | ||
| 215 | #endif | ||
| 197 | 216 | ||
| 198 | return ecdsa_data; | 217 | return ecdsa_data; |
| 199 | } | 218 | } |
diff --git a/src/lib/libcrypto/ecdsa/ecs_locl.h b/src/lib/libcrypto/ecdsa/ecs_locl.h index 3a69a840e2..cb3be13cfc 100644 --- a/src/lib/libcrypto/ecdsa/ecs_locl.h +++ b/src/lib/libcrypto/ecdsa/ecs_locl.h | |||
| @@ -82,6 +82,14 @@ struct ecdsa_method | |||
| 82 | char *app_data; | 82 | char *app_data; |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | /* If this flag is set the ECDSA method is FIPS compliant and can be used | ||
| 86 | * in FIPS mode. This is set in the validated module method. If an | ||
| 87 | * application sets this flag in its own methods it is its responsibility | ||
| 88 | * to ensure the result is compliant. | ||
| 89 | */ | ||
| 90 | |||
| 91 | #define ECDSA_FLAG_FIPS_METHOD 0x1 | ||
| 92 | |||
| 85 | typedef struct ecdsa_data_st { | 93 | typedef struct ecdsa_data_st { |
| 86 | /* EC_KEY_METH_DATA part */ | 94 | /* EC_KEY_METH_DATA part */ |
| 87 | int (*init)(EC_KEY *); | 95 | int (*init)(EC_KEY *); |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 1bbf328de5..7725935610 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
| @@ -167,6 +167,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | |||
| 167 | goto err; | 167 | goto err; |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | #ifndef OPENSSL_NO_EC2M | ||
| 170 | else /* NID_X9_62_characteristic_two_field */ | 171 | else /* NID_X9_62_characteristic_two_field */ |
| 171 | { | 172 | { |
| 172 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 173 | if (!EC_POINT_get_affine_coordinates_GF2m(group, |
| @@ -176,6 +177,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | |||
| 176 | goto err; | 177 | goto err; |
| 177 | } | 178 | } |
| 178 | } | 179 | } |
| 180 | #endif | ||
| 179 | if (!BN_nnmod(r, X, order, ctx)) | 181 | if (!BN_nnmod(r, X, order, ctx)) |
| 180 | { | 182 | { |
| 181 | ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); | 183 | ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); |
| @@ -454,6 +456,7 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, | |||
| 454 | goto err; | 456 | goto err; |
| 455 | } | 457 | } |
| 456 | } | 458 | } |
| 459 | #ifndef OPENSSL_NO_EC2M | ||
| 457 | else /* NID_X9_62_characteristic_two_field */ | 460 | else /* NID_X9_62_characteristic_two_field */ |
| 458 | { | 461 | { |
| 459 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 462 | if (!EC_POINT_get_affine_coordinates_GF2m(group, |
| @@ -463,7 +466,7 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, | |||
| 463 | goto err; | 466 | goto err; |
| 464 | } | 467 | } |
| 465 | } | 468 | } |
| 466 | 469 | #endif | |
| 467 | if (!BN_nnmod(u1, X, order, ctx)) | 470 | if (!BN_nnmod(u1, X, order, ctx)) |
| 468 | { | 471 | { |
| 469 | ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); | 472 | ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); |
