| Index: net/cert/x509_certificate_mac.cc
|
| diff --git a/net/cert/x509_certificate_mac.cc b/net/cert/x509_certificate_mac.cc
|
| index ab479384a170010e9c850195634bd2673c8bb400..48e11667bce9df8a838e2da2b6936428311a3306 100644
|
| --- a/net/cert/x509_certificate_mac.cc
|
| +++ b/net/cert/x509_certificate_mac.cc
|
| @@ -50,8 +50,8 @@ bool IsCertIssuerInEncodedList(X509Certificate::OSCertHandle cert_handle,
|
| return false;
|
|
|
| x509_util::CSSMFieldValue distinguished_name;
|
| - OSStatus status = cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd,
|
| - &distinguished_name);
|
| + OSStatus status =
|
| + cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd, &distinguished_name);
|
| if (status || !distinguished_name.field())
|
| return false;
|
|
|
| @@ -60,7 +60,8 @@ bool IsCertIssuerInEncodedList(X509Certificate::OSCertHandle cert_handle,
|
| static_cast<size_t>(distinguished_name.field()->Length));
|
|
|
| for (std::vector<std::string>::const_iterator it = issuers.begin();
|
| - it != issuers.end(); ++it) {
|
| + it != issuers.end();
|
| + ++it) {
|
| base::StringPiece issuer_piece(*it);
|
| if (name_piece == issuer_piece)
|
| return true;
|
| @@ -82,16 +83,16 @@ void GetCertDateForOID(const x509_util::CSSMCachedCertificate& cached_cert,
|
| const CSSM_X509_TIME* x509_time = field.GetAs<CSSM_X509_TIME>();
|
| if (x509_time->timeType != BER_TAG_UTC_TIME &&
|
| x509_time->timeType != BER_TAG_GENERALIZED_TIME) {
|
| - LOG(ERROR) << "Unsupported date/time format "
|
| - << x509_time->timeType;
|
| + LOG(ERROR) << "Unsupported date/time format " << x509_time->timeType;
|
| return;
|
| }
|
|
|
| base::StringPiece time_string(
|
| reinterpret_cast<const char*>(x509_time->time.Data),
|
| x509_time->time.Length);
|
| - CertDateFormat format = x509_time->timeType == BER_TAG_UTC_TIME ?
|
| - CERT_DATE_FORMAT_UTC_TIME : CERT_DATE_FORMAT_GENERALIZED_TIME;
|
| + CertDateFormat format = x509_time->timeType == BER_TAG_UTC_TIME
|
| + ? CERT_DATE_FORMAT_UTC_TIME
|
| + : CERT_DATE_FORMAT_GENERALIZED_TIME;
|
| if (!ParseCertificateDate(time_string, format, result))
|
| LOG(ERROR) << "Invalid certificate date/time " << time_string;
|
| }
|
| @@ -99,14 +100,13 @@ void GetCertDateForOID(const x509_util::CSSMCachedCertificate& cached_cert,
|
| std::string GetCertSerialNumber(
|
| const x509_util::CSSMCachedCertificate& cached_cert) {
|
| x509_util::CSSMFieldValue serial_number;
|
| - OSStatus status = cached_cert.GetField(&CSSMOID_X509V1SerialNumber,
|
| - &serial_number);
|
| + OSStatus status =
|
| + cached_cert.GetField(&CSSMOID_X509V1SerialNumber, &serial_number);
|
| if (status || !serial_number.field())
|
| return std::string();
|
|
|
| - return std::string(
|
| - reinterpret_cast<const char*>(serial_number.field()->Data),
|
| - serial_number.field()->Length);
|
| + return std::string(reinterpret_cast<const char*>(serial_number.field()->Data),
|
| + serial_number.field()->Length);
|
| }
|
|
|
| // Returns true if |purpose| is listed as allowed in |usage|. This
|
| @@ -143,20 +143,23 @@ bool IsValidOSCertHandle(SecCertificateRef cert_handle) {
|
| // Parses |data| of length |length|, attempting to decode it as the specified
|
| // |format|. If |data| is in the specified format, any certificates contained
|
| // within are stored into |output|.
|
| -void AddCertificatesFromBytes(const char* data, size_t length,
|
| +void AddCertificatesFromBytes(const char* data,
|
| + size_t length,
|
| SecExternalFormat format,
|
| X509Certificate::OSCertHandles* output) {
|
| SecExternalFormat input_format = format;
|
| - ScopedCFTypeRef<CFDataRef> local_data(CFDataCreateWithBytesNoCopy(
|
| - kCFAllocatorDefault, reinterpret_cast<const UInt8*>(data), length,
|
| - kCFAllocatorNull));
|
| + ScopedCFTypeRef<CFDataRef> local_data(
|
| + CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
|
| + reinterpret_cast<const UInt8*>(data),
|
| + length,
|
| + kCFAllocatorNull));
|
|
|
| CFArrayRef items = NULL;
|
| OSStatus status;
|
| {
|
| base::AutoLock lock(crypto::GetMacSecurityServicesLock());
|
| - status = SecKeychainItemImport(local_data, NULL, &input_format,
|
| - NULL, 0, NULL, NULL, &items);
|
| + status = SecKeychainItemImport(
|
| + local_data, NULL, &input_format, NULL, 0, NULL, NULL, &items);
|
| }
|
|
|
| if (status) {
|
| @@ -201,14 +204,14 @@ void AddCertificatesFromBytes(const char* data, size_t length,
|
| void X509Certificate::Initialize() {
|
| x509_util::CSSMCachedCertificate cached_cert;
|
| if (cached_cert.Init(cert_handle_) == CSSM_OK) {
|
| - GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1SubjectNameStd,
|
| - &subject_);
|
| - GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1IssuerNameStd,
|
| - &issuer_);
|
| - GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotBefore,
|
| - &valid_start_);
|
| - GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotAfter,
|
| - &valid_expiry_);
|
| + GetCertDistinguishedName(
|
| + cached_cert, &CSSMOID_X509V1SubjectNameStd, &subject_);
|
| + GetCertDistinguishedName(
|
| + cached_cert, &CSSMOID_X509V1IssuerNameStd, &issuer_);
|
| + GetCertDateForOID(
|
| + cached_cert, &CSSMOID_X509V1ValidityNotBefore, &valid_start_);
|
| + GetCertDateForOID(
|
| + cached_cert, &CSSMOID_X509V1ValidityNotAfter, &valid_expiry_);
|
| serial_number_ = GetCertSerialNumber(cached_cert);
|
| }
|
|
|
| @@ -222,7 +225,8 @@ bool X509Certificate::IsIssuedByEncoded(
|
| return true;
|
|
|
| for (OSCertHandles::iterator it = intermediate_ca_certs_.begin();
|
| - it != intermediate_ca_certs_.end(); ++it) {
|
| + it != intermediate_ca_certs_.end();
|
| + ++it) {
|
| if (IsCertIssuerInEncodedList(*it, valid_issuers))
|
| return true;
|
| }
|
| @@ -260,12 +264,10 @@ void X509Certificate::GetSubjectAltName(
|
| // CSSM_DATA::data into the appropriate output vector.
|
| if (dns_names && name_struct.nameType == GNT_DNSName) {
|
| dns_names->push_back(std::string(
|
| - reinterpret_cast<const char*>(name_data.Data),
|
| - name_data.Length));
|
| + reinterpret_cast<const char*>(name_data.Data), name_data.Length));
|
| } else if (ip_addrs && name_struct.nameType == GNT_IPAddress) {
|
| ip_addrs->push_back(std::string(
|
| - reinterpret_cast<const char*>(name_data.Data),
|
| - name_data.Length));
|
| + reinterpret_cast<const char*>(name_data.Data), name_data.Length));
|
| }
|
| }
|
| }
|
| @@ -276,8 +278,7 @@ bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle,
|
| CSSM_DATA der_data;
|
| if (SecCertificateGetData(cert_handle, &der_data) != noErr)
|
| return false;
|
| - encoded->assign(reinterpret_cast<char*>(der_data.Data),
|
| - der_data.Length);
|
| + encoded->assign(reinterpret_cast<char*>(der_data.Data), der_data.Length);
|
| return true;
|
| }
|
|
|
| @@ -291,23 +292,22 @@ bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a,
|
| return true;
|
| CSSM_DATA a_data, b_data;
|
| return SecCertificateGetData(a, &a_data) == noErr &&
|
| - SecCertificateGetData(b, &b_data) == noErr &&
|
| - a_data.Length == b_data.Length &&
|
| - memcmp(a_data.Data, b_data.Data, a_data.Length) == 0;
|
| + SecCertificateGetData(b, &b_data) == noErr &&
|
| + a_data.Length == b_data.Length &&
|
| + memcmp(a_data.Data, b_data.Data, a_data.Length) == 0;
|
| }
|
|
|
| // static
|
| X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
|
| - const char* data, int length) {
|
| + const char* data,
|
| + int length) {
|
| CSSM_DATA cert_data;
|
| cert_data.Data = const_cast<uint8*>(reinterpret_cast<const uint8*>(data));
|
| cert_data.Length = length;
|
|
|
| OSCertHandle cert_handle = NULL;
|
| - OSStatus status = SecCertificateCreateFromData(&cert_data,
|
| - CSSM_CERT_X_509v3,
|
| - CSSM_CERT_ENCODING_DER,
|
| - &cert_handle);
|
| + OSStatus status = SecCertificateCreateFromData(
|
| + &cert_data, CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_DER, &cert_handle);
|
| if (status != noErr)
|
| return NULL;
|
| if (!IsValidOSCertHandle(cert_handle)) {
|
| @@ -319,7 +319,9 @@ X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
|
|
|
| // static
|
| X509Certificate::OSCertHandles X509Certificate::CreateOSCertHandlesFromBytes(
|
| - const char* data, int length, Format format) {
|
| + const char* data,
|
| + int length,
|
| + Format format) {
|
| OSCertHandles results;
|
|
|
| switch (format) {
|
| @@ -354,8 +356,7 @@ void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) {
|
| }
|
|
|
| // static
|
| -SHA1HashValue X509Certificate::CalculateFingerprint(
|
| - OSCertHandle cert) {
|
| +SHA1HashValue X509Certificate::CalculateFingerprint(OSCertHandle cert) {
|
| SHA1HashValue sha1;
|
| memset(sha1.data, 0, sizeof(sha1.data));
|
|
|
| @@ -432,8 +433,7 @@ bool X509Certificate::SupportsSSLClientAuth() const {
|
|
|
| CFArrayRef X509Certificate::CreateOSCertChainForCert() const {
|
| CFMutableArrayRef cert_list =
|
| - CFArrayCreateMutable(kCFAllocatorDefault, 0,
|
| - &kCFTypeArrayCallBacks);
|
| + CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
|
| if (!cert_list)
|
| return NULL;
|
|
|
| @@ -445,8 +445,8 @@ CFArrayRef X509Certificate::CreateOSCertChainForCert() const {
|
| }
|
|
|
| // static
|
| -X509Certificate::OSCertHandle
|
| -X509Certificate::ReadOSCertHandleFromPickle(PickleIterator* pickle_iter) {
|
| +X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle(
|
| + PickleIterator* pickle_iter) {
|
| const char* data;
|
| int length;
|
| if (!pickle_iter->ReadData(&data, &length))
|
|
|