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

Side by Side Diff: components/webcrypto/algorithms/ecdsa.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 unified diff | Download patch
« no previous file with comments | « components/webcrypto/algorithms/ecdh.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <openssl/ec.h> 5 #include <openssl/ec.h>
6 #include <openssl/ec_key.h> 6 #include <openssl/ec_key.h>
7 #include <openssl/ecdsa.h> 7 #include <openssl/ecdsa.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 28 matching lines...) Expand all
39 *digest = GetDigest(algorithm.ecdsaParams()->hash()); 39 *digest = GetDigest(algorithm.ecdsaParams()->hash());
40 if (!*digest) 40 if (!*digest)
41 return Status::ErrorUnsupported(); 41 return Status::ErrorUnsupported();
42 return Status::Success(); 42 return Status::Success();
43 } 43 }
44 44
45 // Gets the EC key's order size in bytes. 45 // Gets the EC key's order size in bytes.
46 Status GetEcGroupOrderSize(EVP_PKEY* pkey, size_t* order_size_bytes) { 46 Status GetEcGroupOrderSize(EVP_PKEY* pkey, size_t* order_size_bytes) {
47 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 47 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
48 48
49 crypto::ScopedEC_KEY ec(EVP_PKEY_get1_EC_KEY(pkey)); 49 EC_KEY* ec = EVP_PKEY_get0_EC_KEY(pkey);
50 if (!ec.get()) 50 if (!ec)
51 return Status::ErrorUnexpected(); 51 return Status::ErrorUnexpected();
52 52
53 const EC_GROUP* group = EC_KEY_get0_group(ec.get()); 53 const EC_GROUP* group = EC_KEY_get0_group(ec);
54 54
55 crypto::ScopedBIGNUM order(BN_new()); 55 crypto::ScopedBIGNUM order(BN_new());
56 if (!EC_GROUP_get_order(group, order.get(), NULL)) 56 if (!EC_GROUP_get_order(group, order.get(), NULL))
57 return Status::OperationError(); 57 return Status::OperationError();
58 58
59 *order_size_bytes = BN_num_bytes(order.get()); 59 *order_size_bytes = BN_num_bytes(order.get());
60 return Status::Success(); 60 return Status::Success();
61 } 61 }
62 62
63 // Formats a DER-encoded signature (ECDSA-Sig-Value as specified in RFC 3279) to 63 // Formats a DER-encoded signature (ECDSA-Sig-Value as specified in RFC 3279) to
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 }; 252 };
253 253
254 } // namespace 254 } // namespace
255 255
256 std::unique_ptr<AlgorithmImplementation> CreateEcdsaImplementation() { 256 std::unique_ptr<AlgorithmImplementation> CreateEcdsaImplementation() {
257 return base::WrapUnique(new EcdsaImplementation); 257 return base::WrapUnique(new EcdsaImplementation);
258 } 258 }
259 259
260 } // namespace webcrypto 260 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/ecdh.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698