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

Side by Side Diff: net/cert/x509_certificate_openssl.cc

Issue 2610903003: [refactor] Extract the CertVerifyResult assignment of has_md2, has_md4, (Closed)
Patch Set: address comments Created 3 years, 11 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/cert/x509_certificate_nss.cc ('k') | net/cert/x509_certificate_win.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 (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_certificate.h" 5 #include "net/cert/x509_certificate.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 *type = kPublicKeyTypeECDSA; 370 *type = kPublicKeyTypeECDSA;
371 *size_bits = EVP_PKEY_bits(key); 371 *size_bits = EVP_PKEY_bits(key);
372 break; 372 break;
373 case EVP_PKEY_DH: 373 case EVP_PKEY_DH:
374 *type = kPublicKeyTypeDH; 374 *type = kPublicKeyTypeDH;
375 *size_bits = EVP_PKEY_size(key) * 8; 375 *size_bits = EVP_PKEY_size(key) * 8;
376 break; 376 break;
377 } 377 }
378 } 378 }
379 379
380 // static
381 X509Certificate::SignatureHashAlgorithm
382 X509Certificate::GetSignatureHashAlgorithm(OSCertHandle cert_handle) {
383 int sig_alg = OBJ_obj2nid(cert_handle->sig_alg->algorithm);
384 if (sig_alg == NID_md2WithRSAEncryption)
385 return kSignatureHashAlgorithmMd2;
386 if (sig_alg == NID_md4WithRSAEncryption)
387 return kSignatureHashAlgorithmMd4;
388 if (sig_alg == NID_md5WithRSAEncryption || sig_alg == NID_md5WithRSA)
389 return kSignatureHashAlgorithmMd5;
390 if (sig_alg == NID_sha1WithRSAEncryption || sig_alg == NID_dsaWithSHA ||
391 sig_alg == NID_dsaWithSHA1 || sig_alg == NID_dsaWithSHA1_2 ||
392 sig_alg == NID_sha1WithRSA || sig_alg == NID_ecdsa_with_SHA1) {
393 return kSignatureHashAlgorithmSha1;
394 }
395 return kSignatureHashAlgorithmOther;
396 }
397
380 bool X509Certificate::IsIssuedByEncoded( 398 bool X509Certificate::IsIssuedByEncoded(
381 const std::vector<std::string>& valid_issuers) { 399 const std::vector<std::string>& valid_issuers) {
382 if (valid_issuers.empty()) 400 if (valid_issuers.empty())
383 return false; 401 return false;
384 402
385 // Convert to a temporary list of X509_NAME objects. 403 // Convert to a temporary list of X509_NAME objects.
386 // It will own the objects it points to. 404 // It will own the objects it points to.
387 bssl::UniquePtr<STACK_OF(X509_NAME)> issuer_names(sk_X509_NAME_new_null()); 405 bssl::UniquePtr<STACK_OF(X509_NAME)> issuer_names(sk_X509_NAME_new_null());
388 if (!issuer_names.get()) 406 if (!issuer_names.get())
389 return false; 407 return false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { 450 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) {
433 bssl::UniquePtr<EVP_PKEY> scoped_key(X509_get_pubkey(cert_handle)); 451 bssl::UniquePtr<EVP_PKEY> scoped_key(X509_get_pubkey(cert_handle));
434 if (!scoped_key) 452 if (!scoped_key)
435 return false; 453 return false;
436 if (!X509_verify(cert_handle, scoped_key.get())) 454 if (!X509_verify(cert_handle, scoped_key.get()))
437 return false; 455 return false;
438 return X509_check_issued(cert_handle, cert_handle) == X509_V_OK; 456 return X509_check_issued(cert_handle, cert_handle) == X509_V_OK;
439 } 457 }
440 458
441 } // namespace net 459 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_nss.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698