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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 EVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key_ref) { | 127 EVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key_ref) { |
128 JNIEnv* env = AttachCurrentThread(); | 128 JNIEnv* env = AttachCurrentThread(); |
129 // Note: the pointer is passed as a jint here because that's how it | 129 // Note: the pointer is passed as a jint here because that's how it |
130 // is stored in the Java object. Java doesn't have a primitive type | 130 // is stored in the Java object. Java doesn't have a primitive type |
131 // like intptr_t that matches the size of pointers on the host | 131 // like intptr_t that matches the size of pointers on the host |
132 // machine, and Android only runs on 32-bit CPUs. | 132 // machine, and Android only runs on 32-bit CPUs. |
133 // | 133 // |
134 // Given that this routine shall only be called on Android < 4.2, | 134 // Given that this routine shall only be called on Android < 4.2, |
135 // this won't be a problem in the far future (e.g. when Android gets | 135 // this won't be a problem in the far future (e.g. when Android gets |
136 // ported to 64-bit environments, if ever). | 136 // ported to 64-bit environments, if ever). |
137 int pkey = Java_AndroidKeyStore_getOpenSSLHandleForPrivateKey( | 137 long pkey = Java_AndroidKeyStore_getOpenSSLHandleForPrivateKey( |
138 env, | 138 env, |
139 GetKeyStore(private_key_ref).obj(), | 139 GetKeyStore(private_key_ref).obj(), |
140 private_key_ref); | 140 private_key_ref); |
141 return reinterpret_cast<EVP_PKEY*>(pkey); | 141 return reinterpret_cast<EVP_PKEY*>(pkey); |
142 } | 142 } |
143 | 143 |
144 void ReleaseKey(jobject private_key_ref) { | 144 void ReleaseKey(jobject private_key_ref) { |
145 JNIEnv* env = AttachCurrentThread(); | 145 JNIEnv* env = AttachCurrentThread(); |
146 Java_AndroidKeyStore_releaseKey(env, | 146 Java_AndroidKeyStore_releaseKey(env, |
147 GetKeyStore(private_key_ref).obj(), | 147 GetKeyStore(private_key_ref).obj(), |
148 private_key_ref); | 148 private_key_ref); |
149 env->DeleteGlobalRef(private_key_ref); | 149 env->DeleteGlobalRef(private_key_ref); |
150 } | 150 } |
151 | 151 |
152 bool RegisterKeyStore(JNIEnv* env) { | 152 bool RegisterKeyStore(JNIEnv* env) { |
153 return RegisterNativesImpl(env); | 153 return RegisterNativesImpl(env); |
154 } | 154 } |
155 | 155 |
156 } // namespace android | 156 } // namespace android |
157 } // namespace net | 157 } // namespace net |
OLD | NEW |