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 "chrome/common/net/x509_certificate_model.h" | 5 #include "chrome/common/net/x509_certificate_model.h" |
6 | 6 |
7 #include <openssl/obj_mac.h> | 7 #include <openssl/obj_mac.h> |
8 #include <openssl/sha.h> | 8 #include <openssl/sha.h> |
9 #include <openssl/stack.h> | 9 #include <openssl/stack.h> |
10 #include <openssl/x509.h> | 10 #include <openssl/x509.h> |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1129 |
1130 std::string HashCertSHA1(net::X509Certificate::OSCertHandle cert_handle) { | 1130 std::string HashCertSHA1(net::X509Certificate::OSCertHandle cert_handle) { |
1131 unsigned char sha1_data[SHA_DIGEST_LENGTH] = {0}; | 1131 unsigned char sha1_data[SHA_DIGEST_LENGTH] = {0}; |
1132 unsigned int sha1_size = sizeof(sha1_data); | 1132 unsigned int sha1_size = sizeof(sha1_data); |
1133 int ret = X509_digest(cert_handle, EVP_sha1(), sha1_data, &sha1_size); | 1133 int ret = X509_digest(cert_handle, EVP_sha1(), sha1_data, &sha1_size); |
1134 DCHECK(ret); | 1134 DCHECK(ret); |
1135 DCHECK_EQ(sha1_size, sizeof(sha1_data)); | 1135 DCHECK_EQ(sha1_size, sizeof(sha1_data)); |
1136 return ProcessRawBytes(sha1_data, sha1_size); | 1136 return ProcessRawBytes(sha1_data, sha1_size); |
1137 } | 1137 } |
1138 | 1138 |
1139 void GetCertChainFromCert(net::X509Certificate::OSCertHandle cert_handle, | |
1140 net::X509Certificate::OSCertHandles* cert_handles) { | |
1141 // TODO(bulach): how to get the chain out of a certificate? | |
1142 cert_handles->push_back(net::X509Certificate::DupOSCertHandle(cert_handle)); | |
1143 } | |
1144 | |
1145 void DestroyCertChain(net::X509Certificate::OSCertHandles* cert_handles) { | |
1146 for (net::X509Certificate::OSCertHandles::iterator i = cert_handles->begin(); | |
1147 i != cert_handles->end(); ++i) | |
1148 X509_free(*i); | |
1149 cert_handles->clear(); | |
1150 } | |
1151 | |
1152 std::string GetCMSString(const net::X509Certificate::OSCertHandles& cert_chain, | 1139 std::string GetCMSString(const net::X509Certificate::OSCertHandles& cert_chain, |
1153 size_t start, size_t end) { | 1140 size_t start, size_t end) { |
1154 STACK_OF(X509)* certs = sk_X509_new_null(); | 1141 STACK_OF(X509)* certs = sk_X509_new_null(); |
1155 | 1142 |
1156 for (size_t i = start; i < end; ++i) { | 1143 for (size_t i = start; i < end; ++i) { |
1157 sk_X509_push(certs, cert_chain[i]); | 1144 sk_X509_push(certs, cert_chain[i]); |
1158 } | 1145 } |
1159 | 1146 |
1160 CBB pkcs7; | 1147 CBB pkcs7; |
1161 CBB_init(&pkcs7, 1024 * sk_X509_num(certs)); | 1148 CBB_init(&pkcs7, 1024 * sk_X509_num(certs)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 return rv; | 1205 return rv; |
1219 } | 1206 } |
1220 } | 1207 } |
1221 | 1208 |
1222 std::string ProcessRawBitsSignatureWrap( | 1209 std::string ProcessRawBitsSignatureWrap( |
1223 net::X509Certificate::OSCertHandle cert_handle) { | 1210 net::X509Certificate::OSCertHandle cert_handle) { |
1224 return ProcessRawAsn1String(cert_handle->signature); | 1211 return ProcessRawAsn1String(cert_handle->signature); |
1225 } | 1212 } |
1226 | 1213 |
1227 } // namespace x509_certificate_model | 1214 } // namespace x509_certificate_model |
OLD | NEW |