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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/ssl/ssl_client_cert_type.h" 16 #include "net/ssl/ssl_client_cert_type.h"
17 17
18 // Avoid including <openssl/evp.h> here. 18 // Avoid including <openssl/evp.h> here.
19 typedef struct evp_pkey_st EVP_PKEY; 19 typedef struct evp_pkey_st EVP_PKEY;
20 20
21 // Misc functions to access the Android platform KeyStore. 21 // Misc functions to access the Android platform KeyStore.
22 22
23 namespace net { 23 namespace net {
24 namespace android { 24 namespace android {
25 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,
36 // as a series of bytes, in big-endian representation. This can be 36 // as a series of bytes, in big-endian representation. This can be
37 // used with BN_bin2bn() to convert to an OpenSSL BIGNUM. 37 // used with BN_bin2bn() to convert to an OpenSSL BIGNUM.
38 // 38 //
39 // |private_key| is a JNI reference for the private key. 39 // |private_key| is a JNI reference for the private key.
40 // |modulus| will receive the modulus bytes on success. 40 // |modulus| will receive the modulus bytes on success.
41 // Returns true on success, or false on failure (e.g. if the key 41 // Returns true on success, or false on failure (e.g. if the key
42 // is not RSA). 42 // is not RSA).
43 NET_EXPORT bool GetRSAKeyModulus(jobject private_key, 43 NET_EXPORT bool GetRSAKeyModulus(jobject private_key,
44 std::vector<uint8>* modulus); 44 std::vector<uint8>* modulus);
45 45
46 // Returns the Q parameter of a given DSAPrivateKey platform object, 46 // Returns the Q parameter of a given DSAPrivateKey platform object,
47 // as a series of bytes, in big-endian representation. This can be used 47 // as a series of bytes, in big-endian representation. This can be used
48 // with BN_bin2bn() to convert to an OpenSSL BIGNUM. 48 // with BN_bin2bn() to convert to an OpenSSL BIGNUM.
49 // |private_key| is a JNI reference for the private key. 49 // |private_key| is a JNI reference for the private key.
50 // |q| will receive the result bytes on success. 50 // |q| will receive the result bytes on success.
51 // Returns true on success, or false on failure (e.g. if the key is 51 // Returns true on success, or false on failure (e.g. if the key is
52 // not DSA). 52 // not DSA).
53 NET_EXPORT bool GetDSAKeyParamQ(jobject private_key, 53 NET_EXPORT bool GetDSAKeyParamQ(jobject private_key, std::vector<uint8>* q);
54 std::vector<uint8>* q);
55 54
56 // Returns the order parameter of a given ECPrivateKey platform object, 55 // Returns the order parameter of a given ECPrivateKey platform object,
57 // as a series of bytes, in big-endian representation. This can be used 56 // as a series of bytes, in big-endian representation. This can be used
58 // with BN_bin2bn() to convert to an OpenSSL BIGNUM. 57 // with BN_bin2bn() to convert to an OpenSSL BIGNUM.
59 // |private_key| is a JNI reference for the private key. 58 // |private_key| is a JNI reference for the private key.
60 // |order| will receive the result bytes on success. 59 // |order| will receive the result bytes on success.
61 // Returns true on success, or false on failure (e.g. if the key is 60 // Returns true on success, or false on failure (e.g. if the key is
62 // not EC). 61 // not EC).
63 bool GetECKeyOrder(jobject private_key, 62 bool GetECKeyOrder(jobject private_key, std::vector<uint8>* order);
64 std::vector<uint8>* order);
65 63
66 // Returns the encoded PKCS#8 representation of a private key. 64 // Returns the encoded PKCS#8 representation of a private key.
67 // This only works on Android 4.0.3 and older releases for platform keys 65 // This only works on Android 4.0.3 and older releases for platform keys
68 // (i.e. all keys except those explicitely generated by the application). 66 // (i.e. all keys except those explicitely generated by the application).
69 // |private_key| is a JNI reference for the private key. 67 // |private_key| is a JNI reference for the private key.
70 // |encoded| will receive the encoded data on success. 68 // |encoded| will receive the encoded data on success.
71 // Returns true on success, or false on failure (e.g. on 4.0.4 or higher). 69 // Returns true on success, or false on failure (e.g. on 4.0.4 or higher).
72 bool GetPrivateKeyEncodedBytes(jobject private_key, 70 bool GetPrivateKeyEncodedBytes(jobject private_key,
73 std::vector<uint8>* encoded); 71 std::vector<uint8>* encoded);
74 72
75 // Compute the signature of a given message, which is actually a hash, 73 // Compute the signature of a given message, which is actually a hash,
76 // using a private key. For more details, please read the comments for the 74 // using a private key. For more details, please read the comments for the
77 // rawSignDigestWithPrivateKey method in AndroidKeyStore.java. 75 // rawSignDigestWithPrivateKey method in AndroidKeyStore.java.
78 // 76 //
79 // |private_key| is a JNI reference for the private key. 77 // |private_key| is a JNI reference for the private key.
80 // |digest| is the input digest. 78 // |digest| is the input digest.
81 // |signature| will receive the signature on success. 79 // |signature| will receive the signature on success.
82 // Returns true on success, false on failure. 80 // Returns true on success, false on failure.
83 // 81 //
84 NET_EXPORT bool RawSignDigestWithPrivateKey( 82 NET_EXPORT bool RawSignDigestWithPrivateKey(jobject private_key,
85 jobject private_key, 83 const base::StringPiece& digest,
86 const base::StringPiece& digest, 84 std::vector<uint8>* signature);
87 std::vector<uint8>* signature);
88
89 85
90 // Return the PrivateKeyType of a given private key. 86 // Return the PrivateKeyType of a given private key.
91 // |private_key| is a JNI reference for the private key. 87 // |private_key| is a JNI reference for the private key.
92 // Returns a PrivateKeyType, while will be CLIENT_CERT_INVALID_TYPE 88 // Returns a PrivateKeyType, while will be CLIENT_CERT_INVALID_TYPE
93 // on error. 89 // on error.
94 NET_EXPORT PrivateKeyType GetPrivateKeyType(jobject private_key); 90 NET_EXPORT PrivateKeyType GetPrivateKeyType(jobject private_key);
95 91
96 // Returns a handle to the system EVP_PKEY object used to back a given 92 // Returns a handle to the system EVP_PKEY object used to back a given
97 // private_key object. This must *only* be used for RSA private keys 93 // private_key object. This must *only* be used for RSA private keys
98 // on Android < 4.2. Technically, this is only guaranteed to work if 94 // on Android < 4.2. Technically, this is only guaranteed to work if
(...skipping 11 matching lines...) Expand all
110 106
111 NET_EXPORT void ReleaseKey(jobject private_key); 107 NET_EXPORT void ReleaseKey(jobject private_key);
112 108
113 // Register JNI methods 109 // Register JNI methods
114 NET_EXPORT bool RegisterKeyStore(JNIEnv* env); 110 NET_EXPORT bool RegisterKeyStore(JNIEnv* env);
115 111
116 } // namespace android 112 } // namespace android
117 } // namespace net 113 } // namespace net
118 114
119 #endif // NET_ANDROID_KEYSTORE_H 115 #endif // NET_ANDROID_KEYSTORE_H
OLDNEW
« no previous file with comments | « net/android/gurl_utils.cc ('k') | net/android/keystore.cc » ('j') | net/base/mime_sniffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698