Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1560806 - Increased the max size supported for softoken passwords…
…. r=jcj

Differential Revision: https://phabricator.services.mozilla.com/D39444

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Marcus Burghardt committed Jul 26, 2019
1 parent dc4e736 commit b232c5b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/lib/secpwd.c
Expand Up @@ -66,7 +66,7 @@ SEC_GetPassword(FILE *input, FILE *output, char *prompt,
int infd = fileno(input);
int isTTY = isatty(infd);
#endif
char phrase[200] = { '\0' }; /* ensure EOF doesn't return junk */
char phrase[500] = { '\0' }; /* ensure EOF doesn't return junk */

for (;;) {
/* Prompt for password */
Expand Down
2 changes: 1 addition & 1 deletion cmd/pk11mode/pk11mode.c
Expand Up @@ -5229,7 +5229,7 @@ PKM_Digest(CK_FUNCTION_LIST_PTR pFunctionList,
char *
PKM_FilePasswd(char *pwFile)
{
unsigned char phrase[200];
unsigned char phrase[500];
PRFileDesc *fd;
PRInt32 nb;
int i;
Expand Down
2 changes: 1 addition & 1 deletion cmd/shlibsign/shlibsign.c
Expand Up @@ -614,7 +614,7 @@ softokn_Init(CK_FUNCTION_LIST_PTR pFunctionList, const char *configDir,
static char *
filePasswd(char *pwFile)
{
unsigned char phrase[200];
unsigned char phrase[500];
PRFileDesc *fd;
PRInt32 nb;
int i;
Expand Down
21 changes: 21 additions & 0 deletions gtests/softoken_gtest/softoken_gtest.cc
Expand Up @@ -120,6 +120,27 @@ TEST_F(SoftokenTest, CreateObjectChangePassword) {
EXPECT_EQ(nullptr, obj);
}

/* The size limit for a password is 500 characters as defined in pkcs11i.h */
TEST_F(SoftokenTest, CreateObjectChangeToBigPassword) {
ScopedPK11SlotInfo slot(PK11_GetInternalKeySlot());
ASSERT_TRUE(slot);
EXPECT_EQ(SECSuccess, PK11_InitPin(slot.get(), nullptr, nullptr));
EXPECT_EQ(
SECSuccess,
PK11_ChangePW(slot.get(), "",
"rUIFIFr2bxKnbJbitsfkyqttpk6vCJzlYMNxcxXcaN37gSZKbLk763X7iR"
"yeVNWZHQ02lSF69HYjzTyPW3318ZD0DBFMMbALZ8ZPZP73CIo5uIQlaowV"
"IbP8eOhRYtGUqoLGlcIFNEYogV8Q3GN58VeBMs0KxrIOvPQ9s8SnYYkqvt"
"zzgntmAvCgvk64x6eQf0okHwegd5wi6m0WVJytEepWXkP9J629FSa5kNT8"
"FvL3jvslkiImzTNuTvl32fQDXXMSc8vVk5Q3mH7trMZM0VDdwHWYERjHbz"
"kGxFgp0VhediHx7p9kkz6H6ac4et9sW4UkTnN7xhYc1Zr17wRSk2heQtcX"
"oZJGwuzhiKm8A8wkuVxms6zO56P4JORIk8oaUW6lyNTLo2kWWnTA"));
EXPECT_EQ(SECSuccess, PK11_Logout(slot.get()));
ScopedPK11GenericObject obj(PK11_CreateGenericObject(
slot.get(), attributes, PR_ARRAY_SIZE(attributes), true));
EXPECT_EQ(nullptr, obj);
}

TEST_F(SoftokenTest, CreateObjectChangeToEmptyPassword) {
ScopedPK11SlotInfo slot(PK11_GetInternalKeySlot());
ASSERT_TRUE(slot);
Expand Down
2 changes: 1 addition & 1 deletion lib/softoken/pkcs11i.h
Expand Up @@ -459,7 +459,7 @@ struct SFTKItemTemplateStr {

#define SFTK_TOKEN_KRL_HANDLE (SFTK_TOKEN_MAGIC | SFTK_TOKEN_TYPE_CRL | 1)
/* how big (in bytes) a password/pin we can deal with */
#define SFTK_MAX_PIN 255
#define SFTK_MAX_PIN 500
/* minimum password/pin length (in Unicode characters) in FIPS mode */
#define FIPS_MIN_PIN 7

Expand Down

0 comments on commit b232c5b

Please sign in to comment.