Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: components/webcrypto/algorithms/ecdh.cc

Issue 2239863002: Remove some unnecessary refcount increments in WebCrypto's EC code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ec_raw
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/ecdsa.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/ecdh.cc
diff --git a/components/webcrypto/algorithms/ecdh.cc b/components/webcrypto/algorithms/ecdh.cc
index de82db439eda9585230b40bcef2df83b97973d1a..8afca5c2841359610bf960d1b39e6c70e64f8e5c 100644
--- a/components/webcrypto/algorithms/ecdh.cc
+++ b/components/webcrypto/algorithms/ecdh.cc
@@ -79,20 +79,17 @@ class EcdhImplementation : public EcAlgorithm {
return Status::ErrorEcdhCurveMismatch();
}
- crypto::ScopedEC_KEY public_key_ec(
- EVP_PKEY_get1_EC_KEY(GetEVP_PKEY(public_key)));
+ EC_KEY* public_key_ec = EVP_PKEY_get0_EC_KEY(GetEVP_PKEY(public_key));
- const EC_POINT* public_key_point =
- EC_KEY_get0_public_key(public_key_ec.get());
+ const EC_POINT* public_key_point = EC_KEY_get0_public_key(public_key_ec);
- crypto::ScopedEC_KEY private_key_ec(
- EVP_PKEY_get1_EC_KEY(GetEVP_PKEY(base_key)));
+ EC_KEY* private_key_ec = EVP_PKEY_get0_EC_KEY(GetEVP_PKEY(base_key));
// The size of the shared secret is the field size in bytes (rounded up).
// Note that, if rounding was required, the most significant bits of the
// secret are zero. So for P-521, the maximum length is 528 bits, not 521.
- int field_size_bytes = NumBitsToBytes(
- EC_GROUP_get_degree(EC_KEY_get0_group(private_key_ec.get())));
+ int field_size_bytes =
+ NumBitsToBytes(EC_GROUP_get_degree(EC_KEY_get0_group(private_key_ec)));
// If a desired key length was not specified, default to the field size
// (rounded up to nearest byte).
@@ -115,7 +112,7 @@ class EcdhImplementation : public EcAlgorithm {
derived_bytes->resize(NumBitsToBytes(length_bits));
int result = ECDH_compute_key(derived_bytes->data(), derived_bytes->size(),
- public_key_point, private_key_ec.get(), 0);
+ public_key_point, private_key_ec, 0);
if (result < 0 || static_cast<size_t>(result) != derived_bytes->size())
return Status::OperationError();
« no previous file with comments | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/ecdsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698