Skip to content

Commit ae844b4

Browse files
authored
Merge pull request #6378 from SparkiDev/minor_fixes_2
Minor fixes
2 parents c3e4da9 + 55a91c2 commit ae844b4

4 files changed

Lines changed: 35 additions & 68 deletions

File tree

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7702,7 +7702,7 @@ case $host_cpu in
77027702
;;
77037703
esac
77047704

7705-
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")
7705+
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")
77067706
then
77077707
AM_CFLAGS="$AM_CFLAGS -DALT_ECC_SIZE"
77087708
fi

examples/client/client.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,7 @@ static const char* client_usage_msg[][70] = {
12621262
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 73 */
12631263
#endif
12641264
#ifndef NO_PSK
1265-
"--openssl-psk Use TLS 1.3 PSK callback compatible with "
1266-
"OpenSSL\n", /* 74 */
1265+
"--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n", /* 74 */
12671266
#endif
12681267
"\n"
12691268
"For simpler wolfSSL TLS client examples, visit\n"
@@ -1487,8 +1486,7 @@ static const char* client_usage_msg[][70] = {
14871486
"--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 73 */
14881487
#endif
14891488
#ifndef NO_PSK
1490-
"--openssl-psk Use TLS 1.3 PSK callback compatible with "
1491-
"OpenSSL\n", /* 74 */
1489+
"--openssl-psk Use TLS 1.3 PSK callback compatible with OpenSSL\n", /* 74 */
14921490
#endif
14931491
"\n"
14941492
"より簡単なwolfSSL TSL クライアントの例については"

wolfcrypt/src/asn.c

Lines changed: 25 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5556,7 +5556,7 @@ int DecodeObjectId(const byte* in, word32 inSz, word16* out, word32* outSz)
55565556
}
55575557

55585558
/* return length */
5559-
*outSz = y;
5559+
*outSz = (word32)y;
55605560

55615561
return 0;
55625562
}
@@ -37034,73 +37034,43 @@ int wc_Asn1PrintOptions_Set(Asn1PrintOptions* opts, enum Asn1PrintOpt opt,
3703437034
break;
3703537035
/* Number of spaces to indent for each change in depth. */
3703637036
case ASN1_PRINT_OPT_INDENT:
37037-
/* Only 4 bits available for value. */
37037+
/* Only 4 bits allowed for value. */
3703837038
if (val >= (1 << 4)) {
3703937039
ret = BAD_FUNC_ARG;
3704037040
}
3704137041
else {
37042-
opts->indent = val;
37042+
opts->indent = (word8)val;
3704337043
}
3704437044
break;
3704537045
/* Draw branches instead of indenting. */
3704637046
case ASN1_PRINT_OPT_DRAW_BRANCH:
3704737047
/* Boolean value. */
37048-
if (val > 1) {
37049-
ret = BAD_FUNC_ARG;
37050-
}
37051-
else {
37052-
opts->draw_branch = val;
37053-
}
37048+
opts->draw_branch = (val > 0);
3705437049
break;
3705537050
/* Show raw data of primitive types as octets. */
3705637051
case ASN1_PRINT_OPT_SHOW_DATA:
3705737052
/* Boolean value. */
37058-
if (val > 1) {
37059-
ret = BAD_FUNC_ARG;
37060-
}
37061-
else {
37062-
opts->show_data = val;
37063-
}
37053+
opts->show_data = (val > 0);
3706437054
break;
3706537055
/* Show header data as octets. */
3706637056
case ASN1_PRINT_OPT_SHOW_HEADER_DATA:
3706737057
/* Boolean value. */
37068-
if (val > 1) {
37069-
ret = BAD_FUNC_ARG;
37070-
}
37071-
else {
37072-
opts->show_header_data = val;
37073-
}
37058+
opts->show_header_data = (val > 0);
3707437059
break;
3707537060
/* Show the wolfSSL OID value for OBJECT_ID. */
3707637061
case ASN1_PRINT_OPT_SHOW_OID:
3707737062
/* Boolean value. */
37078-
if (val > 1) {
37079-
ret = BAD_FUNC_ARG;
37080-
}
37081-
else {
37082-
opts->show_oid = val;
37083-
}
37063+
opts->show_oid = (val > 0);
3708437064
break;
3708537065
/* Don't show text representations of primitive types. */
3708637066
case ASN1_PRINT_OPT_SHOW_NO_TEXT:
3708737067
/* Boolean value. */
37088-
if (val > 1) {
37089-
ret = BAD_FUNC_ARG;
37090-
}
37091-
else {
37092-
opts->show_no_text = val;
37093-
}
37068+
opts->show_no_text = (val > 0);
3709437069
break;
3709537070
/* Don't show dump text representations of primitive types. */
3709637071
case ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT:
3709737072
/* Boolean value. */
37098-
if (val > 1) {
37099-
ret = BAD_FUNC_ARG;
37100-
}
37101-
else {
37102-
opts->show_no_dump_text = val;
37103-
}
37073+
opts->show_no_dump_text = (val > 0);
3710437074
break;
3710537075
}
3710637076
}
@@ -37251,7 +37221,7 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
3725137221
{
3725237222
word32 oid = (word32)-1;
3725337223
#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
37254-
word32 nid;
37224+
int nid;
3725537225
#endif
3725637226
const char* ln = NULL;
3725737227
word32 i = 0;
@@ -37262,7 +37232,7 @@ static void PrintObjectIdText(Asn1* asn1, Asn1PrintOptions* opts)
3726237232
asn1->item.len + 2);
3726337233
#if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
3726437234
/* Lookup NID for OID value. */
37265-
if ((nid = oid2nid(oid, oidIgnoreType)) != (word32)-1) {
37235+
if ((nid = oid2nid(oid, oidIgnoreType)) != -1) {
3726637236
/* Lookup long name for NID. */
3726737237
ln = wolfSSL_OBJ_nid2ln(nid);
3726837238
}
@@ -37546,9 +37516,9 @@ static void DrawBranch(Asn1* asn1)
3754637516
* @param [in] data Data to print.
3754737517
* @param [in] len Number of bytes to print.
3754837518
*/
37549-
static void PrintHexBytes(XFILE file, unsigned char* data, int len)
37519+
static void PrintHexBytes(XFILE file, unsigned char* data, word32 len)
3755037520
{
37551-
int i;
37521+
word32 i;
3755237522

3755337523
for (i = 0; i < len; i++) {
3755437524
XFPRINTF(file, " %02x", data[i]);
@@ -37564,15 +37534,18 @@ static void DumpHeader(Asn1* asn1, Asn1PrintOptions* opts)
3756437534
{
3756537535
/* Put on same line when not showing data too and not showing text data. */
3756637536
if ((!opts->show_data) && opts->show_no_text) {
37567-
XFPRINTF(asn1->file, "%10s %02x", "", asn1->item.tag);
37537+
XFPRINTF(asn1->file, "%10s", "");
3756837538
}
3756937539
else {
3757037540
/* Align with start of data. */
37571-
XFPRINTF(asn1->file, "\n%12s %02x", "", asn1->item.tag);
37541+
XFPRINTF(asn1->file, "\n%12s", "");
37542+
}
37543+
XFPRINTF(asn1->file, " %02x", asn1->item.tag);
37544+
if (asn1->curr >= asn1->offset + 1) {
37545+
/* Print the header bytes as hex bytes separated by a space. */
37546+
PrintHexBytes(asn1->file, asn1->data + asn1->offset + 1,
37547+
asn1->curr - (asn1->offset + 1));
3757237548
}
37573-
/* Print the header bytes as hex bytes separated by a space. */
37574-
PrintHexBytes(asn1->file, asn1->data + asn1->offset + 1,
37575-
asn1->curr - (asn1->offset + 1));
3757637549
}
3757737550

3757837551
/* Print ASN.1 item info based on header and indeces.
@@ -37628,16 +37601,12 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
3762837601
{
3762937602
int ret = 0;
3763037603

37631-
if ((asn1 == NULL) || (opts == NULL)) {
37632-
ret = BAD_FUNC_ARG;
37633-
}
37634-
3763537604
/* Process tag. */
3763637605
if (asn1->part == ASN_PART_TAG) {
3763737606
/* Recalculate which depth we are at. */
3763837607
UpdateDepth(asn1);
3763937608
/* Get tag. */
37640-
asn1->item.tag = asn1->data[asn1->curr] & ~ASN_CONSTRUCTED;
37609+
asn1->item.tag = asn1->data[asn1->curr] & (byte)~ASN_CONSTRUCTED;
3764137610
/* Store whether tag indicates constructed. */
3764237611
asn1->item.cons = (asn1->data[asn1->curr] & ASN_CONSTRUCTED) ==
3764337612
ASN_CONSTRUCTED;
@@ -37660,7 +37629,7 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
3766037629
/* Store ASN.1 item data offset. */
3766137630
asn1->item.data_idx = asn1->curr;
3766237631
/* Store ASN.1 item data length. */
37663-
asn1->item.len = len;
37632+
asn1->item.len = (word32)len;
3766437633

3766537634
/* Print info about ASN.1 item. */
3766637635
PrintInfo(asn1, opts);
@@ -37721,7 +37690,7 @@ static int wc_Asn1_Print(Asn1* asn1, Asn1PrintOptions* opts)
3772137690
* @param [in] data BER/DER data to print.
3772237691
* @param [in] len Length of data to print in bytes.
3772337692
* @return 0 on success.
37724-
* @return BAD_FUNC_ARG when asn1 or opts is NULL.
37693+
* @return BAD_FUNC_ARG when asn1, opts or data is NULL.
3772537694
* @return ASN_LEN_E when ASN.1 item's length too long.
3772637695
* @return ASN_DEPTH_E when end offset invalid.
3772737696
* @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,
3773137700
{
3773237701
int ret = 0;
3773337702

37734-
if (asn1 == NULL) {
37703+
if ((asn1 == NULL) || (opts == NULL) || (data == NULL)) {
3773537704
ret = BAD_FUNC_ARG;
3773637705
}
3773737706

wolfssl/wolfcrypt/asn_public.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -949,19 +949,19 @@ typedef struct Asn1PrintOptions {
949949
/* Length of DER/BER encoding to parse. */
950950
word32 length;
951951
/* Number of spaces to indent for each change in depth. */
952-
int indent:4;
952+
word8 indent;
953953
/* Draw branches instead of indenting. */
954-
int draw_branch:1;
954+
word8 draw_branch:1;
955955
/* Show raw data of primitive types as octets. */
956-
int show_data:1;
956+
word8 show_data:1;
957957
/* Show header data as octets. */
958-
int show_header_data:1;
958+
word8 show_header_data:1;
959959
/* Show the wolfSSL OID value for OBJECT_ID. */
960-
int show_oid:1;
960+
word8 show_oid:1;
961961
/* Don't show text representations of primitive types. */
962-
int show_no_text:1;
962+
word8 show_no_text:1;
963963
/* Don't show dump text representations of primitive types. */
964-
int show_no_dump_text:1;
964+
word8 show_no_dump_text:1;
965965
} Asn1PrintOptions;
966966

967967
/* ASN.1 item data. */

0 commit comments

Comments
 (0)