diff --git a/security/huks_napi_BasicTest/BUILD.gn b/security/huks_napi_BasicTest/BUILD.gn index f62f70659899070106f5b37d37a39a814edd226a..84c3d01a5d5eacb9690b9f988c1a7371e5c25862 100644 --- a/security/huks_napi_BasicTest/BUILD.gn +++ b/security/huks_napi_BasicTest/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/security/huks/build/config.gni") import("//base/security/huks/huks.gni") import("//test/xts/tools/build/suite.gni") @@ -39,8 +40,6 @@ ohos_moduletest_suite("ActsHuksNAPITest") { "src/huks_agree_ecdh_test.cpp", "src/huks_agree_ecdh_test_common.cpp", "src/huks_agree_x25519_test.cpp", - "src/huks_attest_test.cpp", - "src/huks_attest_test_common.cpp", "src/huks_cipher_aes_test.cpp", "src/huks_cipher_aes_test_common.cpp", "src/huks_cipher_rsa_test.cpp", @@ -55,7 +54,6 @@ ohos_moduletest_suite("ActsHuksNAPITest") { "src/huks_mem.cpp", "src/huks_misc_test.cpp", "src/huks_nullptr_test.cpp", - "src/huks_signverify_dsa_test.cpp", "src/huks_signverify_ecc_test.cpp", "src/huks_signverify_ecc_test_common.cpp", "src/huks_signverify_ed25519_test.cpp", @@ -67,6 +65,14 @@ ohos_moduletest_suite("ActsHuksNAPITest") { "src/huks_wrapped_test_common.cpp", ] + if (huks_security_level != "trusted_environment") { + sources += [ + "src/huks_attest_test.cpp", + "src/huks_attest_test_common.cpp", + "src/huks_signverify_dsa_test.cpp", + ] + } + include_dirs = [ "//test/xts/acts/security/security_huks_basic/huks_napi_BasicTest/include", "include", diff --git a/security/huks_napi_BasicTest/src/huks_agree_ecdh_test.cpp b/security/huks_napi_BasicTest/src/huks_agree_ecdh_test.cpp index cf4f09378f37af539de33c1fa72d1896a178349a..4d53d20d17fd84423a524d01177288951bc66a6b 100644 --- a/security/huks_napi_BasicTest/src/huks_agree_ecdh_test.cpp +++ b/security/huks_napi_BasicTest/src/huks_agree_ecdh_test.cpp @@ -72,7 +72,7 @@ static struct OH_Huks_Param g_genParams001[] = { .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE }, { .tag = OH_HUKS_TAG_KEY_SIZE, - .uint32Param = OH_HUKS_ECC_KEY_SIZE_224 + .uint32Param = OH_HUKS_ECC_KEY_SIZE_256 }, { .tag = OH_HUKS_TAG_DIGEST, .uint32Param = OH_HUKS_DIGEST_NONE @@ -93,7 +93,7 @@ static struct OH_Huks_Param g_agreeParams01Init001[] = { .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE }, { .tag = OH_HUKS_TAG_KEY_SIZE, - .uint32Param = OH_HUKS_ECC_KEY_SIZE_224 + .uint32Param = OH_HUKS_ECC_KEY_SIZE_256 } }; static struct OH_Huks_Param g_agreeParams01Finish001[] = { @@ -135,7 +135,7 @@ static struct OH_Huks_Param g_agreeParams02Init001[] = { .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE }, { .tag = OH_HUKS_TAG_KEY_SIZE, - .uint32Param = OH_HUKS_ECC_KEY_SIZE_224 + .uint32Param = OH_HUKS_ECC_KEY_SIZE_256 } }; static struct OH_Huks_Param g_agreeParams02Finish001[] = { @@ -199,8 +199,8 @@ HWTEST_F(HuksAgreeECDHTest, Security_HUKS_NAPI_Agree_ECDH_0100, TestSize.Level0) ret1 = OH_Huks_GenerateKeyItem(&g_keyAlias02001, genParamSet, nullptr); EXPECT_EQ(ret1.errorCode, (int32_t)OH_HUKS_SUCCESS) << "GenerateKey02 failed."; - struct OH_Huks_Blob publicKey01 = { .size = OH_HUKS_ECC_KEY_SIZE_224, .data = nullptr }; - struct OH_Huks_Blob publicKey02 = { .size = OH_HUKS_ECC_KEY_SIZE_224, .data = nullptr }; + struct OH_Huks_Blob publicKey01 = { .size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr }; + struct OH_Huks_Blob publicKey02 = { .size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr }; ret = MallocAndCheckBlobData(&publicKey01, publicKey01.size); EXPECT_EQ(ret.errorCode, (int32_t)OH_HUKS_SUCCESS) << "Malloc publicKey01 failed."; ret = MallocAndCheckBlobData(&publicKey02, publicKey02.size); diff --git a/security/huks_napi_BasicTest/src/huks_cipher_sm4_test.cpp b/security/huks_napi_BasicTest/src/huks_cipher_sm4_test.cpp index 0efba61125c15bc1501324ac7cb6241df2a99f2e..21ea78e87929b8c1eb0de65171bf5d03c5022bfc 100644 --- a/security/huks_napi_BasicTest/src/huks_cipher_sm4_test.cpp +++ b/security/huks_napi_BasicTest/src/huks_cipher_sm4_test.cpp @@ -60,7 +60,7 @@ static struct OH_Huks_Param g_genParams001[] = { .uint32Param = OH_HUKS_SM4_KEY_SIZE_128 }, { .tag = OH_HUKS_TAG_PADDING, - .uint32Param = OH_HUKS_PADDING_PKCS7 + .uint32Param = OH_HUKS_PADDING_NONE }, { .tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC @@ -81,7 +81,7 @@ static struct OH_Huks_Param g_encryptParams001[] = { .uint32Param = OH_HUKS_SM4_KEY_SIZE_128 }, { .tag = OH_HUKS_TAG_PADDING, - .uint32Param = OH_HUKS_PADDING_PKCS7 + .uint32Param = OH_HUKS_PADDING_NONE }, { .tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC @@ -106,7 +106,7 @@ static struct OH_Huks_Param g_decryptParams001[] = { .uint32Param = OH_HUKS_SM4_KEY_SIZE_128 }, { .tag = OH_HUKS_TAG_PADDING, - .uint32Param = OH_HUKS_PADDING_PKCS7 + .uint32Param = OH_HUKS_PADDING_NONE }, { .tag = OH_HUKS_TAG_BLOCK_MODE, .uint32Param = OH_HUKS_MODE_CBC diff --git a/security/huks_napi_BasicTest/src/huks_derive_hkdf_test.cpp b/security/huks_napi_BasicTest/src/huks_derive_hkdf_test.cpp index 902456fdc369d3d732f0abe4c1faa6fc8cafb045..298bbbda0f29e9c41e45a8ab18ffac74b9ed492e 100644 --- a/security/huks_napi_BasicTest/src/huks_derive_hkdf_test.cpp +++ b/security/huks_napi_BasicTest/src/huks_derive_hkdf_test.cpp @@ -59,7 +59,7 @@ static struct OH_Huks_Param g_genParams001[] = { .uint32Param = OH_HUKS_DIGEST_SHA256 }, { .tag = OH_HUKS_TAG_KEY_SIZE, - .uint32Param = OH_HUKS_AES_KEY_SIZE_128 + .uint32Param = OH_HUKS_AES_KEY_SIZE_256 } }; static struct OH_Huks_Param g_hkdfParams001[] = { diff --git a/security/huks_napi_BasicTest/src/huks_derive_pbkdf_test.cpp b/security/huks_napi_BasicTest/src/huks_derive_pbkdf_test.cpp index 5f73df62ed10c1b169b2449771d2d80ac4dbe74b..a3b6a94baa37a43703ff9d9676f7a2cf274a168d 100644 --- a/security/huks_napi_BasicTest/src/huks_derive_pbkdf_test.cpp +++ b/security/huks_napi_BasicTest/src/huks_derive_pbkdf_test.cpp @@ -49,6 +49,9 @@ void HuksDerivePBKDFTest::TearDown() } uint8_t g_saltdata1[16] = {0}; +uint8_t g_saltgen[16] = { + 0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff +}; static struct OH_Huks_Param g_genParams001[] = { { @@ -62,7 +65,16 @@ static struct OH_Huks_Param g_genParams001[] = { .uint32Param = OH_HUKS_DIGEST_SHA256 }, { .tag = OH_HUKS_TAG_KEY_SIZE, - .uint32Param = 256 + .uint32Param = OH_HUKS_AES_KEY_SIZE_256 + }, { + .tag = OH_HUKS_TAG_ITERATION, + .uint32Param = 1000 + }, { + .tag = OH_HUKS_TAG_SALT, + .blob = { + sizeof(g_saltgen), + (uint8_t *)g_saltgen + } } }; static struct OH_Huks_Param g_pbkdf2Params001[] = { diff --git a/security/huks_napi_BasicTest/src/huks_hmac_test.cpp b/security/huks_napi_BasicTest/src/huks_hmac_test.cpp index 03af1cf9f68197b95a52e4cd329fa31ee4f55908..648379f74aa5918af92273d8e07b8a16cf4a4a98 100644 --- a/security/huks_napi_BasicTest/src/huks_hmac_test.cpp +++ b/security/huks_napi_BasicTest/src/huks_hmac_test.cpp @@ -56,7 +56,7 @@ static struct OH_Huks_Param g_genParams001[] = { .uint32Param = OH_HUKS_KEY_PURPOSE_MAC }, { .tag = OH_HUKS_TAG_DIGEST, - .uint32Param = OH_HUKS_DIGEST_SHA1 + .uint32Param = OH_HUKS_DIGEST_SHA384 }, { .tag = OH_HUKS_TAG_KEY_SIZE, .uint32Param = Unittest::Hmac::COMMON_SIZE @@ -71,7 +71,7 @@ static struct OH_Huks_Param g_hmacParams001[] = { .uint32Param = OH_HUKS_KEY_PURPOSE_MAC }, { .tag = OH_HUKS_TAG_DIGEST, - .uint32Param = OH_HUKS_DIGEST_SHA1 + .uint32Param = OH_HUKS_DIGEST_SHA384 } }; @@ -141,7 +141,7 @@ static OH_Huks_Result HksHmacTestCase(const struct OH_Huks_Blob *keyAlias, struc /** * @tc.name: HksHmacTest.Security_HUKS_NAPI_HMAC_hmac_0100 - * @tc.desc: alg-HMAC pur-MAC dig-SHA1. + * @tc.desc: alg-HMAC pur-MAC dig-SHA384. * @tc.type: FUNC */ HWTEST_F(HksHmacTest, Security_HUKS_NAPI_HMAC_hmac_0100, TestSize.Level0) diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js index 77146bae6012938418958023f902527e18c6c0d9..d70acdf0b580f637f9ac1e78fc35b87034d62e11 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions63kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions63kb = { export default function SecurityHuksECDHBasicAbort63KBCallbackJsunit() { describe('SecurityHuksECDHBasicAbort63KBCallbackJsunit', function () { it('testAgreeEDCH002', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js index 6f87dbeb885cf30a21f313d79b4db846fd4f9432..1edbabf0b49468bcc03f4a5853a42e9931840bb6 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions65kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions65kb = { export default function SecurityHuksECDHBasicAbort65KBCallbackJsunit() { describe('SecurityHuksECDHBasicAbort65KBCallbackJsunit', function () { it('testAgreeEDCH004', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js index 8293e2b83fe82fa9fc6023e17bb0c603434028d4..d992cb34b9503443fbb36c1b6d690310fb0cb6e8 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions63kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions63kb = { export default function SecurityHuksECDHBasicFinish63KBCallbackJsunit() { describe('SecurityHuksECDHBasicFinish63KBCallbackJsunit', function () { it('testAgreeEDCH001', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js index 2507c056e11ead22d47453098ddae0a19b421718..75e78becfd89b65b7723c3b33f46c60e47e2ee62 100644 --- a/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions65kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions65kb = { export default function SecurityHuksECDHBasicFinish65KBCallbackJsunit() { describe('SecurityHuksECDHBasicFinish65KBCallbackJsunit', function () { it('testAgreeEDCH003', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js index e27b73c7c0f57d1389eb80f590af061fa0989cc1..f4b18c74e6adbc83f9b779e522544fd9c9be3f26 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -41,8 +41,8 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () { console.info('test beforeEach called'); }); it('testAgreeECDH102', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js index d4cb1bd4d67bb389d599a57dafa6f2dd5219a2e9..ce11bfc0b5491400107cd65499b9f263b28ac23a 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () { }); it('testAgreeECDH104', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js index ac0b3730d52ee643fe92c6e1daaf5a7086f2f76f..1872f59cb2e0996d49c39afba2720bfd618263d4 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js @@ -22,58 +22,47 @@ import { HksTag } from '../../../../../../utils/param/publicParam'; let srcData63 = Data.Date63KB; let srcData63Kb = stringToUint8Array(srcData63); - -let HuksOptions63kb = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -}; +let HuksOptions63kb = {}; export default function SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit() { -describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - }; - console.info('test beforeEach called'); - }); + describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () { + beforeEach(function () { + HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, + }; + console.info('test beforeEach called'); + }); - it('testAgreeECDH101', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_101'; - let huksOptionsFinish = { - properties: new Array( - HuksAgreeECDH.HuksKeySTORAGE, - HuksAgreeECDH.HuksKeyISKEYALIAS, - HuksAgreeECDH.HuksKeyALGORITHMAES, - HuksAgreeECDH.HuksKeySIZE256, - HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgreeECDH.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgreeECDH.HuksKeyPADDINGNONE, - HuksAgreeECDH.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - }; - await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); - done(); + it('testAgreeECDH101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js index 0f3796b2b85990a12b885f73ae2993405841ab99..193c1ffa1edba6d4916647645aab9a4392259814 100644 --- a/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () { }); it('testAgreeECDH103', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js index 4de2990e60a15386a2ab4217a5c5b3fcf3521304..ff4b2381bd62df3c573ec3140807f23f73de6ae8 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js @@ -17,7 +17,15 @@ import { describe, it, expect } from '@ohos/hypium'; import huks from '@ohos.security.huks'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc'; -let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData64 = + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; let gInData64Array = stringToUint8Array(gInData64); let encryptedData; @@ -27,7 +35,11 @@ let updateResult = new Array(); let exportKey; let genHuksOptions = { - properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512), + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize4096 + ), inData: new Uint8Array(new Array()), }; @@ -319,105 +331,105 @@ async function publicCipherFunc( } export default function SecurityHuksRSABasicCallbackJsunit() { -describe('SecurityHuksRSABasicCallbackJsunit', function () { - it('testCipherRSA001', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001'; - genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); - genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + describe('SecurityHuksRSABasicCallbackJsunit', function () { + it('testCipherRSA001', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias001'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias001'; + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); - HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); - done(); - }); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherRSA002', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias002'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); - done(); - }); + it('testCipherRSA002', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias002'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - it('testCipherRSA003', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias003'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias003'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); - HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); - done(); - }); + it('testCipherRSA003', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias003'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherRSA004', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias004'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias004'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); - done(); + it('testCipherRSA004', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias004'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js index 5ed232244fe7d3cb56bdddee73f40b0625803a59..0ec44fa8d35ad316142a2b38a12b3b41df5fb583 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js @@ -13,16 +13,17 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam'; import { HksTag } from '../../../../../../utils/param/publicParam'; -import {stringToUint8Array,arrayEqual} from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, arrayEqual, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; let IV = '0000000000000000'; let plainData; let encryptedResult; -var handle; +let handle; +let useSoftware = true; const plainString48Bytes = 'Hks_SM4_Cipher_Test_000000000000000000000_string'; const plainData48Bytes = stringToUint8Array(plainString48Bytes); @@ -251,710 +252,559 @@ async function publicCipherFunc( } export default function SecurityHuksSM4BasicCallbackJsunit() { -describe('SecurityHuksSM4BasicCallbackJsunit', function () { - // HKS_SUPPORT_SM4_CBC_NOPADDING - it('testCipherSM4001_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias001'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + describe('SecurityHuksSM4BasicCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) + // HKS_SUPPORT_SM4_CBC_NOPADDING + it('testCipherSM4001_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias001'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4001_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias001'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4001_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias001'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4002_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias002'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4002_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias002'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - it('testCipherSM4002_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias002'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4002_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias002'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - // HKS_SUPPORT_SM4_CBC_PKCS7 - it('testCipherSM4003_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias003'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_CBC_PKCS7 + it('testCipherSM4003_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias003'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true + ); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4003_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias003'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4003_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias003'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4004_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias004'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4004_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias004'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4004_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias004'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4004_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias004'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - // HKS_SUPPORT_SM4_CTR_NOPADDING - it('testCipherSM4005_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias005'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_CTR_NOPADDING + it('testCipherSM4005_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias005'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4005_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias005'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4005_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias005'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4006_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias006'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4006_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias006'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - it('testCipherSM4006_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias006'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4006_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias006'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - // HKS_SUPPORT_SM4_ECB_NOPADDING - it('testCipherSM4007_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias007'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_ECB_NOPADDING + it('testCipherSM4007_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias007'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4007_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias007'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4007_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias007'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4008_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias008'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4008_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias008'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4008_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias008'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4008_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias008'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - // HKS_SUPPORT_SM4_ECB_PKCS7 - it('testCipherSM4009_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias009'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_ECB_PKCS7 + it('testCipherSM4009_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias009'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4009_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias009'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4009_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias009'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4010_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias010'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4010_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias010'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4010_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias010'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); + it('testCipherSM4010_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias010'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js index 8888385eac0232466536666fbdf7dc5911d7e782..564cdf13be3b0e8a85a832bb02e3b5583c19a00b 100644 --- a/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js @@ -13,9 +13,9 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks' import { HuksKeyAlgX25519, HuksAgreeECDH } from '../../../../../../utils/param/agree/publicAgreeParam'; import { @@ -26,6 +26,7 @@ import { } from '../../../../../../utils/param/signverify/publicSignverifyParam'; let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; let gInData64Array = stringToUint8Array(gInData64); +let useSoftware = true; async function publicGenerateKeyFunc(srcKeyAlies, HuksOptions) { await generateKey(srcKeyAlies, HuksOptions) @@ -105,359 +106,375 @@ function deleteKey(srcKeyAlies, HuksOptions) { } export default function securityHuksExportSupportJsunit() { -describe('securityHuksExportSupportJsunit', function () { - // HKS_SUPPORT_SM4_CBC_NOPADDING - it('HUKS_Basic_Capability_Export_0100', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0100"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + describe('securityHuksExportSupportJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) + // HKS_SUPPORT_SM4_CBC_NOPADDING + it('HUKS_Basic_Capability_Export_0100', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0100"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_0200', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0200"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize768, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0200', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0200"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize768, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_0300', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0300"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize1024, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0300', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0300"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize1024, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_0400', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0400"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize2048, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0400', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0400"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_0500', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0500"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize3072, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0500', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0500"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_0600', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0600"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyRSA.HuksKeyAlgRSA, - HuksSignVerifyRSA.HuksKeyRSASize4096, - HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0600', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0600"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_0700', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0700"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCDIGEST - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0700', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0700"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCDIGEST + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_0800', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0800"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyECCSize256, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 - HuksAgreeECDH.HuksKeyECCDIGEST - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0800', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0800"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCDIGEST + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_0900', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_0900"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyECCSize384, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 - HuksAgreeECDH.HuksKeyECCDIGEST - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_0900', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_0900"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyECCSize384, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCDIGEST + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1000', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1000"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyECCSize521, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 - HuksAgreeECDH.HuksKeyECCDIGEST - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1000', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1000"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyECCSize521, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCDIGEST + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1100', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1100"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE, - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1100', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1100"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE, + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_1200', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1200"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize256, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1200', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1200"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1300', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1300"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize384, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1300', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1300"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize384, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1400', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1400"; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize521, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1400', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1400"; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize521, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1500', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1500"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyED25519.HuksKeyAlgED25519, - HuksSignVerifyED25519.HuksKeyRSAPurposeSINGVERIFY, - HuksSignVerifyED25519.HuksKeyED25519Size256, - HuksSignVerifyED25519.HuksTagDigestSHA1 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1500', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1500"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyRSAPurposeSINGVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA256 + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1600', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1600"; - let HuksOptions = { - properties: new Array( - HuksKeyAlgX25519.HuksKeyAlgX25519, - HuksKeyAlgX25519.HuksKeyCURVE25519Size256, - HuksKeyAlgX25519.HuksKeyDIGEST, - HuksKeyAlgX25519.HuksKeyPADDING, - HuksKeyAlgX25519.HuksKeyPurposeAGREE, - HuksKeyAlgX25519.HuksKeyBLOCKMODE - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1600', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1600"; + let HuksOptions = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_1700', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1700"; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksKeySIZE1024 - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1700', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1700"; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: gInData64Array, + }; + if (useSoftware) { + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Export_1800', 0, async function (done) { - let srcKeyAlies = "HUKS_Basic_Capability_Export_1800"; - let HuksOptions = { - properties: new Array( - HuksSignVerifySM2.HuksKeyAlgSM2, - HuksSignVerifySM2.HuksKeySM2PurposeSIGN, - HuksSignVerifySM2.HuksKeySize256, - HuksSignVerifySM2.HuksTagSM2DigestSM3, - ), - inData: gInData64Array, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicExportKeyFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - done(); - }); + it('HUKS_Basic_Capability_Export_1800', 0, async function (done) { + let srcKeyAlies = "HUKS_Basic_Capability_Export_1800"; + let HuksOptions = { + properties: new Array( + HuksSignVerifySM2.HuksKeyAlgSM2, + HuksSignVerifySM2.HuksKeySM2PurposeSIGN, + HuksSignVerifySM2.HuksKeySize256, + HuksSignVerifySM2.HuksTagSM2DigestSM3, + ), + inData: gInData64Array, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicExportKeyFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) + done(); + }); - it('HUKS_Basic_Capability_Export_2000', 0, async function (done) { - const srcKeyAlies = '****' - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - ), - inData: gInData64Array, - }; - await exportkey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test ExportKey data: ${JSON.stringify(data)}`); - expect(null).assertFail(); - }) - .catch((err) => { - console.log('test ImportKey err information: ' + JSON.stringify(err)); - expect(err.code == -13).assertTrue(); + it('HUKS_Basic_Capability_Export_2000', 0, async function (done) { + const srcKeyAlies = '****' + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + ), + inData: gInData64Array, + }; + await exportkey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test ExportKey data: ${JSON.stringify(data)}`); + expect(null).assertFail(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(err.code == -13).assertTrue(); + }); + done(); }); - done(); }); -}); } diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js index 05a705c5bb34f7290e091a2d87a214a5df7852bf..32750abd37d4475ce946911e3fddff3285adc564 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js @@ -17,7 +17,15 @@ import { describe, it, expect } from '@ohos/hypium'; import huks from '@ohos.security.huks'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc'; -let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData64 = + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; let defaultData = '0'; @@ -30,7 +38,7 @@ let updateResult = new Array(); let exportKey; let genHuksOptions = { - properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512), + properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize4096), inData: new Uint8Array(defaultData), }; @@ -224,8 +232,8 @@ async function publicCipherFunc( export default function SecurityHuksCipherRSABasicPromiseJsunit() { describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { it('testCipherRSA101', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias101'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias101'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101'; genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); @@ -234,7 +242,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -246,7 +254,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -258,13 +266,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { }); it('testCipherRSA102', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias102'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias102'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101'; let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -276,13 +284,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { }); it('testCipherRSA103', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias103'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias103'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias103'; let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -294,7 +302,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -306,13 +314,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { }); it('testCipherRSA104', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias104'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias104'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias104'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias104'; let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js index 554ecd9590a16d6924884bd55c1f0dd41c65c144..87bb616fa2b8836ca468e064c58f59dda1a72bd7 100644 --- a/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js @@ -13,16 +13,17 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam'; import { HksTag } from '../../../../../../utils/param/publicParam'; -import {stringToUint8Array,arrayEqual} from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, arrayEqual, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; let IV = '0000000000000000'; let plainData; let encryptedResult; -var handle; +let handle; +let useSoftware; const plainString48Bytes = 'Hks_SM4_Cipher_Test_000000000000000000000_string'; const plainData48Bytes = stringToUint8Array(plainString48Bytes); @@ -175,710 +176,558 @@ async function publicCipherFunc( } export default function SecurityHuksCipherSM4BasicPromiseJsunit() { -describe('SecurityHuksCipherSM4BasicPromiseJsunit', function () { - // HKS_SUPPORT_SM4_CBC_NOPADDING - it('testCipherSM4101_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias101'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + describe('SecurityHuksCipherSM4BasicPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) + // HKS_SUPPORT_SM4_CBC_NOPADDING + it('testCipherSM4101_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4101_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias101'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4101_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4102_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias102'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4102_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias102'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - it('testCipherSM4102_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias102'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4102_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias102'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - // HKS_SUPPORT_SM4_CBC_PKCS7 - it('testCipherSM4103_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias103'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_CBC_PKCS7 + it('testCipherSM4103_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4103_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias103'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4103_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4104_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias104'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4104_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias104'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4104_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias104'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4104_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODECBCKeyAlias104'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECBC); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - // HKS_SUPPORT_SM4_CTR_NOPADDING - it('testCipherSM4105_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias105'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_CTR_NOPADDING + it('testCipherSM4105_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias105'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4105_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias105'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4105_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias105'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); - it('testCipherSM4106_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias106'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4106_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias106'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - it('testCipherSM4106_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias106'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECTR, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4106_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECTRKeyAlias106'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECTR, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + done(); + }); - // HKS_SUPPORT_SM4_ECB_NOPADDING - it('testCipherSM4107_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias107'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_ECB_NOPADDING + it('testCipherSM4107_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias107'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4107_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias107'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4107_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias107'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4108_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias108'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4108_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias108'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4108_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias108'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4108_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODEECBKeyAlias108'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - // HKS_SUPPORT_SM4_ECB_PKCS7 - it('testCipherSM4109_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias109'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData48Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + // HKS_SUPPORT_SM4_ECB_PKCS7 + it('testCipherSM4109_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias109'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData48Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4109_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias109'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: plainData240Bytes, - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); - done(); - }); + it('testCipherSM4109_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias109'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: plainData240Bytes, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); - it('testCipherSM4110_48', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias110'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData48Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); - }); + it('testCipherSM4110_48', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias110'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData48Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); - it('testCipherSM4110_240', 0, async function (done) { - const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias110'; - genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); - genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); - genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(plainData240Bytes), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); - done(); + it('testCipherSM4110_240', 0, async function (done) { + const srcKeyAlias = 'testCipherSM4Size128PADDINGPKCS7MODEECBKeyAlias110'; + genHuksOptions.properties.splice(2, 1, HuksCipherSM4.HuksKeySM4Size128); + genHuksOptions.properties.splice(3, 1, HuksCipherSM4.HuksKeySM4BLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherSM4.HuksKeySM4PADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(plainData240Bytes), + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js index 22979f8785b0cf8fcd28b4f11e11c3ba4c022f53..9b41df5ec5390c25a565ae7f3bbb07243cc3f467 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js @@ -27,7 +27,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -35,7 +35,7 @@ let HuksOptions63kb = { export default function SecurityHuksHKDFBasicAbort63KBCallbackJsunit() { describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () { it('testDeriveHKDF002', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js index 1214f204add53d117f337b22a229e20ab487dd4e..dfe7b03d83330583be7731eadedda6f06a5c435c 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js @@ -27,7 +27,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -35,7 +35,7 @@ let HuksOptions63kb = { export default function SecurityHuksHKDFBasicFinish63KBCallbackJsunit() { describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () { it('testDeriveHKDF001', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js index adec4b1c533b62c6de8150a0707451587bfa8b9e..c1b6d878144c45e6f47eabc7798c241e9d68076f 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js @@ -27,7 +27,9 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; @@ -35,7 +37,7 @@ let HuksOptions63kb = { export default function SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit() { describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () { it('testDerivePBKDF2002', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -49,7 +51,7 @@ describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js index 6d9cafe2e26b1de1c8441d28894149a70e5f7260..48ee1423d1be9731267f2175f90ed96507cd9919 100644 --- a/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js @@ -27,35 +27,37 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; export default function SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit() { -describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () { - it('testDerivePBKDF2001', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001'; - let huksOptionsFinish = { - properties: new Array( - HuksDerivePBKDF2.HuksKeySTORAGE, - HuksDerivePBKDF2.HuksKeyISKEYALIAS, - HuksDerivePBKDF2.HuksKeyALGORITHMAES, - HuksDerivePBKDF2.HuksKeySIZE256, - HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerivePBKDF2.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - }; - let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2,HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); - await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); - done(); + describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () { + it('testDerivePBKDF2001', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyALGORITHMAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js index 00da15ed27edbcde282171544ca3412317394736..31c4365e3af0ea61ec975120fb0373b15fc16de0 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js @@ -28,7 +28,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -36,7 +36,7 @@ let HuksOptions63kb = { export default function SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit() { describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () { it('testDeriveHKDF102', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -50,7 +50,7 @@ describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js index 2a86894a2bf7b812303ba37ce20d6b5ffab96b99..baa392a30585c3404767e0ef893955589fbabf67 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js @@ -27,7 +27,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -35,7 +35,7 @@ let HuksOptions63kb = { export default function SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit() { describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () { it('testDeriveHKDF101', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -49,7 +49,7 @@ describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js index 30df46b8e94ddae2fa89b5e0fd740a258ca695fc..9bce6e75e6f0858189922e9bc7ba8137368c657b 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js @@ -28,14 +28,16 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; export default function SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit() { describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () { it('testDerivePBKDF2102', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -49,7 +51,7 @@ describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js index 563bf700e405e2594755fed678160221dc601aa7..50a8f89df27ac27f3d277ecc18c10014748be46a 100644 --- a/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js @@ -28,7 +28,9 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; @@ -36,7 +38,7 @@ let HuksOptions63kb = { export default function SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit() { describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () { it('testDerivePBKDF2101', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -50,7 +52,7 @@ describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js index f3b32d1196387883ce5197291e825eaec02addbd..551faf85a91a4ddd1a369a44d018892b5f90b25d 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js @@ -12,10 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it, expect } from "@ohos/hypium"; +import { describe, it, expect, beforeAll } from "@ohos/hypium"; import huks from "@ohos.security.huks"; import Data from "../../../../../../utils/data.json"; -import { stringToUint8Array } from "../../../../../../utils/param/publicFunc"; +import { stringToUint8Array, checkSoftware } from "../../../../../../utils/param/publicFunc"; import { HuksSignVerifyDSA, HuksSignVerifyRSA, @@ -33,6 +33,7 @@ import { HuksHmac } from "../../../../../../utils/param/hmac/publicHmacParam"; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); +let useSoftware = true; function generateKey(srcKeyAlies, HuksOptions) { return new Promise((resolve, reject) => { @@ -126,6 +127,11 @@ async function exportKeyFunc(srcKeyAlias, HuksOptions) { export function SecurityHuksAccessControlJsunit() { describe("SecurityHuksAccessControlJsunit", function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) + it("HUKS_Basic_Capability_AccessControl_0100", 0, async function (done) { let srcKeyAlias = "HUKS_Basic_Capability_AccessControl_0100"; let HuksOptions = { @@ -137,22 +143,24 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); - - HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); - HuksOptions.properties.splice(3, 1); - await init(srcKeyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - expect(data.errorCode == -112).assertTrue(); - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - expect(err.code == -112).assertTrue(); - }); - - await deleteKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); + HuksOptions.properties.splice(3, 1); + await init(srcKeyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + expect(data.errorCode == -112).assertTrue(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(err.code == -112).assertTrue(); + }); + + await deleteKeyFunc(srcKeyAlias, HuksOptions); + } done(); }); @@ -162,7 +170,7 @@ export function SecurityHuksAccessControlJsunit() { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, + HuksSignVerifyECC.HuksKeyECCSize384, HuksSignVerifyECC.HuksTagECCDigestNONE ), inData: srcData63Kb, @@ -196,32 +204,34 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); - - HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT); - await init(srcKeyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - expect(null).assertFail(); - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - expect(err.code == -112).assertTrue(); - }); - - HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT); - await init(srcKeyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - expect(null).assertFail(); - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - expect(err.code == -112).assertTrue(); - }); - - await deleteKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT); + await init(srcKeyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + expect(null).assertFail(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(err.code == -112).assertTrue(); + }); + + HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT); + await init(srcKeyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + expect(null).assertFail(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(err.code == -112).assertTrue(); + }); + + await deleteKeyFunc(srcKeyAlias, HuksOptions); + } done(); }); @@ -233,7 +243,7 @@ export function SecurityHuksAccessControlJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize3072 ), inData: srcData63Kb, }; @@ -315,21 +325,23 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); - - HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose); - await init(srcKeyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - expect(null).assertFail(); - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - expect(err.code == -112).assertTrue(); - }); - - await deleteKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose); + await init(srcKeyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + expect(null).assertFail(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(err.code == -112).assertTrue(); + }); + + await deleteKeyFunc(srcKeyAlias, HuksOptions); + } done(); }); @@ -391,7 +403,7 @@ export function SecurityHuksAccessControlJsunit() { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize384, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -448,23 +460,25 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); - - HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); - HuksOptions.properties.splice(3, 1); - await huks - .init(srcKeyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`); - expect(data.errorCode == -112).assertTrue(); - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`); - expect(err.code == -112).assertTrue(); - }); - - await deleteKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); + HuksOptions.properties.splice(3, 1); + await huks + .init(srcKeyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + expect(data.errorCode == -112).assertTrue(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(err.code == -112).assertTrue(); + }); + + await deleteKeyFunc(srcKeyAlias, HuksOptions); + } done(); }); @@ -835,7 +849,7 @@ export function SecurityHuksAccessControlJsunit() { expect(1342197283).assertEqual( huks.HuksTag.HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA ); - expect(0).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_TEMP ); + expect(0).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_TEMP); expect(1).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT); done(); }); diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js index dd41dea0a0a019a63366273f70716f7445625358..c1c7195d3a58d486464041a0f5cb5a43e4a47dad 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js @@ -243,12 +243,12 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { export function SecurityHuksHmacCallbackJsunit() { describe("SecurityHuksHmacCallbackJsunit", function () { it("testHmacSHA1001", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias001"; + let srcKeyAlies = "testHmacDigestSHA256KeyAlias001"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -258,12 +258,12 @@ export function SecurityHuksHmacCallbackJsunit() { }); it("testHmacSHA1002", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias002"; + let srcKeyAlies = "testHmacDigestSHA256KeyAlias002"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -271,12 +271,12 @@ export function SecurityHuksHmacCallbackJsunit() { done(); }); it("testHmacSHA1003", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias003"; + let srcKeyAlies = "testHmacDigestSHA256KeyAlias003"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; @@ -284,12 +284,12 @@ export function SecurityHuksHmacCallbackJsunit() { done(); }); it("testHmacSHA1004", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias004"; + let srcKeyAlies = "testHmacDigestSHA256KeyAlias004"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js index f390ea5794b79fd279cf2652f40cb1cff96c1eb2..baf63d03c7f97ae6e7cf0a444e835e05a77e6def 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js @@ -13,8 +13,8 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; import Data from '../../../../../../utils/data.json'; import { HuksCipherAES, HuksCipherRSA, HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam' @@ -25,6 +25,7 @@ import { HuksKeyAlgX25519, HuksAgreeECDH } from '../../../../../../utils/param/a let IV = '0000000000000000'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); +let useSoftware = true; let aes128Key = new Uint8Array([ 0x20, 0x00, 0x00, 0x00, 0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a @@ -433,503 +434,537 @@ async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { } export function SecurityHuksImportJsunit() { -describe('SecurityHuksImportJsunit', function () { - it('HUKS_Basic_Capability_Import_0100', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0100'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, - HuksSignVerifyECC.HuksTagECCDigestNONE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc224Key, - }; - await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); - await publicImportKey(srcKeyAlies, HuksOptions); - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + beforeAll(async function (done) { + useSoftware = await checkSoftware(); done(); }); + describe('SecurityHuksImportJsunit', function () { + it('HUKS_Basic_Capability_Import_0100', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0100'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, + HuksSignVerifyECC.HuksKeyECCSize256, + HuksSignVerifyECC.HuksTagECCDigestNONE, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } + ), + inData: ecc256Key, + }; + await publicGenerateKeyFunc(srcKeyAlies, HuksOptions); + await publicImportKey(srcKeyAlies, HuksOptions); + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_0200', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0200'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, - HuksSignVerifyECC.HuksTagECCDigestNONE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: dsa2048Key, - }; - await huks.importKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.error(`test ImportKey data: ${JSON.stringify(data)}`); - expect(data.errorCode == -19).assertTrue(); - }) - .catch((err) => { - console.error('test exportKey err information: ' + JSON.stringify(err)); - expect(err.code == -19).assertTrue(); - }); - done(); - }); + it('HUKS_Basic_Capability_Import_0200', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0200'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, + HuksSignVerifyECC.HuksKeyECCSize256, + HuksSignVerifyECC.HuksTagECCDigestNONE, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } + ), + inData: dsa2048Key, + }; + await huks.importKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.error(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == -19).assertTrue(); + }) + .catch((err) => { + console.error('test exportKey err information: ' + JSON.stringify(err)); + expect(err.code == -19).assertTrue(); + }); + done(); + }); - it('HUKS_Basic_Capability_Import_0500', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0500'; - let HuksOptions = { - properties: new Array( - HuksCipherAES.HuksKeyAlgAES, - HuksCipherAES.HuksKeyPurposeENCRYPT, - HuksCipherAES.HuksKeyAESSize128, - HuksCipherAES.HuksKeyAESPADDINGNONE, - HuksCipherAES.HuksKeyAESBLOCKMODE, - HuksCipherAES.HuksKeyAESDIGESTNONE - ), - inData: aes128Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_0500', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0500'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE + ), + inData: aes128Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_0600', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0600'; - let HuksOptions = { - properties: new Array( - HuksCipherAES.HuksKeyAlgAES, - HuksCipherAES.HuksKeyPurposeENCRYPT, - HuksCipherAES.HuksKeyAESSize192, - HuksCipherAES.HuksKeyAESPADDINGNONE, - HuksCipherAES.HuksKeyAESBLOCKMODE, - HuksCipherAES.HuksKeyAESDIGESTNONE - ), - inData: aes192Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_0600', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0600'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE + ), + inData: aes192Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_0700', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0700'; - let HuksOptions = { - properties: new Array( - HuksCipherAES.HuksKeyAlgAES, - HuksCipherAES.HuksKeyPurposeENCRYPT, - HuksCipherAES.HuksKeyAESSize256, - HuksCipherAES.HuksKeyAESPADDINGNONE, - HuksCipherAES.HuksKeyAESBLOCKMODE, - HuksCipherAES.HuksKeyAESDIGESTNONE - ), - inData: aes256Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_0700', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0700'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE + ), + inData: aes256Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_0800', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0800'; - let HuksOptions = { - properties: new Array( - HuksCipherAES.HuksKeyAlgAES, - HuksCipherAES.HuksKeyPurposeENCRYPT, - HuksCipherAES.HuksKeyAESSize512, - HuksCipherAES.HuksKeyAESPADDINGNONE, - HuksCipherAES.HuksKeyAESBLOCKMODE, - HuksCipherAES.HuksKeyAESDIGESTNONE - ), - inData: aes512Key, - }; - await huks.importKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.error(`test ImportKey data: ${JSON.stringify(data)}`); - expect(data.errorCode == -19).assertTrue(); - }) - .catch((err) => { - console.error('test exportKey err information: ' + JSON.stringify(err)); - expect(err.code == -19).assertTrue(); - }); - done(); - }); + it('HUKS_Basic_Capability_Import_0800', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0800'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize512, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE + ), + inData: aes512Key, + }; + if (useSoftware) { + await huks.importKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.error(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == -19).assertTrue(); + }) + .catch((err) => { + console.error('test exportKey err information: ' + JSON.stringify(err)); + expect(err.code == -19).assertTrue(); + }); + } + done(); + }); - it('HUKS_Basic_Capability_Import_0900', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_0900'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize512, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa512Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_0900', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_0900'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } + ), + inData: rsa512Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_1000', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1000'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize768, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa768Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1000', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1000'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize768, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } + ), + inData: rsa768Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_1100', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1100'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize1024, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa1024Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1100', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1100'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize1024, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: rsa1024Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_1200', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1200'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize2048, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa2048Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1200', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1200'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: rsa2048Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_1300', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1300'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize3072, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa3072Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1300', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1300'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: rsa3072Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_1400', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1400'; - let HuksOptions = { - properties: new Array( - HuksCipherRSA.HuksKeyAlgRSA, - HuksCipherRSA.HuksKeyPurpose, - HuksSignVerifyRSA.HuksKeyRSASize4096, - HuksCipherRSA.HuksKeyRSAPADDINGNONE, - HuksCipherRSA.HuksKeyRSABLOCKMODEECB, - HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: rsa4096Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1400', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1400'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksSignVerifyRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: rsa4096Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_1500', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1500'; - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeySIZE, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: aes512Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1500', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1500'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeySIZE, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: aes512Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_1600', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1600'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc224Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1600', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1600'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } + ), + inData: ecc224Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_1700', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1700'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc256Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1700', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1700'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc256Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_1800', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1800'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize384, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc384Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1800', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1800'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize384, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc384Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_1900', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_1900'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyECC.HuksKeyAlgECC, - HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize521, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc521Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_1900', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_1900'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize521, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc521Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2000', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2000'; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc224Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2000', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2000'; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc224Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2100', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2100'; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize256, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc256Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2100', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2100'; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc256Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2200', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2200'; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize384, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc384Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2200', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2200'; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize384, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc384Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2300', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2300'; - let HuksOptions = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize521, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ecc521Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2300', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2300'; + let HuksOptions = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize521, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ecc521Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2400', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2400'; - let HuksOptions = { - properties: new Array( - HuksKeyAlgX25519.HuksKeyAlgX25519, - HuksKeyAlgX25519.HuksKeyPurposeAGREE, - HuksKeyAlgX25519.HuksKeyCURVE25519Size256, - HuksKeyAlgX25519.HuksKeyDIGEST, - HuksKeyAlgX25519.HuksKeyPADDING, - HuksKeyAlgX25519.HuksKeyBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: x25519Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2400', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2400'; + let HuksOptions = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: x25519Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2500', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2500'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyED25519.HuksKeyAlgED25519, - HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, - HuksSignVerifyED25519.HuksKeyED25519Size256, - HuksSignVerifyED25519.HuksTagDigestSHA1, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: ed25519Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2500', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2500'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA256, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: ed25519Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_2800', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2800'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA256, - { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 }, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: dsa2048Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2800', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2800'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA256, + { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 }, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: dsa2048Key, + }; + if (useSoftware) { + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } + done(); + }); - it('HUKS_Basic_Capability_Import_2900', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_2900'; - let HuksOptions = { - properties: new Array( - HuksSignVerifySM2.HuksKeyAlgSM2, - HuksSignVerifySM2.HuksKeySM2PurposeSINGVERIFY, - HuksSignVerifySM2.HuksKeySize256, - HuksSignVerifySM2.HuksTagSM2DigestSM3, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } - ), - inData: sm2Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_2900', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_2900'; + let HuksOptions = { + properties: new Array( + HuksSignVerifySM2.HuksKeyAlgSM2, + HuksSignVerifySM2.HuksKeySM2PurposeSINGVERIFY, + HuksSignVerifySM2.HuksKeySize256, + HuksSignVerifySM2.HuksTagSM2DigestSM3, + { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + ), + inData: sm2Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_3000', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_3000'; - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksKeySIZE, - HuksHmac.HuksTagDigestSM3 - ), - inData: aes512Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); + it('HUKS_Basic_Capability_Import_3000', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_3000'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksKeySIZE, + HuksHmac.HuksTagDigestSM3 + ), + inData: aes512Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); - it('HUKS_Basic_Capability_Import_3100', 0, async function (done) { - const srcKeyAlies = 'HUKS_Basic_Capability_Import_3100'; - let HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeENCRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC - ), - inData: aes128Key, - }; - await publicImportKey(srcKeyAlies, HuksOptions); - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); - done(); - }); -})} + it('HUKS_Basic_Capability_Import_3100', 0, async function (done) { + const srcKeyAlies = 'HUKS_Basic_Capability_Import_3100'; + let HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeENCRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC + ), + inData: aes128Key, + }; + await publicImportKey(srcKeyAlies, HuksOptions); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + done(); + }); + }) +} diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js index a87a9b535a978c4f31359439e8969417c69c9059..757f51774aed9ecbe16639a79545280f76fd1338 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js @@ -234,12 +234,12 @@ async function update(handle, HuksOptions) { export default function SecurityHuksHmacBasicPromiseJsunit() { describe("SecurityHuksHmacBasicPromiseJsunit", function () { it("testHmac101", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias101"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias101"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -248,12 +248,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testHmac102", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias102"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias102"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -262,12 +262,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testHmac103", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias103"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias103"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; @@ -276,12 +276,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testHmac104", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias104"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias104"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js index baa3b5e7248acc99ac44c520bd0295e450b86a90..e6d49a0b53978846b5c0dccf3a671bb4a2e9d512 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js @@ -15,24 +15,27 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() { -describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () { - it('testSignVerifyDSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); - done(); + describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () { + it('testSignVerifyDSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js index d92c85d8f5c8dd01cffe0b852d8d077ce40ef8f0..af3ecd2ba6467235f40c63bddc54d622d783918e 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js @@ -15,25 +15,28 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() { -describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () { - it('testSignVerifyDSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); - done(); + describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () { + it('testSignVerifyDSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js index f7710f59fab2ec0a4982886f90144b664047ddcc..f325ea5f731d4bd2ce37be634baa9377f5e09a66 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js @@ -15,35 +15,38 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); let finishOutData; export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() { -describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () { - it('testSignVerifyDSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksTagDSACOMMONSIZE - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); - done(); + describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () { + it('testSignVerifyDSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js index 1fec79a7c0547d1d4053611d890c2527ddd7e59d..8606560cbd565f675b841984af21f4d837a833a7 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js @@ -15,35 +15,38 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); let finishOutData; export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() { -describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () { - it('testSignVerifyDSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksKeySIZE1024 - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); - done(); + describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () { + it('testSignVerifyDSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js index a94e049cf9f69fc77ee4c1f04fc58bc1ec69f33f..0f48c8a2a1c72f68ba3ee9fb8477b1dc49b81299 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ describe('SecurityHuksECCBasicAbort63KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js index b31c591f7935bb709b65f0da33c0d543469a8127..12ed12278f77e149a959a5fa98998428de84d373 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js @@ -32,7 +32,7 @@ describe('SecurityHuksECCBasicAbort65KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js index 60b2eef1117ddee598235a920f8982ee0af0f908..bfc0ac34b3454ab07072d1a5f4893c8ab8005fd4 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ describe('SecurityHuksECCBasicFinish63KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; @@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish63KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js index ea0cdc9397b960f3b72a3a257859c1bcea43c163..2ec29f62957a65288c38ac00e3350e4ce7af6908 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ describe('SecurityHuksECCBasicFinish65KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; @@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish65KBCallbackJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js index 34840ff52c4e3b64210e104e83f2019cc2eaaff6..aaaa4bd81534d41c9f203e0ba2e6ff06130b926a 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js @@ -25,14 +25,14 @@ let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksRSABasicAbort63KBCallbackJsunit() { describe('SecurityHuksRSABasicAbort63KBCallbackJsunit', function () { it('testSignVerifyRSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias002'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js index 632312ed2fcc9ab3eeff1125f3fe45cea9eb3def..5662ced1077e3b24707361cf14afac8e1af76dfe 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js @@ -22,14 +22,14 @@ let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksRSABasicAbort65KBCallbackJsunit() { describe('SecurityHuksRSABasicAbort65KBCallbackJsunit', function () { it('testSignVerifyRSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias004'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData65Kb, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js index a7b55fc537ad33336dac32aac5dd0202af2c9755..c9408fbf90a3702b68a91e04af15eff51b0a2368 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish63KBCallbackJsunit() { describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () { it('testSignVerifyRSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias001'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData63Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js index cb1400e6a3b725ffb754db1a6b101e050b8fa3cc..cbd333e5b2dc083844cb54dfe61911bd53856e86 100644 --- a/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish65KBCallbackJsunit() { describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () { it('testSignVerifyRSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias003'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData65Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js index 7d7f85af092a9e772276209d0934dd3c843d7d50..e6172c8b5374b3eac42e457e22cdb7d8c0356824 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js @@ -15,24 +15,27 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() { -describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () { - it('testSignVerifyDSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); - done(); + describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () { + it('testSignVerifyDSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js index 4a3d2f28b3df03711e21778a406e8aee053bf93a..8e76711a39c07b20e7753f203112aff166330c3c 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js @@ -15,24 +15,27 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() { -describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () { - it('testSignVerifyDSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); - done(); + describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () { + it('testSignVerifyDSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js index a3948992bb86605855e4ca75e42c7506090aec6b..fda7486138aec3e6bae6280b8a80a541f1e98188 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js @@ -15,35 +15,38 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); let finishOutData; export default function SecurityHuksDSABasicFinish63KBPromiseJsunit() { -describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () { - it('testSignVerifyDSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksTagDSACOMMONSIZE - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); - done(); + describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () { + it('testSignVerifyDSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js index c24e1c6f4dffe4adb4071bc2a6087d03ec81273f..77805b815c499555f602496594dc5bc73655bbb9 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js @@ -15,35 +15,38 @@ import { describe, it } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); let finishOutData; export default function SecurityHuksDSABasicFinish65KBPromiseJsunit() { -describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () { - it('testSignVerifyDSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksKeySIZE1024 - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); - done(); + describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () { + it('testSignVerifyDSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + let useSoftware = await checkSoftware(); + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js index 986f6e00ffa3ba81a0aadcfa58b73e05e3a92698..8d9018824a2186693606f47cf16f6ee4482c0c21 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js @@ -26,13 +26,13 @@ let srcData63AfterSha256 = new Uint8Array([ export default function SecurityHuksECCBasicAbort63KBPromiseJsunit() { describe('SecurityHuksECCBasicAbort63KBPromiseJsunit', function () { it('testSignVerifyECC102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias102'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js index aa080e09d13b95b6b0a9f9656616d569e56abe7c..35fb6c3cdf60ab2f80ab3a680dddc4e3eb615db7 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js @@ -26,13 +26,13 @@ const srcData65Sha256 = new Uint8Array([ export default function SecurityHuksECCBasicAbort65KBPromiseJsunit() { describe('SecurityHuksECCBasicAbort65KBPromiseJsunit', function () { it('testSignVerifyECC104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias104'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js index 83d6d4c59b3484dc04660f1d0e34de4a64e486f6..d2d3e50fb98aa8c7804ea6f5f0cb025e2c0340b7 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js @@ -27,13 +27,13 @@ let srcData63AfterSha256 = new Uint8Array([ export default function SecurityHuksECCBasicFinish63KBPromiseJsunit() { describe('SecurityHuksECCBasicFinish63KBPromiseJsunit', function () { it('testSignVerifyECC101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias101'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; @@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish63KBPromiseJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js index eae0d07b4a282dabb055156598977fe4ddf55f3f..bd71f60f2666fc85f658a84f87a2e093500e39e6 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js @@ -27,13 +27,13 @@ const srcData65Sha256 = new Uint8Array([ export default function SecurityHuksECCBasicFinish65KBPromiseJsunit() { describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { it('testSignVerifyECC103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias103'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; @@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js index b4d1f47e1415e87e988a2505b0f9fee968b41fbe..ecf0b0a723044ed14af5a8821433c45752381117 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js @@ -22,14 +22,14 @@ let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksRSABasicAbort63KBPromiseJsunit() { describe('SecurityHuksRSABasicAbort63KBPromiseJsunit', function () { it('testSignVerifyRSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA384KeyAlias102'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData63Kb, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js index 1a22cd6702534f3f10e6befbe7dad7abba6c2517..2a47b726ed6ddef9b655958cf9c35b410937b4fe 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js @@ -23,14 +23,14 @@ let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksRSABasicAbort65KBPromiseJsunit() { describe('SecurityHuksRSABasicAbort65KBPromiseJsunit', function () { it('testSignVerifyRSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA384KeyAlias104'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData65Kb, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js index 39755af9d05894fcf77267bc62bdb0d1be0abf20..7fa10e99c0173a5ff036dd0d2f65cabbc49c06ec 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish63KBPromiseJsunit() { describe('SecurityHuksRSABasicFinish63KBPromiseJsunit', function () { it('testSignVerifyRSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA384KeyAlias101'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData63Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish63KBPromiseJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js index da54b5a1dbccebc353b7a1359c35c1b8aba17b3c..40cfec86d9695916d9e503330e62239ffbb547da 100644 --- a/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish65KBPromiseJsunit() { describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { it('testSignVerifyRSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA256KeyAlias103'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData65Kb, }; @@ -40,9 +40,9 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: finishOutData, }; diff --git a/security/security_huks_basic/utils/param/cipher/publicCipherParam.js b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js index 49a4542284b8cabcfb1f9c47d480baa12c163b14..f148bf72e786e5c4218b9f9949e3644b4a1d292b 100644 --- a/security/security_huks_basic/utils/param/cipher/publicCipherParam.js +++ b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js @@ -14,6 +14,7 @@ */ import * as param from '../publicParam'; +import huks from '@ohos.security.huks'; let HuksCipherAES = { HuksKeyAlgAES: { @@ -95,6 +96,10 @@ let HuksCipherRSA = { tag: param.HksTag.HKS_TAG_KEY_SIZE, value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, }, + HuksKeyRSASize4096: { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, + }, HuksKeyRSAPADDINGNONE: { tag: param.HksTag.HKS_TAG_PADDING, value: param.HksKeyPadding.HKS_PADDING_NONE, diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveParam.js b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js index 98f49007c912fcc7b6a404ca548321dc27ef12ef..958fb3a309a4a766c12c8afea3c8b92b4c303d8e 100644 --- a/security/security_huks_basic/utils/param/derive/publicDeriveParam.js +++ b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js @@ -13,6 +13,11 @@ * limitations under the License. */ import * as param from '../publicParam'; +import huks from '@ohos.security.huks'; + +let salt = new Uint8Array([ + 0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff +]); let HuksDeriveHKDF = { HuksKeySIZE: { @@ -286,6 +291,14 @@ let HuksDerivePBKDF2 = { tag: param.HksTag.HKS_TAG_BLOCK_MODE, value: param.HksCipherMode.HKS_MODE_GCM, }, + HuksKeyPBKDF2Iteration: { + tag: huks.HuksTag.HUKS_TAG_ITERATION, + value: 1000 + }, + HuksKeyPBKDF2Salt: { + tag: huks.HuksTag.HUKS_TAG_SALT, + value: salt + }, }; export { HuksDeriveHKDF, HuksDerivePBKDF2 }; diff --git a/security/security_huks_basic/utils/param/publicFunc.js b/security/security_huks_basic/utils/param/publicFunc.js index 4e69946a382a6c5e36cec4fb1046f1896156cd4e..30fc0334af1ab58ac0856e032b099ee142a5ef72 100644 --- a/security/security_huks_basic/utils/param/publicFunc.js +++ b/security/security_huks_basic/utils/param/publicFunc.js @@ -12,6 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +import huks from '@ohos.security.huks'; +import { HuksSignVerifyDSA } from "./signverify/publicSignverifyParam"; +import Data from "../data.json"; +let srcData65 = Data.Data65b; + function stringToArray(str) { var arr = []; for (var i = 0, j = str.length; i < j; ++i) { @@ -53,4 +59,26 @@ function arrayEqual(a, b) { return true; } -export { stringToArray, uint8ArrayToString, stringToUint8Array, arrayEqual }; +async function checkSoftware() { + let dsaAlies = "useDsaToCheckSoftware"; + let dsaOption = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY, + HuksSignVerifyDSA.HuksKeySIZE1024, + HuksSignVerifyDSA.HuksTagDSADigestSHA256 + ) + }; + let res = await huks.generateKey(dsaAlies, dsaOption); + console.log(`test generate:${JSON.stringify(res)}`); + if (res.errorCode == 0) { + await huks.deleteKey(dsaAlies, dsaOption); + console.error("This device uses software"); + return true; + } else { + console.error("This device does not use software"); + return false; + } +} + +export { stringToArray, uint8ArrayToString, stringToUint8Array, arrayEqual, checkSoftware }; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js index 05e8b46e538c8987640c04187b1fdc7e34c64334..f040b8b03462ab989aefe48272ea1979dc269cee 100644 --- a/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js @@ -157,6 +157,10 @@ let HuksSignVerifyED25519 = { tag: param.HksTag.HKS_TAG_DIGEST, value: param.HksKeyDigest.HKS_DIGEST_SHA1, }, + HuksTagDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, }; let HuksSignVerifyRSA = { diff --git a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js index 9afbdbe8a143a3fb4b9cd6ebee977fdcf7c88a56..498abb07bbab69b6ad87a019f6eba44f412c174f 100644 --- a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js @@ -13,44 +13,84 @@ * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import * as Data from '../../../../../../utils/data.json'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { HuksAgreeDH } from '../../../../../../utils/param/agree/publicAgreeParam'; import { publicAgreeFunc } from '../../../../../../utils/param/agree/publicAgreeCallback'; import { HksTag } from '../../../../../../utils/param/publicParam'; let srcData65 = Data.Date65KB; let srcData65Kb = stringToUint8Array(srcData65); +let useSoftware = true; -let HuksOptions65kb = { +let HuksOptions2048 = { properties: new Array(HuksAgreeDH.HuksKeyAlgDH, HuksAgreeDH.HuksKeyPurposeDH, HuksAgreeDH.HuksKeyDHSize2048), inData: srcData65Kb, }; +let HuksOptions3072 = { + properties: new Array(HuksAgreeDH.HuksKeyAlgDH, HuksAgreeDH.HuksKeyPurposeDH, HuksAgreeDH.HuksKeyDHSize3072), + inData: srcData65Kb, +}; + +let HuksOptions4096 = { + properties: new Array(HuksAgreeDH.HuksKeyAlgDH, HuksAgreeDH.HuksKeyPurposeDH, HuksAgreeDH.HuksKeyDHSize4096), + inData: srcData65Kb, +}; + +function makehuksOptionsFinish(srcKeyAliesFirst) { + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + return huksOptionsFinish; +} + export default function SecurityHuksDHBasicFinish65KBCallbackJsunit() { -describe('SecurityHuksDHBasicFinish65KBCallbackJsunit', function () { - it('testReformedAgreeDH003', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001'; - let huksOptionsFinish = { - properties: new Array( - HuksAgreeDH.HuksKeySTORAGE, - HuksAgreeDH.HuksKeyISKEYALIAS, - HuksAgreeDH.HuksKeyALGORITHMAES, - HuksAgreeDH.HuksKeySIZE256, - HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgreeDH.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgreeDH.HuksKeyPADDINGNONE, - HuksAgreeDH.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - }; - await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions65kb, huksOptionsFinish, 'finish'); - done(); + describe('SecurityHuksDHBasicFinish65KBCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) + it('testReformedAgreeDH003', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = makehuksOptionsFinish(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions2048, huksOptionsFinish, 'finish'); + done(); + }); + + it('testAgreeDHSize3072Finish65KBAgree001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize3072Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeDHSize3072Finish65KBAgreeKeyAlias_02_001'; + if (useSoftware) { + let huksOptionsFinish = makehuksOptionsFinish(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions3072, huksOptionsFinish, 'finish'); + } + done(); + }); + + it('testAgreeDHSize4096Finish65KBAgree001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize4096Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeDHSize4096Finish65KBAgreeKeyAlias_02_001'; + if (useSoftware) { + let huksOptionsFinish = makehuksOptionsFinish(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions4096, huksOptionsFinish, 'finish'); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js index 0a97e8bd9f854f56edbd7addeb1b107c9ba7c72e..fcc23a89876166d5820358f551a88719f5a368b3 100644 --- a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions63kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions63kb = { export default function SecurityHuksECDHBasicAbort63KBCallbackJsunit() { describe('SecurityHuksECDHBasicAbort63KBCallbackJsunit', function () { it('testReformedAgreeEDCH002', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js index e719bc691b394e495ddd93fe5cfce9a09904cc7d..1017a7dea13835fce6b71323735612bc09d8e9a3 100644 --- a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions65kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions65kb = { export default function SecurityHuksECDHBasicAbort65KBCallbackJsunit() { describe('SecurityHuksECDHBasicAbort65KBCallbackJsunit', function () { it('testReformedAgreeEDCH004', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js index 859e9bffa1944832e52906854adb3c4f6dbb3f3b..5ec8c250fad6db1c5879b5b77f2f5f606337d75b 100644 --- a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js @@ -21,43 +21,46 @@ import { publicAgreeFunc } from '../../../../../../utils/param/agree/publicAgree import { HksTag } from '../../../../../../utils/param/publicParam'; let srcData63 = Data.Date63KB; let srcData63Kb = stringToUint8Array(srcData63); - -let HuksOptions63kb = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -}; +let HuksOptions63kb = {}; export default function SecurityHuksECDHBasicFinish63KBCallbackJsunit() { -describe('SecurityHuksECDHBasicFinish63KBCallbackJsunit', function () { - it('testReformedAgreeEDCH001', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001'; - let huksOptionsFinish = { - properties: new Array( - HuksAgreeECDH.HuksKeySTORAGE, - HuksAgreeECDH.HuksKeyISKEYALIAS, - HuksAgreeECDH.HuksKeyALGORITHMAES, - HuksAgreeECDH.HuksKeySIZE256, - HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgreeECDH.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgreeECDH.HuksKeyPADDINGNONE, - HuksAgreeECDH.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - }; - await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); - done(); + describe('SecurityHuksECDHBasicFinish63KBCallbackJsunit', function () { + beforeEach(function () { + HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, + }; + console.info('test beforeEach called'); + }); + it('testReformedAgreeEDCH001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js index 07ba8c7f5d20cddcf2f73c9188e853744d79473c..403481ecfb4f56d0a73d95a70890c508ae16ba94 100644 --- a/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_callback_BasicTest/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js @@ -26,7 +26,7 @@ let HuksOptions65kb = { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -37,8 +37,8 @@ let HuksOptions65kb = { export default function SecurityHuksECDHBasicFinish65KBCallbackJsunit() { describe('SecurityHuksECDHBasicFinish65KBCallbackJsunit', function () { it('testReformedAgreeEDCH003', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_001'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js index b859ca191b955d1dd7d15f6af310b798b33f6fa4..13d5f6a5ed62de419f6db5e479e128fa9b700441 100644 --- a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js @@ -22,35 +22,98 @@ import { HksTag } from '../../../../../../utils/param/publicParam'; let srcData65 = Data.Date65KB; let srcData65Kb = stringToUint8Array(srcData65); -let HuksOptions65kb = { +let HuksOptions2048 = { properties: new Array(HuksAgreeDH.HuksKeyAlgDH, HuksAgreeDH.HuksKeyPurposeDH, HuksAgreeDH.HuksKeyDHSize2048), inData: srcData65Kb, }; +function makehuksOptionsFinish(srcKeyAliesFirst){ + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + return huksOptionsFinish; +} + +function makehuksOptionsDerive(srcKeyAliesFirst){ + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeDERIVE, + HuksAgreeDH.HuksKeyDIGESTSHA256, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + ), + inData: srcData65Kb, + }; + return huksOptionsFinish; +} + +function makehuksOptionsHmac(srcKeyAliesFirst){ + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeyALGORITHMHMAC, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeMAC, + HuksAgreeDH.HuksKeyDIGESTSHA256, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + ), + inData: srcData65Kb, + }; + return huksOptionsFinish; +} + export default function SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit() { -describe('SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit', function () { - it('testReformedAgreeDH103', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_101'; - let huksOptionsFinish = { - properties: new Array( - HuksAgreeDH.HuksKeySTORAGE, - HuksAgreeDH.HuksKeyISKEYALIAS, - HuksAgreeDH.HuksKeyALGORITHMAES, - HuksAgreeDH.HuksKeySIZE256, - HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgreeDH.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgreeDH.HuksKeyPADDINGNONE, - HuksAgreeDH.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - }; - await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions65kb, huksOptionsFinish, 'finish'); - done(); + describe('SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit', function () { + it('testReformedAgreeDH103', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = makehuksOptionsFinish(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions2048, huksOptionsFinish, 'finish'); + done(); + }); + + it('testAgreeDHSize2048Finish65KBAgree108', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_108'; + const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_108'; + let huksOptionsFinish = makehuksOptionsDerive(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions2048, huksOptionsFinish, 'finish'); + done(); + }); + + it('testAgreeDHSize2048Finish65KBAgree130', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_130'; + const srcKeyAliesSecond = 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_130'; + let huksOptionsFinish = makehuksOptionsHmac(srcKeyAliesFirst); + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions2048, huksOptionsFinish, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js index c2abe4a52fbf8a8944e18ac99b233c2694784553..09165f7357ef4c16e5f1769d9784c7077c240da3 100644 --- a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -41,8 +41,8 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () { console.info('test beforeEach called'); }); it('testReformedAgreeECDH102', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js index 2b36f7c114c256084a0bd86e5951a01cbc680c74..3ff14c497c164bfb297950c0a0a05be8e74ad462 100644 --- a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () { }); it('testReformedAgreeECDH104', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js index 7cae0694d628b8d17875e69f15a0f2448be8b2ff..62554e6052f23811cf51045780f057fe5c0d969b 100644 --- a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js @@ -22,58 +22,47 @@ import { HksTag } from '../../../../../../utils/param/publicParam'; let srcData63 = Data.Date63KB; let srcData63Kb = stringToUint8Array(srcData63); - -let HuksOptions63kb = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -}; +let HuksOptions63kb = {}; export default function SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit() { -describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgreeECDH.HuksKeyAlgECC, - HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, - HuksAgreeECDH.HuksKeyECCDIGEST, - HuksAgreeECDH.HuksKeyECCPADDING, - HuksAgreeECDH.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - }; - console.info('test beforeEach called'); - }); + describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () { + beforeEach(function () { + HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize256, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, + }; + console.info('test beforeEach called'); + }); - it('testReformedAgreeECDH101', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_101'; - let huksOptionsFinish = { - properties: new Array( - HuksAgreeECDH.HuksKeySTORAGE, - HuksAgreeECDH.HuksKeyISKEYALIAS, - HuksAgreeECDH.HuksKeyALGORITHMAES, - HuksAgreeECDH.HuksKeySIZE256, - HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgreeECDH.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgreeECDH.HuksKeyPADDINGNONE, - HuksAgreeECDH.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - }; - await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); - done(); + it('testReformedAgreeECDH101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js index a3120e0a31a579bbf75e66a866d13132dd6bf4c1..92894233505f307b27629cf425e49af84594969a 100644 --- a/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_agree_promise_BasicTest/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js @@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize256, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () { }); it('testReformedAgreeECDH103', 0, async function (done) { - const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101'; - const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_101'; + const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_101'; let huksOptionsFinish = { properties: new Array( HuksAgreeECDH.HuksKeySTORAGE, diff --git a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js index 741408cd7c7206dccc2a4c75478430a99b51e6d8..c5594d0301e080375e93d3bb0853b813568dd88c 100644 --- a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js @@ -17,9 +17,17 @@ import { describe, it, expect } from '@ohos/hypium'; import huks from '@ohos.security.huks'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc'; -let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData512 = 'RSA_512_tttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; -let gInData64Array = stringToUint8Array(gInData64); +let gInData512Array = stringToUint8Array(gInData512); +let defaultData = '0'; let encryptedData; let inputInData; var handle; @@ -27,8 +35,11 @@ let updateResult = new Array(); let exportKey; let genHuksOptions = { - properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512), - inData: new Uint8Array(new Array()), + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize4096), + inData: new Uint8Array(defaultData), }; async function publicGenerateKeyItemFunc(keyAlias, huksOptions) { @@ -375,19 +386,19 @@ export default function SecurityHuksRSABasicCallbackJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -405,12 +416,12 @@ export default function SecurityHuksRSABasicCallbackJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); done(); @@ -423,19 +434,19 @@ export default function SecurityHuksRSABasicCallbackJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -453,12 +464,12 @@ export default function SecurityHuksRSABasicCallbackJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); done(); diff --git a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js index bd1479bd4d51350406e480d2763af4d0291cf1b5..28490b84bff2847e9d5d814242942dd0c0bcf4e3 100644 --- a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/SecurityHuksSM4BasicCallbackJsunit.test.js @@ -13,16 +13,17 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam'; import { HksTag } from '../../../../../../utils/param/publicParam'; -import { stringToUint8Array, arrayEqual } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, arrayEqual, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; let IV = '0000000000000000'; let plainData; let encryptedResult; -var handle; +let handle; +let useSoftware = true; const plainString48Bytes = 'Hks_SM4_Cipher_Test_000000000000000000000_string'; const plainData48Bytes = stringToUint8Array(plainString48Bytes); @@ -295,6 +296,10 @@ async function publicCipherFunc( export default function SecurityHuksSM4BasicCallbackJsunit() { describe('SecurityHuksSM4BasicCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) // HKS_SUPPORT_SM4_CBC_NOPADDING it('testReformedCipherSM4001_48', 0, async function (done) { const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias001'; @@ -312,13 +317,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -330,13 +329,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -356,13 +349,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -374,13 +361,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -400,13 +381,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -426,13 +401,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -453,31 +422,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -497,31 +456,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -541,13 +490,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -567,13 +512,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -594,13 +535,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -612,13 +547,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -638,13 +567,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -656,13 +579,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -682,13 +599,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -708,13 +619,7 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -735,31 +640,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -779,31 +674,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -823,13 +708,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -849,13 +730,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -876,31 +753,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -920,31 +787,21 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -964,13 +821,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -990,13 +843,9 @@ export default function SecurityHuksSM4BasicCallbackJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); }); diff --git a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js index fb53e8c06af7a72f0b25d24566086b640067995b..d42f0d23743d1e9b8338875bf881fb4ae107524d 100644 --- a/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_callback_BasicTest/src/main/js/test/Cipher/securityHuksExportSupportJsunit.test.js @@ -13,10 +13,10 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; -import huks from '@ohos.security.huks' +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; +import huks from '@ohos.security.huks'; import { HuksKeyAlgX25519, HuksAgreeECDH } from '../../../../../../utils/param/agree/publicAgreeParam'; import { HuksSignVerifySM2, @@ -26,6 +26,7 @@ import { } from '../../../../../../utils/param/signverify/publicSignverifyParam'; let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; let gInData64Array = stringToUint8Array(gInData64); +let useSoftware = true; async function publicGenerateKeyItemFunc(keyAlias, huksOptions) { console.info(`enter callback generateKeyItem`); @@ -128,6 +129,10 @@ function deleteKeyItem(srcKeyAlies, HuksOptions) { export default function securityHuksExportSupportJsunit() { describe('securityHuksExportSupportJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) // HKS_SUPPORT_SM4_CBC_NOPADDING it('HUKS_Basic_Capability_Export_Reformed_0100', 0, async function (done) { let srcKeyAlies = "HUKS_Basic_Capability_Export_0100"; @@ -142,9 +147,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -161,9 +168,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -180,9 +189,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -254,9 +265,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -266,7 +279,7 @@ export default function securityHuksExportSupportJsunit() { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyECCSize256, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 + HuksAgreeECDH.HuksKeyPurposeECDH, HuksAgreeECDH.HuksKeyECCDIGEST ), inData: gInData64Array, @@ -283,7 +296,7 @@ export default function securityHuksExportSupportJsunit() { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyECCSize384, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 + HuksAgreeECDH.HuksKeyPurposeECDH, HuksAgreeECDH.HuksKeyECCDIGEST ), inData: gInData64Array, @@ -300,7 +313,7 @@ export default function securityHuksExportSupportJsunit() { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyECCSize521, - HuksAgreeECDH.HuksKeyPurposeECDH,//没找到 + HuksAgreeECDH.HuksKeyPurposeECDH, HuksAgreeECDH.HuksKeyECCDIGEST ), inData: gInData64Array, @@ -324,9 +337,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -434,9 +449,11 @@ export default function securityHuksExportSupportJsunit() { ), inData: gInData64Array, }; - await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); - await publicExportKeyItem(srcKeyAlies, HuksOptions); - await publicDeleteKeyItem(srcKeyAlies, HuksOptions) + if (useSoftware) { + await publicGenerateKeyItemFunc(srcKeyAlies, HuksOptions); + await publicExportKeyItem(srcKeyAlies, HuksOptions); + await publicDeleteKeyItem(srcKeyAlies, HuksOptions); + } done(); }); @@ -463,7 +480,7 @@ export default function securityHuksExportSupportJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, diff --git a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js index 480760fd79cb862ea25eb239439975789be67d9e..530806ed703d787f26834747b589dd092749f92b 100644 --- a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js @@ -13,18 +13,27 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import huks from '@ohos.security.huks'; import { HuksCipherAES } from '../../../../../../utils/param/cipher/publicCipherParam'; import { HksTag } from '../../../../../../utils/param/publicParam'; -import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, uint8ArrayToString, checkSoftware } from '../../../../../../utils/param/publicFunc'; +import { Data64b } from '../../../../../../utils/data.json'; let IV = '0000000000000000'; +let AAD = '0000000000000000'; +let NONCE = '00000000000'; +let AEAD = '0000000000000000'; +let useSoftware = true; let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string'; let srcData63Kb = stringToUint8Array(srcData63); +let srcData65 = 'Hks_AES_Cipher_Test_000000000000000000000000000000000000000_string'; +let srcData65Kb = stringToUint8Array(srcData65); +let srcData64Kb = stringToUint8Array(Data64b) let updateResult = new Array(); -let encryptedData; -var handle; +let finishData = new Array(); +let encryptedData = new Array(); +let handle; let genHuksOptions = { properties: new Array(HuksCipherAES.HuksKeyAlgAES, HuksCipherAES.HuksKeyPurpose), @@ -131,11 +140,11 @@ async function finish(HuksOptions, isEncrypt) { await huks.finishSession(handle, HuksOptions) .then((data) => { console.info(`promise: doFinish success, data = ${JSON.stringify(data)}`); - let finishData; if (encryptedData.length > 64) { finishData = uint8ArrayToString(updateResult.concat(Array.from(data.outData))); updateResult = updateResult.concat(Array.from(data.outData)); } else { + console.info(`updateResult: updateResult success, data = ${JSON.stringify(updateResult)}`); finishData = uint8ArrayToString(updateResult); } }) @@ -170,7 +179,7 @@ async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { console.info(`enter promise deleteKeyItem`); try { await huks.deleteKeyItem(srcKeyAlies, genHuksOptionsNONECBC) - .then ((data) => { + .then((data) => { console.info(`promise: deleteKeyItem key success, data = ${JSON.stringify(data)}`); }) .catch(error => { @@ -202,6 +211,10 @@ async function publicCipherFunc(srcKeyAlies, genHuksOptionsNONECBC, HuksOptions, export default function SecurityHuksCipherAESBasicPromiseJsunit() { describe('SecurityHuksCipherAESBasicPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) it('testReformedCipherAES101', 0, async function (done) { const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias101'; genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); @@ -266,7 +279,7 @@ export default function SecurityHuksCipherAESBasicPromiseJsunit() { HuksCipherAES.HuksKeyAESDIGESTNONE, { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } ), - inData: srcData63Kb, + inData: srcData64Kb, }; await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { @@ -302,6 +315,458 @@ export default function SecurityHuksCipherAESBasicPromiseJsunit() { await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); done(); }); + + it('testCipherAESSize128PADDINGPKCS7MODECBC103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGPKCS7MODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize128PADDINGNONEMODECTR103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECTRKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize128PADDINGPKCS7MODEECB103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGPKCS7MODEECBKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); + + it('testCipherAESSize192PADDINGNONEMODECBC103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize192PADDINGNONEMODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize192); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize192PADDINGPKCS7MODECBC103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize192PADDINGPKCS7MODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize192); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize192PADDINGNONEMODECTR103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize192PADDINGNONEMODECTRKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize192); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize192PADDINGNONEMODEECB103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize192PADDINGNONEMODEECBKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize192); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); + + it('testCipherAESSize192PADDINGPKCS7MODEECB103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize192PADDINGPKCS7MODEECBKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize192); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize192, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); + + it('testCipherAESSize256PADDINGNONEMODECBC103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize256PADDINGNONEMODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize256); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize256PADDINGPKCS7MODECBC103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize256PADDINGPKCS7MODECBCKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize256); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize256PADDINGNONEMODECTR103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize256PADDINGNONEMODECTRKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize256); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODECTR); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODECTR, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherAESSize256PADDINGNONEMODEECB103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize256PADDINGNONEMODEECBKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize256); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData64Kb, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); + + it('testCipherAESSize256PADDINGPKCS7MODEECB103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize256PADDINGPKCS7MODEECBKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize256); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGPKCS7); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData65Kb, + }; + if (useSoftware) { + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize256, + HuksCipherAES.HuksKeyAESPADDINGPKCS7, + HuksCipherAES.HuksKeyAESBLOCKMODEECB, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + } + done(); + }); }); } diff --git a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js index b2807432bcd3b12a0ffd927a519eb34ca698fcef..f1a5a5c5c519836934f2a1042d6fe85204e64f12 100644 --- a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js @@ -17,12 +17,34 @@ import { describe, it, expect } from '@ohos/hypium'; import huks from '@ohos.security.huks'; import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam'; import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc'; -let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData32 = 'RSA_32_ttttttttttttttttttttttttt'; +let gInData256 = + 'RSA_512_tttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData384 = + 'RSA_512_tttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData512 = + 'RSA_512_tttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' + + 'tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; +let gInData32Array = stringToUint8Array(gInData32); +let gInData256Array = stringToUint8Array(gInData256); +let gInData384Array = stringToUint8Array(gInData384); +let gInData512Array = stringToUint8Array(gInData512); let defaultData = '0'; - -let gInData64Array = stringToUint8Array(gInData64); - let encryptedData; let inputInData; var handle; @@ -30,7 +52,11 @@ let updateResult = new Array(); let exportKey; let genHuksOptions = { - properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512), + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize4096 + ), inData: new Uint8Array(defaultData), }; @@ -245,8 +271,9 @@ async function publicCipherFunc( export default function SecurityHuksCipherRSABasicPromiseJsunit() { describe('SecurityHuksCipherRSABasicPromiseJsunit', function () { it('testReformedCipherRSA101', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias101'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias101'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); @@ -255,19 +282,19 @@ export default function SecurityHuksCipherRSABasicPromiseJsunit() { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -279,43 +306,51 @@ export default function SecurityHuksCipherRSABasicPromiseJsunit() { }); it('testReformedCipherRSA102', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias102'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias102'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); done(); }); it('testReformedCipherRSA103', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias103'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias103'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeDECRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 @@ -327,21 +362,501 @@ export default function SecurityHuksCipherRSABasicPromiseJsunit() { }); it('testReformedCipherRSA104', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias104'; - const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias104'; + const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias104'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias104'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); let HuksOptions = { properties: new Array( HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurposeENCRYPT, - HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSASize4096, HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256 ), - inData: gInData64Array, + inData: gInData512Array, }; await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true); done(); }); + + it('testCipherRSASize4096PADDINGPKCS1_V1_5SHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGPKCS1_V1_5SHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGPKCS1_V1_5SHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize4096PADDINGOAEPSHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize4096PADDINGOAEPSHA384KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA384KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA384NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA384); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize4096PADDINGOAEPSHA512KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA384KeyAlias512'; + const newSrcKeyAlies = 'testCipherRSASize4096PADDINGOAEPSHA384NewKeyAlias512'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize4096); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA512); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize4096, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize3072PADDINGNONESHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize3072PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize3072PADDINGNONESHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize3072); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData384Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize3072PADDINGPKCS1_V1_5SHA384KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize3072PADDINGPKCS1_V1_5SHA384KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize3072PADDINGPKCS1_V1_5SHA384NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize3072); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA384); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize3072PADDINGOAEPSHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize3072); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize3072PADDINGOAEPSHA384KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA384KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA384NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize3072); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA384); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize3072PADDINGOAEPSHA512KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA384KeyAlias512'; + const newSrcKeyAlies = 'testCipherRSASize3072PADDINGOAEPSHA384NewKeyAlias512'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize3072); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA512); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize3072, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize2048PADDINGNONESHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize2048PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize2048PADDINGNONESHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize2048); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData256Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize2048PADDINGPKCS1_V1_5SHA512KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize2048PADDINGPKCS1_V1_5SHA512KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize2048PADDINGPKCS1_V1_5SHA512NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize2048); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA512); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize2048PADDINGOAEPSHA256KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA256KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA256NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize2048); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize2048PADDINGOAEPSHA384KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA384KeyAlias103'; + const newSrcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA384NewKeyAlias103'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize2048); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA384); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA384 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); + + it('testCipherRSASize2048PADDINGOAEPSHA512KeyAlias103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA384KeyAlias512'; + const newSrcKeyAlies = 'testCipherRSASize2048PADDINGOAEPSHA384NewKeyAlias512'; + genHuksOptions.properties.splice(2, 1, HuksCipherRSA.HuksKeyRSASize2048); + genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGOAEP); + genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA512); + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: gInData32Array, + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize2048, + HuksCipherRSA.HuksKeyRSAPADDINGOAEP, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA512 + ), + inData: new Uint8Array(updateResult), + }; + await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false); + done(); + }); }); } diff --git a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js index b415d4646d1f8c72840c41c8d69a4600c86465a5..dc585048c7c284e011677b23bd9b7f3b894da402 100644 --- a/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_cipher_promise_BasicTest/src/main/js/test/Cipher/SecurityHuksCipherSM4BasicPromiseJsunit.test.js @@ -13,16 +13,17 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; import { HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam'; import { HksTag } from '../../../../../../utils/param/publicParam'; -import { stringToUint8Array, arrayEqual } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, arrayEqual, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; let IV = '0000000000000000'; let plainData; let encryptedResult; -var handle; +let handle; +let useSoftware = true; const plainString48Bytes = 'Hks_SM4_Cipher_Test_000000000000000000000_string'; const plainData48Bytes = stringToUint8Array(plainString48Bytes); @@ -199,6 +200,10 @@ async function publicCipherFunc( export default function SecurityHuksCipherSM4BasicPromiseJsunit() { describe('SecurityHuksCipherSM4BasicPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) // HKS_SUPPORT_SM4_CBC_NOPADDING it('testReformedCipherSM4101_48', 0, async function (done) { const srcKeyAlias = 'testCipherSM4Size128PADDINGNONEMODECBCKeyAlias101'; @@ -216,13 +221,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -234,13 +233,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -260,13 +253,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -278,13 +265,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -304,13 +285,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -330,13 +305,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -357,31 +326,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -401,31 +360,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODECBC, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODECBC, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -445,13 +394,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -471,13 +416,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -498,13 +439,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -516,13 +451,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -542,13 +471,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); HuksOptions = { properties: new Array( HuksCipherSM4.HuksKeyAlgSM4, @@ -560,13 +483,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(encryptedResult), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); done(); }); @@ -586,13 +503,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -612,13 +523,7 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); done(); }); @@ -639,31 +544,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -683,31 +578,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGNONE, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGNONE, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -727,13 +612,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -753,13 +634,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -780,31 +657,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData48Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -824,31 +691,21 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: plainData240Bytes, }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - true - ); - HuksOptions = { - properties: new Array( - HuksCipherSM4.HuksKeyAlgSM4, - HuksCipherSM4.HuksKeyPurposeDECRYPT, - HuksCipherSM4.HuksKeySM4Size128, - HuksCipherSM4.HuksKeySM4PADDINGPKCS7, - HuksCipherSM4.HuksKeySM4BLOCKMODEECB, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(encryptedResult), - }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'finish', - false - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', true); + HuksOptions = { + properties: new Array( + HuksCipherSM4.HuksKeyAlgSM4, + HuksCipherSM4.HuksKeyPurposeDECRYPT, + HuksCipherSM4.HuksKeySM4Size128, + HuksCipherSM4.HuksKeySM4PADDINGPKCS7, + HuksCipherSM4.HuksKeySM4BLOCKMODEECB, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(encryptedResult), + }; + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'finish', false); + } done(); }); @@ -868,13 +725,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData48Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); @@ -894,13 +747,9 @@ export default function SecurityHuksCipherSM4BasicPromiseJsunit() { ), inData: new Uint8Array(plainData240Bytes), }; - await publicCipherFunc( - srcKeyAlias, - genHuksOptions, - HuksOptions, - 'abort', - true - ); + if (useSoftware) { + await publicCipherFunc(srcKeyAlias, genHuksOptions, HuksOptions, 'abort', true); + } done(); }); }); diff --git a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js index fa6b2f62071a3a794ec8b33e4b93fcdd62e3c100..77479a97263528027a97f195e8610eb421f06459 100644 --- a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js @@ -27,7 +27,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -35,7 +35,7 @@ let HuksOptions63kb = { export default function SecurityHuksHKDFBasicAbort63KBCallbackJsunit() { describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () { it('testReformedDeriveHKDF002', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js index 4933c1f43861f7779e7e402f121ee0fb70327c64..ad24cabd3c59a6103ebfbfdcd41b31c84ed99258 100644 --- a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js @@ -27,7 +27,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize256 ), inData: srcData63Kb, }; @@ -35,7 +35,7 @@ let HuksOptions63kb = { export default function SecurityHuksHKDFBasicFinish63KBCallbackJsunit() { describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () { it('testReformedDeriveHKDF001', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js index 04f29016770152403775b600ee172459f2111a77..5ccf4dc94a4d36504a0cba4bfb32dd56bad1b09d 100644 --- a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js @@ -27,7 +27,9 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; @@ -35,7 +37,7 @@ let HuksOptions63kb = { export default function SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit() { describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () { it('testReformedDerivePBKDF2002', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Abort63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -49,7 +51,7 @@ describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js index 7ce1d4cdf7063254d2110b87847eb4456b993f88..f6dd778963d23ea672a040e5c023b27fe5e87ec0 100644 --- a/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_callback_BasicTest/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js @@ -27,7 +27,9 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size256, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; @@ -35,7 +37,7 @@ let HuksOptions63kb = { export default function SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit() { describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () { it('testReformedDerivePBKDF2001', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_001'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -49,7 +51,7 @@ describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js index 49016c8e6b1cc1317319fa390581e42e3f54623f..5d2b674499275e63bb1a9cc58cf3f0864f98b399 100644 --- a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js @@ -28,7 +28,7 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize192 ), inData: srcData63Kb, }; @@ -36,7 +36,7 @@ let HuksOptions63kb = { export default function SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit() { describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () { it('testReformedDeriveHKDF102', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDeriveHKDFSize192SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDeriveHKDF.HuksKeySTORAGE, @@ -50,7 +50,7 @@ describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js index d5c84eb31042b353a153caa425967305acb69e16..960c33f6c0a82495c9176fa5161ec190c9b4a293 100644 --- a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js @@ -27,35 +27,286 @@ let HuksOptions63kb = { HuksDeriveHKDF.HuksKeyAlgAES, HuksDeriveHKDF.HuksKeyPurposeHKDF, HuksDeriveHKDF.HuksTagHKDFDigestSHA256, - HuksDeriveHKDF.HuksKeyHKDFSize128 + HuksDeriveHKDF.HuksKeyHKDFSize192 ), inData: srcData63Kb, }; export default function SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit() { -describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () { - it('testReformedDeriveHKDF101', 0, async function (done) { - const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101'; - let huksOptionsFinish = { - properties: new Array( - HuksDeriveHKDF.HuksKeySTORAGE, - HuksDeriveHKDF.HuksKeyISKEYALIAS, - HuksDeriveHKDF.HuksKeyALGORITHMAES, - HuksDeriveHKDF.HuksKeySIZE256, - HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, - HuksDeriveHKDF.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDeriveHKDF.HuksKeyPADDINGNONE, - HuksDeriveHKDF.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - }; - let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF,HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); - await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); - done(); + describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () { + it('testReformedDeriveHKDF101', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize192SHA256Finish63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize192SHA256Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize192SHA256Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeDERIVE, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize192SHA256Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize192SHA256Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMHMAC, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeMAC, + HuksDeriveHKDF.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA256Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(3, 1, HuksDeriveHKDF.HuksKeyHKDFSize256); + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA256Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeDERIVE, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA256Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMHMAC, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeMAC, + HuksDeriveHKDF.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA384Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA384Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(2, 1, HuksDeriveHKDF.HuksTagHKDFDigestSHA384); + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA384Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA384Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeDERIVE, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA384Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA384Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMHMAC, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeMAC, + HuksDeriveHKDF.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA512Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA512Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(2, 1, HuksDeriveHKDF.HuksTagHKDFDigestSHA512); + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA512Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA512Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeDERIVE, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDeriveHKDFSize256SHA512Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA512Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeyALGORITHMHMAC, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeMAC, + HuksDeriveHKDF.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDeriveHKDF.HuksKeyAlgHKDF, HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js index 47ee0d4caf116c9154ad61748bd5e835fe721f20..0e330c13e73840bc035fab83dbc70564313fc7f7 100644 --- a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js @@ -28,14 +28,16 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size192, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; export default function SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit() { describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () { it('testReformedDerivePBKDF2102', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size192SHA256Abort63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -49,7 +51,7 @@ describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js index df05122fe5ef184114403034f70ff301983c447c..d0634e4a1be5d84a2dde23f94dfde3827bd98f93 100644 --- a/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_derive_promise_BasicTest/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js @@ -28,7 +28,9 @@ let HuksOptions63kb = { HuksDerivePBKDF2.HuksKeyAlgAES, HuksDerivePBKDF2.HuksKeyPurposePBKDF2, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, - HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + HuksDerivePBKDF2.HuksKeyPBKDF2Size192, + HuksDerivePBKDF2.HuksKeyPBKDF2Iteration, + HuksDerivePBKDF2.HuksKeyPBKDF2Salt ), inData: srcData63Kb, }; @@ -36,7 +38,7 @@ let HuksOptions63kb = { export default function SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit() { describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () { it('testReformedDerivePBKDF2101', 0, async function (done) { - const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101'; + const srcKeyAliesFirst = 'testDerivePBKDF2Size192SHA256Finish63KBDeriveKeyAlias_01_101'; let huksOptionsFinish = { properties: new Array( HuksDerivePBKDF2.HuksKeySTORAGE, @@ -50,7 +52,7 @@ describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () { value: stringToUint8Array(srcKeyAliesFirst), }, HuksDerivePBKDF2.HuksKeyPADDINGNONE, - HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM ), inData: srcData63Kb, }; @@ -58,5 +60,256 @@ describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () { await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); done(); }); + + it('testDerivePBKDF2Size192SHA256Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size192SHA256Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeDERIVE, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size192SHA256Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size192SHA256Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyALGORITHMHMAC, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeMAC, + HuksDerivePBKDF2.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA256Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(3, 1, HuksDerivePBKDF2.HuksKeyPBKDF2Size256); + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA256Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeDERIVE, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA256Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyALGORITHMHMAC, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeMAC, + HuksDerivePBKDF2.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA384Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA384Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(2, 1, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA384); + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA384Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA384Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeDERIVE, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA384Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA384Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyALGORITHMHMAC, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeMAC, + HuksDerivePBKDF2.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA512Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA512Finish63KBDeriveKeyAlias_01_101'; + HuksOptions63kb.properties.splice(2, 1, HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA512); + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA512Finish63KBDerive108', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA512Finish63KBDeriveKeyAlias_01_108'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeDERIVE, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); + + it('testDerivePBKDF2Size256SHA512Finish63KBDerive130', 0, async function (done) { + const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA512Finish63KBDeriveKeyAlias_01_130'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyALGORITHMHMAC, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeMAC, + HuksDerivePBKDF2.HuksKeyDIGESTSHA256, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM + ), + inData: srcData63Kb, + }; + let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE); + await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish'); + done(); + }); }); } diff --git a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js index 1f23fed5636dc3c8db9becaf5c910ad290a0a50f..149dcd68b4ef6c1c26c4b1028b2759febdf30908 100644 --- a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js +++ b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksAccessControlJsunit.test.js @@ -12,28 +12,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it, expect } from "@ohos/hypium"; +import { describe, it, expect, beforeAll } from "@ohos/hypium"; import huks from "@ohos.security.huks"; import Data from "../../../../../../utils/data.json"; -import { stringToUint8Array } from "../../../../../../utils/param/publicFunc"; -import { - HuksSignVerifyDSA, - HuksSignVerifyRSA, - HuksSignVerifyECC, -} from "../../../../../../utils/param/signverify/publicSignverifyParam"; -import { - HuksAgreeDH, - HuksAgreeECDH, -} from "../../../../../../utils/param/agree/publicAgreeParam"; -import { - HuksCipherAES, - HuksCipherRSA, -} from "../../../../../../utils/param/cipher/publicCipherParam"; +import { stringToUint8Array, checkSoftware } from "../../../../../../utils/param/publicFunc"; +import { HuksSignVerifyDSA, HuksSignVerifyRSA, HuksSignVerifyECC } + from "../../../../../../utils/param/signverify/publicSignverifyParam"; +import { HuksAgreeDH, HuksAgreeECDH } + from "../../../../../../utils/param/agree/publicAgreeParam"; +import { HuksCipherAES, HuksCipherRSA } + from "../../../../../../utils/param/cipher/publicCipherParam"; import { HuksHmac } from "../../../../../../utils/param/hmac/publicHmacParam"; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); let exportKey; +let useSoftware = true; async function generateKeyFunc(srcKeyAlies, HuksOptions) { console.info(`enter promise generateKeyItem`); @@ -123,6 +117,10 @@ function isKeyItemExist(srcKeyAlies, HuksOptions) { export function SecurityHuksAccessControlJsunit() { describe("SecurityHuksAccessControlJsunit", function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) it("HUKS_Basic_Capability_AccessControl_Reformed_0100", 0, async function (done) { let srcKeyAlias = "HUKS_Basic_Capability_AccessControl_0100"; let HuksOptions = { @@ -134,27 +132,29 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await publicIsKeyItemExist(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); - - HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); - HuksOptions.properties.splice(3, 1); - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, HuksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000003).assertTrue(); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await publicIsKeyItemExist(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); + HuksOptions.properties.splice(3, 1); + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, HuksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000003).assertTrue(); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } + await deleteKeyFunc(srcKeyAlias, HuksOptions); } - await deleteKeyFunc(srcKeyAlias, HuksOptions); done(); }); @@ -164,7 +164,7 @@ export function SecurityHuksAccessControlJsunit() { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, + HuksSignVerifyECC.HuksKeyECCSize384, HuksSignVerifyECC.HuksTagECCDigestNONE ), inData: srcData63Kb, @@ -218,42 +218,44 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT); + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, HuksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000003).assertTrue(); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } - HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT); - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, HuksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000003).assertTrue(); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); - } + HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT); + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, HuksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000003).assertTrue(); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } - HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT); - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, HuksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000003).assertTrue(); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + await deleteKeyFunc(srcKeyAlias, HuksOptions); } - - await deleteKeyFunc(srcKeyAlias, HuksOptions); done(); }); @@ -263,9 +265,9 @@ export function SecurityHuksAccessControlJsunit() { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize3072 ), inData: srcData63Kb, }; @@ -367,26 +369,28 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose); + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, HuksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000003).assertTrue(); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } - HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose); - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, HuksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000003).assertTrue(); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + await deleteKeyFunc(srcKeyAlias, HuksOptions); } - - await deleteKeyFunc(srcKeyAlias, HuksOptions); done(); }); @@ -403,16 +407,8 @@ export function SecurityHuksAccessControlJsunit() { }; await generateKeyFunc(srcKeyAlias, HuksOptions); - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN - ); - HuksOptions.properties.splice( - 5, - 1, - HuksSignVerifyRSA.HuksTagPKCS1DigestNONE - ); + HuksOptions.properties.splice(1, 1, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN); + HuksOptions.properties.splice(5, 1, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE); console.info(`enter promise doInit`); try { await huks.initSession(srcKeyAlias, HuksOptions) @@ -428,11 +424,7 @@ export function SecurityHuksAccessControlJsunit() { expect(null).assertFail(); } - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY - ); + HuksOptions.properties.splice(1, 1, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY); console.info(`enter promise doInit`); try { await huks.initSession(srcKeyAlias, HuksOptions) @@ -458,7 +450,7 @@ export function SecurityHuksAccessControlJsunit() { properties: new Array( HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyPurposeECDH, - HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCSize384, HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE @@ -468,11 +460,7 @@ export function SecurityHuksAccessControlJsunit() { await generateKeyFunc(srcKeyAlias, HuksOptions); await exportKeyFunc(srcKeyAlias, HuksOptions); - HuksOptions.properties.splice( - 0, - 1, - HuksSignVerifyECC.HuksKeyECCPurposeSIGN - ); + HuksOptions.properties.splice(0, 1, HuksSignVerifyECC.HuksKeyECCPurposeSIGN); HuksOptions.properties.splice(4, 2); console.info(`enter promise doInit`); try { @@ -489,11 +477,7 @@ export function SecurityHuksAccessControlJsunit() { expect(null).assertFail(); } - HuksOptions.properties.splice( - 0, - 1, - HuksSignVerifyECC.HuksKeyECCPurposeVERIFY - ); + HuksOptions.properties.splice(0, 1, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY); HuksOptions.properties.splice(4, 2); console.info(`enter promise doInit`); try { @@ -525,27 +509,29 @@ export function SecurityHuksAccessControlJsunit() { ), inData: srcData63Kb, }; - await generateKeyFunc(srcKeyAlias, HuksOptions); - await exportKeyFunc(srcKeyAlias, HuksOptions); + if (useSoftware) { + await generateKeyFunc(srcKeyAlias, HuksOptions); + await exportKeyFunc(srcKeyAlias, HuksOptions); + + HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); + HuksOptions.properties.splice(3, 1); + console.info(`enter promise doInit`); + try { + await huks.initSession(srcKeyAlias, HuksOptions) + .then((data) => { + console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000003).assertTrue(); + }); + } catch (error) { + console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } - HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH); - HuksOptions.properties.splice(3, 1); - console.info(`enter promise doInit`); - try { - await huks.initSession(srcKeyAlias, HuksOptions) - .then((data) => { - console.info(`promise: doInit success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: doInit key failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000003).assertTrue(); - }); - } catch (error) { - console.error(`promise: doInit input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + await deleteKeyFunc(srcKeyAlias, HuksOptions); } - - await deleteKeyFunc(srcKeyAlias, HuksOptions); done(); }); diff --git a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js index 89b312eeb84837537d28ab08a84f84216d5dc73c..75674c08eb5cd2461325f7640cdd8c476fb79e64 100644 --- a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js @@ -269,13 +269,13 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { export function SecurityHuksHmacCallbackJsunit() { describe("SecurityHuksHmacCallbackJsunit", function () { - it("testReformedHmacSHA1001", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias001"; + it("testReformedHmacSHA256001", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA256KeyAlias001"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -284,39 +284,39 @@ export function SecurityHuksHmacCallbackJsunit() { done(); }); - it("testReformedHmacSHA1002", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias002"; + it("testReformedHmacSHA256002", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA256KeyAlias002"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort"); done(); }); - it("testReformedHmacSHA1003", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias003"; + it("testReformedHmacSHA256003", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA256KeyAlias003"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish"); done(); }); - it("testReformedHmacSHA1004", 0, async function (done) { - let srcKeyAlies = "testHmacDigestSHA1KeyAlias004"; + it("testReformedHmacSHA256004", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA256KeyAlias004"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; diff --git a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js index 4af9bde8ada9ca7914ee8eb99e882aabd9711e75..e5d1566944e00435bbd9a695d2fbb9cc6bb0ba89 100644 --- a/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js +++ b/security/security_huks_reformed_test/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js @@ -13,8 +13,8 @@ * limitations under the License. */ -import { describe, it, expect } from '@ohos/hypium'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import huks from '@ohos.security.huks'; import Data from '../../../../../../utils/data.json'; import { HuksCipherAES, HuksCipherRSA, HuksCipherSM4 } from '../../../../../../utils/param/cipher/publicCipherParam' @@ -44,6 +44,7 @@ let outPlainKeyEncData; let outKekEncData; let outKekEncTag; let outAgreeKeyEncTag; +let useSoftware = true; let mask = [0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000]; function subUint8ArrayOf(arrayBuf, start, end) { @@ -1039,17 +1040,24 @@ async function BuildWrappedDataAndImportWrappedKey(plainKey) { export function SecurityHuksImportJsunit() { describe('SecurityHuksImportJsunit', function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }); it('HUKS_Basic_Capability_Import_Reformed_0100', 0, async function (done) { const srcKeyAlies = 'HUKS_Basic_Capability_Import_0100'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, + HuksSignVerifyECC.HuksKeyECCSize256, HuksSignVerifyECC.HuksTagECCDigestNONE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), - inData: ecc224Key, + inData: ecc256Key, }; await publicGenerateItemFunc(srcKeyAlies, HuksOptions); await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); @@ -1064,9 +1072,12 @@ export function SecurityHuksImportJsunit() { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY, - HuksSignVerifyECC.HuksKeyECCSize224, + HuksSignVerifyECC.HuksKeyECCSize256, HuksSignVerifyECC.HuksTagECCDigestNONE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: dsa2048Key, }; @@ -1186,16 +1197,20 @@ export function SecurityHuksImportJsunit() { ), inData: aes512Key, }; - try { - await huks.importKeyItem(srcKeyAlies, HuksOptions) - .then(data => { - console.info(`promise: importKeyItem success, data = ${JSON.stringify(data)}`); - }).catch(err => { - console.error(`promise: importKeyItem failed, code: ${err.code}, msg: ${err.message}`); - }) - } catch (err) { - console.error(`promise: importKeyItem input arg invalid, code: ${err.code}, msg: ${err.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(srcKeyAlies, HuksOptions) + .then(data => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(err => { + console.error(`callback: generateKeyItem failed, code: ${err.code}, msg: ${err.message}`); + expect(err.code == 401).assertTrue(); + }) + } catch (err) { + console.error(`callback: generateKeyItem invalid, code: ${err.code}, msg: ${err.message}`); + expect(null).assertFail(); + } } done(); }); @@ -1210,12 +1225,17 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa512Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1229,12 +1249,17 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa768Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1248,12 +1273,17 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa1024Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1267,7 +1297,10 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa2048Key, }; @@ -1286,7 +1319,10 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa3072Key, }; @@ -1305,7 +1341,10 @@ export function SecurityHuksImportJsunit() { HuksCipherRSA.HuksKeyRSAPADDINGNONE, HuksCipherRSA.HuksKeyRSABLOCKMODEECB, HuksCipherRSA.HuksKeyRSADIGESTSHA256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: rsa4096Key, }; @@ -1325,8 +1364,10 @@ export function SecurityHuksImportJsunit() { ), inData: aes512Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1338,12 +1379,17 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, HuksSignVerifyECC.HuksKeyECCSize224, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc224Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1355,7 +1401,10 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, HuksSignVerifyECC.HuksKeyECCSize256, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc256Key, }; @@ -1372,7 +1421,10 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, HuksSignVerifyECC.HuksKeyECCSize384, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc384Key, }; @@ -1389,7 +1441,10 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, HuksSignVerifyECC.HuksKeyECCSize521, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc521Key, }; @@ -1408,12 +1463,17 @@ export function SecurityHuksImportJsunit() { HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc224Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1427,7 +1487,10 @@ export function SecurityHuksImportJsunit() { HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc256Key, }; @@ -1446,7 +1509,10 @@ export function SecurityHuksImportJsunit() { HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc384Key, }; @@ -1465,7 +1531,10 @@ export function SecurityHuksImportJsunit() { HuksAgreeECDH.HuksKeyECCDIGEST, HuksAgreeECDH.HuksKeyECCPADDING, HuksAgreeECDH.HuksKeyECCBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ecc521Key, }; @@ -1484,7 +1553,10 @@ export function SecurityHuksImportJsunit() { HuksKeyAlgX25519.HuksKeyDIGEST, HuksKeyAlgX25519.HuksKeyPADDING, HuksKeyAlgX25519.HuksKeyBLOCKMODE, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: x25519Key, }; @@ -1501,7 +1573,10 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, HuksSignVerifyED25519.HuksKeyED25519Size256, HuksSignVerifyED25519.HuksTagDigestSHA1, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: ed25519Key, }; @@ -1561,13 +1636,21 @@ export function SecurityHuksImportJsunit() { HuksSignVerifyDSA.HuksKeyAlgDSA, HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, HuksSignVerifyDSA.HuksTagDSADigestSHA256, - { tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 }, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048 + }, + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: dsa2048Key, }; - await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); - await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + if (useSoftware) { + await publicImportKeyItemFunc(srcKeyAlies, HuksOptions); + await publicDeleteKeyItemFunc(srcKeyAlies, HuksOptions); + } done(); }); @@ -1579,7 +1662,10 @@ export function SecurityHuksImportJsunit() { HuksSignVerifySM2.HuksKeySM2PurposeSINGVERIFY, HuksSignVerifySM2.HuksKeySize256, HuksSignVerifySM2.HuksTagSM2DigestSM3, - { tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR } + { + tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, + value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR + } ), inData: sm2Key, }; diff --git a/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js b/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js index 04b92a634fa7b4a4864083a3b9431b58fa670ee9..70fa56750857b64cefe27935037b2962cfb10cc7 100644 --- a/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js +++ b/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js @@ -13,12 +13,14 @@ * limitations under the License. */ import huks from "@ohos.security.huks"; -import { describe, it, expect } from "@ohos/hypium"; +import { describe, it, expect, beforeAll } from "@ohos/hypium"; +import { checkSoftware } from "../../../../../../utils/param/publicFunc.js"; let securityLevel = stringToUint8Array("sec_level"); let challenge = stringToUint8Array("challenge_data"); let versionInfo = stringToUint8Array("version_info"); let keyAliasString = "key attest"; +let useSoftware = true; function publicAttestKey(srcKeyAlies, HuksOptions) { return new Promise((resolve, reject) => { @@ -181,6 +183,10 @@ async function generateKeyAttest(alias) { export default function SecurityHuksFaceFingerNormalJsunit() { describe("SecurityHuksFaceFingerNormalJsunit", function () { + beforeAll(async function (done) { + useSoftware = await checkSoftware(); + done(); + }) /** * @tc.number HUKS_Cipher_AuthToken_2900 * @tc.name HUKS_Cipher_AuthToken_2900. @@ -196,18 +202,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { }; option.properties.splice(5, 1, err); console.info(`enter promise generateKeyItem`); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 401).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 401).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -227,18 +235,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { }; option.properties.splice(6, 1, err); console.info(`enter promise generateKeyItem`); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000013).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000013).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -258,18 +268,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { }; option.properties.splice(7, 1, err); console.info(`enter promise generateKeyItem`); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 401).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 401).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -288,18 +300,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { value: -1, }; option.properties.splice(8, 1, err); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 12000013).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 12000013).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -318,18 +332,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { value: -1, }; option.properties.splice(8, 1, err); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 401).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 401).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -348,18 +364,20 @@ export default function SecurityHuksFaceFingerNormalJsunit() { value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, }; option.properties.splice(6, 1, err); - try { - await huks.generateKeyItem(alias, option) - .then((data) => { - console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(error.code == 401).assertTrue(); - }); - } catch (error) { - console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + if (useSoftware) { + try { + await huks.generateKeyItem(alias, option) + .then((data) => { + console.info(`promise: generateKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`promise: generateKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(error.code == 401).assertTrue(); + }); + } catch (error) { + console.error(`promise: generateKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); @@ -392,35 +410,37 @@ export default function SecurityHuksFaceFingerNormalJsunit() { let options = { properties: properties, }; - await generateKeyAttest(aliasString); - try { - await huks.attestKeyItem(aliasString, options) - .then((data) => { - console.info(`promise: attestKeyItem success, data = ${JSON.stringify(data)}`); - expect(data.certChains != null).assertTrue(); - }) - .catch(error => { - console.error(`promise: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); - }); - } catch (error) { - console.error(`promise: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); - } + if (useSoftware) { + await generateKeyAttest(aliasString); + try { + await huks.attestKeyItem(aliasString, options) + .then((data) => { + console.info(`promise: attestKeyItem success, data = ${JSON.stringify(data)}`); + expect(data.certChains != null).assertTrue(); + }) + .catch(error => { + console.error(`promise: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + }); + } catch (error) { + console.error(`promise: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } - console.info(`enter callback attestKeyItem`); - try { - await publicAttestKey(aliasString, options) - .then((data) => { - console.info(`callback: attestKeyItem success, data = ${JSON.stringify(data)}`); - }) - .catch(error => { - console.error(`callback: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); - }); - } catch (error) { - console.error(`callback: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); - expect(null).assertFail(); + console.info(`enter callback attestKeyItem`); + try { + await publicAttestKey(aliasString, options) + .then((data) => { + console.info(`callback: attestKeyItem success, data = ${JSON.stringify(data)}`); + }) + .catch(error => { + console.error(`callback: attestKeyItem failed, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + }); + } catch (error) { + console.error(`callback: attestKeyItem input arg invalid, code: ${error.code}, msg: ${error.message}`); + expect(null).assertFail(); + } } done(); }); diff --git a/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js index 0f931633d68563814bfa86258de81ddb119134db..be565fa1bfced6f2c616315604c3d15144d900e1 100644 --- a/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js @@ -219,12 +219,12 @@ async function update(handle, HuksOptions) { export default function SecurityHuksHmacBasicPromiseJsunit() { describe("SecurityHuksHmacBasicPromiseJsunit", function () { it("testReformedHmac101", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias101"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias101"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -233,12 +233,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testReformedHmac102", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias102"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias102"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData63Kb, }; @@ -247,12 +247,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testReformedHmac103", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias103"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias103"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; @@ -261,19 +261,44 @@ export default function SecurityHuksHmacBasicPromiseJsunit() { }); it("testReformedHmac104", 0, async function (done) { - const srcKeyAlies = "testHmacDigestSHA1KeyAlias104"; + const srcKeyAlies = "testHmacDigestSHA256KeyAlias104"; let HuksOptions = { properties: new Array( HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 + HuksHmac.HuksTagDigestSHA256 ), inData: srcData65Kb, }; await publicHmacFunc(srcKeyAlies, HuksOptions, "abort"); done(); }); - + it("testReformedHmacSHA384103", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA384KeyAlias003"; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA384 + ), + inData: srcData65Kb, + }; + await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish"); + done(); + }); + it("testReformedHmacSHA512103", 0, async function (done) { + let srcKeyAlies = "testHmacDigestSHA512KeyAlias003"; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA512 + ), + inData: srcData65Kb, + }; + await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish"); + done(); + }); it("testReformedHmacSM3101", 0, async function (done) { let srcKeyAlies = "testHmacDigestSM3KeyAlias001"; let HuksOptions = { diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js index 54789f5a4610e3b2e3e80bf88371b5867cc57f82..9bef886550f772557fa059e5abe1899e7f455867 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js @@ -12,27 +12,34 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); +let useSoftware = true; export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() { -describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () { - it('testReformedSignVerifyDSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); - done(); + describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js index 4182c18b030dafa3178deb6ba2f5c7945049ddb1..41be9d5070245a38a74c24eb474b5b501d7c7d4e 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js @@ -12,28 +12,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); +let useSoftware = true; export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() { -describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () { - it('testReformedSignVerifyDSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); - done(); + describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js index 37d14ae2381da21b57912097ff1841d59536e0bd..e40b58e5cb575af726a0dd9e9846f9fed99626c7 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js @@ -12,38 +12,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); let finishOutData; +let useSoftware = true; export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() { -describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () { - it('testReformedSignVerifyDSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksTagDSACOMMONSIZE - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); - done(); + describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js index 7a4a75e4a7ca68d3afe4985aaf42a26bdfd42399..7d434055d8d0399f35a8c8fb51b1077dcd7351ab 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js @@ -12,38 +12,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); let finishOutData; +let useSoftware = true; export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() { -describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () { - it('testReformedSignVerifyDSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksKeySIZE1024 - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); - done(); + describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js index b0e7945b026617047c63d07cb05384e10fbb1c95..7594924894022dbe6aafc9099236648a3e4371cb 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js @@ -22,13 +22,13 @@ let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksECCBasicAbort63KBCallbackJsunit() { describe('SecurityHuksECCBasicAbort63KBCallbackJsunit', function () { it('testReformedSignVerifyECC002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias002'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias002'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js index a92e4a366b84fb3db8f3f4b137a69b674516583b..0e934007d8194640c36c7a47c6252a68b6104d0c 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js @@ -22,13 +22,13 @@ let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksECCBasicAbort65KBCallbackJsunit() { describe('SecurityHuksECCBasicAbort65KBCallbackJsunit', function () { it('testReformedSignVerifyECC004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias004'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias004'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, - HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js index 2e88924d0163f589f3b5ea67d508cf53ecb6e124..c975c5f6dd97eaebe37ced9bde3c1d06a9fc9742 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js @@ -33,7 +33,7 @@ export default function SecurityHuksECCBasicFinish63KBCallbackJsunit() { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; @@ -43,7 +43,7 @@ export default function SecurityHuksECCBasicFinish63KBCallbackJsunit() { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js index 6122ee649b40a4eb03c7ce4891d580fe7a45553f..a5f7e20e3b1928898bc37b5b59f60a37307f4c1a 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js @@ -26,13 +26,13 @@ let finishOutData; export default function SecurityHuksECCBasicFinish65KBCallbackJsunit() { describe('SecurityHuksECCBasicFinish65KBCallbackJsunit', function () { it('testReformedSignVerifyECC003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias003'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias003'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; @@ -42,7 +42,7 @@ export default function SecurityHuksECCBasicFinish65KBCallbackJsunit() { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js index a3fb6b6853e58bb96c240893f04372ac71e54530..7ef1a16b92c2cf18da19f3d49fb6384fa82822dc 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js @@ -25,14 +25,14 @@ let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksRSABasicAbort63KBCallbackJsunit() { describe('SecurityHuksRSABasicAbort63KBCallbackJsunit', function () { it('testReformedSignVerifyRSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA256KeyAlias002'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js index e4ec51cfd62eb13e702d9967c650476a98a19cbf..e6768ed9a91846e6d67aad3bb5333a13c1d70dbc 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js @@ -22,14 +22,14 @@ let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksRSABasicAbort65KBCallbackJsunit() { describe('SecurityHuksRSABasicAbort65KBCallbackJsunit', function () { it('testReformedSignVerifyRSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA256KeyAlias004'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData65Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js index f7b7f3510352b317c5c992e8ff70aef260fb5e71..4ca6325a5dba9312d61d6e0c5e6b0fdf658f556d 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish63KBCallbackJsunit() { describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () { it('testReformedSignVerifyRSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA256KeyAlias001'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData63Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js index e98b004e0343120ab65a78f424871c736f43a4b9..89328c88a16bc415522474f52f787c7775c162ab 100644 --- a/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_callback_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish65KBCallbackJsunit() { describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () { it('testReformedSignVerifyRSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003'; + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA256KeyAlias003'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData65Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js index 9b79f6459cc6bdbcc3c44c077af286d0c2006507..fbdf5962dac28499f689092a29e5825030fca78f 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js @@ -12,27 +12,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); +let useSoftware = true; export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() { -describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () { - it('testReformedSignVerifyDSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); - done(); + describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb); + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js index 257e11425145523199f3cead0210d9c2ab64f204..fb41d8e84a251ccbc37d0c58c1befc106e6f15b6 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js @@ -12,27 +12,34 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array,checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); +let useSoftware = true; export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() { -describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () { - it('testReformedSignVerifyDSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); - done(); + describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + if (useSoftware) { + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js index d556e99c43a8bb9070ee63f1acfc9e5c735089ba..c36b3949fbf8446ff23d93e172423dd27bf7608e 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js @@ -12,38 +12,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); let finishOutData; +let useSoftware = true; export default function SecurityHuksDSABasicFinish63KBPromiseJsunit() { -describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () { - it('testReformedSignVerifyDSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksTagDSACOMMONSIZE - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); - done(); + describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js index 235aebd1b663f53607f44c75e28e3686c9d8b0b1..064a1b9e1ed4487e20a2ce238d8b81baab0a51b5 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js @@ -12,38 +12,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, it } from '@ohos/hypium'; +import { describe, it, beforeAll } from '@ohos/hypium'; import Data from '../../../../../../utils/data.json'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; -import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; +import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); let finishOutData; +let useSoftware = true; export default function SecurityHuksDSABasicFinish65KBPromiseJsunit() { -describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () { - it('testReformedSignVerifyDSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; - let HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, - HuksSignVerifyDSA.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - }; - finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); - HuksOptions = { - properties: new Array( - HuksSignVerifyDSA.HuksKeyAlgDSA, - HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, - HuksSignVerifyDSA.HuksTagDSADigestSHA1, - HuksSignVerifyDSA.HuksKeySIZE1024 - ), - inData: finishOutData, - }; - await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); - done(); + describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () { + beforeAll(async function (done) { + useSoftware = checkSoftware(); + done(); + }) + it('testReformedSignVerifyDSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + if (useSoftware) { + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + } + done(); + }); }); -}); } diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js index 687f15bd32f47c092f2e8fe8cbd867631331596f..f721cc0e9d38203d24a30767225669d28eddb2d0 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js @@ -26,13 +26,13 @@ let srcData63AfterSha256 = new Uint8Array([ export default function SecurityHuksECCBasicAbort63KBPromiseJsunit() { describe('SecurityHuksECCBasicAbort63KBPromiseJsunit', function () { it('testReformedSignVerifyECC102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias102'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js index 7ed8d1ebe68f0fae6849c192456ee912ba5370ed..627a349b0b3b3f3ad22293e1f8d0eb1e83c932ca 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js @@ -26,13 +26,13 @@ const srcData65Sha256 = new Uint8Array([ export default function SecurityHuksECCBasicAbort65KBPromiseJsunit() { describe('SecurityHuksECCBasicAbort65KBPromiseJsunit', function () { it('testReformedSignVerifyECC104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias104'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js index 6a8397c97193078979162e0d6e3b104bf20abc49..993c3b90fac2ce5fd8899414ad2aaa23584ea0f6 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js @@ -27,13 +27,13 @@ let srcData63AfterSha256 = new Uint8Array([ export default function SecurityHuksECCBasicFinish63KBPromiseJsunit() { describe('SecurityHuksECCBasicFinish63KBPromiseJsunit', function () { it('testReformedSignVerifyECC101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias101'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData63AfterSha256, }; @@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish63KBPromiseJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js index cbdd6d9977e53e8c15bb9ba6c93079dfaa2761a3..dee0d8d67e3b1573ce68d648b8fae27892c2d89d 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js @@ -27,13 +27,13 @@ const srcData65Sha256 = new Uint8Array([ export default function SecurityHuksECCBasicFinish65KBPromiseJsunit() { describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { it('testReformedSignVerifyECC103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103'; + const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias103'; let HuksOptions = { properties: new Array( HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeSIGN, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: srcData65Sha256, }; @@ -43,12 +43,437 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { HuksSignVerifyECC.HuksKeyAlgECC, HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, HuksSignVerifyECC.HuksTagECCDigestNONE, - HuksSignVerifyECC.HuksKeyECCSize224 + HuksSignVerifyECC.HuksKeyECCSize256 ), inData: finishOutData, }; await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Sha256); done(); }); + + it('testSignVerifyECCSize384SIGNNONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Sha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Sha256); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Sha256); + done(); + }); + + it('testSignVerifyECCSize521SIGNNONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize521SIGNNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Sha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Sha256); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Sha256); + done(); + }); + + it('testSignVerifyECCSize256SIGNSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize256SIGNSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize384SIGNSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize521SIGNSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA1, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize256SIGNSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize256SIGNSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize384SIGNSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize521SIGNSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA224, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize256SIGNSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize256SIGNSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize384SIGNSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize521SIGNSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA256, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize256SIGNSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize256SIGNSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize384SIGNSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize521SIGNSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA384, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize256SIGNSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize256SIGNSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize256 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize384SIGNSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize384 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyECCSize521SIGNSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize384SIGNSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestSHA512, + HuksSignVerifyECC.HuksKeyECCSize521 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); }); } diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js index df3a4b8fcc4412a99e966000fc91e2033e277fdb..dfeeb95d852e06517df1ecee670915ad41b4b590 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js @@ -22,14 +22,14 @@ let srcData63Kb = stringToUint8Array(srcData63); export default function SecurityHuksRSABasicAbort63KBPromiseJsunit() { describe('SecurityHuksRSABasicAbort63KBPromiseJsunit', function () { it('testReformedSignVerifyRSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA512KeyAlias102'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData63Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js index 41f22f5dcd8829157a2b4f6042c77884e2c6bd2d..ee84b89f258fb07a9f531c5237e438af550d5187 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js @@ -23,14 +23,14 @@ let srcData65Kb = stringToUint8Array(srcData65); export default function SecurityHuksRSABasicAbort65KBPromiseJsunit() { describe('SecurityHuksRSABasicAbort65KBPromiseJsunit', function () { it('testReformedSignVerifyRSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA512KeyAlias104'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData65Kb, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js index 2135b17b8a63ab67c61a13feecc33a6497a99d62..d393825136e2b1fd5942eb0e2cad4148185f5d6a 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js @@ -23,14 +23,14 @@ let finishOutData; export default function SecurityHuksRSABasicFinish63KBPromiseJsunit() { describe('SecurityHuksRSABasicFinish63KBPromiseJsunit', function () { it('testReformedSignVerifyRSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA512KeyAlias101'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData63Kb, }; @@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish63KBPromiseJsunit', function () { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, - HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js index 5dec7b2f7a97b74376cadd6c2f78d7b1b0163978..2a4bd95832f8954033578e036d7b2f08a235231d 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js @@ -20,17 +20,21 @@ import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/p let srcData65 = Data.Data65b; let srcData65Kb = stringToUint8Array(srcData65); let finishOutData; +let srcData65KbSha256 = new Uint8Array([ + 0x23,0xF8,0x94,0xEA,0xEE,0x1C,0x70,0xA9,0x33,0x82,0x6C,0xCF,0xEF,0x2D,0x41,0x6F, + 0x64,0xF6,0x46,0xD4,0xCD,0xD4,0x5C,0x33,0x84,0x4D,0x53,0x4A,0x1D,0xF0,0xE7,0xDF +]); export default function SecurityHuksRSABasicFinish65KBPromiseJsunit() { describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { it('testReformedSignVerifyRSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103'; + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1MD5KeyAlias103'; let HuksOptions = { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 ), inData: srcData65Kb, }; @@ -42,7 +46,1155 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize512 + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1NONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1NONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1SHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1SHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1SHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1SHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPKCS1SHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1SHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSMD5103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSMD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSNONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize2048SIGNPSSSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPSSSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize2048 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1MD5103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1MD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1NONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1NONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1SHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1SHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1SHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1SHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1SHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1SHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1SHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1SHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPKCS1SHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPKCS1SHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSMD5103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSMD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSNONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize3072SIGNPSSSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize3072SIGNPSSSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize3072 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1MD5103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1MD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1NONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1NONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1SHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1SHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1SHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1SHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPKCS1SHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSMD5103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSMD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSNONE103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65KbSha256, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65KbSha256); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65KbSha256); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSSHA1103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA1, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSSHA224103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSSHA224KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA224, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSSHA256103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSSHA256KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSSHA384103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSSHA384KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA384, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: finishOutData, + }; + await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); + done(); + }); + + it('testSignVerifyRSASize4096SIGNPSSSHA512103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPSSSHA512KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 + ), + inData: srcData65Kb, + }; + finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPSS, + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: finishOutData, }; diff --git a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js index f73e981f9598264f97dfdfe4c3abfb68eb662a66..263ce1013e0548e8c5a7c2127cde78128ee82804 100644 --- a/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js +++ b/security/security_huks_reformed_test/huks_signverify_promise_BasicTest/src/main/js/test/SignVerify/SecurityHuksRSASignExtendJsunit.test.js @@ -197,7 +197,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSINGVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -207,7 +207,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -224,7 +224,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -249,7 +249,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSINGVERIFY, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -259,7 +259,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -276,7 +276,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -300,7 +300,7 @@ export default function SecurityHuksRSASignExtendJsunit() { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSINGVERIFY, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -310,7 +310,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -327,7 +327,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -353,7 +353,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSINGVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: inDataAfterSha512, } @@ -363,7 +363,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: inDataAfterSha512, } @@ -380,7 +380,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: signedResult, } @@ -406,7 +406,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -415,7 +415,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -438,7 +438,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -447,7 +447,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -470,7 +470,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestSHA256, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, }; @@ -478,7 +478,7 @@ export default function SecurityHuksRSASignExtendJsunit() { properties: new Array( HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: srcData64Kb, } @@ -501,7 +501,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: inDataAfterSha512, }; @@ -511,7 +511,7 @@ export default function SecurityHuksRSASignExtendJsunit() { HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, HuksSignVerifyRSA.HuksTagPKCS1DigestNONE, HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerifyRSA.HuksKeyRSASize1024 + HuksSignVerifyRSA.HuksKeyRSASize4096 ), inData: inDataString, } diff --git a/security/security_huks_reformed_test/utils/param/agree/publicAgreePromise.js b/security/security_huks_reformed_test/utils/param/agree/publicAgreePromise.js index 24689395fe5896e9301cc375bb264bddf972ca92..1d17c5ed0ae3426e7561c321eb43b1093f84bd44 100644 --- a/security/security_huks_reformed_test/utils/param/agree/publicAgreePromise.js +++ b/security/security_huks_reformed_test/utils/param/agree/publicAgreePromise.js @@ -142,6 +142,7 @@ async function publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName) async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { console.info(`enter promise deleteKeyItem`); + console.info(`promise: deleteKeyItem now, data = ${srcKeyAlies}`); try { await huks.deleteKeyItem(srcKeyAlies, HuksOptions) .then((data) => { diff --git a/security/security_huks_reformed_test/utils/param/cipher/publicCipherParam.js b/security/security_huks_reformed_test/utils/param/cipher/publicCipherParam.js index 34602e543c03c61301b860a106ff4146d4b9a329..d517d095b6c1264bdc3f8b49c6e59c02c6ab8e04 100644 --- a/security/security_huks_reformed_test/utils/param/cipher/publicCipherParam.js +++ b/security/security_huks_reformed_test/utils/param/cipher/publicCipherParam.js @@ -14,6 +14,7 @@ */ import * as param from '../publicParam'; +import huks from '@ohos.security.huks'; let HuksCipherAES = { HuksKeyAlgAES: { @@ -72,6 +73,10 @@ let HuksCipherAES = { tag: param.HksTag.HKS_TAG_DIGEST, value: param.HksKeyDigest.HKS_DIGEST_NONE, }, + HuksKeyAESBLOCKMODEGCM: { + tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, + value: huks.HuksCipherMode.HUKS_MODE_GCM, + }, }; let HuksCipherRSA = { @@ -95,6 +100,18 @@ let HuksCipherRSA = { tag: param.HksTag.HKS_TAG_KEY_SIZE, value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, }, + HuksKeyRSASize2048: { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, + }, + HuksKeyRSASize3072: { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_3072, + }, + HuksKeyRSASize4096: { + tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, + value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_4096, + }, HuksKeyRSAPADDINGNONE: { tag: param.HksTag.HKS_TAG_PADDING, value: param.HksKeyPadding.HKS_PADDING_NONE, diff --git a/security/security_huks_reformed_test/utils/param/derive/publicDeriveParam.js b/security/security_huks_reformed_test/utils/param/derive/publicDeriveParam.js index db82b4c41c08607b421bcb03f46dde70b1d13045..543c77c056bf6d843e851da6af0291358cb63444 100644 --- a/security/security_huks_reformed_test/utils/param/derive/publicDeriveParam.js +++ b/security/security_huks_reformed_test/utils/param/derive/publicDeriveParam.js @@ -13,6 +13,11 @@ * limitations under the License. */ import * as param from '../publicParam'; +import huks from '@ohos.security.huks'; + +let salt = new Uint8Array([ + 0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff +]); let HuksDeriveHKDF = { HuksKeySIZE: { @@ -286,6 +291,14 @@ let HuksDerivePBKDF2 = { tag: param.HksTag.HKS_TAG_BLOCK_MODE, value: param.HksCipherMode.HKS_MODE_GCM, }, + HuksKeyPBKDF2Iteration: { + tag: huks.HuksTag.HUKS_TAG_ITERATION, + value: 1000 + }, + HuksKeyPBKDF2Salt: { + tag: huks.HuksTag.HUKS_TAG_SALT, + value: salt + }, }; export { HuksDeriveHKDF, HuksDerivePBKDF2 }; diff --git a/security/security_huks_reformed_test/utils/param/publicFunc.js b/security/security_huks_reformed_test/utils/param/publicFunc.js index 92dbde35212d38a3a64addddf16f24b43ad84cb3..8ba2411e1611050fd684070a91635f5cda698289 100644 --- a/security/security_huks_reformed_test/utils/param/publicFunc.js +++ b/security/security_huks_reformed_test/utils/param/publicFunc.js @@ -12,27 +12,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import huks from '@ohos.security.huks'; +import { HuksSignVerifyDSA } from "./signverify/publicSignverifyParam"; +import Data from "../data.json"; +let srcData65 = Data.Data65b; + function stringToArray(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } return arr; } function uint8ArrayToString(fileData) { - var dataString = ''; - for (var i = 0; i < fileData.length; i++) { + let dataString = ''; + for (let i = 0; i < fileData.length; i++) { dataString += String.fromCharCode(fileData[i]); } return dataString; } function stringToUint8Array(str) { - var arr = []; - for (var i = 0, j = str.length; i < j; ++i) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { arr.push(str.charCodeAt(i)); } - var tmpUint8Array = new Uint8Array(arr); + let tmpUint8Array = new Uint8Array(arr); return tmpUint8Array; } function arrayEqual(a, b) { @@ -53,4 +58,29 @@ function arrayEqual(a, b) { return true; } -export { stringToArray, uint8ArrayToString, stringToUint8Array, arrayEqual }; +async function checkSoftware() { + let dsaAlies = "useDsaToCheckSoftware"; + let dsaOption = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY, + HuksSignVerifyDSA.HuksKeySIZE1024, + HuksSignVerifyDSA.HuksTagDSADigestSHA256 + ) + }; + try { + let res = await huks.generateKeyItem(dsaAlies, dsaOption); + if (res == null) { + await huks.deleteKeyItem(dsaAlies, dsaOption); + console.error("This device uses software"); + return true; + } else { + console.error("This device does not use software"); + return false; + } + } catch (e) { + return false; + } +} + +export { stringToArray, uint8ArrayToString, stringToUint8Array, arrayEqual, checkSoftware }; diff --git a/security/security_huks_reformed_test/utils/param/signverify/publicSignverifyParam.js b/security/security_huks_reformed_test/utils/param/signverify/publicSignverifyParam.js index 17d1f84a53b66e8b825a854e548674ae45093886..e3332db6701b5cc56eae9ad167af5d92ac2a6ac7 100644 --- a/security/security_huks_reformed_test/utils/param/signverify/publicSignverifyParam.js +++ b/security/security_huks_reformed_test/utils/param/signverify/publicSignverifyParam.js @@ -13,6 +13,7 @@ * limitations under the License. */ import * as param from '../publicParam'; +import huks from '@ohos.security.huks'; let DSA_COMMON_SIZE = 1024; let HuksSignVerifyDSA = { HuksTagDSACOMMONSIZE: {