#include <string>
#include <vector>
+#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
#include "base/strings/string_piece.h"
#include "net/base/net_export.h"
#include "net/ssl/ssl_client_cert_type.h"
-// Avoid including <openssl/evp.h> here.
-typedef struct evp_pkey_st EVP_PKEY;
-
// Misc functions to access the Android platform KeyStore.
namespace net {
namespace android {
+struct AndroidEVP_PKEY;
+
// Define a list of constants describing private key types. The
// values are shared with Java through org.chromium.net.PrivateKeyType.
// Example: PRIVATE_KEY_TYPE_RSA.
// on error.
NET_EXPORT PrivateKeyType GetPrivateKeyType(jobject private_key);
-// Returns a handle to the system EVP_PKEY object used to back a given
-// private_key object. This must *only* be used for RSA private keys
-// on Android < 4.2. Technically, this is only guaranteed to work if
-// the system image contains a vanilla implementation of the Java
-// API frameworks based on Harmony + OpenSSL.
+// Returns a handle to the system AndroidEVP_PKEY object used to back a given
+// private_key object. This must *only* be used for RSA private keys on Android
+// < 4.2. Technically, this is only guaranteed to work if the system image
+// contains a vanilla implementation of the Java API frameworks based on Harmony
+// + OpenSSL.
//
// |private_key| is a JNI reference for the private key.
-// Returns an EVP_PKEY* handle, or NULL in case of error.
+// Returns an AndroidEVP_PKEY* handle, or NULL in case of error.
//
// Note: Despite its name and return type, this function doesn't know
// anything about OpenSSL, it just type-casts a system pointer that
// is passed as an int through JNI. As such, it never increments
// the returned key's reference count.
-EVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key);
+AndroidEVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key);
+
+// Returns a JNI reference to the OpenSSLEngine object which is used to back a
+// given private_key object. This must *only* be used for RSA private keys on
+// Android < 4.2. Technically, this is only guaranteed to work if the system
+// image contains a vanilla implementation of the Java API frameworks based on
+// Harmony + OpenSSL.
+base::android::ScopedJavaLocalRef<jobject> GetOpenSSLEngineForPrivateKey(
+ jobject private_key);
NET_EXPORT void ReleaseKey(jobject private_key);