OLD | NEW |
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 "crypto/openssl_util.h" | 7 #include <cstdint> |
| 8 |
8 #include "third_party/boringssl/src/include/openssl/bn.h" | 9 #include "third_party/boringssl/src/include/openssl/bn.h" |
9 #include "third_party/boringssl/src/include/openssl/ec.h" | 10 #include "third_party/boringssl/src/include/openssl/ec.h" |
10 #include "third_party/boringssl/src/include/openssl/ec_key.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; | 15 using base::StringPiece; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 // static | 19 // static |
20 const char ChannelIDVerifier::kContextStr[] = "QUIC ChannelID"; | 20 const char ChannelIDVerifier::kContextStr[] = "QUIC ChannelID"; |
(...skipping 11 matching lines...) Expand all Loading... |
32 bool ChannelIDVerifier::VerifyRaw(StringPiece key, | 32 bool ChannelIDVerifier::VerifyRaw(StringPiece key, |
33 StringPiece signed_data, | 33 StringPiece signed_data, |
34 StringPiece signature, | 34 StringPiece signature, |
35 bool is_channel_id_signature) { | 35 bool is_channel_id_signature) { |
36 if (key.size() != 32 * 2 || signature.size() != 32 * 2) { | 36 if (key.size() != 32 * 2 || signature.size() != 32 * 2) { |
37 return false; | 37 return false; |
38 } | 38 } |
39 | 39 |
40 bssl::UniquePtr<EC_GROUP> p256( | 40 bssl::UniquePtr<EC_GROUP> p256( |
41 EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)); | 41 EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)); |
42 if (!p256) { | 42 if (p256.get() == nullptr) { |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
46 bssl::UniquePtr<BIGNUM> x(BN_new()), y(BN_new()), r(BN_new()), s(BN_new()); | 46 bssl::UniquePtr<BIGNUM> x(BN_new()), y(BN_new()), r(BN_new()), s(BN_new()); |
47 | 47 |
48 ECDSA_SIG sig; | 48 ECDSA_SIG sig; |
49 sig.r = r.get(); | 49 sig.r = r.get(); |
50 sig.s = s.get(); | 50 sig.s = s.get(); |
51 | 51 |
52 const uint8_t* key_bytes = reinterpret_cast<const uint8_t*>(key.data()); | 52 const uint8_t* key_bytes = reinterpret_cast<const uint8_t*>(key.data()); |
(...skipping 29 matching lines...) Expand all Loading... |
82 } | 82 } |
83 SHA256_Update(&sha256, signed_data.data(), signed_data.size()); | 83 SHA256_Update(&sha256, signed_data.data(), signed_data.size()); |
84 | 84 |
85 unsigned char digest[SHA256_DIGEST_LENGTH]; | 85 unsigned char digest[SHA256_DIGEST_LENGTH]; |
86 SHA256_Final(digest, &sha256); | 86 SHA256_Final(digest, &sha256); |
87 | 87 |
88 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1; | 88 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1; |
89 } | 89 } |
90 | 90 |
91 } // namespace net | 91 } // namespace net |
OLD | NEW |