From 2a00e489122f6c4b525090dbdba2855a2ea2d519 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 20 Apr 2015 22:51:55 +0200 Subject: Upgraded to openssl 1.0.2a --- openssl/crypto/ec/ec_asn1.c | 21 +++++++++------------ openssl/crypto/ec/ec_curve.c | 8 ++++---- openssl/crypto/ec/ec_cvt.c | 6 +++--- openssl/crypto/ec/ecp_nistp224.c | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) (limited to 'openssl/crypto/ec') diff --git a/openssl/crypto/ec/ec_asn1.c b/openssl/crypto/ec/ec_asn1.c index 292437409..b4b0e9f3b 100644 --- a/openssl/crypto/ec/ec_asn1.c +++ b/openssl/crypto/ec/ec_asn1.c @@ -1017,14 +1017,8 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) EC_KEY *ret = NULL; EC_PRIVATEKEY *priv_key = NULL; - if ((priv_key = EC_PRIVATEKEY_new()) == NULL) { - ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); - return NULL; - } - - if ((priv_key = d2i_EC_PRIVATEKEY(&priv_key, in, len)) == NULL) { + if ((priv_key = d2i_EC_PRIVATEKEY(NULL, in, len)) == NULL) { ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); - EC_PRIVATEKEY_free(priv_key); return NULL; } @@ -1033,8 +1027,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); goto err; } - if (a) - *a = ret; } else ret = *a; @@ -1102,10 +1094,12 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) ret->enc_flag |= EC_PKEY_NO_PUBKEY; } + if (a) + *a = ret; ok = 1; err: if (!ok) { - if (ret) + if (ret && (a == NULL || *a != ret)) EC_KEY_free(ret); ret = NULL; } @@ -1232,16 +1226,19 @@ EC_KEY *d2i_ECParameters(EC_KEY **a, const unsigned char **in, long len) ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_MALLOC_FAILURE); return NULL; } - if (a) - *a = ret; } else ret = *a; if (!d2i_ECPKParameters(&ret->group, in, len)) { ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_EC_LIB); + if (a == NULL || *a != ret) + EC_KEY_free(ret); return NULL; } + if (a) + *a = ret; + return ret; } diff --git a/openssl/crypto/ec/ec_curve.c b/openssl/crypto/ec/ec_curve.c index 023bd0ec6..6dbe9d825 100644 --- a/openssl/crypto/ec/ec_curve.c +++ b/openssl/crypto/ec/ec_curve.c @@ -69,16 +69,16 @@ * */ -#ifdef OPENSSL_FIPS -# include -#endif - #include #include "ec_lcl.h" #include #include #include +#ifdef OPENSSL_FIPS +# include +#endif + typedef struct { int field_type, /* either NID_X9_62_prime_field or * NID_X9_62_characteristic_two_field */ diff --git a/openssl/crypto/ec/ec_cvt.c b/openssl/crypto/ec/ec_cvt.c index 73cc123e8..5a832ba1c 100644 --- a/openssl/crypto/ec/ec_cvt.c +++ b/openssl/crypto/ec/ec_cvt.c @@ -69,13 +69,13 @@ * */ +#include +#include "ec_lcl.h" + #ifdef OPENSSL_FIPS # include #endif -#include -#include "ec_lcl.h" - EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { diff --git a/openssl/crypto/ec/ecp_nistp224.c b/openssl/crypto/ec/ecp_nistp224.c index 9a59ef0c1..ed09f97ad 100644 --- a/openssl/crypto/ec/ecp_nistp224.c +++ b/openssl/crypto/ec/ecp_nistp224.c @@ -321,7 +321,7 @@ static void bin28_to_felem(felem out, const u8 in[28]) out[0] = *((const uint64_t *)(in)) & 0x00ffffffffffffff; out[1] = (*((const uint64_t *)(in + 7))) & 0x00ffffffffffffff; out[2] = (*((const uint64_t *)(in + 14))) & 0x00ffffffffffffff; - out[3] = (*((const uint64_t *)(in + 21))) & 0x00ffffffffffffff; + out[3] = (*((const uint64_t *)(in+20))) >> 8; } static void felem_to_bin28(u8 out[28], const felem in) -- cgit v1.2.3