1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef  _HASH_DRIVER_H
8 #define  _HASH_DRIVER_H
9 
10 #include "driver_defs.h"
11 
12 /******************************************************************************
13 *               TYPE DEFINITIONS
14 ******************************************************************************/
15 
16 /* The context data-base used by the Hash functions on the low level */
17 typedef struct HashContext {
18     /* mode: SHA1, SHA224, SHA256 */
19     hashMode_t mode;
20 
21     /* last block ack */
22     uint32_t isLastBlockProcessed;
23 
24     /* hash data */
25     uint32_t digest[MAX_DIGEST_SIZE_WORDS];
26 
27     /* The buffer that contains the size of so far digested message in the hardware.
28        For SHA1, sha-224 and SHA-256 it is 64 bits,
29        For SHA-384 and SHA-512 it is 128 bits */
30     uint32_t totalDataSizeProcessed[4];
31 
32 /* the follwing ia used only by soft sha512 */
33 
34     uint32_t valid_tag;
35 
36     /* the size of the Block size in bytes according to the currently running SHA algorithm (64 or 108) */
37     uint32_t blockSizeInBytes;
38 
39     /* The number of bytes in the previous update */
40     uint32_t prevDataInSize;
41 
42     /* A block buffer used for all cases where the update data size
43     is not aligned to a block size - we cannot perform the block,
44     therefore the first block is always loaded from this buffer  */
45     uint32_t prevDataIn[HASH_SHA512_BLOCK_SIZE_IN_WORDS];
46 
47     /* function pointers for llf hash operations */
48     llf_hash_init_operation_func  llfHashInitFuncP;
49     llf_hash_update_operation_func  llfHashUpdateFuncP;
50     llf_hash_finish_operation_func  llfHashFinishFuncP;
51 
52 } HashContext_t;
53 
54 
55 /* HW hash for sha1, sha224 and sha256 */
56 drvError_t InitHashDrv(void  *pCtx);
57 drvError_t ProcessHashDrv(void *pCtx, CCBuffInfo_t *pInputBuffInfo, uint32_t dataInSize);
58 drvError_t FinishHashDrv(void  *pCtx);
59 
60 /* soft hash for sha384 and sha512 */
61 drvError_t InitSwHash512(void  *pCtx);
62 drvError_t ProcessSwHash512(void  *pCtx, CCBuffInfo_t *pInputBuffInfo, uint32_t dataInSize );
63 drvError_t FinishSwHash512(void  *pCtx);
64 
65 #endif /* _HASH_DRIVER_H */
66 
67