• 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 CRYPTO_TEST_UTIL_H
17 #define CRYPTO_TEST_UTIL_H
18 
19 #include "hitls_build.h"
20 #include "crypt_eal_cipher.h"
21 #include "crypt_eal_pkey.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 void TestMemInit(void);
28 
29 int TestRandInit(void);
30 
31 void TestRandDeInit(void);
32 
33 bool IsMdAlgDisabled(int id);
34 
35 bool IsHmacAlgDisabled(int id);
36 
37 bool IsMacAlgDisabled(int id);
38 
39 bool IsDrbgHashAlgDisabled(int id);
40 
41 bool IsDrbgHmacAlgDisabled(int id);
42 
43 int GetAvailableRandAlgId(void);
44 
45 bool IsRandAlgDisabled(int id);
46 
47 bool IsAesAlgDisabled(int id);
48 
49 bool IsSm4AlgDisabled(int id);
50 
51 bool IsCipherAlgDisabled(int id);
52 
53 bool IsCmacAlgDisabled(int id);
54 
55 bool IsCurveDisabled(int eccId);
56 
57 bool IsCurve25519AlgDisabled(int id);
58 
59 int32_t TestSimpleRand(uint8_t *buff, uint32_t len);
60 int32_t TestSimpleRandEx(void *libCtx, uint8_t *buff, uint32_t len);
61 
62 #if defined(HITLS_CRYPTO_EAL) && defined(HITLS_CRYPTO_MAC)
63 uint32_t TestGetMacLen(int algId);
64 void TestMacSameAddr(int algId, Hex *key, Hex *data, Hex *mac);
65 void TestMacAddrNotAlign(int algId, Hex *key, Hex *data, Hex *mac);
66 #endif
67 
68 #ifdef HITLS_CRYPTO_CIPHER
69 CRYPT_EAL_CipherCtx *TestCipherNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t id, const char *attrName, int isProvider);
70 #endif
71 
72 #ifdef HITLS_CRYPTO_PKEY
73 CRYPT_EAL_PkeyCtx *TestPkeyNewCtx(
74     CRYPT_EAL_LibCtx *libCtx, int32_t id, uint32_t operType, const char *attrName, int isProvider);
75 #endif
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif // CRYPTO_TEST_UTIL_H