OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_NETWORK_LIBRARY_H_ | 5 #ifndef NET_ANDROID_NETWORK_LIBRARY_H_ |
6 #define NET_ANDROID_NETWORK_LIBRARY_H_ | 6 #define NET_ANDROID_NETWORK_LIBRARY_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 }; | 26 }; |
27 | 27 |
28 // |cert_chain| is DER encoded chain of certificates, with the server's own | 28 // |cert_chain| is DER encoded chain of certificates, with the server's own |
29 // certificate listed first. | 29 // certificate listed first. |
30 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. | 30 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. |
31 | 31 |
32 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, | 32 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
33 const std::string& auth_type); | 33 const std::string& auth_type); |
34 | 34 |
35 // Helper for the <keygen> handler. Passes the DER-encoded key pair via | 35 // Helper for the <keygen> handler. Passes the DER-encoded key pair via |
36 // JNI to the Credentials store. | 36 // JNI to the Credentials store. Note that the public key must be a DER |
| 37 // encoded SubjectPublicKeyInfo (X.509), as returned by i2d_PUBKEY() |
| 38 // (and *not* i2d_PublicKey(), which returns a PKCS#1 key). |
| 39 // |
| 40 // Also, the private key must be in PKCS#8 format, as returned by |
| 41 // i2d_PKCS8_PRIV_KEY_INFO(EVP_PKEY2PKCS8(pkey)), which is a different |
| 42 // format than what i2d_PrivateKey() returns, so don't use it either. |
| 43 // |
37 bool StoreKeyPair(const uint8* public_key, | 44 bool StoreKeyPair(const uint8* public_key, |
38 size_t public_len, | 45 size_t public_len, |
39 const uint8* private_key, | 46 const uint8* private_key, |
40 size_t private_len); | 47 size_t private_len); |
41 | 48 |
| 49 // Helper used to pass the DER-encoded bytes of an X.509 certificate or |
| 50 // a PKCS#12 keychain to the CertInstaller activity. |
| 51 void StoreCertificateOrKeychain(const char* data, |
| 52 size_t data_len, |
| 53 bool is_pkcs12); |
| 54 |
42 // Returns true if it can determine that only loopback addresses are configured. | 55 // Returns true if it can determine that only loopback addresses are configured. |
43 // i.e. if only 127.0.0.1 and ::1 are routable. | 56 // i.e. if only 127.0.0.1 and ::1 are routable. |
44 // Also returns false if it cannot determine this. | 57 // Also returns false if it cannot determine this. |
45 bool HaveOnlyLoopbackAddresses(); | 58 bool HaveOnlyLoopbackAddresses(); |
46 | 59 |
47 // Return a string containing a list of network interfaces, each item is a | 60 // Return a string containing a list of network interfaces, each item is a |
48 // network name and address pair. | 61 // network name and address pair. |
49 // e.g. "eth0,10.0.0.2;eth0,fe80::5054:ff:fe12:3456" is a result string | 62 // e.g. "eth0,10.0.0.2;eth0,fe80::5054:ff:fe12:3456" is a result string |
50 // containing two items. | 63 // containing two items. |
51 std::string GetNetworkList(); | 64 std::string GetNetworkList(); |
52 | 65 |
53 // Get the mime type (if any) that is associated with the file extension. | 66 // Get the mime type (if any) that is associated with the file extension. |
54 // Returns true if a corresponding mime type exists. | 67 // Returns true if a corresponding mime type exists. |
55 bool GetMimeTypeFromExtension(const std::string& extension, | 68 bool GetMimeTypeFromExtension(const std::string& extension, |
56 std::string* result); | 69 std::string* result); |
57 | 70 |
58 // Register JNI methods | 71 // Register JNI methods |
59 bool RegisterNetworkLibrary(JNIEnv* env); | 72 bool RegisterNetworkLibrary(JNIEnv* env); |
60 | 73 |
61 } // namespace android | 74 } // namespace android |
62 } // namespace net | 75 } // namespace net |
63 | 76 |
64 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ | 77 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |
OLD | NEW |