![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 0003 /* 0004 * Common values for the SM4 algorithm 0005 * Copyright (C) 2018 ARM Limited or its affiliates. 0006 * Copyright (c) 2021 Tianjia Zhang <tianjia.zhang@linux.alibaba.com> 0007 */ 0008 0009 #ifndef _CRYPTO_SM4_H 0010 #define _CRYPTO_SM4_H 0011 0012 #include <linux/types.h> 0013 #include <linux/crypto.h> 0014 0015 #define SM4_KEY_SIZE 16 0016 #define SM4_BLOCK_SIZE 16 0017 #define SM4_RKEY_WORDS 32 0018 0019 struct sm4_ctx { 0020 u32 rkey_enc[SM4_RKEY_WORDS]; 0021 u32 rkey_dec[SM4_RKEY_WORDS]; 0022 }; 0023 0024 extern const u32 crypto_sm4_fk[]; 0025 extern const u32 crypto_sm4_ck[]; 0026 extern const u8 crypto_sm4_sbox[]; 0027 0028 /** 0029 * sm4_expandkey - Expands the SM4 key as described in GB/T 32907-2016 0030 * @ctx: The location where the computed key will be stored. 0031 * @in_key: The supplied key. 0032 * @key_len: The length of the supplied key. 0033 * 0034 * Returns 0 on success. The function fails only if an invalid key size (or 0035 * pointer) is supplied. 0036 */ 0037 int sm4_expandkey(struct sm4_ctx *ctx, const u8 *in_key, 0038 unsigned int key_len); 0039 0040 /** 0041 * sm4_crypt_block - Encrypt or decrypt a single SM4 block 0042 * @rk: The rkey_enc for encrypt or rkey_dec for decrypt 0043 * @out: Buffer to store output data 0044 * @in: Buffer containing the input data 0045 */ 0046 void sm4_crypt_block(const u32 *rk, u8 *out, const u8 *in); 0047 0048 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |