|
24 | 24 | namespace owt { |
25 | 25 | namespace quic { |
26 | 26 |
|
27 | | -ProofSourceOwt::ProofSourceOwt() {} |
| 27 | +ProofSourceOwt::ProofSourceOwt() |
| 28 | + : private_key_(nullptr), ticket_crypter_(nullptr) {} |
28 | 29 |
|
29 | 30 | ProofSourceOwt::~ProofSourceOwt() {} |
30 | 31 |
|
@@ -72,7 +73,8 @@ bool ProofSourceOwt::Initialize(const base::FilePath& pfx_path, |
72 | 73 | } |
73 | 74 |
|
74 | 75 | chain_ = new ::quic::ProofSource::Chain(certs_string); |
75 | | - private_key_ = crypto::RSAPrivateKey::CreateFromKey(key); |
| 76 | + private_key_ = std::make_unique<::quic::CertificatePrivateKey>( |
| 77 | + bssl::UniquePtr<EVP_PKEY>(key)); |
76 | 78 | return true; |
77 | 79 | } |
78 | 80 |
|
@@ -101,18 +103,19 @@ bool ProofSourceOwt::GetProofInner( |
101 | 103 | ::quic::QuicCryptoProof* proof) { |
102 | 104 | // This function is copied from `ProofSourceChromium`, but `leaf_cert_scts` is |
103 | 105 | // not set. |
104 | | - DCHECK(proof != nullptr); |
105 | | - DCHECK(private_key_.get()) << " this: " << this; |
| 106 | + DCHECK(proof); |
| 107 | + DCHECK(private_key_); |
106 | 108 |
|
107 | 109 | crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
108 | 110 | bssl::ScopedEVP_MD_CTX sign_context; |
109 | 111 | EVP_PKEY_CTX* pkey_ctx; |
110 | 112 |
|
111 | 113 | uint32_t len_tmp = chlo_hash.length(); |
112 | 114 | if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(), nullptr, |
113 | | - private_key_->key()) || |
114 | | - !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
115 | | - !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) || |
| 115 | + private_key_->private_key()) || |
| 116 | + (EVP_PKEY_id(private_key_->private_key()) == EVP_PKEY_RSA && |
| 117 | + (!EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
| 118 | + !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1))) || |
116 | 119 | !EVP_DigestSignUpdate( |
117 | 120 | sign_context.get(), |
118 | 121 | reinterpret_cast<const uint8_t*>(::quic::kProofSignatureLabel), |
@@ -198,9 +201,10 @@ void ProofSourceOwt::ComputeTlsSignature( |
198 | 201 | size_t siglen; |
199 | 202 | std::string sig; |
200 | 203 | if (!EVP_DigestSignInit(sign_context.get(), &pkey_ctx, EVP_sha256(), nullptr, |
201 | | - private_key_->key()) || |
202 | | - !EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
203 | | - !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1) || |
| 204 | + private_key_->private_key()) || |
| 205 | + (EVP_PKEY_id(private_key_->private_key()) == EVP_PKEY_RSA && |
| 206 | + (!EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) || |
| 207 | + !EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, -1))) || |
204 | 208 | !EVP_DigestSignUpdate(sign_context.get(), |
205 | 209 | reinterpret_cast<const uint8_t*>(in.data()), |
206 | 210 | in.size()) || |
|
0 commit comments