• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef CRYPT_SM4_X86_64_H
17 #define CRYPT_SM4_X86_64_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_CRYPTO_SM4
21 
22 #include <stdint.h>
23 
24 void SM4_SetEncKey(const uint8_t *key, uint32_t *rk);
25 
26 void SM4_SetDecKey(const uint8_t *key, uint32_t *rk);
27 
28 void SM4_Encrypt(const uint8_t *in, uint8_t *out, const uint32_t *key);
29 
30 #define SM4_Decrypt SM4_Encrypt
31 
32 // SM4 XTS
33 void SM4_XTS_Encrypt_Blocks(const uint8_t *in, uint8_t *out, uint32_t len,
34                             const uint32_t *key, uint8_t *t);
35 
36 void SM4_ECB_Encrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key);
37 void SM4_CBC_Encrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, const int enc);
38 void SM4_OFB_Encrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, int *num);
39 void SM4_CFB128_Encrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, int *num);
40 void SM4_CFB128_Decrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, int *num);
41 void SM4_CTR_EncryptBlocks(const uint8_t *in, uint8_t *out, uint64_t blocks, const uint32_t *key, const uint8_t *iv);
42 
43 #endif /* HITLS_CRYPTO_SM4 */
44 #endif