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

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

Issue 10836150: Revert 150375 - Implement SHA-256 fingerprint support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « net/base/x509_certificate_mac.cc ('k') | net/base/x509_certificate_openssl.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/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <cryptohi.h> 8 #include <cryptohi.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <nss.h> 10 #include <nss.h>
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 OSCertHandle cert_handle) { 377 OSCertHandle cert_handle) {
378 return CERT_DupCertificate(cert_handle); 378 return CERT_DupCertificate(cert_handle);
379 } 379 }
380 380
381 // static 381 // static
382 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { 382 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) {
383 CERT_DestroyCertificate(cert_handle); 383 CERT_DestroyCertificate(cert_handle);
384 } 384 }
385 385
386 // static 386 // static
387 SHA1HashValue X509Certificate::CalculateFingerprint( 387 SHA1Fingerprint X509Certificate::CalculateFingerprint(
388 OSCertHandle cert) { 388 OSCertHandle cert) {
389 SHA1HashValue sha1; 389 SHA1Fingerprint sha1;
390 memset(sha1.data, 0, sizeof(sha1.data)); 390 memset(sha1.data, 0, sizeof(sha1.data));
391 391
392 DCHECK(NULL != cert->derCert.data); 392 DCHECK(NULL != cert->derCert.data);
393 DCHECK_NE(0U, cert->derCert.len); 393 DCHECK_NE(0U, cert->derCert.len);
394 394
395 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, 395 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data,
396 cert->derCert.data, cert->derCert.len); 396 cert->derCert.data, cert->derCert.len);
397 DCHECK_EQ(SECSuccess, rv); 397 DCHECK_EQ(SECSuccess, rv);
398 398
399 return sha1; 399 return sha1;
400 } 400 }
401 401
402 // static 402 // static
403 SHA1HashValue X509Certificate::CalculateCAFingerprint( 403 SHA1Fingerprint X509Certificate::CalculateCAFingerprint(
404 const OSCertHandles& intermediates) { 404 const OSCertHandles& intermediates) {
405 SHA1HashValue sha1; 405 SHA1Fingerprint sha1;
406 memset(sha1.data, 0, sizeof(sha1.data)); 406 memset(sha1.data, 0, sizeof(sha1.data));
407 407
408 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1); 408 HASHContext* sha1_ctx = HASH_Create(HASH_AlgSHA1);
409 if (!sha1_ctx) 409 if (!sha1_ctx)
410 return sha1; 410 return sha1;
411 HASH_Begin(sha1_ctx); 411 HASH_Begin(sha1_ctx);
412 for (size_t i = 0; i < intermediates.size(); ++i) { 412 for (size_t i = 0; i < intermediates.size(); ++i) {
413 CERTCertificate* ca_cert = intermediates[i]; 413 CERTCertificate* ca_cert = intermediates[i];
414 HASH_Update(sha1_ctx, ca_cert->derCert.data, ca_cert->derCert.len); 414 HASH_Update(sha1_ctx, ca_cert->derCert.data, ca_cert->derCert.len);
415 } 415 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 *type = kPublicKeyTypeECDSA; 467 *type = kPublicKeyTypeECDSA;
468 break; 468 break;
469 default: 469 default:
470 *type = kPublicKeyTypeUnknown; 470 *type = kPublicKeyTypeUnknown;
471 *size_bits = 0; 471 *size_bits = 0;
472 break; 472 break;
473 } 473 }
474 } 474 }
475 475
476 } // namespace net 476 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate_mac.cc ('k') | net/base/x509_certificate_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698