OLD | NEW |
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/cert/x509_certificate.h" | 5 #include "net/cert/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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 HASH_Update(sha1_ctx, ca_cert->derCert.data, ca_cert->derCert.len); | 254 HASH_Update(sha1_ctx, ca_cert->derCert.data, ca_cert->derCert.len); |
255 } | 255 } |
256 unsigned int result_len; | 256 unsigned int result_len; |
257 HASH_End(sha1_ctx, sha1.data, &result_len, HASH_ResultLenContext(sha1_ctx)); | 257 HASH_End(sha1_ctx, sha1.data, &result_len, HASH_ResultLenContext(sha1_ctx)); |
258 HASH_Destroy(sha1_ctx); | 258 HASH_Destroy(sha1_ctx); |
259 | 259 |
260 return sha1; | 260 return sha1; |
261 } | 261 } |
262 | 262 |
263 // static | 263 // static |
264 X509Certificate::OSCertHandle | 264 X509Certificate::OSCertHandle X509Certificate::ReadOSCertHandleFromPickle( |
265 X509Certificate::ReadOSCertHandleFromPickle(PickleIterator* pickle_iter) { | 265 base::PickleIterator* pickle_iter) { |
266 return x509_util::ReadOSCertHandleFromPickle(pickle_iter); | 266 return x509_util::ReadOSCertHandleFromPickle(pickle_iter); |
267 } | 267 } |
268 | 268 |
269 // static | 269 // static |
270 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 270 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
271 Pickle* pickle) { | 271 base::Pickle* pickle) { |
272 return pickle->WriteData( | 272 return pickle->WriteData( |
273 reinterpret_cast<const char*>(cert_handle->derCert.data), | 273 reinterpret_cast<const char*>(cert_handle->derCert.data), |
274 cert_handle->derCert.len); | 274 cert_handle->derCert.len); |
275 } | 275 } |
276 | 276 |
277 // static | 277 // static |
278 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 278 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
279 size_t* size_bits, | 279 size_t* size_bits, |
280 PublicKeyType* type) { | 280 PublicKeyType* type) { |
281 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); | 281 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); |
282 } | 282 } |
283 | 283 |
284 // static | 284 // static |
285 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { | 285 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { |
286 crypto::ScopedSECKEYPublicKey public_key(CERT_ExtractPublicKey(cert_handle)); | 286 crypto::ScopedSECKEYPublicKey public_key(CERT_ExtractPublicKey(cert_handle)); |
287 if (!public_key.get()) | 287 if (!public_key.get()) |
288 return false; | 288 return false; |
289 return SECSuccess == CERT_VerifySignedDataWithPublicKey( | 289 return SECSuccess == CERT_VerifySignedDataWithPublicKey( |
290 &cert_handle->signatureWrap, public_key.get(), NULL); | 290 &cert_handle->signatureWrap, public_key.get(), NULL); |
291 } | 291 } |
292 | 292 |
293 } // namespace net | 293 } // namespace net |
OLD | NEW |