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

Side by Side Diff: net/base/x509_certificate_mac.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, 2 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) 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 <CommonCrypto/CommonDigest.h> 7 #include <CommonCrypto/CommonDigest.h>
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 #include <Security/Security.h> 9 #include <Security/Security.h>
10 #include <time.h> 10 #include <time.h>
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (!CSSMOIDEqual(&fields.fields[field].FieldOid, 196 if (!CSSMOIDEqual(&fields.fields[field].FieldOid,
197 &CSSMOID_X509V1SerialNumber)) { 197 &CSSMOID_X509V1SerialNumber)) {
198 continue; 198 continue;
199 } 199 }
200 ret.assign( 200 ret.assign(
201 reinterpret_cast<char*>(fields.fields[field].FieldValue.Data), 201 reinterpret_cast<char*>(fields.fields[field].FieldValue.Data),
202 fields.fields[field].FieldValue.Length); 202 fields.fields[field].FieldValue.Length);
203 break; 203 break;
204 } 204 }
205 205
206 // Remove leading zeros.
207 while (ret.size() > 1 && ret[0] == 0)
208 ret = ret.substr(1, ret.size() - 1);
209
210 return ret; 206 return ret;
211 } 207 }
212 208
213 // Creates a SecPolicyRef for the given OID, with optional value. 209 // Creates a SecPolicyRef for the given OID, with optional value.
214 OSStatus CreatePolicy(const CSSM_OID* policy_OID, 210 OSStatus CreatePolicy(const CSSM_OID* policy_OID,
215 void* option_data, 211 void* option_data,
216 size_t option_length, 212 size_t option_length,
217 SecPolicyRef* policy) { 213 SecPolicyRef* policy) {
218 SecPolicySearchRef search; 214 SecPolicySearchRef search;
219 OSStatus err = SecPolicySearchCreate(CSSM_CERT_X_509v3, policy_OID, NULL, 215 OSStatus err = SecPolicySearchCreate(CSSM_CERT_X_509v3, policy_OID, NULL,
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 CSSM_DATA cert_data; 1335 CSSM_DATA cert_data;
1340 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); 1336 OSStatus status = SecCertificateGetData(cert_handle, &cert_data);
1341 if (status) 1337 if (status)
1342 return false; 1338 return false;
1343 1339
1344 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), 1340 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data),
1345 cert_data.Length); 1341 cert_data.Length);
1346 } 1342 }
1347 1343
1348 } // namespace net 1344 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698