diff options
| author | 2009-07-03 08:51:59 -0700 | |
|---|---|---|
| committer | 2009-07-03 08:51:59 -0700 | |
| commit | 57643ce5c6662754898f47ee70c655c74c394ead (patch) | |
| tree | e4041395086d5c0aa2d9bd24ad8ee6c2d136f495 | |
| parent | 1d70b6110fda83d172fd3ef19e1dfa9a0d473586 (diff) | |
| parent | 37b49519cc2bd8c3b907f7bf3f8f5c21f5692103 (diff) | |
Merge change 6177 into donut
* changes:
Two small checks in keymgmt.
| -rw-r--r-- | cmds/keystore/keymgmt.c | 7 | ||||
| -rw-r--r-- | cmds/keystore/keymgmt.h | 3 | ||||
| -rw-r--r-- | cmds/keystore/netkeystore.c | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/cmds/keystore/keymgmt.c b/cmds/keystore/keymgmt.c index e4102a920e..66edd56616 100644 --- a/cmds/keystore/keymgmt.c +++ b/cmds/keystore/keymgmt.c @@ -185,6 +185,7 @@ static int change_passwd(char *data) p = strtok_r(NULL, delimiter, &context); } if (count != 2) return -1; + if (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; @@ -259,6 +260,11 @@ int list_keys(const char *namespace, char reply[BUFFER_MAX]) DIR *d; struct dirent *de; + if (state != UNLOCKED) { + LOGE("Can not list key with current state %d\n", state); + return -1; + } + if (!namespace || ((d = opendir("."))) == NULL) { LOGE("cannot open keystore dir or namespace is null\n"); return -1; @@ -287,6 +293,7 @@ int passwd(char *data) { 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); diff --git a/cmds/keystore/keymgmt.h b/cmds/keystore/keymgmt.h index 0f1057042b..0e928db494 100644 --- a/cmds/keystore/keymgmt.h +++ b/cmds/keystore/keymgmt.h @@ -27,7 +27,8 @@ #define AES_KEY_LEN 128 #define USER_KEY_LEN (AES_KEY_LEN/8) #define IV_LEN USER_KEY_LEN -#define MAX_RETRY_COUNT 6 +#define MAX_RETRY_COUNT 6 +#define MIN_PASSWD_LENGTH 8 #define gen_key(passwd, key, len) \ PKCS5_PBKDF2_HMAC_SHA1(passwd, strlen(passwd), \ diff --git a/cmds/keystore/netkeystore.c b/cmds/keystore/netkeystore.c index e45e24f687..eac455e0c5 100644 --- a/cmds/keystore/netkeystore.c +++ b/cmds/keystore/netkeystore.c @@ -224,6 +224,7 @@ static void do_reset_keystore(LPC_MARSHAL *cmd, LPC_MARSHAL *reply) } reply->retcode = reset_keystore(); } + static void execute(LPC_MARSHAL *cmd, LPC_MARSHAL *reply) { uint32_t cmd_max = sizeof(cmds)/sizeof(struct cmdinfo); |