Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: net/quic/crypto/proof_source_chromium_openssl.cc

Issue 1765603002: Add QUIC 31 in which the server's proof covers both the static server config as well as a hash of t… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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/crypto/proof_source_chromium_nss.cc ('k') | net/quic/crypto/proof_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/crypto/proof_source_chromium.h" 5 #include "net/quic/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
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 DLOG(FATAL) << "Unable to read signed certificate timestamp."; 75 DLOG(FATAL) << "Unable to read signed certificate timestamp.";
76 return false; 76 return false;
77 } 77 }
78 78
79 return true; 79 return true;
80 } 80 }
81 81
82 bool ProofSourceChromium::GetProof(const IPAddress& server_ip, 82 bool ProofSourceChromium::GetProof(const IPAddress& server_ip,
83 const string& hostname, 83 const string& hostname,
84 const string& server_config, 84 const string& server_config,
85 QuicVersion quic_version,
86 base::StringPiece chlo_hash,
85 bool ecdsa_ok, 87 bool ecdsa_ok,
86 scoped_refptr<ProofSource::Chain>* out_chain, 88 scoped_refptr<ProofSource::Chain>* out_chain,
87 string* out_signature, 89 string* out_signature,
88 string* out_leaf_cert_sct) { 90 string* out_leaf_cert_sct) {
89 DCHECK(private_key_.get()) << " this: " << this; 91 DCHECK(private_key_.get()) << " this: " << this;
90 92
91 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 93 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
92 crypto::ScopedEVP_MD_CTX sign_context(EVP_MD_CTX_create()); 94 crypto::ScopedEVP_MD_CTX sign_context(EVP_MD_CTX_create());
93 EVP_PKEY_CTX* pkey_ctx; 95 EVP_PKEY_CTX* pkey_ctx;
94 if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(), nullptr, 96
95 private_key_->key()) || 97 if (quic_version > QUIC_VERSION_30) {
96 !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || 98 uint32_t len = chlo_hash.length();
97 !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) || 99 if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(),
98 !EVP_DigestSignUpdate( 100 nullptr, private_key_->key()) ||
99 sign_context.get(), 101 !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) ||
100 reinterpret_cast<const uint8_t*>(kProofSignatureLabel), 102 !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) ||
101 sizeof(kProofSignatureLabel)) || 103 !EVP_DigestSignUpdate(
102 !EVP_DigestSignUpdate( 104 sign_context.get(),
103 sign_context.get(), 105 reinterpret_cast<const uint8_t*>(kProofSignatureLabel),
104 reinterpret_cast<const uint8_t*>(server_config.data()), 106 sizeof(kProofSignatureLabel)) ||
105 server_config.size())) { 107 !EVP_DigestSignUpdate(sign_context.get(),
108 reinterpret_cast<const uint8_t*>(&len),
109 sizeof(len)) ||
110 !EVP_DigestSignUpdate(
111 sign_context.get(),
112 reinterpret_cast<const uint8_t*>(chlo_hash.data()), len) ||
113 !EVP_DigestSignUpdate(
114 sign_context.get(),
115 reinterpret_cast<const uint8_t*>(server_config.data()),
116 server_config.size())) {
117 return false;
118 }
119 } else if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(),
120 nullptr, private_key_->key()) ||
121 !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) ||
122 !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) ||
123 !EVP_DigestSignUpdate(
124 sign_context.get(),
125 reinterpret_cast<const uint8_t*>(kProofSignatureLabelOld),
126 sizeof(kProofSignatureLabelOld)) ||
127 !EVP_DigestSignUpdate(
128 sign_context.get(),
129 reinterpret_cast<const uint8_t*>(server_config.data()),
130 server_config.size())) {
106 return false; 131 return false;
107 } 132 }
108 133
109 // Determine the maximum length of the signature. 134 // Determine the maximum length of the signature.
110 size_t len = 0; 135 size_t len = 0;
111 if (!EVP_DigestSignFinal(sign_context.get(), nullptr, &len)) { 136 if (!EVP_DigestSignFinal(sign_context.get(), nullptr, &len)) {
112 return false; 137 return false;
113 } 138 }
114 std::vector<uint8_t> signature(len); 139 std::vector<uint8_t> signature(len);
115 // Sign it. 140 // Sign it.
116 if (!EVP_DigestSignFinal(sign_context.get(), signature.data(), &len)) { 141 if (!EVP_DigestSignFinal(sign_context.get(), signature.data(), &len)) {
117 return false; 142 return false;
118 } 143 }
119 signature.resize(len); 144 signature.resize(len);
120 out_signature->assign(reinterpret_cast<const char*>(signature.data()), 145 out_signature->assign(reinterpret_cast<const char*>(signature.data()),
121 signature.size()); 146 signature.size());
122 *out_chain = chain_; 147 *out_chain = chain_;
123 VLOG(1) << "signature: " 148 VLOG(1) << "signature: "
124 << base::HexEncode(out_signature->data(), out_signature->size()); 149 << base::HexEncode(out_signature->data(), out_signature->size());
125 *out_leaf_cert_sct = signed_certificate_timestamp_; 150 *out_leaf_cert_sct = signed_certificate_timestamp_;
126 return true; 151 return true;
127 } 152 }
128 153
129 } // namespace net 154 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/proof_source_chromium_nss.cc ('k') | net/quic/crypto/proof_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698