0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _CRYPTO_SM3_H
0011 #define _CRYPTO_SM3_H
0012
0013 #include <linux/types.h>
0014
0015 #define SM3_DIGEST_SIZE 32
0016 #define SM3_BLOCK_SIZE 64
0017
0018 #define SM3_T1 0x79CC4519
0019 #define SM3_T2 0x7A879D8A
0020
0021 #define SM3_IVA 0x7380166f
0022 #define SM3_IVB 0x4914b2b9
0023 #define SM3_IVC 0x172442d7
0024 #define SM3_IVD 0xda8a0600
0025 #define SM3_IVE 0xa96f30bc
0026 #define SM3_IVF 0x163138aa
0027 #define SM3_IVG 0xe38dee4d
0028 #define SM3_IVH 0xb0fb0e4e
0029
0030 extern const u8 sm3_zero_message_hash[SM3_DIGEST_SIZE];
0031
0032 struct sm3_state {
0033 u32 state[SM3_DIGEST_SIZE / 4];
0034 u64 count;
0035 u8 buffer[SM3_BLOCK_SIZE];
0036 };
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 static inline void sm3_init(struct sm3_state *sctx)
0049 {
0050 sctx->state[0] = SM3_IVA;
0051 sctx->state[1] = SM3_IVB;
0052 sctx->state[2] = SM3_IVC;
0053 sctx->state[3] = SM3_IVD;
0054 sctx->state[4] = SM3_IVE;
0055 sctx->state[5] = SM3_IVF;
0056 sctx->state[6] = SM3_IVG;
0057 sctx->state[7] = SM3_IVH;
0058 sctx->count = 0;
0059 }
0060
0061 void sm3_update(struct sm3_state *sctx, const u8 *data, unsigned int len);
0062 void sm3_final(struct sm3_state *sctx, u8 *out);
0063
0064 #endif