#include <crypto/internal/hash.h>
#include <linux/module.h>
#include <crypto/sm3_base.h>
#include <linux/bitops.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
const u8 sm3_zero_message_hash[SM3_DIGEST_SIZE] = {
0x1A, 0xB2, 0x1D, 0x83, 0x55, 0xCF, 0xA1, 0x7F,
0x8e, 0x61, 0x19, 0x48, 0x31, 0xE8, 0x1A, 0x8F,
0x22, 0xBE, 0xC8, 0xC7, 0x28, 0xFE, 0xFB, 0x74,
0x7E, 0xD0, 0x35, 0xEB, 0x50, 0x82, 0xAA, 0x2B
EXPORT_SYMBOL_GPL(sm3_zero_message_hash);
static inline u32 p0(u32 x)
return x ^ rol32(x, 9) ^ rol32(x, 17);
static inline u32 p1(u32 x)
return x ^ rol32(x, 15) ^ rol32(x, 23);
static inline u32 ff(unsigned int n, u32 a, u32 b, u32 c)
return (n < 16) ? (a ^ b ^ c) : ((a & b) | (a & c) | (b & c));
static inline u32 gg(unsigned int n, u32 e, u32 f, u32 g)
return (n < 16) ? (e ^ f ^ g) : ((e & f) | ((~e) & g));
static inline u32 t(unsigned int n)
return (n < 16) ? SM3_T1 : SM3_T2;