Skip to content

Commit 5b5686c

Browse files
committed
Peer review improvements.
1 parent 77d9410 commit 5b5686c

3 files changed

Lines changed: 30 additions & 42 deletions

File tree

doc/dox_comments/header_files/aes.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,12 @@ int wc_AesCtrSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
23152315
update parameter. It allows for key updates in certain hardware
23162316
implementations.
23172317
2318+
\note This function is currently only available when building with
2319+
Xilinx hardware acceleration. It requires one of the following build
2320+
options: WOLFSSL_XILINX_CRYPT (for Xilinx SecureIP integration) or
2321+
WOLFSSL_AFALG_XILINX_AES (for Xilinx AF_ALG support). This API may
2322+
be exposed for additional build configurations in the future.
2323+
23182324
\return 0 On success.
23192325
\return BAD_FUNC_ARG If aes or key is NULL, or if key length is invalid.
23202326
@@ -2460,8 +2466,15 @@ int wc_AesGcmEncryptInit_ex(Aes* aes, const byte* key, word32 len,
24602466
It processes plaintext and/or additional authentication data (AAD)
24612467
in a streaming fashion.
24622468
2469+
All the AAD must be passed to update before the plaintext.
2470+
The last part of AAD can be passed with the first part of plaintext.
2471+
2472+
Must set key and IV before calling this function.
2473+
Must call wc_AesGcmInit() before calling this function.
2474+
24632475
\return 0 On success.
2464-
\return BAD_FUNC_ARG If aes is NULL, or if parameters are invalid.
2476+
\return BAD_FUNC_ARG If aes is NULL, or a length is non-zero but
2477+
buffer is NULL.
24652478
24662479
\param aes pointer to the AES structure
24672480
\param out pointer to buffer to store ciphertext (can be NULL if sz=0)
@@ -2480,7 +2493,7 @@ int wc_AesGcmEncryptInit_ex(Aes* aes, const byte* key, word32 len,
24802493
byte aad[20] = { }; // additional data
24812494
24822495
wc_AesInit(&aes, NULL, INVALID_DEVID);
2483-
wc_AesGcmEncryptInit(&aes, key, 16, iv, 12);
2496+
wc_AesGcmInit(&aes, key, 16, iv, 12);
24842497
int ret = wc_AesGcmEncryptUpdate(&aes, ciphertext, plaintext, 100,
24852498
aad, 20);
24862499
if (ret != 0) {
@@ -2489,6 +2502,7 @@ int wc_AesGcmEncryptInit_ex(Aes* aes, const byte* key, word32 len,
24892502
wc_AesFree(&aes);
24902503
\endcode
24912504
2505+
\sa wc_AesGcmInit
24922506
\sa wc_AesGcmEncryptInit
24932507
\sa wc_AesGcmEncryptFinal
24942508
*/
@@ -2575,8 +2589,15 @@ int wc_AesGcmDecryptInit(Aes* aes, const byte* key, word32 len,
25752589
It processes ciphertext and/or additional authentication data (AAD)
25762590
in a streaming fashion.
25772591
2592+
All the AAD must be passed to update before the ciphertext.
2593+
The last part of AAD can be passed with the first part of ciphertext.
2594+
2595+
Must set key and IV before calling this function.
2596+
Must call wc_AesGcmInit() before calling this function.
2597+
25782598
\return 0 On success.
2579-
\return BAD_FUNC_ARG If aes is NULL, or if parameters are invalid.
2599+
\return BAD_FUNC_ARG If aes is NULL, or a length is non-zero but
2600+
buffer is NULL.
25802601
25812602
\param aes pointer to the AES structure
25822603
\param out pointer to buffer to store plaintext (can be NULL if sz=0)
@@ -2595,7 +2616,7 @@ int wc_AesGcmDecryptInit(Aes* aes, const byte* key, word32 len,
25952616
byte aad[20] = { }; // additional data
25962617
25972618
wc_AesInit(&aes, NULL, INVALID_DEVID);
2598-
wc_AesGcmDecryptInit(&aes, key, 16, iv, 12);
2619+
wc_AesGcmInit(&aes, key, 16, iv, 12);
25992620
int ret = wc_AesGcmDecryptUpdate(&aes, plaintext, ciphertext, 100,
26002621
aad, 20);
26012622
if (ret != 0) {
@@ -2604,6 +2625,7 @@ int wc_AesGcmDecryptInit(Aes* aes, const byte* key, word32 len,
26042625
wc_AesFree(&aes);
26052626
\endcode
26062627
2628+
\sa wc_AesGcmInit
26072629
\sa wc_AesGcmDecryptInit
26082630
\sa wc_AesGcmDecryptFinal
26092631
*/

doc/dox_comments/header_files/signature.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ int wc_SignatureGenerate(
177177
word32 sigLen = sizeof(sig);
178178
179179
wc_ecc_init(&eccKey);
180-
// import public key and compute hash
180+
// import public key, signature, and pre-computed hash ...
181181
int ret = wc_SignatureVerifyHash(WC_HASH_TYPE_SHA256,
182182
WC_SIGNATURE_TYPE_ECC, hash,
183183
sizeof(hash), sig, sigLen,
@@ -231,7 +231,7 @@ int wc_SignatureVerifyHash(enum wc_HashType hash_type,
231231
wc_InitRng(&rng);
232232
wc_ecc_init(&eccKey);
233233
wc_ecc_make_key(&rng, 32, &eccKey);
234-
// compute hash
234+
// generate signature from pre-computed hash
235235
int ret = wc_SignatureGenerateHash(WC_HASH_TYPE_SHA256,
236236
WC_SIGNATURE_TYPE_ECC, hash,
237237
sizeof(hash), sig, &sigLen,

wolfcrypt/src/aes.c

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12095,24 +12095,7 @@ int wc_AesGcmEncryptInit_ex(Aes* aes, const byte* key, word32 len, byte* ivOut,
1209512095
return ret;
1209612096
}
1209712097

12098-
/* Update the AES GCM for encryption with data and/or authentication data.
12099-
*
12100-
* All the AAD must be passed to update before the plaintext.
12101-
* Last part of AAD can be passed with first part of plaintext.
12102-
*
12103-
* Must set key and IV before calling this function.
12104-
* Must call wc_AesGcmInit() before calling this function.
12105-
*
12106-
* @param [in, out] aes AES object.
12107-
* @param [out] out Buffer to hold cipher text.
12108-
* @param [in] in Buffer holding plaintext.
12109-
* @param [in] sz Length of plaintext in bytes.
12110-
* @param [in] authIn Buffer holding authentication data.
12111-
* @param [in] authInSz Length of authentication data in bytes.
12112-
* @return 0 on success.
12113-
* @return BAD_FUNC_ARG when aes is NULL, or a length is non-zero but buffer
12114-
* is NULL.
12115-
*/
12098+
/* Update the AES GCM for encryption with data and/or authentication data. */
1211612099
int wc_AesGcmEncryptUpdate(Aes* aes, byte* out, const byte* in, word32 sz,
1211712100
const byte* authIn, word32 authInSz)
1211812101
{
@@ -12254,24 +12237,7 @@ int wc_AesGcmDecryptInit(Aes* aes, const byte* key, word32 len, const byte* iv,
1225412237
return wc_AesGcmInit(aes, key, len, iv, ivSz);
1225512238
}
1225612239

12257-
/* Update the AES GCM for decryption with data and/or authentication data.
12258-
*
12259-
* All the AAD must be passed to update before the cipher text.
12260-
* Last part of AAD can be passed with first part of cipher text.
12261-
*
12262-
* Must set key and IV before calling this function.
12263-
* Must call wc_AesGcmInit() before calling this function.
12264-
*
12265-
* @param [in, out] aes AES object.
12266-
* @param [out] out Buffer to hold plaintext.
12267-
* @param [in] in Buffer holding cipher text.
12268-
* @param [in] sz Length of cipher text in bytes.
12269-
* @param [in] authIn Buffer holding authentication data.
12270-
* @param [in] authInSz Length of authentication data in bytes.
12271-
* @return 0 on success.
12272-
* @return BAD_FUNC_ARG when aes is NULL, or a length is non-zero but buffer
12273-
* is NULL.
12274-
*/
12240+
/* Update the AES GCM for decryption with data and/or authentication data. */
1227512241
int wc_AesGcmDecryptUpdate(Aes* aes, byte* out, const byte* in, word32 sz,
1227612242
const byte* authIn, word32 authInSz)
1227712243
{

0 commit comments

Comments
 (0)