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

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

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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
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>
11 #include <openssl/obj_mac.h> 11 #include <openssl/obj_mac.h>
12 #include <openssl/sha.h> 12 #include <openssl/sha.h>
13 13
14 #include "crypto/openssl_util.h" 14 #include "crypto/openssl_util.h"
15 #include "crypto/scoped_openssl_types.h" 15 #include "crypto/scoped_openssl_types.h"
16 #include "crypto/secure_hash.h" 16 #include "crypto/secure_hash.h"
17 #include "net/quic/crypto/channel_id.h" 17 #include "net/quic/crypto/channel_id.h"
18 18
19 using base::StringPiece; 19 using base::StringPiece;
20 using std::string; 20 using std::string;
21 21
22 namespace net { 22 namespace net {
23 23
24 namespace test { 24 namespace test {
25 25
26 class TestChannelIDKey : public ChannelIDKey { 26 class TestChannelIDKey : public ChannelIDKey {
27 public: 27 public:
28 explicit TestChannelIDKey(EVP_PKEY* ecdsa_key) : ecdsa_key_(ecdsa_key) {} 28 explicit TestChannelIDKey(EVP_PKEY* ecdsa_key) : ecdsa_key_(ecdsa_key) {}
29 virtual ~TestChannelIDKey() OVERRIDE {} 29 virtual ~TestChannelIDKey() override {}
30 30
31 // ChannelIDKey implementation. 31 // ChannelIDKey implementation.
32 32
33 virtual bool Sign(StringPiece signed_data, 33 virtual bool Sign(StringPiece signed_data,
34 string* out_signature) const OVERRIDE { 34 string* out_signature) const override {
35 crypto::ScopedEVP_MD_CTX md_ctx(EVP_MD_CTX_create()); 35 crypto::ScopedEVP_MD_CTX md_ctx(EVP_MD_CTX_create());
36 if (!md_ctx || 36 if (!md_ctx ||
37 EVP_DigestSignInit(md_ctx.get(), nullptr, EVP_sha256(), nullptr, 37 EVP_DigestSignInit(md_ctx.get(), nullptr, EVP_sha256(), nullptr,
38 ecdsa_key_.get()) != 1) { 38 ecdsa_key_.get()) != 1) {
39 return false; 39 return false;
40 } 40 }
41 41
42 EVP_DigestUpdate(md_ctx.get(), ChannelIDVerifier::kContextStr, 42 EVP_DigestUpdate(md_ctx.get(), ChannelIDVerifier::kContextStr,
43 strlen(ChannelIDVerifier::kContextStr) + 1); 43 strlen(ChannelIDVerifier::kContextStr) + 1);
44 EVP_DigestUpdate(md_ctx.get(), ChannelIDVerifier::kClientToServerStr, 44 EVP_DigestUpdate(md_ctx.get(), ChannelIDVerifier::kClientToServerStr,
(...skipping 23 matching lines...) Expand all
68 memset(signature.get(), 0, kSignatureLength); 68 memset(signature.get(), 0, kSignatureLength);
69 BN_bn2bin(sig.get()->r, signature.get() + 32 - BN_num_bytes(sig.get()->r)); 69 BN_bn2bin(sig.get()->r, signature.get() + 32 - BN_num_bytes(sig.get()->r));
70 BN_bn2bin(sig.get()->s, signature.get() + 64 - BN_num_bytes(sig.get()->s)); 70 BN_bn2bin(sig.get()->s, signature.get() + 64 - BN_num_bytes(sig.get()->s));
71 71
72 *out_signature = string(reinterpret_cast<char*>(signature.get()), 72 *out_signature = string(reinterpret_cast<char*>(signature.get()),
73 kSignatureLength); 73 kSignatureLength);
74 74
75 return true; 75 return true;
76 } 76 }
77 77
78 virtual string SerializeKey() const OVERRIDE { 78 virtual string SerializeKey() const override {
79 // 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
80 // 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
81 // elements as 32-byte, big-endian numbers. 81 // elements as 32-byte, big-endian numbers.
82 static const int kExpectedKeyLength = 65; 82 static const int kExpectedKeyLength = 65;
83 83
84 int len = i2d_PublicKey(ecdsa_key_.get(), nullptr); 84 int len = i2d_PublicKey(ecdsa_key_.get(), nullptr);
85 if (len != kExpectedKeyLength) { 85 if (len != kExpectedKeyLength) {
86 return ""; 86 return "";
87 } 87 }
88 88
(...skipping 10 matching lines...) Expand all
99 99
100 class TestChannelIDSource : public ChannelIDSource { 100 class TestChannelIDSource : public ChannelIDSource {
101 public: 101 public:
102 virtual ~TestChannelIDSource() {} 102 virtual ~TestChannelIDSource() {}
103 103
104 // ChannelIDSource implementation. 104 // ChannelIDSource implementation.
105 105
106 virtual QuicAsyncStatus GetChannelIDKey( 106 virtual QuicAsyncStatus GetChannelIDKey(
107 const string& hostname, 107 const string& hostname,
108 scoped_ptr<ChannelIDKey>* channel_id_key, 108 scoped_ptr<ChannelIDKey>* channel_id_key,
109 ChannelIDSourceCallback* /*callback*/) OVERRIDE { 109 ChannelIDSourceCallback* /*callback*/) override {
110 channel_id_key->reset(new TestChannelIDKey(HostnameToKey(hostname))); 110 channel_id_key->reset(new TestChannelIDKey(HostnameToKey(hostname)));
111 return QUIC_SUCCESS; 111 return QUIC_SUCCESS;
112 } 112 }
113 113
114 private: 114 private:
115 static EVP_PKEY* HostnameToKey(const string& hostname) { 115 static EVP_PKEY* HostnameToKey(const string& hostname) {
116 // In order to generate a deterministic key for a given hostname the 116 // In order to generate a deterministic key for a given hostname the
117 // hostname is hashed with SHA-256 and the resulting digest is treated as a 117 // hostname is hashed with SHA-256 and the resulting digest is treated as a
118 // big-endian number. The most-significant bit is cleared to ensure that 118 // big-endian number. The most-significant bit is cleared to ensure that
119 // the resulting value is less than the order of the group and then it's 119 // the resulting value is less than the order of the group and then it's
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 }; 158 };
159 159
160 // static 160 // static
161 ChannelIDSource* CryptoTestUtils::ChannelIDSourceForTesting() { 161 ChannelIDSource* CryptoTestUtils::ChannelIDSourceForTesting() {
162 return new TestChannelIDSource(); 162 return new TestChannelIDSource();
163 } 163 }
164 164
165 } // namespace test 165 } // namespace test
166 166
167 } // namespace net 167 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698