1/*
2 * Copyright (C) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *    http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef SM4_COMMON_H
17#define SM4_COMMON_H
18
19#include "algorithm_parameter.h"
20#include "blob.h"
21#include "cipher.h"
22#include "sym_key.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28HcfResult GenerateSm4SymKey(HcfSymKey **key);
29int32_t GenerateSymKeyForSm4(const char *algoName, HcfSymKey **key);
30
31// use ECB, test abnormal input
32int32_t Sm4EncryptWithInput(HcfCipher *cipher, HcfSymKey *key, HcfBlob *input,
33    uint8_t *cipherText, int *cipherTextLen);
34
35// test encrypt and decrypt with null plain text
36int32_t Sm4DecryptEmptyMsg(HcfCipher *cipher, HcfSymKey *key, HcfParamsSpec *params,
37    uint8_t *cipherText, int cipherTextLen);
38int32_t Sm4Encrypt(HcfCipher *cipher, HcfSymKey *key, HcfParamsSpec *params,
39    uint8_t *cipherText, int *cipherTextLen);
40int32_t Sm4Decrypt(HcfCipher *cipher, HcfSymKey *key, HcfParamsSpec *params,
41    uint8_t *cipherText, int cipherTextLen);
42int32_t Sm4NoUpdateEncrypt(HcfCipher *cipher, HcfSymKey *key, HcfParamsSpec *params,
43    uint8_t *cipherText, int *cipherTextLen);
44int32_t Sm4NoUpdateDecrypt(HcfCipher *cipher, HcfSymKey *key, HcfParamsSpec *params,
45    uint8_t *cipherText, int cipherTextLen);
46const char *GetMockClass(void);
47
48#ifdef __cplusplus
49}
50#endif
51#endif
52