2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * ARM CryptoCell Hash Crypto API
21 #ifndef __SSI_HASH_H__
22 #define __SSI_HASH_H__
24 #include "ssi_buffer_mgr.h"
26 #define HMAC_IPAD_CONST 0x36363636
27 #define HMAC_OPAD_CONST 0x5C5C5C5C
28 #if (DX_DEV_SHA_MAX > 256)
29 #define HASH_LEN_SIZE 16
30 #define SSI_MAX_HASH_DIGEST_SIZE SHA512_DIGEST_SIZE
31 #define SSI_MAX_HASH_BLCK_SIZE SHA512_BLOCK_SIZE
33 #define HASH_LEN_SIZE 8
34 #define SSI_MAX_HASH_DIGEST_SIZE SHA256_DIGEST_SIZE
35 #define SSI_MAX_HASH_BLCK_SIZE SHA256_BLOCK_SIZE
38 #define XCBC_MAC_K1_OFFSET 0
39 #define XCBC_MAC_K2_OFFSET 16
40 #define XCBC_MAC_K3_OFFSET 32
42 #define CC_EXPORT_MAGIC 0xC2EE1070U
44 // this struct was taken from drivers/crypto/nx/nx-aes-xcbc.c and it is used for xcbc/cmac statesize
45 struct aeshash_state {
46 u8 state[AES_BLOCK_SIZE];
48 u8 buffer[AES_BLOCK_SIZE];
52 struct ahash_req_ctx {
55 u8 *digest_result_buff;
56 struct async_gen_req_ctx gen_ctx;
57 enum ssi_req_dma_buf_type data_dma_buf_type;
61 dma_addr_t opad_digest_dma_addr;
62 dma_addr_t digest_buff_dma_addr;
63 dma_addr_t digest_bytes_len_dma_addr;
64 dma_addr_t digest_result_dma_addr;
68 u32 xcbc_count; /* count xcbc update operatations */
69 struct scatterlist buff_sg[2];
70 struct scatterlist *curr_sg;
73 struct mlli_params mlli_params;
76 int ssi_hash_alloc(struct ssi_drvdata *drvdata);
77 int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata);
78 int ssi_hash_free(struct ssi_drvdata *drvdata);
81 * Gets the initial digest length
84 * \param mode The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256/SHA384/SHA512
86 * \return u32 returns the address of the initial digest length in SRAM
89 ssi_ahash_get_initial_digest_len_sram_addr(void *drvdata, u32 mode);
92 * Gets the address of the initial digest in SRAM
93 * according to the given hash mode
96 * \param mode The Hash mode. Supported modes: MD5/SHA1/SHA224/SHA256/SHA384/SHA512
98 * \return u32 The address of the inital digest in SRAM
100 ssi_sram_addr_t ssi_ahash_get_larval_digest_sram_addr(void *drvdata, u32 mode);
102 #endif /*__SSI_HASH_H__*/