提交 3fbfac3c 编写于 作者: 伞木希美
上级 b0dab9bc
...@@ -92,6 +92,7 @@ extern "C" ...@@ -92,6 +92,7 @@ extern "C"
const struct OH_Huks_Blob *keyAlias, const struct OH_Huks_Blob *keyAlias,
const struct OH_Huks_Blob *peerPublicKey, const struct OH_Huks_Blob *peerPublicKey,
struct OH_Huks_Blob *agreedKey); struct OH_Huks_Blob *agreedKey);
bool checkUseSoftware();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -23,6 +23,7 @@ namespace Unittest::AttestKey { ...@@ -23,6 +23,7 @@ namespace Unittest::AttestKey {
static struct OH_Huks_Blob g_secInfo = { sizeof(SEC_INFO_DATA), (uint8_t *)SEC_INFO_DATA }; static struct OH_Huks_Blob g_secInfo = { sizeof(SEC_INFO_DATA), (uint8_t *)SEC_INFO_DATA };
static struct OH_Huks_Blob g_challenge = { sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA }; static struct OH_Huks_Blob g_challenge = { sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA };
static struct OH_Huks_Blob g_version = { sizeof(VERSION_DATA), (uint8_t *)VERSION_DATA }; static struct OH_Huks_Blob g_version = { sizeof(VERSION_DATA), (uint8_t *)VERSION_DATA };
bool useSoftware = true;
class HuksAttestKeyNoIdsTest : public testing::Test { class HuksAttestKeyNoIdsTest : public testing::Test {
public: public:
...@@ -37,6 +38,7 @@ public: ...@@ -37,6 +38,7 @@ public:
void HuksAttestKeyNoIdsTest::SetUpTestCase(void) void HuksAttestKeyNoIdsTest::SetUpTestCase(void)
{ {
useSoftware = checkUseSoftware();
} }
void HuksAttestKeyNoIdsTest::TearDownTestCase(void) void HuksAttestKeyNoIdsTest::TearDownTestCase(void)
...@@ -68,6 +70,8 @@ static const struct OH_Huks_Param g_commonParams[] = { ...@@ -68,6 +70,8 @@ static const struct OH_Huks_Param g_commonParams[] = {
*/ */
HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0) HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0)
{ {
if (useSoftware)
{
OH_Huks_Result ret = TestGenerateKey(&g_keyAlias); OH_Huks_Result ret = TestGenerateKey(&g_keyAlias);
ASSERT_TRUE(ret.errorCode == (int32_t)OH_HUKS_SUCCESS); ASSERT_TRUE(ret.errorCode == (int32_t)OH_HUKS_SUCCESS);
struct OH_Huks_ParamSet *paramSet = NULL; struct OH_Huks_ParamSet *paramSet = NULL;
...@@ -86,5 +90,7 @@ HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0 ...@@ -86,5 +90,7 @@ HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0
OH_Huks_Result ret1 = OH_Huks_DeleteKeyItem(&g_keyAlias, NULL); OH_Huks_Result ret1 = OH_Huks_DeleteKeyItem(&g_keyAlias, NULL);
ASSERT_TRUE(ret1.errorCode == (int32_t)OH_HUKS_SUCCESS); ASSERT_TRUE(ret1.errorCode == (int32_t)OH_HUKS_SUCCESS);
}
ASSERT_TRUE(0 == 0);
} }
} }
...@@ -48,7 +48,6 @@ void HuksDerivePBKDFTest::TearDown() ...@@ -48,7 +48,6 @@ void HuksDerivePBKDFTest::TearDown()
{ {
} }
uint8_t g_saltdata1[16] = {0};
uint8_t g_saltgen[16] = { uint8_t g_saltgen[16] = {
0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff 0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff
}; };
...@@ -96,8 +95,8 @@ static struct OH_Huks_Param g_pbkdf2Params001[] = { ...@@ -96,8 +95,8 @@ static struct OH_Huks_Param g_pbkdf2Params001[] = {
}, { }, {
.tag = OH_HUKS_TAG_SALT, .tag = OH_HUKS_TAG_SALT,
.blob = { .blob = {
sizeof(g_saltdata1), sizeof(g_saltgen),
(uint8_t *)g_saltdata1 (uint8_t *)g_saltgen
} }
}, { }, {
.tag = OH_HUKS_TAG_DERIVE_KEY_SIZE, .tag = OH_HUKS_TAG_DERIVE_KEY_SIZE,
...@@ -148,10 +147,6 @@ HWTEST_F(HuksDerivePBKDFTest, Security_HUKS_NAPI_Derive_pbkdf_0100, TestSize.Lev ...@@ -148,10 +147,6 @@ HWTEST_F(HuksDerivePBKDFTest, Security_HUKS_NAPI_Derive_pbkdf_0100, TestSize.Lev
struct OH_Huks_ParamSet *pbkdf2FinishParamSet = nullptr; struct OH_Huks_ParamSet *pbkdf2FinishParamSet = nullptr;
ret = InitParamSet(&pbkdf2ParamSet, g_pbkdf2Params001, sizeof(g_pbkdf2Params001) / sizeof(OH_Huks_Param)); ret = InitParamSet(&pbkdf2ParamSet, g_pbkdf2Params001, sizeof(g_pbkdf2Params001) / sizeof(OH_Huks_Param));
EXPECT_EQ(ret.errorCode, (int32_t)OH_HUKS_SUCCESS) << "InitParamSet failed."; EXPECT_EQ(ret.errorCode, (int32_t)OH_HUKS_SUCCESS) << "InitParamSet failed.";
struct OH_Huks_Param *saltParam = nullptr;
OH_Huks_GetParam(pbkdf2ParamSet, OH_HUKS_TAG_SALT, &saltParam);
int32_t ret1 = HksGenerateRandom(NULL, (struct HksBlob *)&(saltParam->blob));
EXPECT_EQ(ret1, (int32_t)OH_HUKS_SUCCESS) << "GenerateRandom failed.";
// Finish paramset // Finish paramset
ret = InitParamSet(&pbkdf2FinishParamSet, g_pbkdf2FinishParams001, ret = InitParamSet(&pbkdf2FinishParamSet, g_pbkdf2FinishParams001,
sizeof(g_pbkdf2FinishParams001) / sizeof(OH_Huks_Param)); sizeof(g_pbkdf2FinishParams001) / sizeof(OH_Huks_Param));
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
using namespace testing::ext; using namespace testing::ext;
namespace Unittest::DsaSignVerify { namespace Unittest::DsaSignVerify {
bool useSoftware = true;
class HuksSignVerifyDSATest : public testing::Test { class HuksSignVerifyDSATest : public testing::Test {
public: public:
static void SetUpTestCase(void); static void SetUpTestCase(void);
...@@ -32,6 +33,7 @@ public: ...@@ -32,6 +33,7 @@ public:
void HuksSignVerifyDSATest::SetUpTestCase(void) void HuksSignVerifyDSATest::SetUpTestCase(void)
{ {
useSoftware = checkUseSoftware();
} }
void HuksSignVerifyDSATest::TearDownTestCase(void) void HuksSignVerifyDSATest::TearDownTestCase(void)
...@@ -163,6 +165,8 @@ OH_Huks_Result HksDsaSignVerifyTestNormalCase(struct OH_Huks_Blob keyAlias, stru ...@@ -163,6 +165,8 @@ OH_Huks_Result HksDsaSignVerifyTestNormalCase(struct OH_Huks_Blob keyAlias, stru
*/ */
HWTEST_F(HuksSignVerifyDSATest, Security_HUKS_NAPI_SignVerify_DSA_0100, TestSize.Level0) HWTEST_F(HuksSignVerifyDSATest, Security_HUKS_NAPI_SignVerify_DSA_0100, TestSize.Level0)
{ {
if (useSoftware)
{
const char *keyAliasString = "HksDSASignVerifyKeyAliasTest001"; const char *keyAliasString = "HksDSASignVerifyKeyAliasTest001";
struct OH_Huks_ParamSet *genParamSet = nullptr; struct OH_Huks_ParamSet *genParamSet = nullptr;
struct OH_Huks_ParamSet *signParamSet = nullptr; struct OH_Huks_ParamSet *signParamSet = nullptr;
...@@ -186,5 +190,7 @@ HWTEST_F(HuksSignVerifyDSATest, Security_HUKS_NAPI_SignVerify_DSA_0100, TestSize ...@@ -186,5 +190,7 @@ HWTEST_F(HuksSignVerifyDSATest, Security_HUKS_NAPI_SignVerify_DSA_0100, TestSize
OH_Huks_FreeParamSet(&genParamSet); OH_Huks_FreeParamSet(&genParamSet);
OH_Huks_FreeParamSet(&signParamSet); OH_Huks_FreeParamSet(&signParamSet);
OH_Huks_FreeParamSet(&verifyParamSet); OH_Huks_FreeParamSet(&verifyParamSet);
}
ASSERT_TRUE(0 == 0);
} }
} // namespace Unittest::DsaSignVerify } // namespace Unittest::DsaSignVerify
\ No newline at end of file
...@@ -15,6 +15,17 @@ ...@@ -15,6 +15,17 @@
#include "huks_three_stage_test_common.h" #include "huks_three_stage_test_common.h"
static struct OH_Huks_Param g_genParamsTest001[] = {
{.tag = OH_HUKS_TAG_ALGORITHM,
.uint32Param = OH_HUKS_ALG_DSA},
{.tag = OH_HUKS_TAG_PURPOSE,
.uint32Param = OH_HUKS_KEY_PURPOSE_SIGN | OH_HUKS_KEY_PURPOSE_VERIFY},
{.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = 1024},
{.tag = OH_HUKS_TAG_DIGEST,
.uint32Param = OH_HUKS_DIGEST_SHA1}
};
OH_Huks_Result InitParamSet( OH_Huks_Result InitParamSet(
struct OH_Huks_ParamSet **paramSet, struct OH_Huks_ParamSet **paramSet,
const struct OH_Huks_Param *params, const struct OH_Huks_Param *params,
...@@ -681,3 +692,18 @@ OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struc ...@@ -681,3 +692,18 @@ OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struc
} }
return ret; return ret;
} }
bool checkUseSoftware()
{
const char *keyAliasString = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
struct OH_Huks_ParamSet *genParamSet = nullptr;
struct OH_Huks_Blob keyAlias = {strlen(keyAliasString), (uint8_t *)keyAliasString};
InitParamSet(&genParamSet, g_genParamsTest001, sizeof(g_genParamsTest001) / sizeof(OH_Huks_Param));
OH_Huks_Result ret = OH_Huks_GenerateKeyItem(&keyAlias, genParamSet, nullptr);
if(ret.errorCode == 0){
OH_Huks_DeleteKeyItem(&keyAlias, genParamSet);
OH_Huks_FreeParamSet(&genParamSet);
return true;
}
return false;
}
\ No newline at end of file
...@@ -788,6 +788,7 @@ export function SecurityHuksImportJsunit() { ...@@ -788,6 +788,7 @@ export function SecurityHuksImportJsunit() {
it('HUKS_Basic_Capability_Import_2000', 0, async function (done) { it('HUKS_Basic_Capability_Import_2000', 0, async function (done) {
const srcKeyAlies = 'HUKS_Basic_Capability_Import_2000'; const srcKeyAlies = 'HUKS_Basic_Capability_Import_2000';
if (useSoftware) {
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC, HuksAgreeECDH.HuksKeyAlgECC,
...@@ -802,6 +803,7 @@ export function SecurityHuksImportJsunit() { ...@@ -802,6 +803,7 @@ export function SecurityHuksImportJsunit() {
}; };
await publicImportKey(srcKeyAlies, HuksOptions); await publicImportKey(srcKeyAlies, HuksOptions);
await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); await publicDeleteKeyFunc(srcKeyAlies, HuksOptions);
}
done(); done();
}); });
......
...@@ -1098,6 +1098,7 @@ export function SecurityHuksImportJsunit() { ...@@ -1098,6 +1098,7 @@ export function SecurityHuksImportJsunit() {
it('HUKS_Basic_Capability_Import_Reformed_0300', 0, async function (done) { it('HUKS_Basic_Capability_Import_Reformed_0300', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200'; const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false); await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true); await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
...@@ -1110,11 +1111,13 @@ export function SecurityHuksImportJsunit() { ...@@ -1110,11 +1111,13 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams); await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params); await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done(); done();
}); });
it('HUKS_Basic_Capability_Import_Reformed_0400', 0, async function (done) { it('HUKS_Basic_Capability_Import_Reformed_0400', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0400'; const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0400';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParamsX25519, false); await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParamsX25519, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerX25519Params, true); await generateAndExportPublicKey(callerKeyAlias, genCallerX25519Params, true);
...@@ -1127,6 +1130,7 @@ export function SecurityHuksImportJsunit() { ...@@ -1127,6 +1130,7 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerX25519Params); await publicDeleteKeyItemFunc(callerKeyAlias, genCallerX25519Params);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192ParamsX25519); await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192ParamsX25519);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done(); done();
}); });
...@@ -1556,6 +1560,7 @@ export function SecurityHuksImportJsunit() { ...@@ -1556,6 +1560,7 @@ export function SecurityHuksImportJsunit() {
it('HUKS_Basic_Capability_Import_Reformed_2600', 0, async function (done) { it('HUKS_Basic_Capability_Import_Reformed_2600', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200'; const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false); await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true); await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
...@@ -1569,11 +1574,13 @@ export function SecurityHuksImportJsunit() { ...@@ -1569,11 +1574,13 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams); await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params); await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams); await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done(); done();
}); });
it('HUKS_Basic_Capability_Import_Reformed_2700', 0, async function (done) { it('HUKS_Basic_Capability_Import_Reformed_2700', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_2700'; const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_2700';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false); await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true); await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
await ImportKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey, callerAgreeParams); await ImportKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey, callerAgreeParams);
...@@ -1595,6 +1602,7 @@ export function SecurityHuksImportJsunit() { ...@@ -1595,6 +1602,7 @@ export function SecurityHuksImportJsunit() {
} }
await publicDeleteKeyItemFunc(srcKeyAliesWrap, genWrappingKeyParams); await publicDeleteKeyItemFunc(srcKeyAliesWrap, genWrappingKeyParams);
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams); await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
}
done(); done();
}); });
......
...@@ -23,7 +23,7 @@ let useSoftware = true; ...@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() { export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () { describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA002', 0, async function (done) { it('testReformedSignVerifyDSA002', 0, async function (done) {
......
...@@ -24,7 +24,7 @@ let useSoftware = true; ...@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() { export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () { describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA004', 0, async function (done) { it('testReformedSignVerifyDSA004', 0, async function (done) {
......
...@@ -24,7 +24,7 @@ let useSoftware = true; ...@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() { export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () { describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA001', 0, async function (done) { it('testReformedSignVerifyDSA001', 0, async function (done) {
......
...@@ -24,7 +24,7 @@ let useSoftware = true; ...@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() { export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () { describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA003', 0, async function (done) { it('testReformedSignVerifyDSA003', 0, async function (done) {
......
...@@ -23,7 +23,7 @@ let useSoftware = true; ...@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() { export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () { describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA102', 0, async function (done) { it('testReformedSignVerifyDSA102', 0, async function (done) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import { describe, it, beforeAll } from '@ohos/hypium'; import { describe, it, beforeAll } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json'; import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array,checkSoftware } from '../../../../../../utils/param/publicFunc'; import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData65 = Data.Data65b; let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65); let srcData65Kb = stringToUint8Array(srcData65);
...@@ -23,7 +23,7 @@ let useSoftware = true; ...@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() { export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () { describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA104', 0, async function (done) { it('testReformedSignVerifyDSA104', 0, async function (done) {
......
...@@ -24,7 +24,7 @@ let useSoftware = true; ...@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish63KBPromiseJsunit() { export default function SecurityHuksDSABasicFinish63KBPromiseJsunit() {
describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () { describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA101', 0, async function (done) { it('testReformedSignVerifyDSA101', 0, async function (done) {
......
...@@ -24,7 +24,7 @@ let useSoftware = true; ...@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish65KBPromiseJsunit() { export default function SecurityHuksDSABasicFinish65KBPromiseJsunit() {
describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () { describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
useSoftware = checkSoftware(); useSoftware = await checkSoftware();
done(); done();
}) })
it('testReformedSignVerifyDSA103', 0, async function (done) { it('testReformedSignVerifyDSA103', 0, async function (done) {
......
...@@ -12,20 +12,25 @@ ...@@ -12,20 +12,25 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, it } from '@ohos/hypium'; import { describe, it, beforeAll } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json'; import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyECC } from '../../../../../../utils/param/signverify/publicSignverifyParam'; import { HuksSignVerifyECC } 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'; import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData65 = Data.Data65b; let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65); let srcData65Kb = stringToUint8Array(srcData65);
let finishOutData; let finishOutData;
let useSoftware = true;
const srcData65Sha256 = new Uint8Array([ const srcData65Sha256 = new Uint8Array([
0x23, 0xF8, 0x94, 0xEA, 0xEE, 0x1C, 0x70, 0xA9, 0x33, 0x82, 0x6C, 0xCF, 0xEF, 0x2D, 0x41, 0x6F, 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, 0x64, 0xF6, 0x46, 0xD4, 0xCD, 0xD4, 0x5C, 0x33, 0x84, 0x4D, 0x53, 0x4A, 0x1D, 0xF0, 0xE7, 0xDF,
]); ]);
export default function SecurityHuksECCBasicFinish65KBPromiseJsunit() { export default function SecurityHuksECCBasicFinish65KBPromiseJsunit() {
describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyECC103', 0, async function (done) { it('testReformedSignVerifyECC103', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias103'; const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias103';
let HuksOptions = { let HuksOptions = {
...@@ -112,6 +117,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -112,6 +117,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -123,6 +129,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -123,6 +129,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -137,6 +144,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -137,6 +144,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -148,6 +156,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -148,6 +156,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -162,6 +171,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -162,6 +171,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -173,6 +183,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -173,6 +183,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -187,6 +198,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -187,6 +198,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -198,6 +210,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -198,6 +210,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -212,6 +225,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -212,6 +225,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -223,6 +237,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -223,6 +237,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -237,6 +252,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -237,6 +252,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
...@@ -248,6 +264,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -248,6 +264,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -475,5 +492,5 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () { ...@@ -475,5 +492,5 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
done(); done();
}); });
}); });
} }
...@@ -20,12 +20,17 @@ import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/p ...@@ -20,12 +20,17 @@ import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/p
let srcData65 = Data.Data65b; let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65); let srcData65Kb = stringToUint8Array(srcData65);
let finishOutData; let finishOutData;
let useSoftware = true;
let srcData65KbSha256 = new Uint8Array([ let srcData65KbSha256 = new Uint8Array([
0x23,0xF8,0x94,0xEA,0xEE,0x1C,0x70,0xA9,0x33,0x82,0x6C,0xCF,0xEF,0x2D,0x41,0x6F, 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 0x64, 0xF6, 0x46, 0xD4, 0xCD, 0xD4, 0x5C, 0x33, 0x84, 0x4D, 0x53, 0x4A, 0x1D, 0xF0, 0xE7, 0xDF
]); ]);
export default function SecurityHuksRSABasicFinish65KBPromiseJsunit() { export default function SecurityHuksRSABasicFinish65KBPromiseJsunit() {
describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyRSA103', 0, async function (done) { it('testReformedSignVerifyRSA103', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1MD5KeyAlias103'; const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1MD5KeyAlias103';
let HuksOptions = { let HuksOptions = {
...@@ -38,8 +43,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -38,8 +43,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -51,6 +56,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -51,6 +56,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -94,8 +100,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -94,8 +100,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -107,6 +113,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -107,6 +113,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -122,8 +129,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -122,8 +129,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -135,6 +142,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -135,6 +142,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -234,8 +242,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -234,8 +242,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -247,6 +255,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -247,6 +255,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -290,8 +299,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -290,8 +299,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -303,6 +312,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -303,6 +312,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -318,8 +328,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -318,8 +328,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -331,6 +341,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -331,6 +341,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -430,8 +441,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -430,8 +441,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -443,6 +454,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -443,6 +454,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -486,8 +498,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -486,8 +498,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -499,6 +511,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -499,6 +511,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -514,8 +527,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -514,8 +527,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -527,6 +540,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -527,6 +540,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -626,8 +640,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -626,8 +640,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -639,6 +653,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -639,6 +653,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -682,8 +697,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -682,8 +697,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -695,6 +710,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -695,6 +710,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -710,8 +726,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -710,8 +726,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -723,6 +739,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -723,6 +739,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -822,8 +839,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -822,8 +839,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -835,6 +852,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -835,6 +852,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -878,8 +896,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -878,8 +896,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -891,6 +909,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -891,6 +909,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -906,8 +925,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -906,8 +925,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -919,6 +938,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -919,6 +938,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -1018,8 +1038,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1018,8 +1038,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -1031,6 +1051,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1031,6 +1051,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -1074,8 +1095,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1074,8 +1095,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -1087,6 +1108,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1087,6 +1108,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -1102,8 +1124,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1102,8 +1124,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb); finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = { HuksOptions = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -1115,6 +1137,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1115,6 +1137,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData, inData: finishOutData,
}; };
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done(); done();
}); });
...@@ -1201,5 +1224,5 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () { ...@@ -1201,5 +1224,5 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb); await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
done(); done();
}); });
}); });
} }
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
import huks from "@ohos.security.huks"; import huks from "@ohos.security.huks";
import { describe, it, expect } from "@ohos/hypium"; import { describe, it, expect, beforeAll } from "@ohos/hypium";
import Data from '../../../../../../utils/data.json'; import Data from '../../../../../../utils/data.json';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc'; import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { HuksSignVerifyRSA } from '../../../../../../utils/param/signverify/publicSignverifyParam'; import { HuksSignVerifyRSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
let inDataString = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000" + let inDataString = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000" +
...@@ -29,6 +29,7 @@ let srcData64 = Data.Data64b; ...@@ -29,6 +29,7 @@ let srcData64 = Data.Data64b;
let srcData64Kb = stringToUint8Array(srcData64); let srcData64Kb = stringToUint8Array(srcData64);
let signedResult; let signedResult;
let handle; let handle;
let useSoftware = true;
async function publicGenerateKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) { async function publicGenerateKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) {
console.error(`enter promise generateKeyItem`); console.error(`enter promise generateKeyItem`);
...@@ -127,7 +128,7 @@ async function publicUpdateSessionFunction(HuksOptions) { ...@@ -127,7 +128,7 @@ async function publicUpdateSessionFunction(HuksOptions) {
} }
} }
async function publicUpdateError(HuksOptions, errCode){ async function publicUpdateError(HuksOptions, errCode) {
console.error(`enter promise doUpdate`); console.error(`enter promise doUpdate`);
try { try {
await huks.updateSession(handle, HuksOptions) await huks.updateSession(handle, HuksOptions)
...@@ -184,7 +185,10 @@ async function publicDeleteKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) { ...@@ -184,7 +185,10 @@ async function publicDeleteKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) {
export default function SecurityHuksRSASignExtendJsunit() { export default function SecurityHuksRSASignExtendJsunit() {
describe('SecurityHuksRSASignExtendJsunit', function () { describe('SecurityHuksRSASignExtendJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
/** /**
* @tc.number Security_HUKS_RSA_SignExtend_0100 * @tc.number Security_HUKS_RSA_SignExtend_0100
* @tc.name No Padding and Sign Verify with RSA. * @tc.name No Padding and Sign Verify with RSA.
...@@ -192,6 +196,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -192,6 +196,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/ */
it("Security_HUKS_RSA_SignExtend_0100", 0, async function (done) { it("Security_HUKS_RSA_SignExtend_0100", 0, async function (done) {
let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0100_Gen"; let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0100_Gen";
if (useSoftware) {
let HuksOptionsGen = { let HuksOptionsGen = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -234,6 +239,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -234,6 +239,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult; HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify); await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen); await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done(); done();
}) })
...@@ -244,6 +250,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -244,6 +250,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/ */
it("Security_HUKS_RSA_SignExtend_0200", 0, async function (done) { it("Security_HUKS_RSA_SignExtend_0200", 0, async function (done) {
let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0200"; let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0200";
if (useSoftware) {
let HuksOptionsGen = { let HuksOptionsGen = {
properties: new Array( properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA, HuksSignVerifyRSA.HuksKeyAlgRSA,
...@@ -286,6 +293,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -286,6 +293,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult; HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify); await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen); await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done(); done();
}) })
...@@ -314,6 +322,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -314,6 +322,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
), ),
inData: srcData64Kb, inData: srcData64Kb,
} }
if (useSoftware) {
await publicGenerateKeyFunc(srcKeyAliesGen, HuksOptionsGen); await publicGenerateKeyFunc(srcKeyAliesGen, HuksOptionsGen);
await publicInitFunc(srcKeyAliesGen, HuksOptionsSign); await publicInitFunc(srcKeyAliesGen, HuksOptionsSign);
HuksOptionsSign.inData = srcData64Kb; HuksOptionsSign.inData = srcData64Kb;
...@@ -337,6 +346,7 @@ export default function SecurityHuksRSASignExtendJsunit() { ...@@ -337,6 +346,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult; HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify); await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen); await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册