| 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/chromium/crypto/proof_source_chromium.h" | 5 #include "net/quic/chromium/crypto/proof_source_chromium.h" |
| 6 | 6 |
| 7 #include <openssl/digest.h> | 7 #include <openssl/digest.h> |
| 8 #include <openssl/evp.h> | 8 #include <openssl/evp.h> |
| 9 #include <openssl/rsa.h> | 9 #include <openssl/rsa.h> |
| 10 | 10 |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "crypto/openssl_util.h" | 12 #include "crypto/openssl_util.h" |
| 13 #include "net/quic/core/crypto/crypto_protocol.h" | 13 #include "net/quic/core/crypto/crypto_protocol.h" |
| 14 #include "net/ssl/scoped_openssl_types.h" | |
| 15 | 14 |
| 16 using std::string; | 15 using std::string; |
| 17 using std::vector; | 16 using std::vector; |
| 18 | 17 |
| 19 namespace net { | 18 namespace net { |
| 20 | 19 |
| 21 ProofSourceChromium::ProofSourceChromium() {} | 20 ProofSourceChromium::ProofSourceChromium() {} |
| 22 | 21 |
| 23 ProofSourceChromium::~ProofSourceChromium() {} | 22 ProofSourceChromium::~ProofSourceChromium() {} |
| 24 | 23 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const string& hostname, | 82 const string& hostname, |
| 84 const string& server_config, | 83 const string& server_config, |
| 85 QuicVersion quic_version, | 84 QuicVersion quic_version, |
| 86 base::StringPiece chlo_hash, | 85 base::StringPiece chlo_hash, |
| 87 scoped_refptr<ProofSource::Chain>* out_chain, | 86 scoped_refptr<ProofSource::Chain>* out_chain, |
| 88 string* out_signature, | 87 string* out_signature, |
| 89 string* out_leaf_cert_sct) { | 88 string* out_leaf_cert_sct) { |
| 90 DCHECK(private_key_.get()) << " this: " << this; | 89 DCHECK(private_key_.get()) << " this: " << this; |
| 91 | 90 |
| 92 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 91 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 93 crypto::ScopedEVP_MD_CTX sign_context(EVP_MD_CTX_create()); | 92 bssl::ScopedEVP_MD_CTX sign_context; |
| 94 EVP_PKEY_CTX* pkey_ctx; | 93 EVP_PKEY_CTX* pkey_ctx; |
| 95 | 94 |
| 96 if (quic_version > QUIC_VERSION_30) { | 95 if (quic_version > QUIC_VERSION_30) { |
| 97 uint32_t len = chlo_hash.length(); | 96 uint32_t len = chlo_hash.length(); |
| 98 if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(), | 97 if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(), |
| 99 nullptr, private_key_->key()) || | 98 nullptr, private_key_->key()) || |
| 100 !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || | 99 !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
| 101 !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) || | 100 !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) || |
| 102 !EVP_DigestSignUpdate( | 101 !EVP_DigestSignUpdate( |
| 103 sign_context.get(), | 102 sign_context.get(), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // GetProof, then invoke the callback with the results and destroy it. | 159 // GetProof, then invoke the callback with the results and destroy it. |
| 161 scoped_refptr<ProofSource::Chain> chain; | 160 scoped_refptr<ProofSource::Chain> chain; |
| 162 string signature; | 161 string signature; |
| 163 string leaf_cert_sct; | 162 string leaf_cert_sct; |
| 164 const bool ok = GetProof(server_ip, hostname, server_config, quic_version, | 163 const bool ok = GetProof(server_ip, hostname, server_config, quic_version, |
| 165 chlo_hash, &chain, &signature, &leaf_cert_sct); | 164 chlo_hash, &chain, &signature, &leaf_cert_sct); |
| 166 callback->Run(ok, chain, signature, leaf_cert_sct, nullptr /* details */); | 165 callback->Run(ok, chain, signature, leaf_cert_sct, nullptr /* details */); |
| 167 } | 166 } |
| 168 | 167 |
| 169 } // namespace net | 168 } // namespace net |
| OLD | NEW |