summaryrefslogtreecommitdiffstats
path: root/cmds/keystore/keymgmt.c
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2009-09-08 03:52:45 +0800
committerChung-yih Wang <cywang@google.com>2009-09-09 15:00:43 +0800
commit2a58b6dbf07677e9875ba2306bc118c3eb9aebc6 (patch)
treeac106bb4e54837089fe1632a8041f96ace90317c /cmds/keystore/keymgmt.c
parent20ef5001d7e92100e636ecab71799cfd1a07f7b0 (diff)
downloadframeworks_native-2a58b6dbf07677e9875ba2306bc118c3eb9aebc6.zip
frameworks_native-2a58b6dbf07677e9875ba2306bc118c3eb9aebc6.tar.gz
frameworks_native-2a58b6dbf07677e9875ba2306bc118c3eb9aebc6.tar.bz2
Replace the delimiter whitespace with '\0'.
+ Use '\0' as the delimiter. + Allow whitespace character for keystore password. In previous implementation, we use space as the delimiter. That will stop user from using passphrase with whitespace character.
Diffstat (limited to 'cmds/keystore/keymgmt.c')
-rw-r--r--cmds/keystore/keymgmt.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/cmds/keystore/keymgmt.c b/cmds/keystore/keymgmt.c
index 9a1f845..69e0380 100644
--- a/cmds/keystore/keymgmt.c
+++ b/cmds/keystore/keymgmt.c
@@ -192,21 +192,15 @@ static int create_master_key(char *upasswd)
return ret;
}
-static int change_passwd(char *data)
+int change_passwd(char *old_pass, char *new_pass)
{
unsigned char master_key[USER_KEY_LEN];
- char *old_pass, *new_pass = NULL, *p, *delimiter=" ";
- int ret, count = 0;
- char *context = NULL;
-
- old_pass = p = strtok_r(data, delimiter, &context);
- while (p != NULL) {
- count++;
- new_pass = p;
- p = strtok_r(NULL, delimiter, &context);
- }
- if (count != 2) return -1;
- if (strlen(new_pass) < MIN_PASSWD_LENGTH) return -1;
+ int ret;
+
+ if (state == UNINITIALIZED) return -1;
+ if ((strlen(old_pass) < MIN_PASSWD_LENGTH) ||
+ (strlen(new_pass) < MIN_PASSWD_LENGTH)) return -1;
+
if ((ret = get_master_key(old_pass, master_key)) == 0) {
ret = store_master_key(new_pass, master_key);
retry_count = 0;
@@ -336,14 +330,12 @@ int list_keys(const char *namespace, char reply[BUFFER_MAX])
return 0;
}
-int passwd(char *data)
+int new_passwd(char *password)
{
- if (state == UNINITIALIZED) {
- if (strchr(data, ' ')) return -1;
- if (strlen(data) < MIN_PASSWD_LENGTH) return -1;
- return create_master_key(data);
- }
- return change_passwd(data);
+ int passwdlen = strlen(password);
+
+ if ((state != UNINITIALIZED) || (passwdlen < MIN_PASSWD_LENGTH)) return -1;
+ return create_master_key(password);
}
int lock()