Skip to content

Commit 937d6d4

Browse files
committed
dual alg: clean up comments and line lengths.
1 parent 3df616a commit 937d6d4

3 files changed

Lines changed: 55 additions & 38 deletions

File tree

src/x509.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,10 +1695,10 @@ int wolfSSL_X509_EXTENSION_set_critical(WOLFSSL_X509_EXTENSION* ex, int crit)
16951695
* Returns NULL on error or pointer to the v3_ext_method populated with
16961696
* extension type-specific X509V3_EXT_* function(s).
16971697
*
1698-
* NOTE: WC_NID_subject_key_identifier is currently the only extension implementing
1699-
* the X509V3_EXT_* functions, as it is the only type called directly by QT. The
1700-
* other extension types return a pointer to a v3_ext_method struct that
1701-
* contains only the NID.
1698+
* NOTE: WC_NID_subject_key_identifier is currently the only extension
1699+
* implementing the X509V3_EXT_* functions, as it is the only type called
1700+
* directly by QT. The other extension types return a pointer to a
1701+
* v3_ext_method struct that contains only the NID.
17021702
*/
17031703
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L
17041704
const WOLFSSL_v3_ext_method* wolfSSL_X509V3_EXT_get(WOLFSSL_X509_EXTENSION* ex)
@@ -4559,7 +4559,8 @@ WOLFSSL_GENERAL_NAME* wolfSSL_GENERAL_NAME_dup(WOLFSSL_GENERAL_NAME* gn)
45594559
* WOLFSSL_SUCCESS otherwise.
45604560
*/
45614561
int wolfSSL_GENERAL_NAME_set0_othername(WOLFSSL_GENERAL_NAME* gen,
4562-
WOLFSSL_ASN1_OBJECT* oid, WOLFSSL_ASN1_TYPE* value)
4562+
WOLFSSL_ASN1_OBJECT* oid,
4563+
WOLFSSL_ASN1_TYPE* value)
45634564
{
45644565
WOLFSSL_ASN1_OBJECT *x = NULL;
45654566

@@ -13951,7 +13952,8 @@ int wolfSSL_X509_NAME_print_ex(WOLFSSL_BIO* bio, WOLFSSL_X509_NAME* name,
1395113952
int tmpSz;
1395213953

1395313954
/* reverse name order for RFC2253 and DN_REV */
13954-
if ((flags & WOLFSSL_XN_FLAG_RFC2253) || (flags & WOLFSSL_XN_FLAG_DN_REV)) {
13955+
if ((flags & WOLFSSL_XN_FLAG_RFC2253) ||
13956+
(flags & WOLFSSL_XN_FLAG_DN_REV)) {
1395513957
ne = wolfSSL_X509_NAME_get_entry(name, count - i - 1);
1395613958
}
1395713959
else {

tests/api.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ static int test_dual_alg_ecdsa_mldsa(void)
16211621
defined(WOLFSSL_WC_DILITHIUM) && \
16221622
!defined(WOLFSSL_DILITHIUM_NO_MAKE_KEY) && \
16231623
!defined(WOLFSSL_DILITHIUM_NO_SIGN) && \
1624-
!defined(WOLFSSL_DILITHIUM_NO_VERIFY)
1624+
!defined(WOLFSSL_DILITHIUM_NO_VERIFY) && !defined(WOLFSSL_SMALL_STACK)
16251625
WOLFSSL_CERT_MANAGER * cm = NULL;
16261626
MlDsaKey alt_ca_key;
16271627
ecc_key ca_key;
@@ -1735,12 +1735,16 @@ static int test_dual_alg_ecdsa_mldsa(void)
17351735
cm = wolfSSL_CertManagerNew();
17361736
ExpectNotNull(cm);
17371737

1738+
/* Load the certificate into CertManager. */
17381739
if (cm != NULL && final_der_sz > 0) {
17391740
ret = wolfSSL_CertManagerLoadCABuffer(cm, final_der, final_der_sz,
17401741
WOLFSSL_FILETYPE_ASN1);
17411742
ExpectIntEQ(ret, WOLFSSL_SUCCESS);
1743+
}
17421744

1745+
if (cm != NULL) {
17431746
wolfSSL_CertManagerFree(cm);
1747+
cm = NULL;
17441748
}
17451749

17461750
wc_ecc_free(&ca_key);

wolfcrypt/src/asn.c

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,8 +2451,9 @@ static int GetASNHeader_ex(const byte* input, byte tag, word32* inOutIdx,
24512451
ret = ASN_PARSE_E;
24522452
}
24532453
else if ((input[(int)idx + length - 1] & 0x80) == 0x80) {
2454-
/* Last octet of a sub-identifier has bit 8 clear. Last octet must be
2455-
* last of a subidentifier. Ensure last octet hasn't got top bit set. */
2454+
/* Last octet of a sub-identifier has bit 8 clear. Last octet must
2455+
* be last of a subidentifier. Ensure last octet hasn't got top bit
2456+
* set. */
24562457
WOLFSSL_MSG("OID last octet has top bit set");
24572458
ret = ASN_PARSE_E;
24582459
}
@@ -3629,8 +3630,8 @@ word32 SetIndefEnd(byte* output)
36293630

36303631
/* Breaks an octet string up into chunks for use with streaming
36313632
* returns 0 on success and updates idx */
3632-
int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out, word32* outSz,
3633-
word32* idx)
3633+
int StreamOctetString(const byte* inBuf, word32 inBufSz, byte* out,
3634+
word32* outSz, word32* idx)
36343635
{
36353636
word32 i = 0;
36363637
word32 outIdx = *idx;
@@ -11477,8 +11478,8 @@ int wc_DsaKeyToParamsDer(DsaKey* key, byte* output, word32 inLen)
1147711478
}
1147811479

1147911480
/* This version of the function allows output to be NULL. In that case, the
11480-
DsaKeyIntsToDer will return WC_NO_ERR_TRACE(LENGTH_ONLY_E) and the required output buffer
11481-
size will be pointed to by inLen. */
11481+
DsaKeyIntsToDer will return WC_NO_ERR_TRACE(LENGTH_ONLY_E) and the required
11482+
output buffer size will be pointed to by inLen. */
1148211483
int wc_DsaKeyToParamsDer_ex(DsaKey* key, byte* output, word32* inLen)
1148311484
{
1148411485
if (!key || !inLen)
@@ -16265,7 +16266,8 @@ static WC_INLINE int IsSigAlgoECC(word32 algoOID)
1626516266
* @return Encoded data size on success.
1626616267
* @return 0 when dynamic memory allocation fails.
1626716268
*/
16268-
static word32 SetAlgoIDImpl(int algoOID, byte* output, int type, int curveSz, byte absentParams)
16269+
static word32 SetAlgoIDImpl(int algoOID, byte* output, int type, int curveSz,
16270+
byte absentParams)
1626916271
{
1627016272
#ifndef WOLFSSL_ASN_TEMPLATE
1627116273
word32 tagSz, idSz, seqSz, algoSz = 0;
@@ -16395,7 +16397,8 @@ word32 SetAlgoID(int algoOID, byte* output, int type, int curveSz)
1639516397
return SetAlgoIDImpl(algoOID, output, type, curveSz, FALSE);
1639616398
}
1639716399

16398-
word32 SetAlgoIDEx(int algoOID, byte* output, int type, int curveSz, byte absentParams)
16400+
word32 SetAlgoIDEx(int algoOID, byte* output, int type, int curveSz,
16401+
byte absentParams)
1639916402
{
1640016403
return SetAlgoIDImpl(algoOID, output, type, curveSz, absentParams);
1640116404
}
@@ -34375,7 +34378,8 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
3437534378
ret = BUFFER_E;
3437634379
else {
3437734380
#ifdef WOLFSSL_SMALL_STACK
34378-
pub = (byte*)XMALLOC(pubSz, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
34381+
pub = (byte*)XMALLOC(pubSz, key->heap,
34382+
DYNAMIC_TYPE_TMP_BUFFER);
3437934383
if (pub == NULL)
3438034384
ret = MEMORY_E;
3438134385
else
@@ -36015,7 +36019,8 @@ int wc_Ed25519PrivateKeyToDer(ed25519_key* key, byte* output, word32 inLen)
3601536019
#if defined(HAVE_CURVE25519) && defined(HAVE_CURVE25519_KEY_EXPORT)
3601636020
/* Write only private Curve25519 key to DER format,
3601736021
* length on success else < 0 */
36018-
int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output, word32 inLen)
36022+
int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output,
36023+
word32 inLen)
3601936024
{
3602036025
int ret;
3602136026
byte privKey[CURVE25519_KEYSIZE];
@@ -36057,7 +36062,8 @@ int wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen,
3605736062
/* Export Curve25519 key to DER format - handles private only, public only,
3605836063
* or private+public key pairs based on what's set in the key structure.
3605936064
* Returns length written on success, negative on error */
36060-
int wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen, int withAlg)
36065+
int wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen,
36066+
int withAlg)
3606136067
{
3606236068
int ret;
3606336069
byte privKey[CURVE25519_KEYSIZE];
@@ -36488,12 +36494,13 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3648836494
single->status->thisDateParsed.length);
3648936495
#endif
3649036496
if (GetBasicDate(source, &idx, single->status->thisDate,
36491-
&single->status->thisDateFormat, size) < 0)
36497+
&single->status->thisDateFormat, size) < 0)
3649236498
return ASN_PARSE_E;
3649336499

3649436500
#ifndef NO_ASN_TIME_CHECK
3649536501
#ifndef WOLFSSL_NO_OCSP_DATE_CHECK
36496-
if (!XVALIDATE_DATE(single->status->thisDate, single->status->thisDateFormat, ASN_BEFORE))
36502+
if (!XVALIDATE_DATE(single->status->thisDate,
36503+
single->status->thisDateFormat, ASN_BEFORE))
3649736504
return ASN_BEFORE_DATE_E;
3649836505
#endif
3649936506
#endif
@@ -36524,7 +36531,7 @@ static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size,
3652436531
single->status->nextDateParsed.length);
3652536532
#endif
3652636533
if (GetBasicDate(source, &idx, single->status->nextDate,
36527-
&single->status->nextDateFormat, size) < 0)
36534+
&single->status->nextDateFormat, size) < 0)
3652836535
return ASN_PARSE_E;
3652936536

