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

Side by Side Diff: net/base/x509_certificate_win.cc

Issue 10883012: net: don't crash when processing a certificate with an unknown public key. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/base/x509_certificate_openssl.cc ('k') | no next file » | 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/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. 7 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS.
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 Pickle* pickle) { 421 Pickle* pickle) {
422 return pickle->WriteData( 422 return pickle->WriteData(
423 reinterpret_cast<char*>(cert_handle->pbCertEncoded), 423 reinterpret_cast<char*>(cert_handle->pbCertEncoded),
424 cert_handle->cbCertEncoded); 424 cert_handle->cbCertEncoded);
425 } 425 }
426 426
427 // static 427 // static
428 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, 428 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle,
429 size_t* size_bits, 429 size_t* size_bits,
430 PublicKeyType* type) { 430 PublicKeyType* type) {
431 *type = kPublicKeyTypeUnknown;
432 *size_bits = 0;
433
431 PCCRYPT_OID_INFO oid_info = CryptFindOIDInfo( 434 PCCRYPT_OID_INFO oid_info = CryptFindOIDInfo(
432 CRYPT_OID_INFO_OID_KEY, 435 CRYPT_OID_INFO_OID_KEY,
433 cert_handle->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId, 436 cert_handle->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId,
434 CRYPT_PUBKEY_ALG_OID_GROUP_ID); 437 CRYPT_PUBKEY_ALG_OID_GROUP_ID);
435 PCHECK(oid_info); 438 if (!oid_info)
436 CHECK(oid_info->dwGroupId == CRYPT_PUBKEY_ALG_OID_GROUP_ID); 439 return;
440
441 CHECK_EQ(oid_info->dwGroupId,
442 static_cast<DWORD>(CRYPT_PUBKEY_ALG_OID_GROUP_ID));
437 443
438 *size_bits = CertGetPublicKeyLength( 444 *size_bits = CertGetPublicKeyLength(
439 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 445 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
440 &cert_handle->pCertInfo->SubjectPublicKeyInfo); 446 &cert_handle->pCertInfo->SubjectPublicKeyInfo);
441 447
442 switch (oid_info->Algid) { 448 switch (oid_info->Algid) {
443 case CALG_RSA_SIGN: 449 case CALG_RSA_SIGN:
444 case CALG_RSA_KEYX: 450 case CALG_RSA_KEYX:
445 *type = kPublicKeyTypeRSA; 451 *type = kPublicKeyTypeRSA;
446 break; 452 break;
447 case CALG_DSS_SIGN: 453 case CALG_DSS_SIGN:
448 *type = kPublicKeyTypeDSA; 454 *type = kPublicKeyTypeDSA;
449 break; 455 break;
450 case CALG_ECDSA: 456 case CALG_ECDSA:
451 *type = kPublicKeyTypeECDSA; 457 *type = kPublicKeyTypeECDSA;
452 break; 458 break;
453 case CALG_ECDH: 459 case CALG_ECDH:
454 *type = kPublicKeyTypeECDH; 460 *type = kPublicKeyTypeECDH;
455 break; 461 break;
456 default:
457 *type = kPublicKeyTypeUnknown;
458 *size_bits = 0;
459 break;
460 } 462 }
461 } 463 }
462 464
463 } // namespace net 465 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698