| 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/crypto/channel_id.h" | 5 #include "net/quic/crypto/channel_id.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/obj_mac.h> | 10 #include <openssl/obj_mac.h> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 if (!p256) { | 37 if (!p256) { |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 crypto::ScopedBIGNUM x(BN_new()), y(BN_new()), r(BN_new()), s(BN_new()); | 41 crypto::ScopedBIGNUM x(BN_new()), y(BN_new()), r(BN_new()), s(BN_new()); |
| 42 | 42 |
| 43 ECDSA_SIG sig; | 43 ECDSA_SIG sig; |
| 44 sig.r = r.get(); | 44 sig.r = r.get(); |
| 45 sig.s = s.get(); | 45 sig.s = s.get(); |
| 46 | 46 |
| 47 const uint8* key_bytes = reinterpret_cast<const uint8*>(key.data()); | 47 const uint8_t* key_bytes = reinterpret_cast<const uint8_t*>(key.data()); |
| 48 const uint8* signature_bytes = | 48 const uint8_t* signature_bytes = |
| 49 reinterpret_cast<const uint8*>(signature.data()); | 49 reinterpret_cast<const uint8_t*>(signature.data()); |
| 50 | 50 |
| 51 if (BN_bin2bn(key_bytes + 0, 32, x.get()) == nullptr || | 51 if (BN_bin2bn(key_bytes + 0, 32, x.get()) == nullptr || |
| 52 BN_bin2bn(key_bytes + 32, 32, y.get()) == nullptr || | 52 BN_bin2bn(key_bytes + 32, 32, y.get()) == nullptr || |
| 53 BN_bin2bn(signature_bytes + 0, 32, sig.r) == nullptr || | 53 BN_bin2bn(signature_bytes + 0, 32, sig.r) == nullptr || |
| 54 BN_bin2bn(signature_bytes + 32, 32, sig.s) == nullptr) { | 54 BN_bin2bn(signature_bytes + 32, 32, sig.s) == nullptr) { |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 crypto::ScopedEC_POINT point(EC_POINT_new(p256.get())); | 58 crypto::ScopedEC_POINT point(EC_POINT_new(p256.get())); |
| 59 if (!point || | 59 if (!point || |
| (...skipping 17 matching lines...) Expand all Loading... |
| 77 } | 77 } |
| 78 SHA256_Update(&sha256, signed_data.data(), signed_data.size()); | 78 SHA256_Update(&sha256, signed_data.data(), signed_data.size()); |
| 79 | 79 |
| 80 unsigned char digest[SHA256_DIGEST_LENGTH]; | 80 unsigned char digest[SHA256_DIGEST_LENGTH]; |
| 81 SHA256_Final(digest, &sha256); | 81 SHA256_Final(digest, &sha256); |
| 82 | 82 |
| 83 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1; | 83 return ECDSA_do_verify(digest, sizeof(digest), &sig, ecdsa_key.get()) == 1; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace net | 86 } // namespace net |
| OLD | NEW |