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/core/crypto/channel_id.cc

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 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 | « net/quic/core/crypto/channel_id.h ('k') | net/quic/core/crypto/channel_id_test.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 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/core/crypto/channel_id.h" 5 #include "net/quic/core/crypto/channel_id.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 8
9 #include "third_party/boringssl/src/include/openssl/bn.h" 9 #include "third_party/boringssl/src/include/openssl/bn.h"
10 #include "third_party/boringssl/src/include/openssl/ec.h" 10 #include "third_party/boringssl/src/include/openssl/ec.h"
11 #include "third_party/boringssl/src/include/openssl/ecdsa.h" 11 #include "third_party/boringssl/src/include/openssl/ecdsa.h"
12 #include "third_party/boringssl/src/include/openssl/nid.h" 12 #include "third_party/boringssl/src/include/openssl/nid.h"
13 #include "third_party/boringssl/src/include/openssl/sha.h" 13 #include "third_party/boringssl/src/include/openssl/sha.h"
14 14
15 using base::StringPiece;
16
17 namespace net { 15 namespace net {
18 16
19 // static 17 // static
20 const char ChannelIDVerifier::kContextStr[] = "QUIC ChannelID"; 18 const char ChannelIDVerifier::kContextStr[] = "QUIC ChannelID";
21 // static 19 // static
22 const char ChannelIDVerifier::kClientToServerStr[] = "client -> server"; 20 const char ChannelIDVerifier::kClientToServerStr[] = "client -> server";
23 21
24 // static 22 // static
25 bool ChannelIDVerifier::Verify(StringPiece key, 23 bool ChannelIDVerifier::Verify(QuicStringPiece key,
26 StringPiece signed_data, 24 QuicStringPiece signed_data,
27 StringPiece signature) { 25 QuicStringPiece signature) {
28 return VerifyRaw(key, signed_data, signature, true); 26 return VerifyRaw(key, signed_data, signature, true);
29 } 27 }
30 28
31 // static 29 // static
32 bool ChannelIDVerifier::VerifyRaw(StringPiece key, 30 bool ChannelIDVerifier::VerifyRaw(QuicStringPiece key,
33 StringPiece signed_data, 31 QuicStringPiece signed_data,
34 StringPiece signature, 32 QuicStringPiece signature,
35 bool is_channel_id_signature) { 33 bool is_channel_id_signature) {
36 if (key.size() != 32 * 2 || signature.size() != 32 * 2) { 34 if (key.size() != 32 * 2 || signature.size() != 32 * 2) {
37 return false; 35 return false;
38 } 36 }
39 37
40 bssl::UniquePtr<EC_GROUP> p256( 38 bssl::UniquePtr<EC_GROUP> p256(
41 EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)); 39 EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1));
42 if (p256.get() == nullptr) { 40 if (p256.get() == nullptr) {
43 return false; 41 return false;
44 } 42 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 80 }
83 SHA256_Update(&sha256, signed_data.data(), signed_data.size()); 81 SHA256_Update(&sha256, signed_data.data(), signed_data.size());
84 82
85 unsigned char digest[SHA256_DIGEST_LENGTH]; 83 unsigned char digest[SHA256_DIGEST_LENGTH];
86 SHA256_Final(digest, &sha256); 84 SHA256_Final(digest, &sha256);
87 85
88 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1; 86 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1;
89 } 87 }
90 88
91 } // namespace net 89 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/channel_id.h ('k') | net/quic/core/crypto/channel_id_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698