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

Side by Side Diff: net/quic/test_tools/crypto_test_utils_openssl.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « net/quic/quic_utils_test.cc ('k') | net/socket/next_proto.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/quic/test_tools/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 uint8* derp = der_sig.get(); 57 uint8* derp = der_sig.get();
58 crypto::ScopedECDSA_SIG sig( 58 crypto::ScopedECDSA_SIG sig(
59 d2i_ECDSA_SIG(nullptr, const_cast<const uint8**>(&derp), sig_len)); 59 d2i_ECDSA_SIG(nullptr, const_cast<const uint8**>(&derp), sig_len));
60 if (sig.get() == nullptr) { 60 if (sig.get() == nullptr) {
61 return false; 61 return false;
62 } 62 }
63 63
64 // The signature consists of a pair of 32-byte numbers. 64 // The signature consists of a pair of 32-byte numbers.
65 static const size_t kSignatureLength = 32 * 2; 65 static const size_t kSignatureLength = 32 * 2;
66 scoped_ptr<uint8[]> signature(new uint8[kSignatureLength]); 66 scoped_ptr<uint8[]> signature(new uint8[kSignatureLength]);
67 memset(signature.get(), 0, kSignatureLength); 67 if (!BN_bn2bin_padded(&signature[0], 32, sig->r) ||
68 BN_bn2bin(sig.get()->r, signature.get() + 32 - BN_num_bytes(sig.get()->r)); 68 !BN_bn2bin_padded(&signature[32], 32, sig->s)) {
69 BN_bn2bin(sig.get()->s, signature.get() + 64 - BN_num_bytes(sig.get()->s)); 69 return false;
70 }
70 71
71 *out_signature = string(reinterpret_cast<char*>(signature.get()), 72 *out_signature = string(reinterpret_cast<char*>(signature.get()),
72 kSignatureLength); 73 kSignatureLength);
73 74
74 return true; 75 return true;
75 } 76 }
76 77
77 string SerializeKey() const override { 78 string SerializeKey() const override {
78 // i2d_PublicKey will produce an ANSI X9.62 public key which, for a P-256 79 // i2d_PublicKey will produce an ANSI X9.62 public key which, for a P-256
79 // key, is 0x04 (meaning uncompressed) followed by the x and y field 80 // key, is 0x04 (meaning uncompressed) followed by the x and y field
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 }; 158 };
158 159
159 // static 160 // static
160 ChannelIDSource* CryptoTestUtils::ChannelIDSourceForTesting() { 161 ChannelIDSource* CryptoTestUtils::ChannelIDSourceForTesting() {
161 return new TestChannelIDSource(); 162 return new TestChannelIDSource();
162 } 163 }
163 164
164 } // namespace test 165 } // namespace test
165 166
166 } // namespace net 167 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_utils_test.cc ('k') | net/socket/next_proto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698