OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <keyhi.h> | 9 #include <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 SECOidTag ev_policy_tag = SEC_OID_UNKNOWN; | 822 SECOidTag ev_policy_tag = SEC_OID_UNKNOWN; |
823 if (!metadata->GetPolicyOID(fingerprint, &ev_policy_tag)) | 823 if (!metadata->GetPolicyOID(fingerprint, &ev_policy_tag)) |
824 return false; | 824 return false; |
825 | 825 |
826 if (!CheckCertPolicies(cert_handle_, ev_policy_tag)) | 826 if (!CheckCertPolicies(cert_handle_, ev_policy_tag)) |
827 return false; | 827 return false; |
828 | 828 |
829 return true; | 829 return true; |
830 } | 830 } |
831 | 831 |
| 832 bool X509Certificate::GetDEREncoded(std::string* encoded) { |
| 833 if (!cert_handle_->derCert.len) |
| 834 return false; |
| 835 encoded->clear(); |
| 836 encoded->append(reinterpret_cast<char*>(cert_handle_->derCert.data), |
| 837 cert_handle_->derCert.len); |
| 838 return true; |
| 839 } |
| 840 |
832 // static | 841 // static |
833 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, | 842 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, |
834 X509Certificate::OSCertHandle b) { | 843 X509Certificate::OSCertHandle b) { |
835 DCHECK(a && b); | 844 DCHECK(a && b); |
836 if (a == b) | 845 if (a == b) |
837 return true; | 846 return true; |
838 return a->derCert.len == b->derCert.len && | 847 return a->derCert.len == b->derCert.len && |
839 memcmp(a->derCert.data, b->derCert.data, a->derCert.len) == 0; | 848 memcmp(a->derCert.data, b->derCert.data, a->derCert.len) == 0; |
840 } | 849 } |
841 | 850 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 DCHECK(0 != cert->derCert.len); | 927 DCHECK(0 != cert->derCert.len); |
919 | 928 |
920 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, | 929 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, |
921 cert->derCert.data, cert->derCert.len); | 930 cert->derCert.data, cert->derCert.len); |
922 DCHECK(rv == SECSuccess); | 931 DCHECK(rv == SECSuccess); |
923 | 932 |
924 return sha1; | 933 return sha1; |
925 } | 934 } |
926 | 935 |
927 } // namespace net | 936 } // namespace net |
OLD | NEW |