3653036537
#ifndef NO_ASN_TIME_CHECK
@@ -38685,7 +38692,7 @@ static int ParseCRL_CertList(RevokedCert* rcert, DecodedCRL* dcrl,
3868538692
{
3868638693
#if !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_CRL_DATE_CHECK)
3868738694
if (verify != NO_VERIFY &&
38688-
!XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, ASN_AFTER)) {
38695+
!XVALIDATE_DATE(dcrl->nextDate, dcrl->nextDateFormat, ASN_AFTER)) {
3868938696
WOLFSSL_MSG("CRL after date is no longer valid");
3869038697
WOLFSSL_ERROR_VERBOSE(CRL_CERT_DATE_ERR);
3869138698
return CRL_CERT_DATE_ERR;
@@ -39790,8 +39797,8 @@ int wc_MIME_header_strip(char* in, char** out, size_t start, size_t end)
3979039797
}
3979139798

3979239799
/*****************************************************************************
39793-
* wc_MIME_find_header_name - Searches through all given headers until a header with
39794-
* a name matching the provided name is found.
39800+
* wc_MIME_find_header_name - Searches through all given headers until a header
39801+
* with a name matching the provided name is found.
3979539802
*
3979639803
* RETURNS:
3979739804
* returns a pointer to the found header, if no match was found, returns NULL.
@@ -39869,8 +39876,8 @@ char* wc_MIME_single_canonicalize(const char* line, word32* len)
3986939876
}
3987039877

3987139878
/*****************************************************************************
39872-
* wc_MIME_free_hdrs - Frees all MIME headers, parameters and strings starting from
39873-
* the provided header pointer.
39879+
* wc_MIME_free_hdrs - Frees all MIME headers, parameters and strings starting
39880+
* from the provided header pointer.
3987439881
*
3987539882
* RETURNS:
3987639883
* returns zero on success, non-zero on error.
@@ -40726,9 +40733,9 @@ int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
4072640733
#endif /* !NO_RSA && (!NO_BIG_INT || WOLFSSL_SP_MATH) */
4072740734

4072840735
#if defined(WOLFSSL_ACERT) && defined(WOLFSSL_ASN_TEMPLATE)
40729-
/* Initialize decoded certificate object with buffer of DER encoding.
40736+
/* Initialize decoded attribute certificate object with buffer of DER encoding.
4073040737
*
40731-
* @param [in, out] cert Decoded certificate object.
40738+
* @param [in, out] acert Decoded attribute certificate object.
4073240739
* @param [in] source Buffer containing DER encoded certificate.
4073340740
* @param [in] inSz Size of DER data in buffer in bytes.
4073440741
* @param [in] heap Dynamic memory hint.
@@ -40755,7 +40762,7 @@ void InitDecodedAcert(DecodedAcert* acert, const byte* source, word32 inSz,
4075540762

4075640763
/* Free the decoded attribute cert object's dynamic data.
4075740764
*
40758-
* @param [in, out] acert Attribute Decoded certificate object.
40765+
* @param [in, out] acert Decoded attribute certificate object.
4075940766
*/
4076040767
void FreeDecodedAcert(DecodedAcert * acert)
4076140768
{
@@ -40792,7 +40799,7 @@ void FreeDecodedAcert(DecodedAcert * acert)
4079240799
* @param [in, out] inOutIdx On in, the index of the start of the OtherName.
4079340800
* On out, index after OtherName.
4079440801
* @param [in] len Length of data in buffer.
40795-
* @param [in] cert Decoded attribute certificate object.
40802+
* @param [in] acert Decoded attribute certificate object.
4079640803
* @param [in, out] entries Linked list of DNS name entries.
4079740804
*
4079840805
* @return 0 on success.
@@ -40933,7 +40940,7 @@ static int DecodeAcertGeneralName(const byte* input, word32* inOutIdx,
4093340940
* @param [in] input Buffer holding encoded data.
4093440941
* @param [in] sz Size of encoded data in bytes.
4093540942
* @param [in] tag ASN.1 tag value expected in header.
40936-
* @param [in, out] cert Decoded certificate object.
40943+
* @param [in, out] acert Decoded certificate object.
4093740944
* @param [in, out] entries Linked list of DNS name entries.
4093840945
*
4093940946
* @return 0 on success.
@@ -41059,11 +41066,10 @@ enum {
4105941066
#define HolderASN_Length (sizeof(HolderASN) / sizeof(ASNItem))
4106041067

4106141068
/* Decode the Holder field of an x509 attribute certificate.
41062-
*
4106341069
*
4106441070
* @param [in] input Buffer containing encoded Holder field.
4106541071
* @param [in] len Length of Holder field.
41066-
* @param [in] cert Decoded certificate object.
41072+
* @param [in, out] acert Decoded certificate object.
4106741073
*
4106841074
* @return 0 on success.
4106941075
* @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or
@@ -41227,7 +41233,7 @@ enum {
4122741233
*
4122841234
* @param [in] input Buffer containing encoded AttCertIssuer field.
4122941235
* @param [in] len Length of Holder field.
41230-
* @param [in] cert Decoded certificate object.
41236+
* @param [in,out] acert Decoded attribute certificate object.
4123141237
*
4123241238
* @return 0 on success.
4123341239
* @return ASN_PARSE_E when BER encoded data does not match ASN.1 items or
@@ -41403,8 +41409,10 @@ enum {
4140341409
* - extensions
4140441410
* - attributes
4140541411
*
41406-
* Returns 0 on success.
41407-
* Returns negative error code on error/failure.
41412+
* @param [in, out] acert Decoded attribute certificate object.
41413+
* @param [in] verify Whether to verify dates.
41414+
* @return 0 on success.
41415+
* @return negative error code on error/fail.
4140841416
* */
4140941417
int ParseX509Acert(DecodedAcert* acert, int verify)
4141041418
{
@@ -41614,7 +41622,6 @@ int ParseX509Acert(DecodedAcert* acert, int verify)
4161441622
}
4161541623

4161641624
/* Given the parsed attribute cert info, verify the signature.
41617-
*
4161841625
* The sigCtx is alloced and freed here.
4161941626
*
4162041627
* @param [in] acinfo the parsed acinfo sequence
@@ -41705,7 +41712,7 @@ int VerifyX509Acert(const byte* der, word32 derSz,
4170541712
const byte * sigParams = NULL;
4170641713
word32 sigParamsSz = 0;
4170741714

41708-
WOLFSSL_MSG("ParseX509Acert");
41715+
WOLFSSL_MSG("VerifyX509Acert");
4170941716

4171041717
if (der == NULL || pubKey == NULL || derSz == 0 || pubKeySz == 0) {
4171141718
WOLFSSL_MSG("error: VerifyX509Acert: bad args");
@@ -41794,6 +41801,10 @@ int VerifyX509Acert(const byte* der, word32 derSz,
4179441801
return ret;
4179541802
}
4179641803

41804+
/**
41805+
* Wrapper API to expose Acert ASN functions. See Acert ASN functions
41806+
* for comments.
41807+
* */
4179741808
void wc_InitDecodedAcert(DecodedAcert* acert, const byte* source, word32 inSz,
4179841809
void* heap)
4179941810
{

0 commit comments

Comments
 (0)