提交 a927a6d4 编写于 作者: C code4lala

add 8 test cases

Signed-off-by: Ncode4lala <fenglala@outlook.com>
Change-Id: I4ce833b1d66837a55f4b30cf845a8d75ed26dad1
上级 f7fc437f
......@@ -50,16 +50,8 @@ hctest_suite("ActsSecurityHichainBasicDeps") {
"UTILS_FILE_IMPLEMENTED=1",
"TEST_PTHREAD_CREATE_DETACHED=0",
"TEST_HC_FILE_OPEN_SERIES=1",
"TEST_HKDF_WITH_KEY_ALIAS_TRUE=1",
"TEST_IMPORT_ASYMMETRIC_KEY=1",
"TEST_COMPUTEHMAC_WITH_ISALIAS_TRUE=1",
"TEST_HASH_TO_POINT=1",
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET=1",
"TEST_BIG_NUM_EXP_MOD=1",
]
defines += DEVICEAUTH_BASIC_DEPS_ALGORITHM_DEFINES
if (defined(ohos_lite)) {
include_dirs += [
......@@ -76,11 +68,42 @@ hctest_suite("ActsSecurityHichainBasicDeps") {
defines -= [
"FLASH_START_ADDRESS_HICHAIN=0",
"TEST_HC_FILE_OPEN_SERIES=1",
"TEST_HKDF_WITH_KEY_ALIAS_TRUE=1",
"TEST_COMPUTEHMAC_WITH_ISALIAS_TRUE=1",
"TEST_HASH_TO_POINT=1",
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET=1",
"TEST_GENERATE_KEY_PAIR=1",
"TEST_EXPORT_PUBLIC_KEY=1",
"TEST_ALGORITHM_SIGN=1",
"TEST_ALGORITHM_VERIFY=1",
"TEST_IMPORT_PUBLIC_KEY=1",
"TEST_CHECK_KEY_EXIST=1",
"TEST_DELETE_KEY=1",
"TEST_AES_GCM_ENCRYPT=1",
"TEST_AES_GCM_DECRYPT=1",
]
defines += [
"FLASH_START_ADDRESS_HICHAIN=0x1F6000",
"TEST_HC_FILE_OPEN_SERIES=0",
"TEST_HKDF_WITH_KEY_ALIAS_TRUE=0",
"TEST_COMPUTEHMAC_WITH_ISALIAS_TRUE=0",
"TEST_HASH_TO_POINT=0",
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=0",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=0",
"TEST_AGREE_SHARED_SECRET=0",
"TEST_GENERATE_KEY_PAIR=0",
"TEST_EXPORT_PUBLIC_KEY=0",
"TEST_ALGORITHM_SIGN=0",
"TEST_ALGORITHM_VERIFY=0",
"TEST_IMPORT_PUBLIC_KEY=0",
"TEST_CHECK_KEY_EXIST=0",
"TEST_DELETE_KEY=0",
"TEST_AES_GCM_ENCRYPT=0",
"TEST_AES_GCM_DECRYPT=0",
]
defines += [ "DO_NOT_TEST_DEPRECATED_IMPORT_SYMMETRIC_KEY=1" ]
}
if (board_name == "hispark_pegasus") {
# 3861
......@@ -90,7 +113,11 @@ hctest_suite("ActsSecurityHichainBasicDeps") {
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET=1",
"TEST_BIG_NUM_EXP_MOD=1",
"TEST_GENERATE_KEY_PAIR=1",
"TEST_EXPORT_PUBLIC_KEY=1",
"TEST_ALGORITHM_SIGN=1",
"TEST_ALGORITHM_VERIFY=1",
"TEST_IMPORT_PUBLIC_KEY=1",
]
defines += [
"TEST_HKDF_WITH_KEY_ALIAS_TRUE=0",
......@@ -98,7 +125,11 @@ hctest_suite("ActsSecurityHichainBasicDeps") {
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=0",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=0",
"TEST_AGREE_SHARED_SECRET=0",
"TEST_BIG_NUM_EXP_MOD=0",
"TEST_GENERATE_KEY_PAIR=0",
"TEST_EXPORT_PUBLIC_KEY=0",
"TEST_ALGORITHM_SIGN=0",
"TEST_ALGORITHM_VERIFY=0",
"TEST_IMPORT_PUBLIC_KEY=0",
]
}
} else {
......
## wifiiot_hispark_pegasus
1. compile command:
``` bash
cd test/xts/tools/lite
./build.sh product=wifiiot xts=acts target=//test/xts/acts/security_lite/deviceauth_basic_deps:ActsSecurityHichainBasicDeps
```
......@@ -40,3 +40,27 @@ DEVICEAUTH_BASIC_DEPS_INC = [
"//base/security/deviceauth/common_lib/interfaces",
"//base/security/deviceauth/interfaces/innerkits",
]
DEVICEAUTH_BASIC_DEPS_ALGORITHM_DEFINES = [
"TEST_HKDF_WITH_KEY_ALIAS_TRUE=1",
"TEST_IMPORT_SYMMETRIC_KEY=1",
"TEST_COMPUTEHMAC_WITH_ISALIAS_TRUE=1",
"TEST_HASH_TO_POINT=1",
"TEST_GENERATE_KEY_PAIR_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET_WITH_STORAGE=1",
"TEST_AGREE_SHARED_SECRET=1",
"TEST_BIG_NUM_EXP_MOD=1",
"TEST_EXPORT_IMPORT_SIGN_VERIFY_ED25519=1",
"TEST_EXPORT_IMPORT_SIGN_VERIFY_P256=1",
"TEST_BIG_NUM_COMPARE=1",
"TEST_GENERATE_KEY_PAIR=1",
"TEST_EXPORT_PUBLIC_KEY=1",
"TEST_ALGORITHM_SIGN=1",
"TEST_ALGORITHM_VERIFY=1",
"TEST_IMPORT_PUBLIC_KEY=1",
"TEST_CHECK_DL_PUBLIC_KEY=1",
"TEST_CHECK_KEY_EXIST=1",
"TEST_DELETE_KEY=1",
"TEST_AES_GCM_ENCRYPT=1",
"TEST_AES_GCM_DECRYPT=1",
]
......@@ -372,9 +372,9 @@ enum {
HKDF_PAKE_SHAREDSECRET_DERIVE_UNIONKEY_SALT_LEN = 16,
HKDF_PAKE_SHAREDSECRET_DERIVE_UNIONKEY_OUTKEY_LEN = 48,
IMPORT_ASYMMETRIC_KEY_KEYALIAS_LEN_MAX = 32,
IMPORT_ASYMMETRIC_KEY_KEYALIAS_LEN_MIN = 1,
IMPORT_ASYMMETRIC_KEY_AUTHTOKEN_LEN = 32,
IMPORT_SYMMETRIC_KEY_KEYALIAS_LEN_MAX = 32,
IMPORT_SYMMETRIC_KEY_KEYALIAS_LEN_MIN = 1,
IMPORT_SYMMETRIC_KEY_AUTHTOKEN_LEN = 32,
};
enum {
......@@ -623,14 +623,103 @@ enum {
};
enum {
TEST_IMPORT_ASYMMETRIC_KEY_AUTH_ID_LENGTH_32 = 32,
TEST_IMPORT_ASYMMETRIC_KEY_AUTH_ID_LENGTH_64 = 64,
TEST_IMPORT_SYMMETRIC_KEY_AUTH_ID_LENGTH_32 = 32,
TEST_IMPORT_SYMMETRIC_KEY_AUTH_ID_LENGTH_64 = 64,
};
enum {
TEST_GENERATE_KEY_PAIR_WITH_STORAGE_AUTH_ID_LENGTH = 32,
};
// TestExportImportSignVerify
enum {
TEST_EX_IM_SN_VF_EXTRA_INFO_AUTH_ID_LENGTH = 32,
TEST_EX_IM_SN_VF_KEY_ALIAS_LENGTH = 64,
TEST_EX_IM_SN_VF_KEY_LENGTH = 32,
TEST_EX_IM_SN_VF_OUT_PUB_KEY_LENGTH = 32,
TEST_SIGN_MESSAGE_LENGTH_1 = 1,
TEST_SIGN_MESSAGE_LENGTH_2 = 2,
TEST_SIGN_MESSAGE_LENGTH_4 = 4,
TEST_SIGN_MESSAGE_LENGTH_8 = 8,
TEST_SIGN_MESSAGE_LENGTH_16 = 16,
TEST_SIGN_MESSAGE_LENGTH_32 = 32,
TEST_SIGN_MESSAGE_LENGTH_64 = 64,
TEST_SIGN_MESSAGE_LENGTH_128 = 128,
TEST_SIGN_MESSAGE_LENGTH_256 = 256,
TEST_SIGN_MESSAGE_LENGTH_512 = 512,
TEST_SIGN_MESSAGE_LENGTH_1024 = 1024,
TEST_SIGN_SIGNATURE_LENGTH = 64,
};
static const uint32_t TEST_SIGN_MSG_LENGTHES[] = {
TEST_SIGN_MESSAGE_LENGTH_1,
TEST_SIGN_MESSAGE_LENGTH_2,
TEST_SIGN_MESSAGE_LENGTH_4,
TEST_SIGN_MESSAGE_LENGTH_8,
TEST_SIGN_MESSAGE_LENGTH_16,
TEST_SIGN_MESSAGE_LENGTH_32,
TEST_SIGN_MESSAGE_LENGTH_64,
TEST_SIGN_MESSAGE_LENGTH_128,
TEST_SIGN_MESSAGE_LENGTH_256,
TEST_SIGN_MESSAGE_LENGTH_512,
TEST_SIGN_MESSAGE_LENGTH_1024,
};
static const char TEST_EXPORT_DIFFERENT_ERROR_MESSAGE[] = "two different public keys are exported";
// g_largePrimeNumberHex384 and g_largePrimeNumberHex256 are from
// base/security/deviceauth/services/protocol/src/pake_protocol/pake_protocol_dl_common/pake_protocol_dl_common.c
static const char LARGE_PRIME_NUM_HEX_384[] =
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74"
"020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437"
"4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05"
"98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB"
"9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718"
"3995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33"
"A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7"
"ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864"
"D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E2"
"08E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF";
static const char LARGE_PRIME_NUM_HEX_256[] =
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74"
"020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437"
"4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05"
"98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB"
"9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718"
"3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF";
enum {
PAKE_DL_PRIME_LEN_256 = 256,
PAKE_DL_PRIME_LEN_384 = 384,
};
enum {
TEST_CHECK_DL_VALUE_ONE = 1,
TEST_CHECK_DL_VALUE_TWO = 2,
};
enum {
TEST_BIG_NUM_COMPARE_NUM_LENGTH_FULL = 32,
TEST_BIG_NUM_COMPARE_NUM_LENGTH_HALF = TEST_BIG_NUM_COMPARE_NUM_LENGTH_FULL / 2, // 16
};
static const uint8_t TEST_BIG_NUM_COMPARE_NUM_EXAMPLE_FULL[TEST_BIG_NUM_COMPARE_NUM_LENGTH_FULL] = {
/* */ /* */
0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89,
0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89,
};
static const uint8_t TEST_BIG_NUM_COMPARE_NUM_EXAMPLE_HALF[TEST_BIG_NUM_COMPARE_NUM_LENGTH_HALF] = {
/* */ /* */
0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89,
};
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册