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 #include <stdint.h> |
9 | 10 |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/basictypes.h" | |
14 #include "net/android/cert_verify_result_android.h" | 14 #include "net/android/cert_verify_result_android.h" |
15 #include "net/base/mime_util.h" | 15 #include "net/base/mime_util.h" |
16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 namespace android { | 19 namespace android { |
20 | 20 |
21 // |cert_chain| is DER encoded chain of certificates, with the server's own | 21 // |cert_chain| is DER encoded chain of certificates, with the server's own |
22 // certificate listed first. | 22 // certificate listed first. |
23 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. | 23 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. |
24 void VerifyX509CertChain(const std::vector<std::string>& cert_chain, | 24 void VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
25 const std::string& auth_type, | 25 const std::string& auth_type, |
26 const std::string& host, | 26 const std::string& host, |
27 CertVerifyStatusAndroid* status, | 27 CertVerifyStatusAndroid* status, |
28 bool* is_issued_by_known_root, | 28 bool* is_issued_by_known_root, |
29 std::vector<std::string>* verified_chain); | 29 std::vector<std::string>* verified_chain); |
30 | 30 |
31 // Adds a certificate as a root trust certificate to the trust manager. | 31 // Adds a certificate as a root trust certificate to the trust manager. |
32 // |cert| is DER encoded certificate, |len| is its length in bytes. | 32 // |cert| is DER encoded certificate, |len| is its length in bytes. |
33 void AddTestRootCertificate(const uint8* cert, size_t len); | 33 void AddTestRootCertificate(const uint8_t* cert, size_t len); |
34 | 34 |
35 // Removes all root certificates added by |AddTestRootCertificate| calls. | 35 // Removes all root certificates added by |AddTestRootCertificate| calls. |
36 void ClearTestRootCertificates(); | 36 void ClearTestRootCertificates(); |
37 | 37 |
38 // Helper for the <keygen> handler. Passes the DER-encoded key pair via | 38 // Helper for the <keygen> handler. Passes the DER-encoded key pair via |
39 // JNI to the Credentials store. Note that the public key must be a DER | 39 // JNI to the Credentials store. Note that the public key must be a DER |
40 // encoded SubjectPublicKeyInfo (X.509), as returned by i2d_PUBKEY() | 40 // encoded SubjectPublicKeyInfo (X.509), as returned by i2d_PUBKEY() |
41 // (and *not* i2d_PublicKey(), which returns a PKCS#1 key). | 41 // (and *not* i2d_PublicKey(), which returns a PKCS#1 key). |
42 // | 42 // |
43 // Also, the private key must be in PKCS#8 format, as returned by | 43 // Also, the private key must be in PKCS#8 format, as returned by |
44 // i2d_PKCS8_PRIV_KEY_INFO(EVP_PKEY2PKCS8(pkey)), which is a different | 44 // i2d_PKCS8_PRIV_KEY_INFO(EVP_PKEY2PKCS8(pkey)), which is a different |
45 // format than what i2d_PrivateKey() returns, so don't use it either. | 45 // format than what i2d_PrivateKey() returns, so don't use it either. |
46 // | 46 // |
47 bool StoreKeyPair(const uint8* public_key, | 47 bool StoreKeyPair(const uint8_t* public_key, |
48 size_t public_len, | 48 size_t public_len, |
49 const uint8* private_key, | 49 const uint8_t* private_key, |
50 size_t private_len); | 50 size_t private_len); |
51 | 51 |
52 // Helper used to pass the DER-encoded bytes of an X.509 certificate or | 52 // Helper used to pass the DER-encoded bytes of an X.509 certificate or |
53 // a PKCS#12 archive holding a private key to the CertInstaller activity. | 53 // a PKCS#12 archive holding a private key to the CertInstaller activity. |
54 NET_EXPORT void StoreCertificate(CertificateMimeType cert_type, | 54 NET_EXPORT void StoreCertificate(CertificateMimeType cert_type, |
55 const void* data, | 55 const void* data, |
56 size_t data_len); | 56 size_t data_len); |
57 | 57 |
58 // Returns true if it can determine that only loopback addresses are configured. | 58 // Returns true if it can determine that only loopback addresses are configured. |
59 // i.e. if only 127.0.0.1 and ::1 are routable. | 59 // i.e. if only 127.0.0.1 and ::1 are routable. |
(...skipping 13 matching lines...) Expand all Loading... |
73 // the numeric name of the current registered operator. | 73 // the numeric name of the current registered operator. |
74 NET_EXPORT std::string GetTelephonyNetworkOperator(); | 74 NET_EXPORT std::string GetTelephonyNetworkOperator(); |
75 | 75 |
76 // Register JNI methods | 76 // Register JNI methods |
77 NET_EXPORT bool RegisterNetworkLibrary(JNIEnv* env); | 77 NET_EXPORT bool RegisterNetworkLibrary(JNIEnv* env); |
78 | 78 |
79 } // namespace android | 79 } // namespace android |
80 } // namespace net | 80 } // namespace net |
81 | 81 |
82 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ | 82 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |
OLD | NEW |