@@ -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. */
1148211483int 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 */
4076040767void 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 * */
4140941417int 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+ * */
4179741808void wc_InitDecodedAcert(DecodedAcert* acert, const byte* source, word32 inSz,
4179841809 void* heap)
4179941810{
0 commit comments