SM4 encryption algorithm. More...
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
#define | TAU(a) |
#define | L(b) ((b) ^ ROL32(b, 2) ^ ROL32(b, 10) ^ ROL32(b, 18) ^ ROL32(b, 24)) |
#define | LP(b) ((b) ^ ROL32(b, 13) ^ ROL32(b, 23)) |
#define | F(x0, x1, x2, x3, rk) |
Functions | |
__weak_func error_t | sm4Init (Sm4Context *context, const uint8_t *key, size_t keyLen) |
Key expansion. More... | |
__weak_func void | sm4EncryptBlock (Sm4Context *context, const uint8_t *input, uint8_t *output) |
Encrypt a 16-byte block using SM4 algorithm. More... | |
__weak_func void | sm4DecryptBlock (Sm4Context *context, const uint8_t *input, uint8_t *output) |
Decrypt a 16-byte block using SM4 algorithm. More... | |
__weak_func void | sm4Deinit (Sm4Context *context) |
Release SM4 context. More... | |
Variables | |
const uint8_t | SM4_ECB_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x01} |
const uint8_t | SM4_CBC_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x02} |
const uint8_t | SM4_OFB_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x03} |
const uint8_t | SM4_CFB_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x04} |
const uint8_t | SM4_CTR_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x07} |
const uint8_t | SM4_GCM_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x08} |
const uint8_t | SM4_CCM_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x09} |
const uint8_t | SM4_XTS_OID [8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x0A} |
const CipherAlgo | sm4CipherAlgo |
Detailed Description
SM4 encryption algorithm.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCRYPTO Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file sm4.c.
Macro Definition Documentation
◆ F
#define F | ( | x0, | |
x1, | |||
x2, | |||
x3, | |||
rk | |||
) |
◆ L
◆ LP
◆ TAU
#define TAU | ( | a | ) |
◆ TRACE_LEVEL
Function Documentation
◆ sm4DecryptBlock()
__weak_func void sm4DecryptBlock | ( | Sm4Context * | context, |
const uint8_t * | input, | ||
uint8_t * | output | ||
) |
◆ sm4Deinit()
__weak_func void sm4Deinit | ( | Sm4Context * | context | ) |
◆ sm4EncryptBlock()
__weak_func void sm4EncryptBlock | ( | Sm4Context * | context, |
const uint8_t * | input, | ||
uint8_t * | output | ||
) |
◆ sm4Init()
__weak_func error_t sm4Init | ( | Sm4Context * | context, |
const uint8_t * | key, | ||
size_t | keyLen | ||
) |
Variable Documentation
◆ SM4_CBC_OID
const uint8_t SM4_CBC_OID = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x02} |
◆ SM4_CCM_OID
const uint8_t SM4_CCM_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x09} |
◆ SM4_CFB_OID
const uint8_t SM4_CFB_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x04} |
◆ SM4_CTR_OID
const uint8_t SM4_CTR_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x07} |
◆ SM4_ECB_OID
const uint8_t SM4_ECB_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x01} |
◆ SM4_GCM_OID
const uint8_t SM4_GCM_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x08} |
◆ SM4_OFB_OID
const uint8_t SM4_OFB_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x03} |
◆ SM4_XTS_OID
const uint8_t SM4_XTS_OID[8] = {0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, 0x68, 0x0A} |
◆ sm4CipherAlgo
const CipherAlgo sm4CipherAlgo |