1 /* 2 * (C) Copyright ASPEED Technology Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #ifndef _CRYPTO_H_ 8 #define _CRYPTO_H_ 9 10 #define ASPEED_SHA224 0x0 11 #define ASPEED_SHA256 0x1 12 #define ASPEED_SHA384 0x2 13 #define ASPEED_SHA512 0x3 14 15 #define ASPEED_RSA1024 0x0 16 #define ASPEED_RSA2048 0x1 17 #define ASPEED_RSA3072 0x2 18 #define ASPEED_RSA4096 0x3 19 20 #define ASPEED_HACE_BASE (0x1E6D0000) 21 #define ASPEED_HACE_SRC 0x00 22 #define ASPEED_HACE_DEST 0x04 23 #define ASPEED_HACE_CONTEXT 0x08 /* 8 byte aligned*/ 24 #define ASPEED_HACE_DATA_LEN 0x0C 25 #define ASPEED_HACE_CMD 0x10 26 #define ASPEED_HACE_STS (ASPEED_HACE_BASE + 0x1C) 27 #define HACE_RSA_ISR BIT(13) 28 #define HACE_CRYPTO_ISR BIT(12) 29 #define HACE_HASH_ISR BIT(9) 30 #define HACE_RSA_BUSY BIT(2) 31 #define HACE_CRYPTO_BUSY BIT(1) 32 #define HACE_HASH_BUSY BIT(0) 33 #define ASPEED_HACE_HASH_SRC (ASPEED_HACE_BASE + 0x20) 34 #define ASPEED_HACE_HASH_DIGEST_BUFF (ASPEED_HACE_BASE + 0x24) 35 #define ASPEED_HACE_HASH_KEY_BUFF (ASPEED_HACE_BASE + 0x28) // 64 byte aligned,g6 16 byte aligned 36 #define ASPEED_HACE_HASH_DATA_LEN (ASPEED_HACE_BASE + 0x2C) 37 #define ASPEED_HACE_HASH_CMD (ASPEED_HACE_BASE + 0x30) 38 39 struct aspeed_sg_list { 40 u32 len; 41 u32 phy_addr; 42 } __packed; 43 44 extern int aspeed_sg_digest(struct aspeed_sg_list *src_list, u32 list_length, u32 length, u8 *digest, u32 method); 45 extern int digest_object(u8 *src, u32 length, u8 *digest, u32 method); 46 extern int aes256ctr_decrypt_object(u8 *src, u8 *dst, u32 length, u8 *context); 47 extern int rsa_alg(u8 *data, int data_bytes, u8 *m, int m_bits, u8 *e, int e_bits, u8 *dst, void *contex_buf); 48 extern void enable_crypto(void); 49 50 #endif /* #ifndef _CRYPTO_H_ */ 51