Skip to content

Commit 5d7a908

Browse files
committed
Better explanation of the use of mbedtls_sha1_context fields
1 parent 2af6294 commit 5d7a908

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

features/mbedtls/targets/TARGET_STM/sha1_alt.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ extern "C" {
3333
#endif
3434

3535
/**
36-
* \brief SHA-1 context structure
36+
* \brief SHA-1 context structure
37+
* \note HAL_HASH_SHA1_Accumulate cannot handle less than 4 bytes, unless it is the last call to the function
38+
* In case of buffer size < 4, flag is set to 1, remaining bytes are copied in a temp buffer.
39+
* The pointer and the length are saved in sbuf and sbuf_len.
40+
* At the next accumulation, the saved values are taken into account, and flag is set to 0
41+
* If SHA1_finish is called and flag=1, the remaining bytes are accumulated before the call to HAL_HASH_SHA1_Finish
3742
*/
3843
typedef struct
3944
{
40-
unsigned char *sbuf;
41-
unsigned char sbuf_len;
42-
HASH_HandleTypeDef hhash_sha1;
43-
int flag; /* flag to manage buffer constraint of crypto Hw */
45+
unsigned char *sbuf; /*!< pointer to the remaining buffer to be processed */
46+
unsigned char sbuf_len; /*!< number of bytes remaining in sbuf to be processed */
47+
HASH_HandleTypeDef hhash_sha1; /*!< ST HAL HASH struct */
48+
int flag; /*!< 1 : there are sbuf_len bytes to be processed in sbuf, 0 : every data have been processed. */
4449
}
4550
mbedtls_sha1_context;
4651

0 commit comments

Comments
 (0)