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

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

Issue 11571059: Add net/android/keystore.h (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Appease the angry 'findbugs' gods. Created 7 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_ANDROID_KEYSTORE_H
6 #define NET_ANDROID_KEYSTORE_H
7
8 #include <jni.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/string_piece.h"
15 #include "net/base/net_export.h"
16 #include "net/base/ssl_client_cert_type.h"
17
18 // Avoid including OpenSSL headers here.
19 typedef struct evp_pkey_st EVP_PKEY;
20
21 // Misc classes to access the Android platform KeyStore.
22
23 namespace net {
24 namespace android {
25
26 // Define a list of constants describing private key types. The
27 // values are shared with Java through org.chromium.net.PrivateKeyType.
28 // Example: PRIVATE_KEY_TYPE_RSA.
29 enum PrivateKeyType {
30 #define DEFINE_PRIVATE_KEY_TYPE(name,value) PRIVATE_KEY_TYPE_ ## name = value,
31 #include "net/android/private_key_type_list.h"
32 #undef DEFINE_PRIVATE_KEY_TYPE
33 };
34
35 // Compute the signature of a given message, using a private key.
36 // This is used to implement OpenSSL's client certificate signing
37 // callback, so must end up implementing the same thing than
agl 2013/01/30 14:28:53 s/than/as/
digit1 2013/01/31 17:44:30 Done.
38 // RSA_sign() / DSA_sign() / ECDSA_sign(), depending on the key
39 // type.
40 //
41 // |private_key| is a JNI reference for the private key.
42 // |message| is the input message.
agl 2013/01/30 14:28:53 ditto with the comment around |message| - prehashe
digit1 2013/01/31 17:44:30 I've clarified the comment. Thanks.
43 // |signature| will receive the signature on success.
44 // Returns true on success, false on failure.
45 //
46 bool SignWithPrivateKey(
47 jobject private_key,
48 const base::StringPiece& message,
49 std::vector<uint8>* signature);
50
51
52 // Return the PrivateKeyType of a given private key.
53 // |private_key| is a JNI reference for the private key.
54 // Returns a PrivateKeyType, while will be CLIENT_CERT_INVALID_TYPE
55 // on error.
56 PrivateKeyType GetPrivateKeyType(jobject private_key);
57
58 // Returns a handle to the system EVP_PKEY object used to back a given
59 // private_key object. This must *only* be used for RSA private keys
60 // on Android < 4.2. Technically, this is only guaranteed to work if
61 // the system image contains a vanilla implementation of the Java
62 // API frameworks based on Harmony + OpenSSL.
63 //
64 // |private_key| is a JNI reference for the private key.
65 // Returns an EVP_PKEY* handle, or NULL in case of error.
66 //
67 // Note: Despite its name and return type, this function doesn't know
68 // anything about OpenSSL, it just type-casts a system pointer that
69 // is passed as an int through JNI. As such, it never increments
70 // the returned key's reference count.
71 EVP_PKEY* GetOpenSSLSystemHandleForPrivateKey(jobject private_key);
72
73 // Register JNI methods
74 NET_EXPORT bool RegisterKeyStore(JNIEnv* env);
75
76 } // namespace android
77 } // namespace net
78
79 #endif // NET_ANDROID_KEYSTORE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698