keygen-moduli passed

Handle trailing newlines in wolfSSL_BN_hex2bn
This commit is contained in:
Juliusz Sosinowicz
2019-12-20 17:24:06 +01:00
parent ae948e2a07
commit ab56d078a4
2 changed files with 11 additions and 3 deletions

View File

@@ -500,7 +500,7 @@ fi
if test "$ENABLED_OPENSSH" = "yes"
then
ENABLED_FORTRESS="yes"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_OPENSSH -DHAVE_EX_DATA"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_OPENSSH -DHAVE_EX_DATA -DWOLFSSL_BASE16"
fi
#Qt Support

View File

@@ -46782,6 +46782,7 @@ int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM** bn, const char* str)
byte decoded[1024];
#endif
int weOwn = 0;
int strLen;
WOLFSSL_MSG("wolfSSL_BN_hex2bn");
@@ -46791,9 +46792,16 @@ int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM** bn, const char* str)
return ret;
#endif
if (str == NULL || str[0] == '\0')
if (str == NULL || str[0] == '\0') {
WOLFSSL_MSG("Bad function argument");
else if (Base16_Decode((byte*)str, (int)XSTRLEN(str), decoded, &decSz) < 0)
return WOLFSSL_FAILURE;
}
strLen = XSTRLEN(str);
/* ignore trailing new lines */
while (str[strLen-1] == '\n' && strLen > 0) strLen--;
if (Base16_Decode((byte*)str, strLen, decoded, &decSz) < 0)
WOLFSSL_MSG("Bad Base16_Decode error");
else if (bn == NULL)
ret = decSz;