~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/crypto/sm3.h

Version: ~ [ linux-5.19-rc3 ] ~ [ linux-5.18.5 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.48 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.123 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.199 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.248 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.284 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.319 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 
 18 #define SM3_T1          0x79CC4519
 19 #define SM3_T2          0x7A879D8A
 20 
 21 #define SM3_IVA         0x7380166f
 22 #define SM3_IVB         0x4914b2b9
 23 #define SM3_IVC         0x172442d7
 24 #define SM3_IVD         0xda8a0600
 25 #define SM3_IVE         0xa96f30bc
 26 #define SM3_IVF         0x163138aa
 27 #define SM3_IVG         0xe38dee4d
 28 #define SM3_IVH         0xb0fb0e4e
 29 
 30 extern const u8 sm3_zero_message_hash[SM3_DIGEST_SIZE];
 31 
 32 struct sm3_state {
 33         u32 state[SM3_DIGEST_SIZE / 4];
 34         u64 count;
 35         u8 buffer[SM3_BLOCK_SIZE];
 36 };
 37 
 38 /*
 39  * Stand-alone implementation of the SM3 algorithm. It is designed to
 40  * have as little dependencies as possible so it can be used in the
 41  * kexec_file purgatory. In other cases you should generally use the
 42  * hash APIs from include/crypto/hash.h. Especially when hashing large
 43  * amounts of data as those APIs may be hw-accelerated.
 44  *
 45  * For details see lib/crypto/sm3.c
 46  */
 47 
 48 static inline void sm3_init(struct sm3_state *sctx)
 49 {
 50         sctx->state[0] = SM3_IVA;
 51         sctx->state[1] = SM3_IVB;
 52         sctx->state[2] = SM3_IVC;
 53         sctx->state[3] = SM3_IVD;
 54         sctx->state[4] = SM3_IVE;
 55         sctx->state[5] = SM3_IVF;
 56         sctx->state[6] = SM3_IVG;
 57         sctx->state[7] = SM3_IVH;
 58         sctx->count = 0;
 59 }
 60 
 61 void sm3_update(struct sm3_state *sctx, const u8 *data, unsigned int len);
 62 void sm3_final(struct sm3_state *sctx, u8 *out);
 63 
 64 #endif
 65 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp