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 <limits.h> | 7 #include <limits.h> |
8 #include <openssl/mem.h> | 8 #include <openssl/mem.h> |
9 #include <openssl/obj_mac.h> | 9 #include <openssl/obj_mac.h> |
10 #include <openssl/sha.h> | 10 #include <openssl/sha.h> |
11 #include <openssl/stack.h> | 11 #include <openssl/stack.h> |
12 #include <openssl/x509.h> | 12 #include <openssl/x509.h> |
13 #include <openssl/x509v3.h> | 13 #include <openssl/x509v3.h> |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 #include <stdint.h> | 15 #include <stdint.h> |
16 | 16 |
| 17 #include <memory> |
| 18 |
17 #include "base/i18n/number_formatting.h" | 19 #include "base/i18n/number_formatting.h" |
18 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
19 #include "base/logging.h" | 21 #include "base/logging.h" |
20 #include "base/macros.h" | 22 #include "base/macros.h" |
21 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
24 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
25 #include "crypto/openssl_bio_string.h" | 27 #include "crypto/openssl_bio_string.h" |
26 #include "crypto/openssl_util.h" | 28 #include "crypto/openssl_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
37 | 39 |
38 std::string ProcessRawAsn1String(ASN1_STRING* data) { | 40 std::string ProcessRawAsn1String(ASN1_STRING* data) { |
39 return ProcessRawBytes(ASN1_STRING_data(data), ASN1_STRING_length(data)); | 41 return ProcessRawBytes(ASN1_STRING_data(data), ASN1_STRING_length(data)); |
40 } | 42 } |
41 | 43 |
42 std::string ProcessRawAsn1Type(ASN1_TYPE* data) { | 44 std::string ProcessRawAsn1Type(ASN1_TYPE* data) { |
43 int len = i2d_ASN1_TYPE(data, NULL); | 45 int len = i2d_ASN1_TYPE(data, NULL); |
44 if (len <= 0) | 46 if (len <= 0) |
45 return std::string(); | 47 return std::string(); |
46 | 48 |
47 scoped_ptr<unsigned char[]> buf(new unsigned char[len]); | 49 std::unique_ptr<unsigned char[]> buf(new unsigned char[len]); |
48 unsigned char* bufp = buf.get(); | 50 unsigned char* bufp = buf.get(); |
49 | 51 |
50 len = i2d_ASN1_TYPE(data, &bufp); | 52 len = i2d_ASN1_TYPE(data, &bufp); |
51 | 53 |
52 return ProcessRawBytes(buf.get(), len); | 54 return ProcessRawBytes(buf.get(), len); |
53 } | 55 } |
54 | 56 |
55 std::string ProcessRawBignum(BIGNUM* n) { | 57 std::string ProcessRawBignum(BIGNUM* n) { |
56 int len = BN_num_bytes(n); | 58 int len = BN_num_bytes(n); |
57 scoped_ptr<unsigned char[]> buf(new unsigned char[len]); | 59 std::unique_ptr<unsigned char[]> buf(new unsigned char[len]); |
58 len = BN_bn2bin(n, buf.get()); | 60 len = BN_bn2bin(n, buf.get()); |
59 return ProcessRawBytes(buf.get(), len); | 61 return ProcessRawBytes(buf.get(), len); |
60 } | 62 } |
61 | 63 |
62 std::string Asn1StringToUTF8(ASN1_STRING* asn1_string) { | 64 std::string Asn1StringToUTF8(ASN1_STRING* asn1_string) { |
63 std::string rv; | 65 std::string rv; |
64 unsigned char* buf = NULL; | 66 unsigned char* buf = NULL; |
65 int len = ASN1_STRING_to_UTF8(&buf, asn1_string); | 67 int len = ASN1_STRING_to_UTF8(&buf, asn1_string); |
66 if (len < 0) | 68 if (len < 0) |
67 return rv; | 69 return rv; |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 return rv; | 1210 return rv; |
1209 } | 1211 } |
1210 } | 1212 } |
1211 | 1213 |
1212 std::string ProcessRawBitsSignatureWrap( | 1214 std::string ProcessRawBitsSignatureWrap( |
1213 net::X509Certificate::OSCertHandle cert_handle) { | 1215 net::X509Certificate::OSCertHandle cert_handle) { |
1214 return ProcessRawAsn1String(cert_handle->signature); | 1216 return ProcessRawAsn1String(cert_handle->signature); |
1215 } | 1217 } |
1216 | 1218 |
1217 } // namespace x509_certificate_model | 1219 } // namespace x509_certificate_model |
OLD | NEW |