API参考
载入中...
搜索中...
未找到
crypt_sm4_armv8.h
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_ARMV8_H
17#define CRYPT_SM4_ARMV8_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_SM4
21
22#include <stdint.h>
23#include <stddef.h>
24
25#define XTS_KEY_LEN 32
26#define SM4_KEY_LEN 16
27
28typedef struct SM4_KEY_st {
29 uint32_t rk[XTS_KEY_LEN];
30} SM4_KEY;
31
32void Vpsm4SetEncryptKey(const unsigned char *userKey, SM4_KEY *key);
33
34void Vpsm4SetDecryptKey(const unsigned char *userKey, SM4_KEY *key);
35
36#ifdef HITLS_CRYPTO_XTS
37
38void Vpsm4XtsCipher(const unsigned char *in, unsigned char *out, uint32_t length, const SM4_KEY *key1,
39 const SM4_KEY *key2, const uint8_t *iv, uint32_t enc);
40#endif
41
42#ifdef HITLS_CRYPTO_CBC
43void Vpsm4CbcEncrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, const int enc);
44#endif
45
46#ifdef HITLS_CRYPTO_ECB
47void Vpsm4EcbEncrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key);
48#endif
49
50#ifdef HITLS_CRYPTO_CFB
51void Vpsm4Cfb128Encrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, int *num);
52void Vpsm4Cfb128Decrypt(const uint8_t *in, uint8_t *out, uint64_t len, const uint32_t *key, uint8_t *iv, int *num);
53#endif
54
55#if defined(HITLS_CRYPTO_CTR) || defined(HITLS_CRYPTO_GCM)
56void Vpsm4Ctr32EncryptBlocks(const uint8_t *in, uint8_t *out, uint64_t blocks, const uint32_t *key, uint8_t *iv);
57#endif
58
59#endif // HITLS_CRYPTO_SM4
60
61#endif