diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_cvt.c')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_cvt.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/lib/libcrypto/ec/ec_cvt.c b/src/lib/libcrypto/ec/ec_cvt.c index bfcbab35fe..2f755fefaf 100644 --- a/src/lib/libcrypto/ec/ec_cvt.c +++ b/src/lib/libcrypto/ec/ec_cvt.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * are met: | 10 | * are met: |
| 11 | * | 11 | * |
| 12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * | 14 | * |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
| @@ -58,7 +58,7 @@ | |||
| 58 | /* ==================================================================== | 58 | /* ==================================================================== |
| 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 60 | * | 60 | * |
| 61 | * Portions of the attached software ("Contribution") are developed by | 61 | * Portions of the attached software ("Contribution") are developed by |
| 62 | * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. | 62 | * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. |
| 63 | * | 63 | * |
| 64 | * The Contribution is licensed pursuant to the OpenSSL open source | 64 | * The Contribution is licensed pursuant to the OpenSSL open source |
| @@ -73,8 +73,10 @@ | |||
| 73 | #include "ec_lcl.h" | 73 | #include "ec_lcl.h" |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | 76 | EC_GROUP * |
| 77 | { | 77 | EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, |
| 78 | BN_CTX *ctx) | ||
| 79 | { | ||
| 78 | const EC_METHOD *meth; | 80 | const EC_METHOD *meth; |
| 79 | EC_GROUP *ret; | 81 | EC_GROUP *ret; |
| 80 | 82 | ||
| @@ -104,28 +106,24 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM | |||
| 104 | #else | 106 | #else |
| 105 | meth = EC_GFp_nist_method(); | 107 | meth = EC_GFp_nist_method(); |
| 106 | #endif | 108 | #endif |
| 107 | 109 | ||
| 108 | ret = EC_GROUP_new(meth); | 110 | ret = EC_GROUP_new(meth); |
| 109 | if (ret == NULL) | 111 | if (ret == NULL) |
| 110 | return NULL; | 112 | return NULL; |
| 111 | 113 | ||
| 112 | if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) | 114 | if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { |
| 113 | { | ||
| 114 | unsigned long err; | 115 | unsigned long err; |
| 115 | 116 | ||
| 116 | err = ERR_peek_last_error(); | 117 | err = ERR_peek_last_error(); |
| 117 | 118 | ||
| 118 | if (!(ERR_GET_LIB(err) == ERR_LIB_EC && | 119 | if (!(ERR_GET_LIB(err) == ERR_LIB_EC && |
| 119 | ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || | 120 | ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || |
| 120 | (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) | 121 | (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) { |
| 121 | { | ||
| 122 | /* real error */ | 122 | /* real error */ |
| 123 | 123 | ||
| 124 | EC_GROUP_clear_free(ret); | 124 | EC_GROUP_clear_free(ret); |
| 125 | return NULL; | 125 | return NULL; |
| 126 | } | 126 | } |
| 127 | |||
| 128 | |||
| 129 | /* not an actual error, we just cannot use EC_GFp_nist_method */ | 127 | /* not an actual error, we just cannot use EC_GFp_nist_method */ |
| 130 | 128 | ||
| 131 | ERR_clear_error(); | 129 | ERR_clear_error(); |
| @@ -137,34 +135,32 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM | |||
| 137 | if (ret == NULL) | 135 | if (ret == NULL) |
| 138 | return NULL; | 136 | return NULL; |
| 139 | 137 | ||
| 140 | if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) | 138 | if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { |
| 141 | { | ||
| 142 | EC_GROUP_clear_free(ret); | 139 | EC_GROUP_clear_free(ret); |
| 143 | return NULL; | 140 | return NULL; |
| 144 | } | ||
| 145 | } | 141 | } |
| 146 | |||
| 147 | return ret; | ||
| 148 | } | 142 | } |
| 143 | return ret; | ||
| 144 | } | ||
| 149 | 145 | ||
| 150 | #ifndef OPENSSL_NO_EC2M | 146 | #ifndef OPENSSL_NO_EC2M |
| 151 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | 147 | EC_GROUP * |
| 152 | { | 148 | EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, |
| 149 | BN_CTX *ctx) | ||
| 150 | { | ||
| 153 | const EC_METHOD *meth; | 151 | const EC_METHOD *meth; |
| 154 | EC_GROUP *ret; | 152 | EC_GROUP *ret; |
| 155 | 153 | ||
| 156 | meth = EC_GF2m_simple_method(); | 154 | meth = EC_GF2m_simple_method(); |
| 157 | 155 | ||
| 158 | ret = EC_GROUP_new(meth); | 156 | ret = EC_GROUP_new(meth); |
| 159 | if (ret == NULL) | 157 | if (ret == NULL) |
| 160 | return NULL; | 158 | return NULL; |
| 161 | 159 | ||
| 162 | if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) | 160 | if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) { |
| 163 | { | ||
| 164 | EC_GROUP_clear_free(ret); | 161 | EC_GROUP_clear_free(ret); |
| 165 | return NULL; | 162 | return NULL; |
| 166 | } | ||
| 167 | |||
| 168 | return ret; | ||
| 169 | } | 163 | } |
| 164 | return ret; | ||
| 165 | } | ||
| 170 | #endif | 166 | #endif |
