OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <openssl/bn.h> | 5 #include <openssl/bn.h> |
6 #include <openssl/dsa.h> | 6 #include <openssl/dsa.h> |
7 #include <openssl/ecdsa.h> | 7 #include <openssl/ecdsa.h> |
8 #include <openssl/err.h> | 8 #include <openssl/err.h> |
9 #include <openssl/evp.h> | 9 #include <openssl/evp.h> |
10 #include <openssl/pem.h> | 10 #include <openssl/pem.h> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return result; | 90 return result; |
91 } | 91 } |
92 | 92 |
93 // Resize a string to |size| bytes of data, then return its data buffer | 93 // Resize a string to |size| bytes of data, then return its data buffer |
94 // address cast as an 'unsigned char*', as expected by OpenSSL functions. | 94 // address cast as an 'unsigned char*', as expected by OpenSSL functions. |
95 // |str| the target string. | 95 // |str| the target string. |
96 // |size| the number of bytes to write into the string. | 96 // |size| the number of bytes to write into the string. |
97 // Return the string's new buffer in memory, as an 'unsigned char*' | 97 // Return the string's new buffer in memory, as an 'unsigned char*' |
98 // pointer. | 98 // pointer. |
99 unsigned char* OpenSSLWriteInto(std::string* str, size_t size) { | 99 unsigned char* OpenSSLWriteInto(std::string* str, size_t size) { |
100 return reinterpret_cast<unsigned char*>(WriteInto(str, size + 1)); | 100 return reinterpret_cast<unsigned char*>(base::WriteInto(str, size + 1)); |
101 } | 101 } |
102 | 102 |
103 // Load a given private key file into an EVP_PKEY. | 103 // Load a given private key file into an EVP_PKEY. |
104 // |filename| is the key file path. | 104 // |filename| is the key file path. |
105 // Returns a new EVP_PKEY on success, NULL on failure. | 105 // Returns a new EVP_PKEY on success, NULL on failure. |
106 EVP_PKEY* ImportPrivateKeyFile(const char* filename) { | 106 EVP_PKEY* ImportPrivateKeyFile(const char* filename) { |
107 // Load file in memory. | 107 // Load file in memory. |
108 base::FilePath certs_dir = GetTestCertsDirectory(); | 108 base::FilePath certs_dir = GetTestCertsDirectory(); |
109 base::FilePath file_path = certs_dir.AppendASCII(filename); | 109 base::FilePath file_path = certs_dir.AppendASCII(filename); |
110 base::ScopedFILE handle(base::OpenFile(file_path, "rb")); | 110 base::ScopedFILE handle(base::OpenFile(file_path, "rb")); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 std::string signature; | 548 std::string signature; |
549 DoKeySigningWithWrapper(wrapper_key.get(), | 549 DoKeySigningWithWrapper(wrapper_key.get(), |
550 openssl_key.get(), | 550 openssl_key.get(), |
551 message, | 551 message, |
552 &signature); | 552 &signature); |
553 ASSERT_TRUE(VerifyTestECDSASignature(message, signature)); | 553 ASSERT_TRUE(VerifyTestECDSASignature(message, signature)); |
554 } | 554 } |
555 | 555 |
556 } // namespace android | 556 } // namespace android |
557 } // namespace net | 557 } // namespace net |
OLD | NEW |