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_util_openssl.h" | 5 #include "net/cert/x509_util_openssl.h" |
6 | 6 |
7 #include <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
8 #include <openssl/mem.h> | 8 #include <openssl/mem.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return cert.release(); | 129 return cert.release(); |
130 } | 130 } |
131 | 131 |
132 // DER-encodes |x509|. On success, returns true and writes the | 132 // DER-encodes |x509|. On success, returns true and writes the |
133 // encoding to |*out_der|. | 133 // encoding to |*out_der|. |
134 bool DerEncodeCert(X509* x509, std::string* out_der) { | 134 bool DerEncodeCert(X509* x509, std::string* out_der) { |
135 int len = i2d_X509(x509, NULL); | 135 int len = i2d_X509(x509, NULL); |
136 if (len < 0) | 136 if (len < 0) |
137 return false; | 137 return false; |
138 | 138 |
139 uint8_t* ptr = reinterpret_cast<uint8_t*>(WriteInto(out_der, len + 1)); | 139 uint8_t* ptr = reinterpret_cast<uint8_t*>(base::WriteInto(out_der, len + 1)); |
140 if (i2d_X509(x509, &ptr) < 0) { | 140 if (i2d_X509(x509, &ptr) < 0) { |
141 NOTREACHED(); | 141 NOTREACHED(); |
142 out_der->clear(); | 142 out_der->clear(); |
143 return false; | 143 return false; |
144 } | 144 } |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 bool SignAndDerEncodeCert(X509* cert, | 148 bool SignAndDerEncodeCert(X509* cert, |
149 EVP_PKEY* key, | 149 EVP_PKEY* key, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 internal_cache = new_cache.get(); | 331 internal_cache = new_cache.get(); |
332 X509_set_ex_data(x509, x509_der_cache_index, new_cache.release()); | 332 X509_set_ex_data(x509, x509_der_cache_index, new_cache.release()); |
333 } | 333 } |
334 *der_cache = base::StringPiece(internal_cache->data); | 334 *der_cache = base::StringPiece(internal_cache->data); |
335 return true; | 335 return true; |
336 } | 336 } |
337 | 337 |
338 } // namespace x509_util | 338 } // namespace x509_util |
339 | 339 |
340 } // namespace net | 340 } // namespace net |
OLD | NEW |