| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/x509_util_openssl.h" | 5 #include "net/cert/x509_util_openssl.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <openssl/asn1.h> | 8 #include <openssl/asn1.h> |
| 9 #include <openssl/digest.h> | 9 #include <openssl/digest.h> |
| 10 #include <openssl/mem.h> | 10 #include <openssl/mem.h> |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 bool GetTLSServerEndPointChannelBinding(const X509Certificate& certificate, | 311 bool GetTLSServerEndPointChannelBinding(const X509Certificate& certificate, |
| 312 std::string* token) { | 312 std::string* token) { |
| 313 static const char kChannelBindingPrefix[] = "tls-server-end-point:"; | 313 static const char kChannelBindingPrefix[] = "tls-server-end-point:"; |
| 314 | 314 |
| 315 std::string der_encoded_certificate; | 315 std::string der_encoded_certificate; |
| 316 if (!X509Certificate::GetDEREncoded(certificate.os_cert_handle(), | 316 if (!X509Certificate::GetDEREncoded(certificate.os_cert_handle(), |
| 317 &der_encoded_certificate)) | 317 &der_encoded_certificate)) |
| 318 return false; | 318 return false; |
| 319 | 319 |
| 320 ParsedCertificate parsed_certificate; | 320 der::Input tbs_certificate_tlv; |
| 321 if (!ParseCertificate(der::Input(base::StringPiece(der_encoded_certificate)), | 321 der::Input signature_algorithm_tlv; |
| 322 &parsed_certificate)) | 322 der::BitString signature_value; |
| 323 if (!ParseCertificate(der::Input(&der_encoded_certificate), |
| 324 &tbs_certificate_tlv, &signature_algorithm_tlv, |
| 325 &signature_value)) |
| 323 return false; | 326 return false; |
| 324 | 327 |
| 325 std::unique_ptr<SignatureAlgorithm> signature_algorithm = | 328 std::unique_ptr<SignatureAlgorithm> signature_algorithm = |
| 326 SignatureAlgorithm::CreateFromDer( | 329 SignatureAlgorithm::CreateFromDer(signature_algorithm_tlv); |
| 327 parsed_certificate.signature_algorithm_tlv); | |
| 328 if (!signature_algorithm) | 330 if (!signature_algorithm) |
| 329 return false; | 331 return false; |
| 330 | 332 |
| 331 const EVP_MD* digest_evp_md = nullptr; | 333 const EVP_MD* digest_evp_md = nullptr; |
| 332 switch (signature_algorithm->digest()) { | 334 switch (signature_algorithm->digest()) { |
| 333 case net::DigestAlgorithm::Sha1: | 335 case net::DigestAlgorithm::Sha1: |
| 334 case net::DigestAlgorithm::Sha256: | 336 case net::DigestAlgorithm::Sha256: |
| 335 digest_evp_md = EVP_sha256(); | 337 digest_evp_md = EVP_sha256(); |
| 336 break; | 338 break; |
| 337 | 339 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 355 | 357 |
| 356 digest.resize(out_size); | 358 digest.resize(out_size); |
| 357 token->assign(kChannelBindingPrefix); | 359 token->assign(kChannelBindingPrefix); |
| 358 token->append(digest.begin(), digest.end()); | 360 token->append(digest.begin(), digest.end()); |
| 359 return true; | 361 return true; |
| 360 } | 362 } |
| 361 | 363 |
| 362 } // namespace x509_util | 364 } // namespace x509_util |
| 363 | 365 |
| 364 } // namespace net | 366 } // namespace net |
| OLD | NEW |