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

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

Issue 8381017: net: retain leading zero bytes in X.509 serial numbers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <nss.h> 9 #include <nss.h>
10 #include <pk11pub.h> 10 #include <pk11pub.h>
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 ParsePrincipal(&cert_handle_->issuer, &issuer_); 674 ParsePrincipal(&cert_handle_->issuer, &issuer_);
675 675
676 ParseDate(&cert_handle_->validity.notBefore, &valid_start_); 676 ParseDate(&cert_handle_->validity.notBefore, &valid_start_);
677 ParseDate(&cert_handle_->validity.notAfter, &valid_expiry_); 677 ParseDate(&cert_handle_->validity.notAfter, &valid_expiry_);
678 678
679 fingerprint_ = CalculateFingerprint(cert_handle_); 679 fingerprint_ = CalculateFingerprint(cert_handle_);
680 680
681 serial_number_ = std::string( 681 serial_number_ = std::string(
682 reinterpret_cast<char*>(cert_handle_->serialNumber.data), 682 reinterpret_cast<char*>(cert_handle_->serialNumber.data),
683 cert_handle_->serialNumber.len); 683 cert_handle_->serialNumber.len);
684 // Remove leading zeros.
685 while (serial_number_.size() > 1 && serial_number_[0] == 0)
686 serial_number_ = serial_number_.substr(1, serial_number_.size() - 1);
687 } 684 }
688 685
689 // static 686 // static
690 X509Certificate* X509Certificate::CreateSelfSigned( 687 X509Certificate* X509Certificate::CreateSelfSigned(
691 crypto::RSAPrivateKey* key, 688 crypto::RSAPrivateKey* key,
692 const std::string& subject, 689 const std::string& subject,
693 uint32 serial_number, 690 uint32 serial_number,
694 base::TimeDelta valid_duration) { 691 base::TimeDelta valid_duration) {
695 DCHECK(key); 692 DCHECK(key);
696 693
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 1016
1020 // static 1017 // static
1021 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, 1018 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle,
1022 Pickle* pickle) { 1019 Pickle* pickle) {
1023 return pickle->WriteData( 1020 return pickle->WriteData(
1024 reinterpret_cast<const char*>(cert_handle->derCert.data), 1021 reinterpret_cast<const char*>(cert_handle->derCert.data),
1025 cert_handle->derCert.len); 1022 cert_handle->derCert.len);
1026 } 1023 }
1027 1024
1028 } // namespace net 1025 } // 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