Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ssl/token_binding.h" | 5 #include "net/ssl/token_binding.h" |
| 6 | 6 |
| 7 #include <openssl/bytestring.h> | 7 #include <openssl/bytestring.h> |
| 8 #include <openssl/ec.h> | 8 #include <openssl/ec.h> |
| 9 #include <openssl/evp.h> | 9 #include <openssl/evp.h> |
| 10 #include <openssl/mem.h> | 10 #include <openssl/mem.h> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 return CBB_add_u8(out, TB_PARAM_ECDSAP256) && | 26 return CBB_add_u8(out, TB_PARAM_ECDSAP256) && |
| 27 CBB_add_u8_length_prefixed(out, &ec_point) && | 27 CBB_add_u8_length_prefixed(out, &ec_point) && |
| 28 EC_POINT_point2cbb(&ec_point, EC_KEY_get0_group(ec_key), | 28 EC_POINT_point2cbb(&ec_point, EC_KEY_get0_group(ec_key), |
| 29 EC_KEY_get0_public_key(ec_key), | 29 EC_KEY_get0_public_key(ec_key), |
| 30 POINT_CONVERSION_UNCOMPRESSED, nullptr) && | 30 POINT_CONVERSION_UNCOMPRESSED, nullptr) && |
| 31 CBB_flush(out); | 31 CBB_flush(out); |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 bool IsTokenBindingSupported() { | 36 bool IsTokenBindingSupported() { |
|
davidben
2016/04/25 16:53:24
Either now or in a follow-up, but we can take this
svaldez
2016/04/25 19:44:05
Done.
| |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool SignTokenBindingEkm(base::StringPiece ekm, | 40 bool SignTokenBindingEkm(base::StringPiece ekm, |
| 41 crypto::ECPrivateKey* key, | 41 crypto::ECPrivateKey* key, |
| 42 std::vector<uint8_t>* out) { | 42 std::vector<uint8_t>* out) { |
| 43 size_t sig_len; | 43 size_t sig_len; |
| 44 const uint8_t* ekm_data = reinterpret_cast<const uint8_t*>(ekm.data()); | 44 const uint8_t* ekm_data = reinterpret_cast<const uint8_t*>(ekm.data()); |
| 45 crypto::ScopedEVP_PKEY_CTX pctx(EVP_PKEY_CTX_new(key->key(), nullptr)); | 45 crypto::ScopedEVP_PKEY_CTX pctx(EVP_PKEY_CTX_new(key->key(), nullptr)); |
| 46 if (!EVP_PKEY_sign_init(pctx.get()) || | 46 if (!EVP_PKEY_sign_init(pctx.get()) || |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 !EVP_PKEY_verify( | 157 !EVP_PKEY_verify( |
| 158 pctx.get(), reinterpret_cast<const uint8_t*>(signature.data()), | 158 pctx.get(), reinterpret_cast<const uint8_t*>(signature.data()), |
| 159 signature.size(), reinterpret_cast<const uint8_t*>(ekm.data()), | 159 signature.size(), reinterpret_cast<const uint8_t*>(ekm.data()), |
| 160 ekm.size())) { | 160 ekm.size())) { |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace net | 166 } // namespace net |
| OLD | NEW |