| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // Retrieve a JNI local ref from encoded PKCS#8 data. | 161 // Retrieve a JNI local ref from encoded PKCS#8 data. |
| 162 ScopedJava GetPKCS8PrivateKeyJava(PrivateKeyType key_type, | 162 ScopedJava GetPKCS8PrivateKeyJava(PrivateKeyType key_type, |
| 163 const std::string& pkcs8_key) { | 163 const std::string& pkcs8_key) { |
| 164 JNIEnv* env = base::android::AttachCurrentThread(); | 164 JNIEnv* env = base::android::AttachCurrentThread(); |
| 165 base::android::ScopedJavaLocalRef<jbyteArray> bytes( | 165 base::android::ScopedJavaLocalRef<jbyteArray> bytes( |
| 166 base::android::ToJavaByteArray( | 166 base::android::ToJavaByteArray( |
| 167 env, reinterpret_cast<const uint8_t*>(pkcs8_key.data()), | 167 env, reinterpret_cast<const uint8_t*>(pkcs8_key.data()), |
| 168 pkcs8_key.size())); | 168 pkcs8_key.size())); |
| 169 | 169 |
| 170 ScopedJava key( | 170 ScopedJava key(Java_AndroidKeyStoreTestUtil_createPrivateKeyFromPKCS8( |
| 171 Java_AndroidKeyStoreTestUtil_createPrivateKeyFromPKCS8( | 171 env, key_type, bytes)); |
| 172 env, key_type, bytes.obj())); | |
| 173 | 172 |
| 174 return key; | 173 return key; |
| 175 } | 174 } |
| 176 | 175 |
| 177 const char kTestRsaKeyFile[] = "android-test-key-rsa.pem"; | 176 const char kTestRsaKeyFile[] = "android-test-key-rsa.pem"; |
| 178 | 177 |
| 179 // The RSA test hash must be 36 bytes exactly. | 178 // The RSA test hash must be 36 bytes exactly. |
| 180 const char kTestRsaHash[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 179 const char kTestRsaHash[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
| 181 | 180 |
| 182 // Retrieve a JNI local ref for our test RSA key. | 181 // Retrieve a JNI local ref for our test RSA key. |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 std::string signature; | 534 std::string signature; |
| 536 DoKeySigningWithWrapper(wrapper_key.get(), | 535 DoKeySigningWithWrapper(wrapper_key.get(), |
| 537 openssl_key.get(), | 536 openssl_key.get(), |
| 538 message, | 537 message, |
| 539 &signature); | 538 &signature); |
| 540 ASSERT_TRUE(VerifyTestECDSASignature(message, signature)); | 539 ASSERT_TRUE(VerifyTestECDSASignature(message, signature)); |
| 541 } | 540 } |
| 542 | 541 |
| 543 } // namespace android | 542 } // namespace android |
| 544 } // namespace net | 543 } // namespace net |
| OLD | NEW |