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

Side by Side Diff: crypto/ec_signature_creator_openssl.cc

Issue 1739403002: Cut down on usage of deprecated APIs in //crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grumble grumble string vector char uint8_t grumble Created 4 years, 9 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 | « crypto/ec_private_key_unittest.cc ('k') | crypto/openssl_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "crypto/ec_signature_creator_impl.h" 5 #include "crypto/ec_signature_creator_impl.h"
6 6
7 #include <openssl/bn.h> 7 #include <openssl/bn.h>
8 #include <openssl/ec.h> 8 #include <openssl/ec.h>
9 #include <openssl/ecdsa.h> 9 #include <openssl/ecdsa.h>
10 #include <openssl/evp.h> 10 #include <openssl/evp.h>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // one, which may be smaller. 48 // one, which may be smaller.
49 signature->resize(sig_len); 49 signature->resize(sig_len);
50 return true; 50 return true;
51 } 51 }
52 52
53 bool ECSignatureCreatorImpl::DecodeSignature( 53 bool ECSignatureCreatorImpl::DecodeSignature(
54 const std::vector<uint8_t>& der_sig, 54 const std::vector<uint8_t>& der_sig,
55 std::vector<uint8_t>* out_raw_sig) { 55 std::vector<uint8_t>* out_raw_sig) {
56 OpenSSLErrStackTracer err_tracer(FROM_HERE); 56 OpenSSLErrStackTracer err_tracer(FROM_HERE);
57 // Create ECDSA_SIG object from DER-encoded data. 57 // Create ECDSA_SIG object from DER-encoded data.
58 const unsigned char* der_data = &der_sig.front();
59 ScopedECDSA_SIG ecdsa_sig( 58 ScopedECDSA_SIG ecdsa_sig(
60 d2i_ECDSA_SIG(NULL, &der_data, static_cast<long>(der_sig.size()))); 59 ECDSA_SIG_from_bytes(der_sig.data(), der_sig.size()));
61 if (!ecdsa_sig.get()) 60 if (!ecdsa_sig.get())
62 return false; 61 return false;
63 62
64 // The result is made of two 32-byte vectors. 63 // The result is made of two 32-byte vectors.
65 const size_t kMaxBytesPerBN = 32; 64 const size_t kMaxBytesPerBN = 32;
66 std::vector<uint8_t> result(2 * kMaxBytesPerBN); 65 std::vector<uint8_t> result(2 * kMaxBytesPerBN);
67 66
68 if (!BN_bn2bin_padded(&result[0], kMaxBytesPerBN, ecdsa_sig->r) || 67 if (!BN_bn2bin_padded(&result[0], kMaxBytesPerBN, ecdsa_sig->r) ||
69 !BN_bn2bin_padded(&result[kMaxBytesPerBN], kMaxBytesPerBN, 68 !BN_bn2bin_padded(&result[kMaxBytesPerBN], kMaxBytesPerBN,
70 ecdsa_sig->s)) { 69 ecdsa_sig->s)) {
71 return false; 70 return false;
72 } 71 }
73 out_raw_sig->swap(result); 72 out_raw_sig->swap(result);
74 return true; 73 return true;
75 } 74 }
76 75
77 } // namespace crypto 76 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_private_key_unittest.cc ('k') | crypto/openssl_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698