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 "net/android/keystore.h" | 5 #include "net/android/keystore.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 JNIEnv* env = AttachCurrentThread(); | 52 JNIEnv* env = AttachCurrentThread(); |
53 | 53 |
54 // Convert message to byte[] array. | 54 // Convert message to byte[] array. |
55 ScopedJavaLocalRef<jbyteArray> digest_ref = ToJavaByteArray( | 55 ScopedJavaLocalRef<jbyteArray> digest_ref = ToJavaByteArray( |
56 env, reinterpret_cast<const uint8_t*>(digest.data()), digest.length()); | 56 env, reinterpret_cast<const uint8_t*>(digest.data()), digest.length()); |
57 DCHECK(!digest_ref.is_null()); | 57 DCHECK(!digest_ref.is_null()); |
58 | 58 |
59 // Invoke platform API | 59 // Invoke platform API |
60 ScopedJavaLocalRef<jbyteArray> signature_ref = | 60 ScopedJavaLocalRef<jbyteArray> signature_ref = |
61 Java_AndroidKeyStore_rawSignDigestWithPrivateKey(env, private_key_ref, | 61 Java_AndroidKeyStore_rawSignDigestWithPrivateKey(env, private_key_ref, |
62 digest_ref.obj()); | 62 digest_ref); |
63 if (HasException(env) || signature_ref.is_null()) | 63 if (HasException(env) || signature_ref.is_null()) |
64 return false; | 64 return false; |
65 | 65 |
66 // Write signature to string. | 66 // Write signature to string. |
67 JavaByteArrayToByteVector(env, signature_ref.obj(), signature); | 67 JavaByteArrayToByteVector(env, signature_ref.obj(), signature); |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 PrivateKeyType GetPrivateKeyType(jobject private_key_ref) { | 71 PrivateKeyType GetPrivateKeyType(jobject private_key_ref) { |
72 JNIEnv* env = AttachCurrentThread(); | 72 JNIEnv* env = AttachCurrentThread(); |
(...skipping 19 matching lines...) Expand all Loading... |
92 ScopedJavaLocalRef<jobject> GetOpenSSLEngineForPrivateKey( | 92 ScopedJavaLocalRef<jobject> GetOpenSSLEngineForPrivateKey( |
93 jobject private_key_ref) { | 93 jobject private_key_ref) { |
94 JNIEnv* env = AttachCurrentThread(); | 94 JNIEnv* env = AttachCurrentThread(); |
95 ScopedJavaLocalRef<jobject> engine = | 95 ScopedJavaLocalRef<jobject> engine = |
96 Java_AndroidKeyStore_getOpenSSLEngineForPrivateKey(env, private_key_ref); | 96 Java_AndroidKeyStore_getOpenSSLEngineForPrivateKey(env, private_key_ref); |
97 return engine; | 97 return engine; |
98 } | 98 } |
99 | 99 |
100 } // namespace android | 100 } // namespace android |
101 } // namespace net | 101 } // namespace net |
OLD | NEW |