未验证 提交 e29fa0a0 编写于 作者: O openharmony_ci 提交者: Gitee

!8007 适配必选算法2monthlyy

Merge pull request !8007 from 伞木希美/cherry-pick-1678892665
......@@ -92,6 +92,7 @@ extern "C"
const struct OH_Huks_Blob *keyAlias,
const struct OH_Huks_Blob *peerPublicKey,
struct OH_Huks_Blob *agreedKey);
bool checkUseSoftware();
#ifdef __cplusplus
}
#endif
......
......@@ -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_challenge = { sizeof(CHALLENGE_DATA), (uint8_t *)CHALLENGE_DATA };
static struct OH_Huks_Blob g_version = { sizeof(VERSION_DATA), (uint8_t *)VERSION_DATA };
bool useSoftware = true;
class HuksAttestKeyNoIdsTest : public testing::Test {
public:
......@@ -37,6 +38,7 @@ public:
void HuksAttestKeyNoIdsTest::SetUpTestCase(void)
{
useSoftware = checkUseSoftware();
}
void HuksAttestKeyNoIdsTest::TearDownTestCase(void)
......@@ -68,6 +70,8 @@ static const struct OH_Huks_Param g_commonParams[] = {
*/
HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0)
{
if (useSoftware)
{
OH_Huks_Result ret = TestGenerateKey(&g_keyAlias);
ASSERT_TRUE(ret.errorCode == (int32_t)OH_HUKS_SUCCESS);
struct OH_Huks_ParamSet *paramSet = NULL;
......@@ -86,5 +90,7 @@ HWTEST_F(HuksAttestKeyNoIdsTest, Security_HUKS_NAPI_Attest_0100, TestSize.Level0
OH_Huks_Result ret1 = OH_Huks_DeleteKeyItem(&g_keyAlias, NULL);
ASSERT_TRUE(ret1.errorCode == (int32_t)OH_HUKS_SUCCESS);
}
ASSERT_TRUE(0 == 0);
}
}
......@@ -48,7 +48,6 @@ 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
};
......@@ -96,8 +95,8 @@ static struct OH_Huks_Param g_pbkdf2Params001[] = {
}, {
.tag = OH_HUKS_TAG_SALT,
.blob = {
sizeof(g_saltdata1),
(uint8_t *)g_saltdata1
sizeof(g_saltgen),
(uint8_t *)g_saltgen
}
}, {
.tag = OH_HUKS_TAG_DERIVE_KEY_SIZE,
......@@ -148,10 +147,6 @@ HWTEST_F(HuksDerivePBKDFTest, Security_HUKS_NAPI_Derive_pbkdf_0100, TestSize.Lev
struct OH_Huks_ParamSet *pbkdf2FinishParamSet = nullptr;
ret = InitParamSet(&pbkdf2ParamSet, g_pbkdf2Params001, sizeof(g_pbkdf2Params001) / sizeof(OH_Huks_Param));
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
ret = InitParamSet(&pbkdf2FinishParamSet, g_pbkdf2FinishParams001,
sizeof(g_pbkdf2FinishParams001) / sizeof(OH_Huks_Param));
......
......@@ -19,6 +19,7 @@
using namespace testing::ext;
namespace Unittest::DsaSignVerify {
bool useSoftware = true;
class HuksSignVerifyDSATest : public testing::Test {
public:
static void SetUpTestCase(void);
......@@ -32,6 +33,7 @@ public:
void HuksSignVerifyDSATest::SetUpTestCase(void)
{
useSoftware = checkUseSoftware();
}
void HuksSignVerifyDSATest::TearDownTestCase(void)
......@@ -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)
{
if (useSoftware)
{
const char *keyAliasString = "HksDSASignVerifyKeyAliasTest001";
struct OH_Huks_ParamSet *genParamSet = nullptr;
struct OH_Huks_ParamSet *signParamSet = nullptr;
......@@ -186,5 +190,7 @@ HWTEST_F(HuksSignVerifyDSATest, Security_HUKS_NAPI_SignVerify_DSA_0100, TestSize
OH_Huks_FreeParamSet(&genParamSet);
OH_Huks_FreeParamSet(&signParamSet);
OH_Huks_FreeParamSet(&verifyParamSet);
}
ASSERT_TRUE(0 == 0);
}
} // namespace Unittest::DsaSignVerify
\ No newline at end of file
......@@ -15,6 +15,17 @@
#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(
struct OH_Huks_ParamSet **paramSet,
const struct OH_Huks_Param *params,
......@@ -681,3 +692,18 @@ OH_Huks_Result HuksAgreeKey(const struct OH_Huks_ParamSet *paramSet, const struc
}
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() {
it('HUKS_Basic_Capability_Import_2000', 0, async function (done) {
const srcKeyAlies = 'HUKS_Basic_Capability_Import_2000';
if (useSoftware) {
let HuksOptions = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
......@@ -802,6 +803,7 @@ export function SecurityHuksImportJsunit() {
};
await publicImportKey(srcKeyAlies, HuksOptions);
await publicDeleteKeyFunc(srcKeyAlies, HuksOptions);
}
done();
});
......
......@@ -1098,6 +1098,7 @@ export function SecurityHuksImportJsunit() {
it('HUKS_Basic_Capability_Import_Reformed_0300', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
......@@ -1110,11 +1111,13 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done();
});
it('HUKS_Basic_Capability_Import_Reformed_0400', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0400';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParamsX25519, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerX25519Params, true);
......@@ -1127,6 +1130,7 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerX25519Params);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192ParamsX25519);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done();
});
......@@ -1556,6 +1560,7 @@ export function SecurityHuksImportJsunit() {
it('HUKS_Basic_Capability_Import_Reformed_2600', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_0200';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
......@@ -1569,11 +1574,13 @@ export function SecurityHuksImportJsunit() {
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
await publicDeleteKeyItemFunc(importedKeyAliasAes192, importWrappedAes192Params);
await publicDeleteKeyItemFunc(callerKekAliasAes256, callerAgreeParams);
}
done();
});
it('HUKS_Basic_Capability_Import_Reformed_2700', 0, async function (done) {
const srcKeyAliesWrap = 'HUKS_Basic_Capability_Import_2700';
if (useSoftware) {
await generateAndExportPublicKey(srcKeyAliesWrap, genWrappingKeyParams, false);
await generateAndExportPublicKey(callerKeyAlias, genCallerEcdhParams, true);
await ImportKekAndAgreeSharedSecret(callerKekAliasAes256, importParamsCallerKek, callerKeyAlias, huksPubKey, callerAgreeParams);
......@@ -1595,6 +1602,7 @@ export function SecurityHuksImportJsunit() {
}
await publicDeleteKeyItemFunc(srcKeyAliesWrap, genWrappingKeyParams);
await publicDeleteKeyItemFunc(callerKeyAlias, genCallerEcdhParams);
}
done();
});
......
......@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA002', 0, async function (done) {
......
......@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA004', 0, async function (done) {
......
......@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA001', 0, async function (done) {
......
......@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA003', 0, async function (done) {
......
......@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA102', 0, async function (done) {
......
......@@ -15,7 +15,7 @@
import { describe, it, beforeAll } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
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';
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
......@@ -23,7 +23,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA104', 0, async function (done) {
......
......@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish63KBPromiseJsunit() {
describe('SecurityHuksDSABasicFinish63KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA101', 0, async function (done) {
......
......@@ -24,7 +24,7 @@ let useSoftware = true;
export default function SecurityHuksDSABasicFinish65KBPromiseJsunit() {
describe('SecurityHuksDSABasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = checkSoftware();
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyDSA103', 0, async function (done) {
......
......@@ -12,20 +12,25 @@
* 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 { 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';
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
let finishOutData;
let useSoftware = true;
const srcData65Sha256 = 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 SecurityHuksECCBasicFinish65KBPromiseJsunit() {
describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyECC103', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyECCSize256SIGNNONEKeyAlias103';
let HuksOptions = {
......@@ -112,6 +117,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -123,6 +129,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -137,6 +144,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -148,6 +156,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -162,6 +171,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -173,6 +183,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -187,6 +198,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -198,6 +210,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -212,6 +225,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -223,6 +237,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -237,6 +252,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
......@@ -248,6 +264,7 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -475,5 +492,5 @@ describe('SecurityHuksECCBasicFinish65KBPromiseJsunit', function () {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
done();
});
});
});
}
......@@ -20,12 +20,17 @@ import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/p
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
let finishOutData;
let useSoftware = true;
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
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 () {
describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
it('testReformedSignVerifyRSA103', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize2048SIGNPKCS1MD5KeyAlias103';
let HuksOptions = {
......@@ -38,8 +43,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -51,6 +56,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -94,8 +100,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -107,6 +113,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -122,8 +129,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -135,6 +142,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -234,8 +242,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -247,6 +255,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -290,8 +299,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -303,6 +312,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -318,8 +328,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -331,6 +341,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -430,8 +441,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -443,6 +454,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -486,8 +498,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -499,6 +511,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -514,8 +527,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -527,6 +540,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -626,8 +640,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -639,6 +653,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -682,8 +697,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -695,6 +710,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -710,8 +726,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -723,6 +739,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -822,8 +839,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -835,6 +852,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -878,8 +896,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -891,6 +909,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -906,8 +925,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -919,6 +938,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -1018,8 +1038,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -1031,6 +1051,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -1074,8 +1095,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -1087,6 +1108,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -1102,8 +1124,8 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
),
inData: srcData65Kb,
};
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -1115,6 +1137,7 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
......@@ -1201,5 +1224,5 @@ describe('SecurityHuksRSABasicFinish65KBPromiseJsunit', function () {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
done();
});
});
});
}
......@@ -13,9 +13,9 @@
* 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 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';
let inDataString = "Hks_RSA_Sign_Verify_Test_0000000000000000000000000000000000000000000000000000000" +
......@@ -29,6 +29,7 @@ let srcData64 = Data.Data64b;
let srcData64Kb = stringToUint8Array(srcData64);
let signedResult;
let handle;
let useSoftware = true;
async function publicGenerateKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) {
console.error(`enter promise generateKeyItem`);
......@@ -127,7 +128,7 @@ async function publicUpdateSessionFunction(HuksOptions) {
}
}
async function publicUpdateError(HuksOptions, errCode){
async function publicUpdateError(HuksOptions, errCode) {
console.error(`enter promise doUpdate`);
try {
await huks.updateSession(handle, HuksOptions)
......@@ -184,7 +185,10 @@ async function publicDeleteKeyFunc(srcKeyAlias, genHuksOptionsNONECBC) {
export default function SecurityHuksRSASignExtendJsunit() {
describe('SecurityHuksRSASignExtendJsunit', function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
/**
* @tc.number Security_HUKS_RSA_SignExtend_0100
* @tc.name No Padding and Sign Verify with RSA.
......@@ -192,6 +196,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/
it("Security_HUKS_RSA_SignExtend_0100", 0, async function (done) {
let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0100_Gen";
if (useSoftware) {
let HuksOptionsGen = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -234,6 +239,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done();
})
......@@ -244,6 +250,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
*/
it("Security_HUKS_RSA_SignExtend_0200", 0, async function (done) {
let srcKeyAliesGen = "Security_HUKS_RSA_SignExtend_0200";
if (useSoftware) {
let HuksOptionsGen = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
......@@ -286,6 +293,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done();
})
......@@ -314,6 +322,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
),
inData: srcData64Kb,
}
if (useSoftware) {
await publicGenerateKeyFunc(srcKeyAliesGen, HuksOptionsGen);
await publicInitFunc(srcKeyAliesGen, HuksOptionsSign);
HuksOptionsSign.inData = srcData64Kb;
......@@ -337,6 +346,7 @@ export default function SecurityHuksRSASignExtendJsunit() {
HuksOptionsVerify.inData = signedResult;
await publicFinishSessionFunc(HuksOptionsVerify);
await publicDeleteKeyFunc(srcKeyAliesGen, HuksOptionsGen);
}
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册