diff options
author | Adam Langley <agl@google.com> | 2015-06-12 16:28:27 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-06-12 16:28:27 +0000 |
commit | 9701a2fbe20a18d08253e84e8ec39d94db5376e0 (patch) | |
tree | 26c038b10145f502cb98f5675516a7ed6bd27fdb /src/crypto/ec | |
parent | 82ea518198c8ce74418c90597ccf8f444d1154ab (diff) | |
parent | 53b272a2813a0b11f107d77100ff8805ada8fbd2 (diff) | |
download | external_boringssl-9701a2fbe20a18d08253e84e8ec39d94db5376e0.zip external_boringssl-9701a2fbe20a18d08253e84e8ec39d94db5376e0.tar.gz external_boringssl-9701a2fbe20a18d08253e84e8ec39d94db5376e0.tar.bz2 |
am 53b272a2: Bump revision of BoringSSL.
* commit '53b272a2813a0b11f107d77100ff8805ada8fbd2':
Bump revision of BoringSSL.
Diffstat (limited to 'src/crypto/ec')
-rw-r--r-- | src/crypto/ec/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/crypto/ec/ec.c | 6 | ||||
-rw-r--r-- | src/crypto/ec/ec_key.c | 5 | ||||
-rw-r--r-- | src/crypto/ec/ec_test.cc | 3 | ||||
-rw-r--r-- | src/crypto/ec/internal.h | 3 | ||||
-rw-r--r-- | src/crypto/ec/p256-64.c | 1 | ||||
-rw-r--r-- | src/crypto/ec/wnaf.c | 7 |
7 files changed, 22 insertions, 7 deletions
diff --git a/src/crypto/ec/CMakeLists.txt b/src/crypto/ec/CMakeLists.txt index a218c0d..b5ebefa 100644 --- a/src/crypto/ec/CMakeLists.txt +++ b/src/crypto/ec/CMakeLists.txt @@ -20,12 +20,16 @@ add_executable( example_mul example_mul.c + + $<TARGET_OBJECTS:test_support> ) add_executable( ec_test ec_test.cc + + $<TARGET_OBJECTS:test_support> ) target_link_libraries(example_mul crypto) diff --git a/src/crypto/ec/ec.c b/src/crypto/ec/ec.c index 5e30730..f38eba6 100644 --- a/src/crypto/ec/ec.c +++ b/src/crypto/ec/ec.c @@ -289,6 +289,12 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor) { + if (group->curve_name != NID_undef) { + /* |EC_GROUP_set_generator| should only be used with |EC_GROUP|s returned + * by |EC_GROUP_new_curve_GFp|. */ + return 0; + } + if (group->generator == NULL) { group->generator = EC_POINT_new(group); if (group->generator == NULL) { diff --git a/src/crypto/ec/ec_key.c b/src/crypto/ec/ec_key.c index 348ec46..e5cbfed 100644 --- a/src/crypto/ec/ec_key.c +++ b/src/crypto/ec/ec_key.c @@ -143,7 +143,7 @@ void EC_KEY_free(EC_KEY *r) { return; } - if (CRYPTO_add(&r->references, -1, CRYPTO_LOCK_EC)) { + if (!CRYPTO_refcount_dec_and_test_zero(&r->references)) { return; } @@ -234,7 +234,8 @@ EC_KEY *EC_KEY_dup(const EC_KEY *ec_key) { } int EC_KEY_up_ref(EC_KEY *r) { - return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC) > 1; + CRYPTO_refcount_inc(&r->references); + return 1; } int EC_KEY_is_opaque(const EC_KEY *key) { diff --git a/src/crypto/ec/ec_test.cc b/src/crypto/ec/ec_test.cc index 74685eb..5af42d5 100644 --- a/src/crypto/ec/ec_test.cc +++ b/src/crypto/ec/ec_test.cc @@ -125,6 +125,9 @@ bool Testd2i_ECPrivateKey() { } ScopedOpenSSLString x_hex(BN_bn2hex(x.get())); ScopedOpenSSLString y_hex(BN_bn2hex(y.get())); + if (!x_hex || !y_hex) { + return false; + } if (0 != strcmp( x_hex.get(), "c81561ecf2e54edefe6617db1c7a34a70744ddb261f269b83dacfcd2ade5a681") || diff --git a/src/crypto/ec/internal.h b/src/crypto/ec/internal.h index 0a8bf24..71062c1 100644 --- a/src/crypto/ec/internal.h +++ b/src/crypto/ec/internal.h @@ -72,6 +72,7 @@ #include <openssl/bn.h> #include <openssl/ex_data.h> +#include <openssl/thread.h> #if defined(__cplusplus) extern "C" { @@ -331,7 +332,7 @@ struct ec_key_st { unsigned int enc_flag; point_conversion_form_t conv_form; - int references; + CRYPTO_refcount_t references; int flags; ECDSA_METHOD *ecdsa_meth; diff --git a/src/crypto/ec/p256-64.c b/src/crypto/ec/p256-64.c index 8f824de..fdb942c 100644 --- a/src/crypto/ec/p256-64.c +++ b/src/crypto/ec/p256-64.c @@ -1601,7 +1601,6 @@ static void batch_mul(felem x_out, felem y_out, felem z_out, /* Precomputation for the group generator. */ typedef struct { smallfelem g_pre_comp[2][16][3]; - int references; } NISTP256_PRE_COMP; /******************************************************************************/ diff --git a/src/crypto/ec/wnaf.c b/src/crypto/ec/wnaf.c index d87a7d9..ae0d73f 100644 --- a/src/crypto/ec/wnaf.c +++ b/src/crypto/ec/wnaf.c @@ -75,6 +75,7 @@ #include <openssl/thread.h> #include "internal.h" +#include "../internal.h" /* This file implements the wNAF-based interleaving multi-exponentation method @@ -91,7 +92,7 @@ typedef struct ec_pre_comp_st { EC_POINT **points; /* array with pre-calculated multiples of generator: * 'num' pointers to EC_POINT objects followed by a NULL */ size_t num; /* numblocks * 2^(w-1) */ - int references; + CRYPTO_refcount_t references; } EC_PRE_COMP; static EC_PRE_COMP *ec_pre_comp_new(void) { @@ -116,13 +117,13 @@ void *ec_pre_comp_dup(EC_PRE_COMP *pre_comp) { return NULL; } - CRYPTO_add(&pre_comp->references, 1, CRYPTO_LOCK_EC_PRE_COMP); + CRYPTO_refcount_inc(&pre_comp->references); return pre_comp; } void ec_pre_comp_free(EC_PRE_COMP *pre_comp) { if (pre_comp == NULL || - CRYPTO_add(&pre_comp->references, -1, CRYPTO_LOCK_EC_PRE_COMP) > 0) { + !CRYPTO_refcount_dec_and_test_zero(&pre_comp->references)) { return; } |