Skip to content

Commit

Permalink
cleanup: review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
philljj committed Sep 12, 2024
1 parent 2ab55bc commit b09a675
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
23 changes: 14 additions & 9 deletions src/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -5851,16 +5851,16 @@ static struct acert_dir_print_t acert_dir_print[ACERT_NUM_DIR_TAGS] =
* Returns total_len of str on success.
* Returns < 0 on failure.
* */
static int X509PrintDirType(char * dst, word32 max_len, const DNS_entry * entry)
static int X509PrintDirType(char * dst, int max_len, const DNS_entry * entry)
{
word32 k = 0;
word32 i = 0;
int k = 0;
int i = 0;
const char * src = entry->name;
word32 src_len = XSTRLEN(src);
word32 total_len = 0;
word32 bytes_left = max_len;
word32 fld_len = 0;
word32 match_found = 0;
int src_len = XSTRLEN(src);
int total_len = 0;
int bytes_left = max_len;
int fld_len = 0;
int match_found = 0;

XMEMSET(dst, 0, max_len);

Expand Down Expand Up @@ -5888,6 +5888,11 @@ static int X509PrintDirType(char * dst, word32 max_len, const DNS_entry * entry)
fld_len = src[i + 4];
i += 5;

if ((int) XSTRLEN(pfx) > bytes_left) {
/* Not enough space left. */
break;
}

XSTRNCPY(dst, pfx, bytes_left);
dst += XSTRLEN(pfx);
total_len += XSTRLEN(pfx);
Expand All @@ -5909,7 +5914,7 @@ static int X509PrintDirType(char * dst, word32 max_len, const DNS_entry * entry)
}
}

return 0;
return total_len;
}

static int X509_ACERT_print_name_entry(WOLFSSL_BIO* bio,
Expand Down
10 changes: 3 additions & 7 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -41018,8 +41018,8 @@ int ParseX509Acert(DecodedAcert* acert, int verify)
* @param [in] sig the parsed signature
* @param [in] sigSz the parsed signature length
* @param [in] sigOID the parsed signature OID
* @param [in] sigParams the parsed signature params
* @param [in] sigParamsSz the parsed signature params length
* @param [in] sigParams the parsed signature RSA-PSS params
* @param [in] sigParamsSz the parsed signature RSA-PSS params length
* @param [in] heap heap hint
*
* @return 0 on verify success
Expand Down Expand Up @@ -41054,7 +41054,7 @@ static int acert_sig_verify(const byte * acinfo, word32 acinfoSz,
(word32)pubKeyOID, sig, sigSz, sigOID,
sigParams, sigParamsSz, NULL);

if (ret == ASN_SIG_CONFIRM_E) {
if (ret == WC_NO_ERR_TRACE(ASN_SIG_CONFIRM_E)) {
WOLFSSL_MSG("info: VerifyX509Acert: confirm signature failed");
}

Expand All @@ -41064,10 +41064,6 @@ static int acert_sig_verify(const byte * acinfo, word32 acinfoSz,
sigCtx = NULL;
#endif

/* todo: RSA PSS support. */
(void) sigParams;
(void) sigParamsSz;

return ret;
}

Expand Down
8 changes: 4 additions & 4 deletions wolfssl/wolfcrypt/asn.h
Original file line number Diff line number Diff line change
Expand Up @@ -2323,17 +2323,17 @@ WOLFSSL_ASN_API int GetASNInt(const byte* input, word32* inOutIdx, int* len,
WOLFSSL_LOCAL int DecodeObjectId(const byte* in, word32 inSz,
word16* out, word32* outSz);
#endif
WOLFSSL_ASN_API int GetASNObjectId(const byte* input, word32* inOutIdx, int* len,
word32 maxIdx);
WOLFSSL_LOCAL int GetASNObjectId(const byte* input, word32* inOutIdx, int* len,
word32 maxIdx);
WOLFSSL_LOCAL int SetObjectId(int len, byte* output);
WOLFSSL_LOCAL int GetObjectId(const byte* input, word32* inOutIdx, word32* oid,
word32 oidType, word32 maxIdx);
WOLFSSL_LOCAL int GetAlgoId(const byte* input, word32* inOutIdx, word32* oid,
word32 oidType, word32 maxIdx);
WOLFSSL_LOCAL int GetAlgoIdEx(const byte* input, word32* inOutIdx, word32* oid,
word32 oidType, word32 maxIdx, byte *absentParams);
WOLFSSL_LOCAL int GetASNTag(const byte* input, word32* idx, byte* tag,
word32 inputSz);
WOLFSSL_ASN_API int GetASNTag(const byte* input, word32* idx, byte* tag,
word32 inputSz);
WOLFSSL_LOCAL int GetASN_BitString(const byte* input, word32 idx, int length);

WOLFSSL_LOCAL word32 SetASNLength(word32 length, byte* output);
Expand Down
5 changes: 5 additions & 0 deletions wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,11 @@ extern void uITRON4_free(void *p) ;
/* Extended Key Usage */
#undef WOLFSSL_EKU_OID
#define WOLFSSL_EKU_OID
/* Attribute Certificate support */
#if defined(WOLFSSL_ASN_TEMPLATE) && !defined(WOLFSSL_ACERT)
#define WOLFSSL_ACERT
#endif
#endif

#if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \
Expand Down

0 comments on commit b09a675

Please sign in to comment.