Minor fixes

configure.ac: Don't use == in test.
client.c: Merge string to one line.
asn.c/asn_public.h:
  fix conversion warnings/errors.
  wc_Asn1_Print no longer public and doesn't need to check for NULL.
  wc_Asn1_PrintAll check all pointer parameters for NULL.
This commit is contained in:
Sean Parkinson 2023-05-05 08:43:50 +10:00
parent c3e4da9f66
commit 55a91c2b55
4 changed files with 35 additions and 68 deletions

View File

@ -7702,7 +7702,7 @@ case $host_cpu in
;;
esac
if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_ECC" = "yes" && (test "$ENABLED_RSA" = "yes" || test "$ENABLED_DH" == "yes") && (test "$ENABLED_SP_MATH" = "yes" || test "$ENABLED_SP_MATH_ALL" = "yes")
if test "$ENABLED_LOWRESOURCE" = "yes" && test "$ENABLED_ECC" = "yes" && (test "$ENABLED_RSA" = "yes" || test "$ENABLED_DH" = "yes") && (test "$ENABLED_SP_MATH" = "yes" || test "$ENABLED_SP_MATH_ALL" = "yes")
then
AM_CFLAGS="$AM_CFLAGS -DALT_ECC_SIZE"
fi

View File

@ -1262,8 +1262,7 @@ static const char* client_usage_msg[][70] = {
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 73 */
#endif
#ifndef NO_PSK
"--openssl-psk Use TLS 1.3 PSK callback compatible with "
"OpenSSL\n", /* 74 */
"--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n", /* 74 */
#endif
"\n"
"For simpler wolfSSL TLS client examples, visit\n"
@ -1487,8 +1486,7 @@ static const char* client_usage_msg[][70] = {
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 73 */
#endif
#ifndef NO_PSK
"--openssl-psk Use TLS 1.3 PSK callback compatible with "
"OpenSSL\n", /* 74 */
"--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n", /* 74 */
#endif
"\n"
"より簡単なwolfSSL TSL クライアントの例については"

View File

@ -5556,7 +5556,7 @@ int DecodeObjectId(const byte* in, word32 inSz, word16* out, word32* outSz)
}
/* return length */
*outSz = y;
*outSz = (word32)y;
return 0;
}
@ -37034,73 +37034,43 @@ int wc_Asn1PrintOptions_Set(Asn1PrintOptions* opts, enum Asn1PrintOpt opt,
break;
/* Number of spaces to indent for each change in depth. */
case ASN1_PRINT_OPT_INDENT:
/* Only 4 bits available for value. */
/* Only 4 bits allowed for value. */
if (val >= (1 << 4)) {
ret = BAD_FUNC_ARG;
}
else {
opts->indent = val;
opts->indent = (word8)val;
}
break;
/* Draw branches instead of indenting. */
case ASN1_PRINT_OPT_DRAW_BRANCH:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->draw_branch = val;
}
opts->draw_branch = (val > 0);
break;
/* Show raw data of primitive types as octets. */
case ASN1_PRINT_OPT_SHOW_DATA:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->show_data = val;
}
opts->show_data = (val > 0);
break;
/* Show header data as octets. */
case ASN1_PRINT_OPT_SHOW_HEADER_DATA:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->show_header_data = val;
}
opts->show_header_data = (val > 0);
break;
/* Show the wolfSSL OID value for OBJECT_ID. */
case ASN1_PRINT_OPT_SHOW_OID:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->show_oid = val;
}
opts->show_oid = (val > 0);
break;
/* Don't show text representations of primitive types. */
case ASN1_PRINT_OPT_SHOW_NO_TEXT:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->show_no_text = val;
}
opts->show_no_text = (val > 0);
break;
/* Don't show dump text representations of primitive types. */
case ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT:
/* Boolean value. */
if (val > 1) {
ret = BAD_FUNC_ARG;
}
else {
opts->show_no_dump_text = val;
}
opts->show_no_dump_text = (val > 0);
break;
}
}
@ -37251,7 +37221,7 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
{
word32 oid = (word32)-1;
#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
word32 nid;
int nid;
#endif
const char* ln = NULL;
word32 i = 0;
@ -37262,7 +37232,7 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
asn1->item.len + 2);
#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
/* Lookup NID for OID value. */
if ((nid = oid2nid(oid, oidIgnoreType)) != (word32)-1) {
if ((nid = oid2nid(oid, oidIgnoreType)) != -1) {
/* Lookup long name for NID. */
ln = wolfSSL_OBJ_nid2ln(nid);
}
@ -37546,9 +37516,9 @@ static void DrawBranch(Asn1* asn1)
* @param [in] data Data to print.
* @param [in] len Number of bytes to print.
*/
static void PrintHexBytes(XFILE file, unsigned char* data, int len)
static void PrintHexBytes(XFILE file, unsigned char* data, word32 len)
{
int i;
word32 i;
for (i = 0; i < len; i++) {
XFPRINTF(file, " %02x", data[i]);
@ -37564,15 +37534,18 @@ static void DumpHeader(Asn1* asn1, Asn1PrintOptions* opts)
{
/* Put on same line when not showing data too and not showing text data. */
if ((!opts->show_data) && opts->show_no_text) {
XFPRINTF(asn1->file, "%10s %02x", "", asn1->item.tag);
XFPRINTF(asn1->file, "%10s", "");
}
else {
/* Align with start of data. */
XFPRINTF(asn1->file, "\n%12s %02x", "", asn1->item.tag);
XFPRINTF(asn1->file, "\n%12s", "");
}
XFPRINTF(asn1->file, " %02x", asn1->item.tag);
if (asn1->curr >= asn1->offset + 1) {
/* Print the header bytes as hex bytes separated by a space. */
PrintHexBytes(asn1->file, asn1->data + asn1->offset + 1,
asn1->curr - (asn1->offset + 1));
}
/* Print the header bytes as hex bytes separated by a space. */
PrintHexBytes(asn1->file, asn1->data + asn1->offset + 1,
asn1->curr - (asn1->offset + 1));
}
/* Print ASN.1 item info based on header and indeces.
@ -37628,16 +37601,12 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
{
int ret = 0;
if ((asn1 == NULL) || (opts == NULL)) {
ret = BAD_FUNC_ARG;
}
/* Process tag. */
if (asn1->part == ASN_PART_TAG) {
/* Recalculate which depth we are at. */
UpdateDepth(asn1);
/* Get tag. */
asn1->item.tag = asn1->data[asn1->curr] & ~ASN_CONSTRUCTED;
asn1->item.tag = asn1->data[asn1->curr] & (byte)~ASN_CONSTRUCTED;
/* Store whether tag indicates constructed. */
asn1->item.cons = (asn1->data[asn1->curr] & ASN_CONSTRUCTED) ==
ASN_CONSTRUCTED;
@ -37660,7 +37629,7 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
/* Store ASN.1 item data offset. */
asn1->item.data_idx = asn1->curr;
/* Store ASN.1 item data length. */
asn1->item.len = len;
asn1->item.len = (word32)len;
/* Print info about ASN.1 item. */
PrintInfo(asn1, opts);
@ -37721,7 +37690,7 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
* @param [in] data BER/DER data to print.
* @param [in] len Length of data to print in bytes.
* @return 0 on success.
* @return BAD_FUNC_ARG when asn1 or opts is NULL.
* @return BAD_FUNC_ARG when asn1, opts or data is NULL.
* @return ASN_LEN_E when ASN.1 item's length too long.
* @return ASN_DEPTH_E when end offset invalid.
* @return ASN_PARSE_E when not all of an ASN.1 item parsed.
@ -37731,7 +37700,7 @@ int wc_Asn1_PrintAll(Asn1* asn1, Asn1PrintOptions* opts, unsigned char* data,
{
int ret = 0;
if (asn1 == NULL) {
if ((asn1 == NULL) || (opts == NULL) || (data == NULL)) {
ret = BAD_FUNC_ARG;
}

View File

@ -949,19 +949,19 @@ typedef struct Asn1PrintOptions {
/* Length of DER/BER encoding to parse. */
word32 length;
/* Number of spaces to indent for each change in depth. */
int indent:4;
word8 indent;
/* Draw branches instead of indenting. */
int draw_branch:1;
word8 draw_branch:1;
/* Show raw data of primitive types as octets. */
int show_data:1;
word8 show_data:1;
/* Show header data as octets. */
int show_header_data:1;
word8 show_header_data:1;
/* Show the wolfSSL OID value for OBJECT_ID. */
int show_oid:1;
word8 show_oid:1;
/* Don't show text representations of primitive types. */
int show_no_text:1;
word8 show_no_text:1;
/* Don't show dump text representations of primitive types. */
int show_no_dump_text:1;
word8 show_no_dump_text:1;
} Asn1PrintOptions;
/* ASN.1 item data. */