1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Common values for SM3 algorithm 4 * 5 * Copyright (C) 2017 ARM Limited or its affiliates. 6 * Copyright (C) 2017 Gilad Ben-Yossef <gilad@benyossef.com> 7 * Copyright (C) 2021 Tianjia Zhang <tianjia.zhang@linux.alibaba.com> 8 */ 9 10 #ifndef _CRYPTO_SM3_H 11 #define _CRYPTO_SM3_H 12 13 #include <linux/types.h> 14 15 #define SM3_DIGEST_SIZE 32 16 #define SM3_BLOCK_SIZE 64 17 #define SM3_STATE_SIZE 40 18 19 #define SM3_IVA 0x7380166f 20 #define SM3_IVB 0x4914b2b9 21 #define SM3_IVC 0x172442d7 22 #define SM3_IVD 0xda8a0600 23 #define SM3_IVE 0xa96f30bc 24 #define SM3_IVF 0x163138aa 25 #define SM3_IVG 0xe38dee4d 26 #define SM3_IVH 0xb0fb0e4e 27 28 struct sm3_state { 29 u32 state[SM3_DIGEST_SIZE / 4]; 30 u64 count; 31 u8 buffer[SM3_BLOCK_SIZE]; 32 }; 33 34 /* 35 * Stand-alone implementation of the SM3 algorithm. It is designed to 36 * have as little dependencies as possible so it can be used in the 37 * kexec_file purgatory. In other cases you should generally use the 38 * hash APIs from include/crypto/hash.h. Especially when hashing large 39 * amounts of data as those APIs may be hw-accelerated. 40 * 41 * For details see lib/crypto/sm3.c 42 */ 43 44 void sm3_block_generic(struct sm3_state *sctx, u8 const *data, int blocks); 45 46 #endif 47