Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: net/android/keystore.h

Issue 365503007: Insulate the legacy Android client auth code from OpenSSL ABI changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mismerge Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef NET_ANDROID_KEYSTORE_H 5 #ifndef NET_ANDROID_KEYSTORE_H
6 #define NET_ANDROID_KEYSTORE_H 6 #define NET_ANDROID_KEYSTORE_H
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/android/scoped_java_ref.h"
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
16 #include "net/ssl/ssl_client_cert_type.h" 17 #include "net/ssl/ssl_client_cert_type.h"
17 18
18 // Avoid including <openssl/evp.h> here.
19 typedef struct evp_pkey_st EVP_PKEY;
20
21 // Misc functions to access the Android platform KeyStore. 19 // Misc functions to access the Android platform KeyStore.
22 20
23 namespace net { 21 namespace net {
24 namespace android { 22 namespace android {
25 23
24 struct AndroidEVP_PKEY;
25
26 // Define a list of constants describing private key types. The 26 // Define a list of constants describing private key types. The
27 // values are shared with Java through org.chromium.net.PrivateKeyType. 27 // values are shared with Java through org.chromium.net.PrivateKeyType.
28 // Example: PRIVATE_KEY_TYPE_RSA. 28 // Example: PRIVATE_KEY_TYPE_RSA.
29 enum PrivateKeyType { 29 enum PrivateKeyType {
30 #define DEFINE_PRIVATE_KEY_TYPE(name,value) PRIVATE_KEY_TYPE_ ## name = value, 30 #define DEFINE_PRIVATE_KEY_TYPE(name,value) PRIVATE_KEY_TYPE_ ## name = value,
31 #include "net/android/private_key_type_list.h" 31 #include "net/android/private_key_type_list.h"
32 #undef DEFINE_PRIVATE_KEY_TYPE 32 #undef DEFINE_PRIVATE_KEY_TYPE
33 }; 33 };
34 34
35 // Returns the modulus of a given RSAPrivateKey platform object, 35 // Returns the modulus of a given RSAPrivateKey platform object,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const base::StringPiece& digest, 86 const base::StringPiece& digest,
87 std::vector<uint8>* signature); 87 std::vector<uint8>* signature);
88 88
89 89
90 // Return the PrivateKeyType of a given private key. 90 // Return the PrivateKeyType of a given private key.
91 // |private_key| is a JNI reference for the private key. 91 // |private_key| is a JNI reference for the private key.
92 // Returns a PrivateKeyType, while will be CLIENT_CERT_INVALID_TYPE 92 // Returns a PrivateKeyType, while will be CLIENT_CERT_INVALID_TYPE
93 // on error. 93 // on error.
94 NET_EXPORT PrivateKeyType GetPrivateKeyType(jobject private_key); 94 NET_EXPORT PrivateKeyType GetPrivateKeyType(jobject private_key);
95 95
96 // Returns a handle to the system EVP_PKEY object used to back a given 96 // Returns a handle to the system AndroidEVP_PKEY object used to back a given
97 // private_key object. This must *only* be used for RSA private keys 97 // private_key object. This must *only* be used for RSA private keys on Android
98 // on Android < 4.2. Technically, this is only guaranteed to work if 98 // < 4.2. Technically, this is only guaranteed to work if the system image
99 // the system image contains a vanilla implementation of the Java 99 // contains a vanilla implementation of the Java API frameworks based on Harmony
100 // API frameworks based on Harmony + OpenSSL. 100 // + OpenSSL.
101 // 101 //
102 // |private_key| is a JNI reference for the private key. 102 // |private_key| is a JNI reference for the private key.
103 // Returns an EVP_PKEY* handle, or NULL in case of error. 103 // Returns an AndroidEVP_PKEY* handle, or NULL in case of error.
104 // 104 //
105 // Note: Despite its name and return type, this function doesn't know 105 // Note: Despite its name and return type, this function doesn't know
106 // anything about OpenSSL, it just type-casts a system pointer that 106 // anything about OpenSSL, it just type-casts a system pointer that
107 // is passed as an int through JNI. As such, it never increments 107 // is passed as an int through JNI. As such, it never increments
108 // the returned key's reference count. 108 // the returned key's reference count.
109 EVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key); 109 AndroidEVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key);
110
111 // Returns a JNI reference to the OpenSSLEngine object which is used to back a
112 // given private_key object. This must *only* be used for RSA private keys on
113 // Android < 4.2. Technically, this is only guaranteed to work if the system
114 // image contains a vanilla implementation of the Java API frameworks based on
115 // Harmony + OpenSSL.
116 base::android::ScopedJavaLocalRef<jobject> GetOpenSSLEngineForPrivateKey(
117 jobject private_key);
110 118
111 NET_EXPORT void ReleaseKey(jobject private_key); 119 NET_EXPORT void ReleaseKey(jobject private_key);
112 120
113 // Register JNI methods 121 // Register JNI methods
114 NET_EXPORT bool RegisterKeyStore(JNIEnv* env); 122 NET_EXPORT bool RegisterKeyStore(JNIEnv* env);
115 123
116 } // namespace android 124 } // namespace android
117 } // namespace net 125 } // namespace net
118 126
119 #endif // NET_ANDROID_KEYSTORE_H 127 #endif // NET_ANDROID_KEYSTORE_H
OLDNEW
« no previous file with comments | « net/android/java/src/org/chromium/net/RemoteAndroidKeyStore.java ('k') | net/android/keystore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698