xref: /aosp_15_r20/external/cronet/net/ssl/ssl_platform_key_android.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors
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_SSL_SSL_PLATFORM_KEY_ANDROID_H_
6 #define NET_SSL_SSL_PLATFORM_KEY_ANDROID_H_
7 
8 #include <jni.h>
9 
10 #include <string>
11 #include <vector>
12 
13 #include "base/android/scoped_java_ref.h"
14 #include "base/containers/span.h"
15 #include "base/memory/scoped_refptr.h"
16 #include "net/base/net_export.h"
17 
18 namespace net {
19 
20 class SSLPrivateKey;
21 class X509Certificate;
22 
23 // Returns a new SSLPrivateKey for `cert` which uses `key` for signing
24 // operations or nullptr on error. `key` must be a java.security.PrivateKey
25 // object.
26 NET_EXPORT scoped_refptr<SSLPrivateKey> WrapJavaPrivateKey(
27     const X509Certificate* cert,
28     const base::android::JavaRef<jobject>& key);
29 
30 // Converts `algorithms` to a list of strings containing Java key types,
31 // suitable for use with android.security.KeyChain.choosePrivateKeyAlias.
32 NET_EXPORT std::vector<std::string> SignatureAlgorithmsToJavaKeyTypes(
33     base::span<const uint16_t> algorithms);
34 
35 }  // namespace net
36 
37 #endif  // NET_SSL_SSL_PLATFORM_KEY_ANDROID_H_
38