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

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: g try Created 8 years, 4 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
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)
439 return;
440
436 CHECK(oid_info->dwGroupId == CRYPT_PUBKEY_ALG_OID_GROUP_ID); 441 CHECK(oid_info->dwGroupId == CRYPT_PUBKEY_ALG_OID_GROUP_ID);
Ryan Sleevi 2012/08/23 20:48:59 nit: While you're here, CHECK_EQ ?
agl 2012/08/24 13:46:17 Done.
437 442
438 *size_bits = CertGetPublicKeyLength( 443 *size_bits = CertGetPublicKeyLength(
439 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 444 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
440 &cert_handle->pCertInfo->SubjectPublicKeyInfo); 445 &cert_handle->pCertInfo->SubjectPublicKeyInfo);
441 446
442 switch (oid_info->Algid) { 447 switch (oid_info->Algid) {
443 case CALG_RSA_SIGN: 448 case CALG_RSA_SIGN:
444 case CALG_RSA_KEYX: 449 case CALG_RSA_KEYX:
445 *type = kPublicKeyTypeRSA; 450 *type = kPublicKeyTypeRSA;
446 break; 451 break;
447 case CALG_DSS_SIGN: 452 case CALG_DSS_SIGN:
448 *type = kPublicKeyTypeDSA; 453 *type = kPublicKeyTypeDSA;
449 break; 454 break;
450 case CALG_ECDSA: 455 case CALG_ECDSA:
451 *type = kPublicKeyTypeECDSA; 456 *type = kPublicKeyTypeECDSA;
452 break; 457 break;
453 case CALG_ECDH: 458 case CALG_ECDH:
454 *type = kPublicKeyTypeECDH; 459 *type = kPublicKeyTypeECDH;
455 break; 460 break;
456 default:
457 *type = kPublicKeyTypeUnknown;
458 *size_bits = 0;
459 break;
460 } 461 }
461 } 462 }
462 463
463 } // namespace net 464 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698