@@ -80,8 +80,9 @@ typedef struct DecodedX509 {
8080 \param maxIdx Maximum allowed index in buffer
8181 \return Length on success, TPM_RC_INSUFFICIENT on buffer error
8282*/
83- WOLFTPM_API int TPM2_ASN_GetLength (const uint8_t * input , word32 * inOutIdx , int * len ,
84- word32 maxIdx );
83+ WOLFTPM_API int TPM2_ASN_GetLength (const uint8_t * input , word32 * inOutIdx ,
84+ int * len , word32 maxIdx );
85+
8586/*!
8687 \ingroup ASN
8788 \brief Decodes ASN.1 length with optional length checking
@@ -92,8 +93,9 @@ WOLFTPM_API int TPM2_ASN_GetLength(const uint8_t* input, word32* inOutIdx, int*
9293 \param check Flag to enable length validation
9394 \return Length on success, TPM_RC_INSUFFICIENT on buffer error
9495*/
95- WOLFTPM_API int TPM2_ASN_GetLength_ex (const uint8_t * input , word32 * inOutIdx , int * len ,
96- word32 maxIdx , int check );
96+ WOLFTPM_API int TPM2_ASN_GetLength_ex (const uint8_t * input , word32 * inOutIdx ,
97+ int * len , word32 maxIdx , int check );
98+
9799/*!
98100 \ingroup ASN
99101 \brief Decodes ASN.1 tag and validates length
@@ -104,44 +106,59 @@ WOLFTPM_API int TPM2_ASN_GetLength_ex(const uint8_t* input, word32* inOutIdx, in
104106 \param tag Expected ASN.1 tag value
105107 \return 0 on success, TPM_RC_INSUFFICIENT on buffer error, TPM_RC_VALUE on tag mismatch
106108*/
107- WOLFTPM_API int TPM2_ASN_DecodeTag (const uint8_t * input , int inputSz , int * inOutIdx , int * tag_len , uint8_t tag );
109+ WOLFTPM_API int TPM2_ASN_DecodeTag (const uint8_t * input , int inputSz ,
110+ int * inOutIdx , int * tag_len , uint8_t tag );
111+
108112/*!
109113 \ingroup ASN
110114 \brief Decodes RSA signature from ASN.1 format
111115 \param pInput Pointer to buffer containing ASN.1 encoded RSA signature
112116 \param inputSz Size of input buffer
113- \return Size of decoded signature on success, TPM_RC_VALUE on invalid input, TPM_RC_INSUFFICIENT on buffer error
117+ \return Size of decoded signature on success, TPM_RC_VALUE on invalid input,
118+ TPM_RC_INSUFFICIENT on buffer error
114119*/
115120WOLFTPM_API int TPM2_ASN_RsaDecodeSignature (uint8_t * * pInput , int inputSz );
121+
116122/*!
117123 \brief Decodes an X.509 certificate
118124 \param input Buffer containing ASN.1 encoded X.509 certificate
119125 \param inputSz Size of input buffer
120126 \param x509 Structure to store decoded certificate data
121127 \return 0 on success, TPM_RC_VALUE on invalid input, TPM_RC_INSUFFICIENT on buffer error
122128*/
123- WOLFTPM_API int TPM2_ASN_DecodeX509Cert (uint8_t * input , int inputSz , DecodedX509 * x509 );
129+ WOLFTPM_API int TPM2_ASN_DecodeX509Cert (uint8_t * input , int inputSz ,
130+ DecodedX509 * x509 );
131+
124132/*!
125133 \ingroup ASN
126134 \brief Decodes RSA public key from ASN.1 format into TPM2B_PUBLIC structure
127135 \param input Buffer containing ASN.1 encoded RSA public key
128136 \param inputSz Size of input buffer
129137 \param pub TPM2B_PUBLIC structure to store decoded key
130- \return 0 on success, TPM_RC_VALUE on invalid input, TPM_RC_INSUFFICIENT on buffer error
138+ \return 0 on success, TPM_RC_VALUE on invalid input,
139+ TPM_RC_INSUFFICIENT on buffer error
131140*/
132- WOLFTPM_API int TPM2_ASN_DecodeRsaPubKey (uint8_t * input , int inputSz , TPM2B_PUBLIC * pub );
141+ WOLFTPM_API int TPM2_ASN_DecodeRsaPubKey (uint8_t * input , int inputSz ,
142+ TPM2B_PUBLIC * pub );
143+
133144/*!
134145 \ingroup ASN
135146 \brief Removes PKCS#1 v1.5 padding from RSA signature
136- \param pSig Pointer to buffer containing padded signature, updated to point to unpadded data
147+ \param pSig Pointer to buffer containing padded signature, updated to point
148+ to unpadded data
137149 \param sigSz Size of signature buffer, updated with unpadded size
138150 \return 0 on success, TPM_RC_VALUE on invalid padding
139151*/
140152WOLFTPM_API int TPM2_ASN_RsaUnpadPkcsv15 (uint8_t * * pSig , int * sigSz );
141153
142-
143- WOLFTPM_LOCAL byte * TPM2_ASN_TrimZeros (byte * in , word32 * len );
144-
154+ /*!
155+ \ingroup ASN
156+ \brief Removes leading zero bytes from a buffer
157+ \param in Pointer to input buffer containing data to trim
158+ \param len Pointer to length of input buffer, updated with new length after trimming
159+ \return Pointer to the trimmed buffer (may be same as input if no trimming needed)
160+ */
161+ WOLFTPM_API byte * TPM2_ASN_TrimZeros (byte * in , word32 * len );
145162
146163#ifdef __cplusplus
147164 } /* extern "C" */
0 commit comments