OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 // Misc classes to access the Android platform KeyStore. |
| 19 |
| 20 namespace net { |
| 21 namespace android { |
| 22 |
| 23 // Compute the signature of a given message, using a private key. |
| 24 // This is used to implement OpenSSL's client certificate signing |
| 25 // callback, so must end up implementing the same thing than |
| 26 // RSA_sign() / DSA_sign() / ECDSA_sign(), depending on the key |
| 27 // type. |
| 28 // |
| 29 // |private_key| is a JNI reference for the private key. |
| 30 // |message| is the input message. |
| 31 // |signature| will receive the signature on success. |
| 32 // Returns true on success, false on failure. |
| 33 // |
| 34 bool SignWithPrivateKey( |
| 35 jobject private_key, |
| 36 const base::StringPiece& message, |
| 37 std::vector<uint8>* signature); |
| 38 |
| 39 |
| 40 // Return the SSLClientCertType of a given private key. |
| 41 // |private_key| is a JNI reference for the private key. |
| 42 // Returns a SSLClientCertType, while will be CLIENT_CERT_INVALID_TYPE |
| 43 // on error. |
| 44 SSLClientCertType GetPrivateKeySigningType(jobject private_key); |
| 45 |
| 46 // Register JNI methods |
| 47 NET_EXPORT bool RegisterKeyStore(JNIEnv* env); |
| 48 |
| 49 } // namespace android |
| 50 } // namespace net |
| 51 |
| 52 #endif // NET_ANDROID_KEYSTORE_H |
OLD | NEW |