Loading cmds/keystore/certtool.h +12 −4 Original line number Diff line number Diff line Loading @@ -26,21 +26,29 @@ #include "common.h" #include "netkeystore.h" #define CERT_NAME_LEN (2 * MAX_KEY_NAME_LENGTH + 2) /* * The specific function 'get_cert' is used in daemons to get the key value * from keystore. Caller should allocate the buffer and the length of the buffer * should be MAX_KEY_VALUE_LENGTH. */ static inline int get_cert(char *certname, unsigned char *value, int *size) static inline int get_cert(const char *certname, unsigned char *value, int *size) { int count, fd, ret = -1; LPC_MARSHAL cmd; char delimiter[] = "_"; char *namespace, *keyname; char *context = NULL; char cname[CERT_NAME_LEN]; if ((certname == NULL) || (value == NULL)) { LOGE("get_cert: certname or value is null\n"); return -1; } if (value == NULL) { LOGE("get_cert: value is null\n"); if (strlcpy(cname, certname, CERT_NAME_LEN) >= CERT_NAME_LEN) { LOGE("get_cert: keyname is too long\n"); return -1; } Loading @@ -53,7 +61,7 @@ static inline int get_cert(char *certname, unsigned char *value, int *size) } cmd.opcode = GET; if (((namespace = strtok_r(certname, delimiter, &context)) == NULL) || if (((namespace = strtok_r(cname, delimiter, &context)) == NULL) || ((keyname = strtok_r(NULL, delimiter, &context)) == NULL)) { goto err; } Loading keystore/java/android/security/CertTool.java +9 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ import android.text.TextUtils; * {@hide} */ public class CertTool { static { System.loadLibrary("certtool_jni"); } public static final String ACTION_ADD_CREDENTIAL = "android.security.ADD_CREDENTIAL"; public static final String KEY_TYPE_NAME = "typeName"; Loading @@ -52,7 +56,7 @@ public class CertTool { private static final String USER_KEY = "USRKEY"; private static final String KEYNAME_DELIMITER = "_"; private static final Keystore keystore = Keystore.getInstance(); private static final Keystore sKeystore = Keystore.getInstance(); private native String generateCertificateRequest(int bits, String subject); private native boolean isPkcs12Keystore(byte[] data); Loading @@ -65,6 +69,8 @@ public class CertTool { private static CertTool singleton = null; private CertTool() { } public static final CertTool getInstance() { if (singleton == null) { singleton = new CertTool(); Loading @@ -85,11 +91,11 @@ public class CertTool { } public String[] getAllUserCertificateKeys() { return keystore.listKeys(USER_KEY); return sKeystore.listKeys(USER_KEY); } public String[] getAllCaCertificateKeys() { return keystore.listKeys(CA_CERTIFICATE); return sKeystore.listKeys(CA_CERTIFICATE); } public String[] getSupportedKeyStrenghs() { Loading keystore/jni/certtool.c +2 −2 Original line number Diff line number Diff line Loading @@ -115,9 +115,9 @@ static JNINativeMethod gCertToolMethods[] = { /* name, signature, funcPtr */ {"generateCertificateRequest", "(ILjava/lang/String;)Ljava/lang/String;", (void*)android_security_CertTool_generateCertificateRequest}, {"isPkcs12Keystore", "(B[)I", {"isPkcs12Keystore", "([B)Z", (void*)android_security_CertTool_isPkcs12Keystore}, {"generateX509Certificate", "(B[)I", {"generateX509Certificate", "([B)I", (void*)android_security_CertTool_generateX509Certificate}, {"isCaCertificate", "(I)Z", (void*)android_security_CertTool_isCaCertificate}, Loading services/java/com/android/server/WifiService.java +11 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,17 @@ public class WifiService extends IWifiManager.Stub { break setVariables; } if ((config.password != null) && !WifiNative.setNetworkVariableCommand( netId, WifiConfiguration.passwordVarName, config.password)) { if (DBG) { Log.d(TAG, config.SSID + ": failed to set password: "+ config.password); } break setVariables; } if ((config.clientCert != null) && !WifiNative.setNetworkVariableCommand( netId, WifiConfiguration.clientCertVarName, Loading wifi/java/android/net/wifi/WifiConfiguration.java +11 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ public class WifiConfiguration implements Parcelable { /** {@hide} */ public static final String anonymousIdentityVarName = "anonymous_identity"; /** {@hide} */ public static final String passwordVarName = "password"; /** {@hide} */ public static final String clientCertVarName = "client_cert"; /** {@hide} */ public static final String caCertVarName = "ca_cert"; Loading Loading @@ -278,6 +280,8 @@ public class WifiConfiguration implements Parcelable { public String identity; /** {@hide} */ public String anonymousIdentity; /** {@hide} */ public String password; /** The path of the client certificate file. * {@hide} */ Loading Loading @@ -312,6 +316,7 @@ public class WifiConfiguration implements Parcelable { eap = null; identity = null; anonymousIdentity = null; password = null; clientCert = null; caCert = null; privateKey = null; Loading Loading @@ -402,6 +407,10 @@ public class WifiConfiguration implements Parcelable { if (this.anonymousIdentity != null) { sbuf.append(anonymousIdentity); } sbuf.append('\n').append(" Password: "); if (this.password != null) { sbuf.append(password); } sbuf.append('\n').append(" ClientCert: "); if (this.clientCert != null) { sbuf.append(clientCert); Loading Loading @@ -479,6 +488,7 @@ public class WifiConfiguration implements Parcelable { dest.writeString(eap); dest.writeString(identity); dest.writeString(anonymousIdentity); dest.writeString(password); dest.writeString(clientCert); dest.writeString(caCert); dest.writeString(privateKey); Loading Loading @@ -508,6 +518,7 @@ public class WifiConfiguration implements Parcelable { config.eap = in.readString(); config.identity = in.readString(); config.anonymousIdentity = in.readString(); config.password = in.readString(); config.clientCert = in.readString(); config.caCert = in.readString(); config.privateKey = in.readString(); Loading Loading
cmds/keystore/certtool.h +12 −4 Original line number Diff line number Diff line Loading @@ -26,21 +26,29 @@ #include "common.h" #include "netkeystore.h" #define CERT_NAME_LEN (2 * MAX_KEY_NAME_LENGTH + 2) /* * The specific function 'get_cert' is used in daemons to get the key value * from keystore. Caller should allocate the buffer and the length of the buffer * should be MAX_KEY_VALUE_LENGTH. */ static inline int get_cert(char *certname, unsigned char *value, int *size) static inline int get_cert(const char *certname, unsigned char *value, int *size) { int count, fd, ret = -1; LPC_MARSHAL cmd; char delimiter[] = "_"; char *namespace, *keyname; char *context = NULL; char cname[CERT_NAME_LEN]; if ((certname == NULL) || (value == NULL)) { LOGE("get_cert: certname or value is null\n"); return -1; } if (value == NULL) { LOGE("get_cert: value is null\n"); if (strlcpy(cname, certname, CERT_NAME_LEN) >= CERT_NAME_LEN) { LOGE("get_cert: keyname is too long\n"); return -1; } Loading @@ -53,7 +61,7 @@ static inline int get_cert(char *certname, unsigned char *value, int *size) } cmd.opcode = GET; if (((namespace = strtok_r(certname, delimiter, &context)) == NULL) || if (((namespace = strtok_r(cname, delimiter, &context)) == NULL) || ((keyname = strtok_r(NULL, delimiter, &context)) == NULL)) { goto err; } Loading
keystore/java/android/security/CertTool.java +9 −3 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ import android.text.TextUtils; * {@hide} */ public class CertTool { static { System.loadLibrary("certtool_jni"); } public static final String ACTION_ADD_CREDENTIAL = "android.security.ADD_CREDENTIAL"; public static final String KEY_TYPE_NAME = "typeName"; Loading @@ -52,7 +56,7 @@ public class CertTool { private static final String USER_KEY = "USRKEY"; private static final String KEYNAME_DELIMITER = "_"; private static final Keystore keystore = Keystore.getInstance(); private static final Keystore sKeystore = Keystore.getInstance(); private native String generateCertificateRequest(int bits, String subject); private native boolean isPkcs12Keystore(byte[] data); Loading @@ -65,6 +69,8 @@ public class CertTool { private static CertTool singleton = null; private CertTool() { } public static final CertTool getInstance() { if (singleton == null) { singleton = new CertTool(); Loading @@ -85,11 +91,11 @@ public class CertTool { } public String[] getAllUserCertificateKeys() { return keystore.listKeys(USER_KEY); return sKeystore.listKeys(USER_KEY); } public String[] getAllCaCertificateKeys() { return keystore.listKeys(CA_CERTIFICATE); return sKeystore.listKeys(CA_CERTIFICATE); } public String[] getSupportedKeyStrenghs() { Loading
keystore/jni/certtool.c +2 −2 Original line number Diff line number Diff line Loading @@ -115,9 +115,9 @@ static JNINativeMethod gCertToolMethods[] = { /* name, signature, funcPtr */ {"generateCertificateRequest", "(ILjava/lang/String;)Ljava/lang/String;", (void*)android_security_CertTool_generateCertificateRequest}, {"isPkcs12Keystore", "(B[)I", {"isPkcs12Keystore", "([B)Z", (void*)android_security_CertTool_isPkcs12Keystore}, {"generateX509Certificate", "(B[)I", {"generateX509Certificate", "([B)I", (void*)android_security_CertTool_generateX509Certificate}, {"isCaCertificate", "(I)Z", (void*)android_security_CertTool_isCaCertificate}, Loading
services/java/com/android/server/WifiService.java +11 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,17 @@ public class WifiService extends IWifiManager.Stub { break setVariables; } if ((config.password != null) && !WifiNative.setNetworkVariableCommand( netId, WifiConfiguration.passwordVarName, config.password)) { if (DBG) { Log.d(TAG, config.SSID + ": failed to set password: "+ config.password); } break setVariables; } if ((config.clientCert != null) && !WifiNative.setNetworkVariableCommand( netId, WifiConfiguration.clientCertVarName, Loading
wifi/java/android/net/wifi/WifiConfiguration.java +11 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ public class WifiConfiguration implements Parcelable { /** {@hide} */ public static final String anonymousIdentityVarName = "anonymous_identity"; /** {@hide} */ public static final String passwordVarName = "password"; /** {@hide} */ public static final String clientCertVarName = "client_cert"; /** {@hide} */ public static final String caCertVarName = "ca_cert"; Loading Loading @@ -278,6 +280,8 @@ public class WifiConfiguration implements Parcelable { public String identity; /** {@hide} */ public String anonymousIdentity; /** {@hide} */ public String password; /** The path of the client certificate file. * {@hide} */ Loading Loading @@ -312,6 +316,7 @@ public class WifiConfiguration implements Parcelable { eap = null; identity = null; anonymousIdentity = null; password = null; clientCert = null; caCert = null; privateKey = null; Loading Loading @@ -402,6 +407,10 @@ public class WifiConfiguration implements Parcelable { if (this.anonymousIdentity != null) { sbuf.append(anonymousIdentity); } sbuf.append('\n').append(" Password: "); if (this.password != null) { sbuf.append(password); } sbuf.append('\n').append(" ClientCert: "); if (this.clientCert != null) { sbuf.append(clientCert); Loading Loading @@ -479,6 +488,7 @@ public class WifiConfiguration implements Parcelable { dest.writeString(eap); dest.writeString(identity); dest.writeString(anonymousIdentity); dest.writeString(password); dest.writeString(clientCert); dest.writeString(caCert); dest.writeString(privateKey); Loading Loading @@ -508,6 +518,7 @@ public class WifiConfiguration implements Parcelable { config.eap = in.readString(); config.identity = in.readString(); config.anonymousIdentity = in.readString(); config.password = in.readString(); config.clientCert = in.readString(); config.caCert = in.readString(); config.privateKey = in.readString(); Loading