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

!1841 huks

Merge pull request !1841 from 胡吉翔/security_20220209_1
......@@ -17,8 +17,9 @@ group("security") {
testonly = true
if (is_standard_system) {
deps = [
"user_iam/face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
"user_iam/face_auth/js_api_test/performance_test/performance:ActsUserauthPerformanceTest",
"huks_standard",
#"user_iam/face_auth/js_api_test/function_test/userauth:ActsUserauthTest",
#"user_iam/face_auth/js_api_test/performance_test/performance:ActsUserauthPerformanceTest",
]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
group("huks_standard") {
testonly = true
if (is_standard_system) {
deps = [
"HuksAbnormalTest:ActsHuksAbnormalTest",
"HuksAlgCompletionTest:ActsHuksAlgCompletionTest",
"HuksConcurrencyApp1:ActsHuksConcurrencyApp1Test",
"HuksConcurrencyApp2:ActsHuksConcurrencyApp2Test",
"HuksConcurrencyTest:ActsHuksConcurrencyTest",
"HuksJSTimingTest:ActsHuksJSTimingTest",
#"HuksStressTest:ActsHuksStressTest",
]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsHuksAbnormalTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsHuksAbnormalTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for algorithm completion test",
"driver": {
"type": "JSUnitTest",
"test-timeout": "7200000",
"package": "com.example.err",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsHuksAbnormalTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.err",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.err",
"name": ".MyApplication",
"mainAbility": "com.example.err.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.err.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "singleton",
"visible": true,
"isVisible": "true"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index';
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
const reportExtend = new ReportExtend(file);
core.addService('expect', expectExtend);
core.addService('report', reportExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 1000000;
configService.setConfig(this);
require('../../../test/hks_abnormal_testList.test.js');
core.execute();
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hks from '@ohos.security.huks'
export var alias = 'alias';
export var aliasEmpty = '';
export var aliasTooLong = '01234567890123456789012345678901234567890123456789012345678901234';
export var aliasCritical = '0123456789012345678901234567890123456789012345678901234567890123';
export var aliasNotExist = 'aliasNotExist';
export var emptyOption = makeEmptyOption();
export var plainTextSize64 = makeRandomArr(64);
export var plainTextSize16 = makeRandomArr(16);
export var plainTextSize8 = makeRandomArr(8);
export var invalidValue = 99999;
export var generateAesCBCKeyOption = makeGenerateKeyOption(
hks.HksKeyAlg.HKS_ALG_AES,
hks.HksKeySize.HKS_AES_KEY_SIZE_128,
hks.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | hks.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT,
hks.HksKeyPadding.HKS_PADDING_NONE,
hks.HksCipherMode.HKS_MODE_CBC,
null
);
export var generateAesGCMKeyOption = makeGenerateKeyOption(
hks.HksKeyAlg.HKS_ALG_AES,
hks.HksKeySize.HKS_AES_KEY_SIZE_128,
hks.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | hks.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT,
hks.HksKeyPadding.HKS_PADDING_NONE,
hks.HksCipherMode.HKS_MODE_GCM,
null
);
export var generateRSAKeyOption = makeGenerateKeyOption(
hks.HksKeyAlg.HKS_ALG_RSA,
hks.HksKeySize.HKS_RSA_KEY_SIZE_512,
hks.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | hks.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY,
hks.HksKeyPadding.HKS_PADDING_PKCS1_V1_5,
null,
hks.HksKeyDigest.HKS_DIGEST_SHA1
);
export var generateECCKeyOption = makeGenerateKeyOption(
hks.HksKeyAlg.HKS_ALG_ECC,
hks.HksKeySize.HKS_ECC_KEY_SIZE_224,
hks.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE,
null,
null,
hks.HksKeyDigest.HKS_DIGEST_NONE
);
export var generateMACKeyOption = makeGenerateKeyOption(
hks.HksKeyAlg.HKS_ALG_HMAC,
160,
hks.HksKeyPurpose.HKS_KEY_PURPOSE_MAC,
null,
null,
hks.HksKeyDigest.HKS_DIGEST_SHA1
);
export function makeEmptyOption() {
var emptyOptions = {
properties: []
};
return emptyOptions;
};
export function makeRandomArr(size) {
var arr = new Uint8Array(size);
for (var i = 0; i < size; i++) {
arr[i] = Math.floor(Math.random() * 10);
}
return arr;
};
function makeAlgTag(alg){
var tag = {
tag: hks.HksTag.HKS_TAG_ALGORITHM,
value: alg
};
return tag;
};
function makeSizeTag(size){
var tag = {
tag: hks.HksTag.HKS_TAG_KEY_SIZE,
value: size
};
return tag;
};
function makePurposeTag(purpose){
var tag = {
tag: hks.HksTag.HKS_TAG_PURPOSE,
value: purpose
};
return tag;
};
function makePaddingTag(padding){
var tag = {
tag: hks.HksTag.HKS_TAG_PADDING,
value: padding
};
return tag;
};
function makeDigestTag(digest){
var tag = {
tag: hks.HksTag.HKS_TAG_DIGEST,
value: digest
};
return tag;
};
function makeModeTag(mode){
var tag = {
tag: hks.HksTag.HKS_TAG_BLOCK_MODE,
value: mode
};
return tag;
};
export function makeGenerateKeyOption(alg, size, purpose, padding, mode, digest) {
var properties = new Array();
properties[0] = makeAlgTag(alg);
properties[1] = makeSizeTag(size);
properties[2] = makePurposeTag(purpose);
if (purpose == (hks.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | hks.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT)) {
properties[3] = makePaddingTag(padding);
properties[4] = makeModeTag(mode);
} else if (purpose == (hks.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | hks.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY)) {
properties[3] = makePaddingTag(padding);
properties[4] = makeDigestTag(digest);
} else {
properties[3] = makeDigestTag(digest);
}
var option = {
properties: properties
};
return option;
};
export function makeEncryptAndDecryptOption(mode){
var properties = new Array();
properties[0] = makeAlgTag(hks.HksKeyAlg.HKS_ALG_AES);
properties[1] = makePurposeTag(hks.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | hks.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT);
properties[2] = makeModeTag(mode);
properties[3] = makePaddingTag(hks.HksKeyPadding.HKS_PADDING_NONE);
if (mode == hks.HksCipherMode.HKS_MODE_CBC) {
properties[4] = {
tag: hks.HksTag.HKS_TAG_IV,
value: new Uint8Array(16)
};
} else {
properties[4] = {
tag: hks.HksTag.HKS_TAG_NONCE,
value: new Uint8Array(16)
};
properties[5] = {
tag: hks.HksTag.HKS_TAG_ASSOCIATED_DATA,
value: new Uint8Array(16)
};
}
var option = {
properties: properties,
inData: plainTextSize64
};
return option;
};
export function makeSignVerifyAndImportOption(text){
var properties = new Array();
properties[0] = makeAlgTag(hks.HksKeyAlg.HKS_ALG_RSA);
properties[1] = makePurposeTag(hks.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | hks.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY);
properties[2] = makePaddingTag(hks.HksKeyPadding.HKS_PADDING_NONE);
properties[3] = makeDigestTag(hks.HksKeyDigest.HKS_DIGEST_SHA1);
var option = {
properties: properties,
inData: text
};
return option;
};
export function makeAgreeOption() {
var properties = new Array();
properties[0] = makeAlgTag(hks.HksKeyAlg.HKS_ALG_ECDH);
properties[1] = makeSizeTag(hks.HksKeySize.HKS_ECC_KEY_SIZE_224);
var options = {
properties: properties,
inData: new Uint8Array(76)
};
return options;
};
export function makeMacOption() {
var properties = new Array();
properties[0] = {
tag: hks.HksTag.HKS_TAG_PURPOSE,
value: hks.HksKeyPurpose.HKS_KEY_PURPOSE_MAC
};
properties[1] = {
tag: hks.HksTag.HKS_TAG_DIGEST,
value: hks.HksKeyDigest.HKS_DIGEST_SHA1
};
var options = {
properties: properties,
inData: plainTextSize16
};
return options;
};
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./hks_abnormal_promise.test.js');
require('./hks_abnormal_callback.test.js');
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsHuksAlgCompletionTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsHuksAlgCompletionTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for algorithm completion test",
"driver": {
"type": "JSUnitTest",
"test-timeout": "26000000",
"package": "com.example.hksxtstest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsHuksAlgCompletionTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.hksxtstest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.hksxtstest",
"name": ".MyApplication",
"mainAbility": "com.example.hksxtstest.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.hksxtstest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "singleton",
"visible": true,
"isVisible": "true"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000;
opacity: .9;
}
.btn {
background-color: dodgerblue;
color: white;
padding: 15px 32px;
text-align: center;
font-size: 12px;
margin-top: 5px;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url(../../common/images/Wallpaper.png);
background-size: cover;
background-repeat: no-repeat;
}
.title {
font-size: 100px;
color: #FFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file';
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index';
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
const reportExtend = new ReportExtend(file);
core.addService('expect', expectExtend);
core.addService('report', reportExtend);
core.init();
const configService = core.getDefaultService('config');
this.timeout = 7200000;
configService.setConfig(this);
require('../../../test/hks_xtsTestList_algCompletion.test.js');
core.execute();
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "JS_Empty Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import huks from '@ohos.security.huks'
import {describe, it, expect} from 'deccjsunit/index'
import {
alias,
emptyOption,
inDataOption,
timer,
targetAlias
} from '../../../../../../hks_xts_common.test'
describe('HuksTest_JSApiTest_CA', function () {
/**
* @tc.number HuksTest_JSApiTest_CA_00100
* @tc.name JSAPI_Test_CA
* @tc.desc Test for attestKey.
*/
it('HuksTest_JSApiTest_CA_00100', 0, async function (done) {
var attestKeyRet = await huks.attestKey(alias, emptyOption);
expect(attestKeyRet.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
var getCertificateChainRet = await huks.getCertificateChain(alias, emptyOption);
expect(getCertificateChainRet.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
var wrapKeyRet = await huks.wrapKey(alias, targetAlias, emptyOption);
expect(wrapKeyRet.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
var unwrapKeyRet = await huks.unwrapKey(alias, targetAlias, inDataOption);
expect(unwrapKeyRet.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
done();
setTimeout(function () {
}, timer);
});
/**
* @tc.number HuksTest_JSApiTest_CA_00200
* @tc.name JSAPI_Test_CA
* @tc.desc Test for attestKey.
*/
it('HuksTest_JSApiTest_CA_00200', 0, async function (done) {
huks.attestKey(alias, emptyOption, function (err, data) {
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
done();
});
});
/**
* @tc.number HuksTest_JSApiTest_CA_00300
* @tc.name JSAPI_Test_CA
* @tc.desc Test for attestKey.
*/
it('HuksTest_JSApiTest_CA_00300', 0, async function (done) {
huks.getCertificateChain(alias, emptyOption, function (err, data) {
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
done();
});
});
/**
* @tc.number HuksTest_JSApiTest_CA_00400
* @tc.name JSAPI_Test_CA
* @tc.desc Test for attestKey.
*/
it('HuksTest_JSApiTest_CA_00400', 0, async function (done) {
huks.wrapKey(alias, targetAlias, emptyOption, function (err, data) {
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
done();
});
});
/**
* @tc.number HuksTest_JSApiTest_CA_00500
* @tc.name JSAPI_Test_CA
* @tc.desc Test for attestKey.
*/
it('HuksTest_JSApiTest_CA_00500', 0, async function (done) {
huks.unwrapKey(alias, targetAlias, inDataOption, function (err, data) {
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_ERROR_NOT_SUPPORTED);
done();
});
});
});
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import huks from '@ohos.security.huks'
import {describe, it, expect} from 'deccjsunit/index'
import {
emptyOption,
timer
} from '../../../../../../hks_xts_common.test.js'
describe('HuksTest_JSApiTest_getSdkVersion', function () {
/**
* @tc.number HuksTest_JSApiTest_getSdkVersion_00100
* @tc.name JSAPI_Test_getSdkVersion
* @tc.desc Test for get sdk version.
*/
it('HuksTest_JSApiTest_getSdkVersion_00100', 0, async function (done) {
var sdkVersion = await huks.getSdkVersion(emptyOption);
console.log('sdk version ' + JSON.stringify(sdkVersion));
var result = false;
if (sdkVersion.length > 0) {
result = true;
}
expect(result).assertEqual(true);
done();
setTimeout(function () {
}, timer);
});
});
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./hks_xtsTest_algCompletion_encryptAndDecrypt_aes.test.js');
require('./hks_xtsTest_algCompletion_encryptAndDecrypt_rsa.test.js');
require ('./hks_xtsTest_algCompletion_signAndVerify_promise.test.js');
require ('./hks_xtsTest_algCompletion_signAndVerify_callback.test.js');
require('./hks_xtsTest_algCompletion_agree.test.js');
require('./hks_xtsTest_algCompletion_mac.test.js');
require('./hks_jsApi_ca.test.js');
require('./hks_jsApi_deriveKey.test.js');
require('./hks_jsApi_generateKey.test.js');
require('./hks_jsApi_getKeyProperties.test.js');
require('./hks_jsApi_getSdkVersion.test.js');
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import huks from '@ohos.security.huks'
import {describe, it, expect} from 'deccjsunit/index'
import {
emptyOption,
makeGenerateKeyOption,
makeRandomArr,
timer
} from '../../../../../../hks_xts_common.test.js'
var defaultAlias = 'defaultAlias';
var plaintText = makeRandomArr(64);
describe('Hks_XtsTest_AlgCompletion_Mac', function () {
/**
* @tc.number HUKS_ALG_COMPLETION_39900
* @tc.name HmacSHA1_Promise
* @tc.desc Test for algorithm completion(HmacSHA1).
*/
it('HUKS_ALG_COMPLETION_39900', 0, async function (done) {
macPromise(
huks.HksKeyDigest.HKS_DIGEST_SHA1,
160,
done,
'HUKS_ALG_COMPLETION_39900'
);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40000
* @tc.name HmacSHA224_Promise
* @tc.desc Test for algorithm completion(HmacSHA224).
*/
it('HUKS_ALG_COMPLETION_40000', 0, async function (done) {
macPromise(
huks.HksKeyDigest.HKS_DIGEST_SHA224,
224,
done,
'HUKS_ALG_COMPLETION_40000'
);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40100
* @tc.name HmacSHA256_Promise
* @tc.desc Test for algorithm completion(HmacSHA256).
*/
it('HUKS_ALG_COMPLETION_40100', 0, async function (done) {
macPromise(
huks.HksKeyDigest.HKS_DIGEST_SHA256,
256,
done,
'HUKS_ALG_COMPLETION_40100'
);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40200
* @tc.name HmacSHA384_Promise
* @tc.desc Test for algorithm completion(HmacSHA384).
*/
it('HUKS_ALG_COMPLETION_40200', 0, async function (done) {
macPromise(
huks.HksKeyDigest.HKS_DIGEST_SHA384,
384,
done,
'HUKS_ALG_COMPLETION_40200'
);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40300
* @tc.name HmacSHA512_Promise
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40300', 0, async function (done) {
macPromise(
huks.HksKeyDigest.HKS_DIGEST_SHA512,
512,
done,
'HUKS_ALG_COMPLETION_40300'
);
});
function isKeyExist(done,caseId){
huks.isKeyExist(defaultAlias, emptyOption,function(err,data){
expect(data).assertEqual(false);
console.log(caseId + ' end');
done();
});
};
function deleteKey(done, caseId){
huks.deleteKey(defaultAlias, emptyOption, function(err,data){
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
isKeyExist(done, caseId);
});
};
function doMac(digest, size, done, caseId){
var macOption = makeMacOption(size, digest);
huks.mac(defaultAlias, macOption,function(err,data){
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
deleteKey(done,caseId);
});
};
function macCallback(digest, size, done, caseId) {
var generateKeyOption = makeGenerateKeyOption(
huks.HksKeyAlg.HKS_ALG_HMAC, size, huks.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, null, null, digest
);
huks.generateKey(defaultAlias, generateKeyOption, function (err, data) {
expect(data.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
doMac(digest, size, done, caseId);
});
};
/**
* @tc.number HUKS_ALG_COMPLETION_40400
* @tc.name HmacSHA1_AsyncCallback
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40400', 0, async function (done) {
macCallback(
huks.HksKeyDigest.HKS_DIGEST_SHA1,
160,
done,
'HUKS_ALG_COMPLETION_40400'
);
setTimeout(function () {
}, timer);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40500
* @tc.name HmacSHA224_AsyncCallback
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40500', 0, async function (done) {
macCallback(
huks.HksKeyDigest.HKS_DIGEST_SHA224,
224,
done,
'HUKS_ALG_COMPLETION_40500'
);
setTimeout(function () {
}, timer);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40600
* @tc.name HmacSHA256_AsyncCallback
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40600', 0, async function (done) {
macCallback(
huks.HksKeyDigest.HKS_DIGEST_SHA256,
256,
done,
'HUKS_ALG_COMPLETION_40600'
);
setTimeout(function () {
}, timer);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40700
* @tc.name HmacSHA384_AsyncCallback
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40700', 0, async function (done) {
macCallback(
huks.HksKeyDigest.HKS_DIGEST_SHA384,
384,
done,
'HUKS_ALG_COMPLETION_40700'
);
setTimeout(function () {
}, timer);
});
/**
* @tc.number HUKS_ALG_COMPLETION_40800
* @tc.name HmacSHA512_AsyncCallback
* @tc.desc Test for algorithm completion(HmacSHA512).
*/
it('HUKS_ALG_COMPLETION_40800', 0, async function (done) {
macCallback(
huks.HksKeyDigest.HKS_DIGEST_SHA512,
512,
done,
'HUKS_ALG_COMPLETION_40800'
);
setTimeout(function () {
}, timer);
});
function makeMacOption(size, digest) {
var properties = new Array();
properties[0] = {
tag: huks.HksTag.HKS_TAG_ALGORITHM,
value: huks.HksKeyAlg.HKS_ALG_HMAC
};
properties[1] = {
tag: huks.HksTag.HKS_TAG_PURPOSE,
value: huks.HksKeyPurpose.HKS_KEY_PURPOSE_MAC
};
properties[2] = {
tag: huks.HksTag.HKS_TAG_DIGEST,
value: digest
};
var options = {
properties: properties,
inData: plaintText
};
return options;
};
async function macPromise(digest, size, done, caseId) {
var generateKeyOption = makeGenerateKeyOption(
huks.HksKeyAlg.HKS_ALG_HMAC, size, huks.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, null, null, digest
);
var generateKeyRet = await huks.generateKey(defaultAlias, generateKeyOption);
expect(generateKeyRet.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
var macOption = makeMacOption(size, digest);
var macRet = await huks.mac(defaultAlias, macOption);
expect(macRet.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
var deleteKeyRet = await huks.deleteKey(defaultAlias, emptyOption);
expect(deleteKeyRet.errorCode).assertEqual(huks.HksErrorCode.HKS_SUCCESS);
var isKeyExist = await huks.isKeyExist(defaultAlias, emptyOption);
expect(isKeyExist).assertEqual(false);
console.log(caseId + ' end');
done();
setTimeout(function () {
}, timer);
}
});
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsHuksConcurrencyApp1Test") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsHuksConcurrencyApp1Test"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for concurrency test",
"driver": {
"type": "JSUnitTest",
"test-timeout": "72000000",
"package": "com.example.concurrencyapp1",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsHuksConcurrencyApp1Test.hap",
"ActsHuksConcurrencyApp2Test.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册