OLD | NEW |
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 Loading... |
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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 CSSM_DATA cert_data; | 1336 CSSM_DATA cert_data; |
1341 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); | 1337 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); |
1342 if (status) | 1338 if (status) |
1343 return false; | 1339 return false; |
1344 | 1340 |
1345 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), | 1341 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), |
1346 cert_data.Length); | 1342 cert_data.Length); |
1347 } | 1343 } |
1348 | 1344 |
1349 } // namespace net | 1345 } // namespace net |
OLD | NEW |