password length check for adminlessmode

This commit is contained in:
NIIBE Yutaka
2012-12-14 10:31:46 +09:00
parent d72a0b7893
commit 12bd1161a4
2 changed files with 17 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
2012-12-14 Niibe Yutaka <gniibe@fsij.org>
* src/openpgp.c (cmd_change_password): Check password length
for admin less mode.
2012-12-13 Niibe Yutaka <gniibe@fsij.org> 2012-12-13 Niibe Yutaka <gniibe@fsij.org>
* src/openpgp-do.c (gpg_do_put_data): Add GPG_SUCCESS for * src/openpgp-do.c (gpg_do_put_data): Add GPG_SUCCESS for

View File

@@ -29,6 +29,8 @@
#include "openpgp.h" #include "openpgp.h"
#include "sha256.h" #include "sha256.h"
#define ADMIN_PASSWD_MINLEN 8
#define CLS(a) a.cmd_apdu_head[0] #define CLS(a) a.cmd_apdu_head[0]
#define INS(a) a.cmd_apdu_head[1] #define INS(a) a.cmd_apdu_head[1]
#define P1(a) a.cmd_apdu_head[2] #define P1(a) a.cmd_apdu_head[2]
@@ -259,8 +261,18 @@ cmd_change_password (void)
} }
else else
{ {
const uint8_t *ks_pw3 = gpg_do_read_simple (NR_DO_KEYSTRING_PW3);
newpw = pw + pw_len; newpw = pw + pw_len;
newpw_len = len - pw_len; newpw_len = len - pw_len;
/* Check length of password for admin-less mode. */
if (ks_pw3 == NULL && newpw_len < ADMIN_PASSWD_MINLEN)
{
DEBUG_INFO ("new password length is too short.");
GPG_CONDITION_NOT_SATISFIED ();
return;
}
} }
} }
else /* PW3 (0x83) */ else /* PW3 (0x83) */