diff --git a/security/BUILD.gn b/security/BUILD.gn index dc7ea7886ef4e7ce52e04ac4b50e4c1234c622b1..f77b8122f7abae00452bc0860ba983175f0001cc 100644 --- a/security/BUILD.gn +++ b/security/BUILD.gn @@ -20,7 +20,7 @@ group("security") { "access_token/AccessTokenTest_NoPermission_js:ActsAccessTokenJSApiTestNoPermission", "access_token/AccessTokenTest_Normal_js:ActsAccessTokenJSApiTestNormal", "huks_standard", - "security_huks", + "security_huks_basic", ] } } diff --git a/security/security_huks/huks_agree_callback_BasicTest/Test.json b/security/security_huks/huks_agree_callback_BasicTest/Test.json deleted file mode 100644 index 3a7a58c255a426726f3885e4f53ead02fb746ecc..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksAgreeBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksagreebasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAgreeBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index ea2f6b3a7db02308f1942a5d406a1fde77b10358..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 4be2c143ced512d31549ee6e8aee353bcf8197fb..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 6af1de93169a465514a7e45b332a10e4a104885a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 09e5dddde1aea454d09c8ecd148b493a6c3fb360..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,554 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 066b908dc046065928abb9cf90c1b743203197e6..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index f9034549b6dddd3648d27c3dcb59672059c7dbfb..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,594 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 11a0c0b9b6f0de42bed7fb16ec4058521a68c11a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,594 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 86f192b62f8ef7c6a42f6275158298d49e1c537b..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,595 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index f1cc789d12f01b2bc13d3865b09dabebae5b6361..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,595 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 34a09d8e5c07f5815bc0994ccdf74413961f6095..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index c857833f51d00d37c8a50174033e29359528cc54..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index b6e2e942a0b28a7f966a96a75b4b674e2c52e633..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,591 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index ef7f19f9d490f1feeb2d773b205764a26c294b86..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,591 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/Test.json b/security/security_huks/huks_agree_promise_BasicTest/Test.json deleted file mode 100644 index 577bcde4395a914ec10563fe728f5a4eda38cc77..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksAgreeBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksagreebasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAgreeBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 713b3dbbfbb8e08ae51395a688535b34bc292675..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index d95faef73de5c4395751e070796065b8e8e9d355..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Abort63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 3051c64ab8a70730453f2da3824df5da7e5f024b..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Abort65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 6241a63cecb0ef73ce8723f4967ca235b94b757a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,455 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHFinish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 44d25f92a85f73661d36006b49b3f73797847491..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Finish65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index c1575369bcd6d8e3e894693b3c17e40a039d7953..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,498 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) -let HuksOptions63kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - } - console.info('test beforeEach called') - }) - it('testAgreeECDHFinish63KBAgree003', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4320931c6be5a86bec8777035cdd1b4d732ef881..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,499 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HuksOptions65kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree004', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index b20f8960bbb7838aa3be67c0e0895a29cf68a24d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,511 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 591b7d8f9af7747132410a39afcb81c7560ba924..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,500 +0,0 @@ -/* - * 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 { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HuksOptions65kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree002', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index ccf94a17b86511a379754bbe5bc898a8c24358e7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Abort63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4c0442e8d5144b077a117e91706db0ad75121c69..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Abort65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index e409b554b8454e5b8acecb4e6377dc089b7863ff..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,492 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 86b3bc16eb7755dcfe2d24147874f3e914d5df74..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,492 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_callback_BasicTest/Test.json b/security/security_huks/huks_cipher_callback_BasicTest/Test.json deleted file mode 100644 index 5f20212e10e8387ab1c31eed11f9267252fa656b..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksCipherBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukscipherbasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksCipherBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 48c4a19657b38ac4040e3bc6e5b3a037050679d4..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js deleted file mode 100644 index d1e8765eeb44974dbcd6b791640b1b34e69f6fb7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js +++ /dev/null @@ -1,674 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let IV = '0000000000000000' -let AAD = '0000000000000000' -let NONCE = '000000000000' -let AEAD = '0000000000000000' - -let HksKeyAlg = { - HKS_ALG_AES: 20, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_PKCS7: 5, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, - HKS_TAG_AE_TAG: HksTagType.HKS_TAG_TYPE_BYTES | 10009, -} - -let HuksCipher001 = { - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyAESSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyAESSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyAESSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyAESPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyAESPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyAESBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyAESBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyAESBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyAESDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, -} -let defaultData = '0' - -let srcData65 = - 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string' -let srcData65Kb = stringToUint8Array(srcData65) - -let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string' -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let updateResult = new Array() -let encryptFinishData -let encryptedData -var handle = {} -var handle1 -var handle2 - -let genHuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurpose - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ) - await generateKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - // HuksOptions.inData = new Uint8Array(new Array()); - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - 0, - huksOptionsInData.length - ) - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - console.log('test count ' + count + 'remainder ' + remainder) - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - } - HuksOptions.inData = huksOptionsInData - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - huksOptionsInData.length - ) - } -} - -async function update(handle, HuksOptions) { - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - if (updateResult.length !== 0) { - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - updateResult = Array.from(data.outData) - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - dataLength -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - console.log(`test remainder ${remainder}`) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await finishCallback(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - let finishData - if (encryptedData.length > 64) { - finishData = uint8ArrayToString( - updateResult.concat(Array.from(data.outData)) - ) - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - finishData = uint8ArrayToString(updateResult) - } - if (isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - expect(data.errorCode == 0).assertTrue() - } else { - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finishCallback(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function abort(HuksOptions) { - await abortCallback(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abortCallback(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - await deleteKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicCipherFunc( - srcKeyAlies, - genHuksOptionsNONECBC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - try { - updateResult = new Array() - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - encryptedData = HuksOptions.inData - } - await publicInitFunc(srcKeyAlies, HuksOptions) - await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherAESCallbackJsunit', function () { - it('testCipherAES001', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - genHuksOptions.properties.splice(2, 1, HuksCipher001.HuksKeyAESSize128) - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher001.HuksKeyAESBLOCKMODE - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher001.HuksKeyAESPADDINGNONE - ) - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES002', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherAES003', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES004', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js deleted file mode 100644 index f4c437f37408cbc95ca00b2dedd991db0bf52712..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js +++ /dev/null @@ -1,723 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let gInData64 = - 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher002 = { - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSAPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGOAEP: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_OAEP, - }, - HuksKeyRSABLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyRSADIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyRSADIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyRSADIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyRSADIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyRSADIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyRSADIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} -let defaultData = '0' - -let gInData64Array = stringToUint8Array(gInData64) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let encryptFinishData -let encryptedData -let inputInData -var handle = {} -var handle1 -var handle2 -let updateResult = new Array() -let exportKey -let importKey - -let genHuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurpose, - HuksCipher002.HuksKeyRSASize512 - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await generateKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await exportkey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test ExportKey data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { - HuksOptions.inData = exportKey - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importkey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - importKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function importkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = stringToUint8Array('0') - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)) - HuksOptions.inData = new Uint8Array(new Array()) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await finishCallback(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - if (isEncrypt) { - updateResult = Array.from(data.outData) - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - expect(null).assertFail() - } else { - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - expect(data.errorCode == 0).assertTrue() - } else { - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finishCallback(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function abort(HuksOptions) { - await abortCallback(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abortCallback(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - await deleteKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} -async function publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptionsNONC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - inputInData = HuksOptions.inData - try { - updateResult = new Array() - let KeyAlias = srcKeyAlies - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) - encryptedData = HuksOptions.inData - await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicImportKeyFunc(newSrcKeyAlies, HuksOptions) - KeyAlias = newSrcKeyAlies - } - HuksOptions.inData = inputInData - await publicInitFunc(KeyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherRSACallbackJsunit', function () { - it('testCipherRSA001', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher002.HuksKeyRSABLOCKMODEECB - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher002.HuksKeyRSAPADDINGNONE - ) - genHuksOptions.properties.splice( - 5, - 1, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ) - - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA002', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherRSA003', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA004', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_promise_BasicTest/Test.json b/security/security_huks/huks_cipher_promise_BasicTest/Test.json deleted file mode 100644 index 09ddfbd589cd73fdacf3a884a7714202a24f30cb..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksCipherBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukscipherbasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksCipherBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 48c4a19657b38ac4040e3bc6e5b3a037050679d4..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js deleted file mode 100644 index 30a582c71e738f1caed40473aa68c0c89c4dec0c..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js +++ /dev/null @@ -1,616 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' - -let IV = '0000000000000000' -let AAD = '0000000000000000' -let NONCE = '000000000000' -let AEAD = '0000000000000000' - -let HksKeyAlg = { - HKS_ALG_AES: 20, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_PKCS7: 5, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher001 = { - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyAESSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyAESSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyAESSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyAESPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyAESPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyAESBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyAESBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyAESBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyAESDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, -} -let defaultData = '0' -let srcData65 = - 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string' -let srcData65Kb = stringToUint8Array(srcData65) - -let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string' -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let updateResult = new Array() -let encryptFinishData -let encryptedData -var handle = {} -var handle1 -var handle2 - -let genHuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurpose - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ) - await huks - .generateKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = new Uint8Array(new Array()) - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - 0, - huksOptionsInData.length - ) - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - console.log('test count ' + count + 'remainder ' + remainder) - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - } - HuksOptions.inData = huksOptionsInData - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } else { - HuksOptions.inData = new Uint8Array(new Array()) - } - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - huksOptionsInData.length - ) - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - console.log(`test update data ${JSON.stringify(HuksOptions.inData.length)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - if (updateResult.length !== 0) { - console.log(`test update outDatalength ${updateResult.length}`) - updateResult = updateResult.concat(Array.from(data.outData)) - console.log(`test update outDatalength ${updateResult.length}`) - } else { - console.log(`test update outDatalength ${updateResult.length}`) - updateResult = Array.from(data.outData) - console.log(`test update outDatalength ${updateResult.length}`) - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - dataLength -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - console.log(`test remainder ${remainder}`) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - let finishData - if (encryptedData.length > 64) { - finishData = uint8ArrayToString( - updateResult.concat(Array.from(data.outData)) - ) - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - finishData = uint8ArrayToString(updateResult) - } - if (isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Decrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } else { - console.log( - `test finish Decrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function abort(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - await huks - .deleteKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicCipherFunc( - srcKeyAlies, - genHuksOptionsNONECBC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - try { - updateResult = new Array() - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - encryptedData = HuksOptions.inData - } - await publicInitFunc(srcKeyAlies, HuksOptions) - await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherAESPromiseJsunit', function () { - it('testCipherAES001', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - genHuksOptions.properties.splice(2, 1, HuksCipher001.HuksKeyAESSize128) - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher001.HuksKeyAESBLOCKMODE - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher001.HuksKeyAESPADDINGNONE - ) - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES002', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherAES003', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES004', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js deleted file mode 100644 index 01ba2241f76b891fb9e19198e3041b3c899b6096..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js +++ /dev/null @@ -1,662 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' - -let gInData64 = - 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher002 = { - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSAPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGOAEP: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_OAEP, - }, - HuksKeyRSABLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyRSADIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyRSADIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyRSADIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyRSADIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyRSADIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyRSADIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} -let defaultData = '0' - -let gInData64Array = stringToUint8Array(gInData64) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let encryptFinishData -let encryptedData -let inputInData -var handle = {} -var handle1 -var handle2 -let updateResult = new Array() -let exportKey -let importKey - -let genHuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurpose, - HuksCipher002.HuksKeyRSASize512 - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await huks - .generateKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await huks - .exportKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test ExportKey data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { - HuksOptions.inData = exportKey - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - importKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = stringToUint8Array('0') - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)) - HuksOptions.inData = new Uint8Array(new Array()) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - console.log('test before finish HuksOptions inData: ' + HuksOptions.inData) - console.log( - 'test before finish HuksOptions outData: ' + HuksOptions.outData - ) - console.log( - 'test before finish HuksOptions outData: ' + HuksOptions.outData.length - ) - console.log( - 'test before finish HuksOptions properties: ' + - JSON.stringify(HuksOptions.properties) - ) - - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - if (isEncrypt) { - updateResult = Array.from(data.outData) - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - data.outData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - data.outData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - console.log( - `test finish Decrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt success ${uint8ArrayToString( - data.outData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } else { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - data.outData - )}` - ) - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function abort(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - await huks - .deleteKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptionsNONC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - inputInData = HuksOptions.inData - try { - updateResult = new Array() - let KeyAlias = srcKeyAlies - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) - encryptedData = HuksOptions.inData - await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicImportKeyFunc(newSrcKeyAlies, HuksOptions) - KeyAlias = newSrcKeyAlies - } - HuksOptions.inData = inputInData - await publicInitFunc(KeyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherRSAPromiseJsunit', function () { - it('testCipherRSA001', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher002.HuksKeyRSABLOCKMODEECB - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher002.HuksKeyRSAPADDINGNONE - ) - genHuksOptions.properties.splice( - 5, - 1, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ) - - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA002', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherRSA003', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA004', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/Test.json b/security/security_huks/huks_derive_callback_BasicTest/Test.json deleted file mode 100644 index 999041316ae322bdcbd5ce2ec531b91ac4180a15..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksDeriveBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksderivebasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksDeriveBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d336ad13090d887931c07a4fafaaec4a7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index bdf2d0717aff665c19ef4c5bc7e569c035f00bc0..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 639d629dc7e5d552e3c7cbdd851451f7b2bfb490..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index f581619f48c9231c34a423923c84db6dde049185..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Abort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index ed038dec913d198e75dbf5caae20eeae64a5a86a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Finish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 11f4277ab72dc57c486dffb20e310cc7cf4126d7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export {isOpenSSL} diff --git a/security/security_huks/huks_derive_promise_BasicTest/Test.json b/security/security_huks/huks_derive_promise_BasicTest/Test.json deleted file mode 100644 index 11ec956d756074775d8aa06c8ad51889f41166a2..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksDeriveBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksderivebasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksDeriveBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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'); - } -}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d336ad13090d887931c07a4fafaaec4a7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 39345dc890322a08b798c813ba537184a109a23d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFAbort63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 8657d2906c1472d1daec846d7e249d672be6d748..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFFinish63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index c38e894c921f914451d2cf8d4f2e7497324de820..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Abort63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 7d7cda1ca582802741a32d79615a1d12335d236e..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Finish63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b958ff3614401d9177e8f379809359e14..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_hmac_callback_BasicTest/Test.json b/security/security_huks/huks_hmac_callback_BasicTest/Test.json deleted file mode 100644 index edd5a3c522e2d9b5eb0c2548f97889be592e41b1..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksHmacBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksHmacbasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksHmacBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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'); - } -}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d336ad13090d887931c07a4fafaaec4a7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js deleted file mode 100644 index 05d3af51f3438b8a9e6509b4841bb00fb75e2a6f..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js +++ /dev/null @@ -1,432 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyAlg = { - HKS_ALG_HMAC: 50, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksHmac = { - HuksKeyAlg: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let srcData63Kb = Data.Date63KB -let srcData65Kb = Data.Date65KB - -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -var handle = {} -var handleStart -var handleEnd - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + - JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log( - 'test generateKey err information: ' + JSON.stringify(e) - ) - reject(e) - } - }) - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test init err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - handleStart = data.handle1 - handleEnd = data.handle2 - handle = { - handle1: handleStart, - handle2: handleEnd, - } - resolve(data) - } - } catch (e) { - console.log('test init err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test update err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function finish(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.finish(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test finish err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function abort(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.abort(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test abort err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(e) - ) - reject(e) - } - }) - }) -} - -async function publicHmacUpdate(HuksOptions) { - let dateSize = 64 * 1024 - let huksOptionsInData = HuksOptions.inData - let inDataArray = stringToArray(HuksOptions.inData) - - if (HuksOptions.inData.length <= dateSize) { - HuksOptions.inData = new Uint8Array(inDataArray) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor(inDataArray.length / dateSize) - let remainder = inDataArray.length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * count, - inDataArray.length - ) - ) - console.log(`test update HuksOptions.inData ${HuksOptions.inData}`) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - } -} - -async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - console.log( - 'test before generateKey HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log('test generateKey data = ' + JSON.stringify(data)) - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) - - HuksOptions.properties.splice(1, 1) - console.log('test before init HuksOptions = ' + JSON.stringify(HuksOptions)) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) - console.log( - 'test before Update HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await publicHmacUpdate(HuksOptions) - - if (thirdInderfaceName == 'finish') { - HuksOptions.inData = new Uint8Array(stringToArray('0')) - console.log( - 'test before finish HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - console.log( - 'test before abort HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${data}`) - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - console.log( - 'test before deleteKey HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${data}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -describe('SecurityHuksHmacCallbackJsunit', function () { - it('testHmacSHA1001', 0, async function (done) { - let srcKeyAlies = 'testHmacDigestSHA1KeyAlias001' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - - await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - it('testHmacSHA1002', 0, async function (done) { - let srcKeyAlies = 'testHmacDigestSHA1KeyAlias002' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) - it('testHmacSHA1003', 0, async function (done) { - let srcKeyAlies = 'testHmacDigestSHA1KeyAlias003' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - it('testHmacSHA1004', 0, async function (done) { - let srcKeyAlies = 'testHmacDigestSHA1KeyAlias004' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) -}) diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b958ff3614401d9177e8f379809359e14..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_hmac_promise_BasicTest/Test.json b/security/security_huks/huks_hmac_promise_BasicTest/Test.json deleted file mode 100644 index 3a98e1ac50d5f6af7c4f98e4bab62dea186111be..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksHmacBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksHmacbasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksHmacBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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'); - } -}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index ff144d1e076fd0a922eb557a7d6b0b28b8145194..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 {Core, ExpectExtend} 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js deleted file mode 100644 index a0050a3c67a0e0c898ff48778af990ebb71c513a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js +++ /dev/null @@ -1,291 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -var handle = {} -var handle1 -var handle2 -let srcData63Kb = Data.Date63KB -let srcData65Kb = Data.Date65KB -let HksKeyPurpose = { - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyAlg = { - HKS_ALG_HMAC: 50, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, -} - -let HuksHmac = { - HuksKeyAlg: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicHmacGenFunc(srcKeyAlies, HuksOptions) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.properties.splice(1, 1) -} - -async function publicHmacInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then(async (data) => { - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) -} - -async function publicHmacUpdateFunc(HuksOptions) { - let dateSize = 64 * 1024 - let huksOptionsInData = HuksOptions.inData - let inDataArray = stringToArray(HuksOptions.inData) - if (inDataArray.length < dateSize) { - HuksOptions.inData = new Uint8Array(inDataArray) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor(inDataArray.length / dateSize) - let remainder = inDataArray.length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * count, - inDataArray.length - ) - ) - await update(handle, HuksOptions) - } - } -} - -async function publicHmacFinish(HuksOptions, thirdInderfaceName) { - if (thirdInderfaceName == 'finish') { - HuksOptions.inData = new Uint8Array(stringToArray('0')) - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + err) - expect(null).assertFail() - }) - } else if (thirdInderfaceName == 'abort') { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + err) - expect(null).assertFail() - }) - } -} - -async function publicHmacDelete(srcKeyAlies, HuksOptions) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicHmacFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { - try { - await publicHmacGenFunc(srcKeyAlies, HuksOptions) - await publicHmacInitFunc(srcKeyAlies, HuksOptions) - await publicHmacUpdateFunc(HuksOptions) - await publicHmacFinish(HuksOptions, thirdInderfaceName) - await publicHmacDelete(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -describe('SecurityHuksHmacBasicPromiseJsunit', function () { - it('testHmac001', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias101' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - it('testHmac002', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias102' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) - - it('testHmac003', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias103' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - it('testHmac004', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias104' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) -}) diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b958ff3614401d9177e8f379809359e14..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_signverify_callback_BasicTest/Test.json b/security/security_huks/huks_signverify_callback_BasicTest/Test.json deleted file mode 100644 index 4d9e4ea3215b42b862d8f48c56708928f659f7df..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksSignVerifyBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukssignverifybasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksSignVerifyBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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'); - } -}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 680546925222e6ffa56259b236221d5df85e37bc..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js deleted file mode 100644 index 8ca9a6fab94d31d4113da52e063ae74abeecce78..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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("./SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js") \ No newline at end of file diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 1212ab40eac648613acaaa4f0004082dba33921b..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,509 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 3565847400483333c596990236864860f35653ac..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,514 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - it('testSignVerifyDSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index c6970b1536b27491bcf9dd9b1a47beee07dc6c02..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,531 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let DSA_COMMON_SIZE = 1024 - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagDSACOMMONSIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: DSA_COMMON_SIZE, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let exportKey -var handle = {} -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksTagDSACOMMONSIZE - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 2b739bba1456b13a7424af77ab7dbf5a785f1356..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,525 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksKeySIZE1024 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 260d4aa59a7baa1638108efdc1b468a05d13ada7..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,526 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 9c5a363d3a478c1f1242f56bd9694d017314476a..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,526 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias004' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index c20c2a3f7e4fe42c759eb8e1562d76adf14176b0..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,542 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 1c24c25dd90c28f92d417f05448c9cf8704e4fb1..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,536 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - it('testSignVerifyECC103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias003' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js deleted file mode 100644 index dcdede377b5819593b548bc3cb6abcae33faeec4..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js +++ /dev/null @@ -1,606 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ED25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeySize = { - HKS_CURVE25519_KEY_SIZE_256: 256, - HKS_ED25519_KEY_SIZE_512: 512, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksSignVerify004 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ED25519_KEY_SIZE_512, - }, - HuksKeyAlgED25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ED25519, - }, - HuksKeyED25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyED25519PurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyED25519PurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyED25519CallbackJsunit', function () { - it('testSignVerifyED25519101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 7c14885c8235fb40c39df63899b0f8feb1603ced..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index a9ea8974cf2b55ad288b86d1acbb52e2626004a1..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 967d3eff40ee3c9bf1647ffd816623a96ccb958d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,607 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 1c5022e4b55b1f99e551e9b544b00cb20dca520e..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,608 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b958ff3614401d9177e8f379809359e14..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_signverify_promise_BasicTest/Test.json b/security/security_huks/huks_signverify_promise_BasicTest/Test.json deleted file mode 100644 index 8bf497f55ca193fd8b9b66d0253223349abd8ccd..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksSignVerifyBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukssignverifybasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksSignVerifyBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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'); - } -}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd7567028568bd522193b2519d545ca6dcf397d..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.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; - } -} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 680546925222e6ffa56259b236221d5df85e37bc..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 { Core, ExpectExtend } 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' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js deleted file mode 100644 index 7a28d1bae05cdb3232e2d27de5a036634e95cd39..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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("./SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksED25519BasicPromiseJsunit.test") \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 97fc6127e693d707031446b8c182654b8cc70e71..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,409 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4404963cc9e3ca4cf716ca9c6f1b71e828d4ebf3..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,410 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 72d9b443a665148245cd7d48a3594e4324e7cf80..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,438 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let exportKey -let handle = {} -let srcData63 = Data.Data63b -console.log(`test srcData63 ${srcData63}`) -let srcData63Kb = stringToUint8Array(srcData63) -console.log(`test srcData63Kb ${JSON.stringify(srcData63Kb)}`) - -let DSA_COMMON_SIZE = 1024 - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagDSACOMMONSIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: DSA_COMMON_SIZE, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - console.log(`test stringToUint8Array arr ${JSON.stringify(arr)}`) - var tmpUint8Array = new Uint8Array(arr) - console.log( - `test stringToUint8Array tmpUint8Array ${JSON.stringify(tmpUint8Array)}` - ) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksTagDSACOMMONSIZE - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 1e0a1f63cfd354417c0c19cbc19c763eadef1c71..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,426 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksKeySIZE1024 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 81863b702d58ba141231850d6874b4669cce4778..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 10d6d3b9dade783c876e8747fd8191f6d9017b00..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,425 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData65Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 025482f7d9a3d607f04c47d758301a68e7071df3..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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 { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 38c7ddc8bf9e24d98a8364cf7f0e6a121e418ae1..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,435 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - it('testSignVerifyECC003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js deleted file mode 100644 index aaf10103ab2bb5139a0719994a5a97fcccb8f957..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js +++ /dev/null @@ -1,493 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ED25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeySize = { - HKS_CURVE25519_KEY_SIZE_256: 256, - HKS_ED25519_KEY_SIZE_512: 512, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksSignVerify004 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ED25519_KEY_SIZE_512, - }, - HuksKeyAlgED25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ED25519, - }, - HuksKeyED25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyED25519PurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyED25519PurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyED25519PromiseJsunit', function () { - it('testSignVerifyED25519Size256SIGN101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 7fdce758036a45179828b1066f9aa3f88e7aac95..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,477 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index a0e4a8caf8692dd2010fad369a91904d81d7ee71..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,477 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 043fc11c4c96bcd495f7e929755b542547e82c63..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,494 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index a19c44a756b92139c3a682502dcc2f4744173ff6..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,495 +0,0 @@ -/* - * 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 { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b958ff3614401d9177e8f379809359e14..0000000000000000000000000000000000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/BUILD.gn b/security/security_huks_basic/BUILD.gn similarity index 97% rename from security/security_huks/BUILD.gn rename to security/security_huks_basic/BUILD.gn index 259aa6502ed4c9b36810f54d48ed6c80f1bcb132..e6b366c893317007cca166d979da6270c59ef1de 100644 --- a/security/security_huks/BUILD.gn +++ b/security/security_huks_basic/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//test/xts/tools/build/suite.gni") -group("security_huks") { +group("security_huks_basic") { testonly = true if (is_standard_system) { deps = [ diff --git a/security/security_huks/huks_agree_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json b/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d339724ca113ad6a3b1d1d67e7f49ba9237091a6 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksAgreeBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksagreebasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksAgreeBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js index fe09ae65fe95e2b2490235fbaeb8aefe42064db2..03bdca4c355a186eb638028322e8a94a7d424a17 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c50c0bca16e770bd158b0b3a5314c14a3afeebde --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d537f07565f54a1f4461b5b4484930d53c054f57 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0f6e3beb8c227faaa8ad9fa3f1fde033ddc7561c --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHAbort65KB001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ed856cd8a5cb98e3da4e8376d2342e7a8f444181 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,66 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..38b37a112453666d40d5b938d930b9dcd7b0c7ac --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,66 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHFinish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..06ce05f18db9c0d993ec32150b3534cb577d57ff --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..887cd2ab05be3c5c35801e3827db8b0786f357df --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHAbort65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ff5749455d6375d5bbda7a342f6a9c2dad7f7280 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7a38031c3f001e9ef30214883424f09f96d403ae --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHFinish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7e8c2d57e977efd070685c51a192d320020a6966 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Abort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e8957771327a1594de789181c02d786559f1bb1c --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Abort65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3537c2786271f47d87663f079fd0bcccfe0662b4 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Finish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..42cb711cd86a50e589b9bbc3e8f05fb67464a66a --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Finish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 90% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js index 83c693575e428d3af5f807b4aa7a67bd969b1120..08f78e52cbb2b15880354d4e2b34cd6dd45b7f4b 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,15 +13,15 @@ * limitations under the License. */ -require('./Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js') +require('./Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js'); diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b958ff3614401d9177e8f379809359e14..d7bc32507efcead9a811ada467661cb683992314 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_agree_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json b/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3aca2b28171a9fcba3a5b902d1d117ab2dff7ec0 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksAgreeBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksagreebasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksAgreeBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..5a5f568dfc0d7be0d64e09123ae920f1116557f6 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..37fcfbc58b5879980f4af9f48fe9eb14f514fb5a --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Abort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ebc03048afe3f7a383c9c34d8beed9d3a50948c1 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Abort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e8415d016f302fcf527310274cafb2229bdacb49 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,66 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Finish63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a5a9f8a15a5897d66c59eb7d4fe357640a17d5f9 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,66 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Finish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4cbafaef032c8467ad9b3fb2ea0433abc0e2f7a8 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,73 @@ +/* + * 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 { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, + }; + console.info('test beforeEach called'); + }); + it('testAgreeECDHAbort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d84c7ee11e73461657c28626577159fd6763a105 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,74 @@ +/* + * 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 { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, + }; + console.info('test beforeEach called'); + }); + + it('testAgreeECDHAbort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..014451133a4df9bb7552238dc7d544235e77516a --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,85 @@ +/* + * 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 { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions63kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData63Kb, + }; + console.info('test beforeEach called'); + }); + + it('testAgreeECDHFinish63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..aa0ac398ccc91eab54b6cb88275307ff15d5c0c9 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,74 @@ +/* + * 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 { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, + }; + console.info('test beforeEach called'); + }); + + it('testAgreeECDHFinish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeECDH.HuksKeySTORAGE, + HuksAgreeECDH.HuksKeyISKEYALIAS, + HuksAgreeECDH.HuksKeyALGORITHMAES, + HuksAgreeECDH.HuksKeySIZE256, + HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeECDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeECDH.HuksKeyPADDINGNONE, + HuksAgreeECDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6cf0fb1150aabb0f291fae6252c43b39d9b5ca03 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,70 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Abort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..66db29bb8dc3bfb3555e4fc40581063c9dd8d69c --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Abort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ee096574f4f8b35f124763cc33be7ff53804a353 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Finish63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..2200d3718e8a314203a5b3956c4d5c717bb7c4b9 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Finish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 87% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js index 9ea8290ef9267b5ca8da67de088bfeabae4f4cd3..dd19bcc701daf0ed78d5425eae9512ee84a3cce8 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,15 +13,15 @@ * limitations under the License. */ -require('./Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js') +require('./Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js'); diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b958ff3614401d9177e8f379809359e14..d7bc32507efcead9a811ada467661cb683992314 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_cipher_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..f63b998e18bd166ee5f725863f2e7dfc6ece8562 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksCipherBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukscipherbasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksCipherBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..5a5f568dfc0d7be0d64e09123ae920f1116557f6 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3803e093e3eff7b9be0656b8f20b117f18e9ceb5 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js @@ -0,0 +1,484 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherAES } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let IV = '0000000000000000'; + +let defaultData = '0'; + +let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string'; +let srcData63Kb = stringToUint8Array(srcData63); +let updateResult = new Array(); +let encryptedData; +var handle; + +let genHuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurpose + ), + inData: new Uint8Array(defaultData), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + console.log( + `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` + ); + await generateKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + // HuksOptions.inData = new Uint8Array(new Array()); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt, 0); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + console.log('test count ' + count + 'remainder ' + remainder); + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + } + HuksOptions.inData = huksOptionsInData; + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + await publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder + ); + } +} + +async function update(handle, HuksOptions) { + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + if (updateResult.length !== 0) { + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + updateResult = Array.from(data.outData); + } + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + console.log(`test remainder ${remainder}`); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await finishCallback(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + let finishData; + if (encryptedData.length > 64) { + finishData = uint8ArrayToString( + updateResult.concat(Array.from(data.outData)) + ); + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + finishData = uint8ArrayToString(updateResult); + } + if (isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + expect(data.errorCode == 0).assertTrue(); + } else { + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finishCallback(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function abort(HuksOptions) { + await abortCallback(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abortCallback(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + await deleteKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + genHuksOptionsNONECBC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + try { + updateResult = new Array(); + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + encryptedData = HuksOptions.inData; + } + await publicInitFunc(srcKeyAlies, HuksOptions); + await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherAESCallbackJsunit', function () { + it('testCipherAES001', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES002', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherAES003', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES004', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a4d564c3b5685a9387bfeb71c0848a7f5bbebc3a --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js @@ -0,0 +1,539 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherRSA } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let gInData64 = + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; + +let gInData64Array = stringToUint8Array(gInData64); +let encryptedData; +let inputInData; +var handle; +let updateResult = new Array(); +let exportKey; + +let genHuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize512 + ), + inData: new Uint8Array(new Array()), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await generateKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await exportkey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test ExportKey data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { + HuksOptions.inData = exportKey; + console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await importkey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function importkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test importKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test importKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = stringToUint8Array('0'); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(1024)); + HuksOptions.inData = new Uint8Array(new Array()); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await finishCallback(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + if (isEncrypt) { + updateResult = Array.from(data.outData); + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + expect(null).assertFail(); + } else { + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + expect(data.errorCode == 0).assertTrue(); + } else { + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finishCallback(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function abort(HuksOptions) { + await abortCallback(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abortCallback(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + await deleteKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} +async function publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptionsNONC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + inputInData = HuksOptions.inData; + try { + updateResult = new Array(); + let KeyAlias = srcKeyAlies; + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC); + encryptedData = HuksOptions.inData; + await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicImportKeyFunc(newSrcKeyAlies, HuksOptions); + KeyAlias = newSrcKeyAlies; + } + HuksOptions.inData = inputInData; + await publicInitFunc(KeyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherRSACallbackJsunit', function () { + it('testCipherRSA001', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001'; + genHuksOptions.properties.splice( + 3, + 1, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB + ); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice( + 5, + 1, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ); + + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA002', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherRSA003', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias003'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA004', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias004'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 80% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js index 7cfeabde694d20c3b9eab07422f86099144b5a3f..9aba31c2a99c347672f1bb64b91cdfa323d7cf81 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,5 +13,5 @@ * limitations under the License. */ -require("./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js") -require("./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js") +require('./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js'); +require('./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js'); diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b958ff3614401d9177e8f379809359e14..d7bc32507efcead9a811ada467661cb683992314 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_cipher_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..5d0b830663ecdc611d66350ca576204a12cfe4e5 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksCipherBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukscipherbasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksCipherBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..5a5f568dfc0d7be0d64e09123ae920f1116557f6 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..218270015f09a446106bea96727cca6bf1cecb80 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js @@ -0,0 +1,430 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherAES } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let IV = '0000000000000000'; + +let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string'; +let srcData63Kb = stringToUint8Array(srcData63); +let updateResult = new Array(); +let encryptedData; +var handle; + +let genHuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurpose + ), + inData: new Uint8Array(new Array()), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + console.log( + `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` + ); + await huks + .generateKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = new Uint8Array(new Array()); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt, 0); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + console.log('test count ' + count + 'remainder ' + remainder); + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + } + HuksOptions.inData = huksOptionsInData; + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } else { + HuksOptions.inData = new Uint8Array(new Array()); + } + await publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder + ); + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + console.log(`test update data ${JSON.stringify(HuksOptions.inData.length)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + if (updateResult.length !== 0) { + console.log(`test update outDatalength ${updateResult.length}`); + updateResult = updateResult.concat(Array.from(data.outData)); + console.log(`test update outDatalength ${updateResult.length}`); + } else { + console.log(`test update outDatalength ${updateResult.length}`); + updateResult = Array.from(data.outData); + console.log(`test update outDatalength ${updateResult.length}`); + } + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + console.log(`test remainder ${remainder}`); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + let finishData; + if (encryptedData.length > 64) { + finishData = uint8ArrayToString( + updateResult.concat(Array.from(data.outData)) + ); + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + finishData = uint8ArrayToString(updateResult); + } + if (isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } else { + console.log( + `test finish Decrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function abort(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + await huks + .deleteKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + genHuksOptionsNONECBC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + try { + updateResult = new Array(); + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + encryptedData = HuksOptions.inData; + } + await publicInitFunc(srcKeyAlies, HuksOptions); + await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherAESPromiseJsunit', function () { + it('testCipherAES101', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES102', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherAES103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES104', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..085596fdde3fba370767886548e3b0ab54e53af7 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js @@ -0,0 +1,478 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherRSA } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let gInData64 = + 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt'; + +let defaultData = '0'; + +let gInData64Array = stringToUint8Array(gInData64); + +let encryptedData; +let inputInData; +var handle; +let updateResult = new Array(); +let exportKey; + +let genHuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize512 + ), + inData: new Uint8Array(defaultData), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await huks + .generateKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await huks + .exportKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test ExportKey data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { + HuksOptions.inData = exportKey; + console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .importKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = stringToUint8Array('0'); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(1024)); + HuksOptions.inData = new Uint8Array(new Array()); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + console.log('test before finish HuksOptions inData: ' + HuksOptions.inData); + console.log('test before finish HuksOptions outData: ' + HuksOptions.outData); + console.log( + 'test before finish HuksOptions outData: ' + HuksOptions.outData.length + ); + console.log( + 'test before finish HuksOptions properties: ' + + JSON.stringify(HuksOptions.properties) + ); + + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + if (isEncrypt) { + updateResult = Array.from(data.outData); + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(data.outData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + console.log( + `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt success ${uint8ArrayToString(data.outData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } else { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` + ); + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function abort(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + await huks + .deleteKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptionsNONC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + inputInData = HuksOptions.inData; + try { + updateResult = new Array(); + let KeyAlias = srcKeyAlies; + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC); + encryptedData = HuksOptions.inData; + await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicImportKeyFunc(newSrcKeyAlies, HuksOptions); + KeyAlias = newSrcKeyAlies; + } + HuksOptions.inData = inputInData; + await publicInitFunc(KeyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherRSAPromiseJsunit', function () { + it('testCipherRSA101', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias101'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + genHuksOptions.properties.splice( + 3, + 1, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB + ); + genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE); + genHuksOptions.properties.splice( + 5, + 1, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ); + + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA102', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias102'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherRSA103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeDECRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA104', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias104'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 79% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js index 7137ae0dc968424cfa71683ed8d1cffb05389632..bac53362294dba49a975a0c762b09a9d1472f350 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,5 +13,5 @@ * limitations under the License. */ -require("./Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js") -require("./Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js") +require('./Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js'); +require('./Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js'); diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js index 11f4277ab72dc57c486dffb20e310cc7cf4126d7..d7bc32507efcead9a811ada467661cb683992314 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export {isOpenSSL} +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_derive_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json b/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..182fb0f29ad790e0a380b8518d9ebb5f3982288c --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksDeriveBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksderivebasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksDeriveBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce4698ec1d7dc86c3eea3990a5e7b1085..5a5f568dfc0d7be0d64e09123ae920f1116557f6 100644 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..49ceea6b5276f6c8d87626b3ea0b6b0f91f50491 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { + it('testDeriveHKDFAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..248e202e7072867089fe42d21c0f3d5f264d528b --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { + it('testDeriveHKDFFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..eaa617a588f1b3fa44f148b76bab14a8ed841944 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { + it('testDerivePBKDF2Abort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyALGORITHMAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d28f8b73540b9586ab0bebd51a519c9897702bba --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { + it('testDerivePBKDF2Finish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyALGORITHMAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 65% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js index 270b033be41900f3d937fb949d4c0e22db6b072a..95e7d79eb20c4cd5d4214c664fd22fa386340977 100644 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ -require("./Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js") +require('./Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_derive_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json b/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..dc27c0af8a857b2d345e68f738cea27a4e414257 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksDeriveBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksderivebasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksDeriveBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5f568dfc0d7be0d64e09123ae920f1116557f6 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + }, +}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..b02bb8d19551f35cc01c173407dd6d47c9aed88d --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { + it('testDeriveHKDFAbort63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bcb9b2123022e6cdea65b029e5b17531855a2db8 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { + it('testDeriveHKDFFinish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f788979f28e23d9090d54a68a6cc777bf2975688 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,64 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; +describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { + it('testDerivePBKDF2Abort63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyALGORITHMAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..77f71810a6f968ad6046aeb3cf43b3da4945e2fa --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { + it('testDerivePBKDF2Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDerivePBKDF2.HuksKeySTORAGE, + HuksDerivePBKDF2.HuksKeyISKEYALIAS, + HuksDerivePBKDF2.HuksKeyALGORITHMAES, + HuksDerivePBKDF2.HuksKeySIZE256, + HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT, + HuksDerivePBKDF2.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDerivePBKDF2.HuksKeyPADDINGNONE, + HuksDerivePBKDF2.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 64% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js index 6210010937a41011b160365475a860b297aa3488..25ac4070b55dabeef601fbec03f5090aad10be4c 100644 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ -require("./Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js") +require('./Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js'); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_hmac_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..14b835e98c90ae4fbceaac4e13e5bfcb28751540 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksHmacBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksHmacbasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksHmacBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5f568dfc0d7be0d64e09123ae920f1116557f6 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + }, +}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8bfe363a9afb8417a8d06c743d9d792285e26923 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js @@ -0,0 +1,314 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import Data from '../../../../../../../utils/data.json'; +import { HuksHmac } from '../../../../../../../utils/param/hmac/publicHmacParam.js'; +import { stringToArray } from '../../../../../../../utils/param/publicFunc.js'; + +var handle; +let srcData63Kb = Data.Date63KB; +let srcData65Kb = Data.Date65KB; + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log( + 'test generateKey err information: ' + JSON.stringify(err) + ); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test generateKey err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + handle = data.handle; + resolve(data); + } + } catch (e) { + console.log('test init err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test update err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function finish(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test finish err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test finish err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function abort(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test abort err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test deleteKey err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +async function publicHmacUpdate(HuksOptions) { + let dateSize = 64 * 1024; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = stringToArray(HuksOptions.inData); + + if (HuksOptions.inData.length <= dateSize) { + HuksOptions.inData = new Uint8Array(inDataArray); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = huksOptionsInData; + } else { + let count = Math.floor(inDataArray.length / dateSize); + let remainder = inDataArray.length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice( + dateSize * count, + inDataArray.length + ) + ); + console.log(`test update HuksOptions.inData ${HuksOptions.inData}`); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + } +} + +async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + console.log( + 'test before generateKey HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log('test generateKey data = ' + JSON.stringify(data)); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); + + HuksOptions.properties.splice(1, 1); + console.log('test before init HuksOptions = ' + JSON.stringify(HuksOptions)); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); + console.log( + 'test before Update HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await publicHmacUpdate(HuksOptions); + + if (thirdInderfaceName == 'finish') { + HuksOptions.inData = new Uint8Array(stringToArray('0')); + console.log( + 'test before finish HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await finish(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + console.log( + 'test before abort HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${data}`); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + console.log( + 'test before deleteKey HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${data}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +describe('SecurityHuksHmacCallbackJsunit', function () { + it('testHmacSHA1001', 0, async function (done) { + let srcKeyAlies = 'testHmacDigestSHA1KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + + await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + it('testHmacSHA1002', 0, async function (done) { + let srcKeyAlies = 'testHmacDigestSHA1KeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); + it('testHmacSHA1003', 0, async function (done) { + let srcKeyAlies = 'testHmacDigestSHA1KeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + it('testHmacSHA1004', 0, async function (done) { + let srcKeyAlies = 'testHmacDigestSHA1KeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); +}); diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 88% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js index 6eec73e0c00044ed14cb4a84ab340fc0099942a7..c1577523b98849d3ccf760e7255cf16e5f3a3954 100644 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require("./HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js") \ No newline at end of file +require('./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_hmac_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ce4accfe9ba41aea3da5847cb58b6111c327473a --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksHmacBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksHmacbasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksHmacBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5f568dfc0d7be0d64e09123ae920f1116557f6 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + }, +}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..dc07a64217be0fb8a2f5ae988e2fd88cf28368d3 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js @@ -0,0 +1,206 @@ +/* + * 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 { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import Data from '../../../../../../../utils/data.json'; +import { HuksHmac } from '../../../../../../../utils/param/hmac/publicHmacParam.js'; +import { stringToArray } from '../../../../../../../utils/param/publicFunc.js'; + +var handle; +let srcData63Kb = Data.Date63KB; +let srcData65Kb = Data.Date65KB; + +async function publicHmacGenFunc(srcKeyAlies, HuksOptions) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.properties.splice(1, 1); +} + +async function publicHmacInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then(async (data) => { + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); +} + +async function publicHmacUpdateFunc(HuksOptions) { + let dateSize = 64 * 1024; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = stringToArray(HuksOptions.inData); + if (inDataArray.length < dateSize) { + HuksOptions.inData = new Uint8Array(inDataArray); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } else { + let count = Math.floor(inDataArray.length / dateSize); + let remainder = inDataArray.length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + await update(handle, HuksOptions); + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice( + dateSize * count, + inDataArray.length + ) + ); + await update(handle, HuksOptions); + } + } +} + +async function publicHmacFinish(HuksOptions, thirdInderfaceName) { + if (thirdInderfaceName == 'finish') { + HuksOptions.inData = new Uint8Array(stringToArray('0')); + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + err); + expect(null).assertFail(); + }); + } else if (thirdInderfaceName == 'abort') { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + err); + expect(null).assertFail(); + }); + } +} + +async function publicHmacDelete(srcKeyAlies, HuksOptions) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicHmacFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { + try { + await publicHmacGenFunc(srcKeyAlies, HuksOptions); + await publicHmacInitFunc(srcKeyAlies, HuksOptions); + await publicHmacUpdateFunc(HuksOptions); + await publicHmacFinish(HuksOptions, thirdInderfaceName); + await publicHmacDelete(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +describe('SecurityHuksHmacBasicPromiseJsunit', function () { + it('testHmac101', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + it('testHmac102', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); + + it('testHmac103', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + it('testHmac104', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); +}); diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 88% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js index 102a1825c43d1ceef16cbfc150f3623c21a37912..7fcc13c26e75c15732b62e9daab90180ceb7f4be 100644 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require("./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js") \ No newline at end of file +require('./HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js'); diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_signverify_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c33854cb2e6d9b9b88553b4d79f9581f037169db --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksSignVerifyBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukssignverifybasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksSignVerifyBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json similarity index 95% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json index 4b8cd464b428020eeda0531241cf77d994adf111..43adac6f31ad96cb52b69cf81ad678657eeb2440 100644 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json @@ -61,4 +61,4 @@ } ] } -} +} \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5f568dfc0d7be0d64e09123ae920f1116557f6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + }, +}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4487b0266ae2d71e42cdb032b79e4b34c99f7032 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -0,0 +1,28 @@ +/* + * 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('./SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..035fc8051b3ae8d0c777dd4b9769392fefef50c4 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..95895d8d4ed68464948eecc48d4ea8c8c91ce961 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,44 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); + +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7bff51dc60d5d457a6a5ead1e13f1755f7cf2f9c --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..490b801c3029771538b7acf019bb32098dc12735 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d8a9591ec62ee94ffc24f47716e330e6068fdd5d --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..cb986da792396057c9e1dd1eafa110340ae0e5a6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..45db6668f847c448e73bc7ed44f2c1601d7b2cd6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..279d6b8bf83f8ea9aa17a3ec29a59482d158e0f0 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..36f4de9239b3cfe7e498a277d1e0513b5b932221 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js @@ -0,0 +1,141 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyED25519 } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyED25519CallbackJsunit', function () { + it('testSignVerifyED25519001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testSignVerifyED25519003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..61fc28e2a1c4bca6230e4d05fa298a039fef087a --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,47 @@ +/* + + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); + +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f0945bfadef115c1b90a6257e15e8b4ea4e7cd86 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,44 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..de55c6474b5e7c5d758104b062375f2dfdaeebfe --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,61 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..dce3cdd51bbe70b19a0dc7adb75aa9d4d5a75a60 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,61 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_signverify_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..8375b5d603eb47b8418a85d36c0f2c57697eb281 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksSignVerifyBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukssignverifybasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksSignVerifyBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json similarity index 95% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json index 2f8af3d84a63cff16a2915d9bf5f805bbe4e0ef0..f0674418eb36e508bd3cdea30d6872d157f00f0a 100644 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json @@ -61,4 +61,4 @@ } ] } -} +} \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5f568dfc0d7be0d64e09123ae920f1116557f6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * 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'); + }, +}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..f42c43b7cced3e43b1af3bbebb744df6c21f8d4f --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.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; + } +} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..b73c0cda6eb1bf1c44a794156fd2f4a0dffc94e7 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * 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 { Core, ExpectExtend } 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', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..94a5e5897052bc948fec85c3b42170f26f0899b0 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -0,0 +1,28 @@ +/* + * 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('./SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksED25519BasicPromiseJsunit.test'); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ee369309d6a24ac3b22ef0d9d4fecc415ee8efce --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3f76d1261e1e9714698f13b6138f84fd535dd9a5 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6eb95fec69445cf6822f814960d7bd556e5e4f0d --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..db70b9f297319d412c1b6646a3658225f1b52f88 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8ce919a55fbe1e01840a3fd5ea5c8991209ecd99 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e5665962919041737b3f5a6ccb75f8df60012ef7 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..54882eaf98c83a8778370164d26d4d82d869f813 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5e579de4586ee974043b3d8633ab55d4df5ab696 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3bba46b1d4d28497d20e92a6c721402c279be17d --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js @@ -0,0 +1,141 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyED25519 } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyED25519PromiseJsunit', function () { + it('testSignVerifyED25519101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testSignVerifyED25519103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..09aee608bae09698e077336b42640e3693e4077f --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,44 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c0c5cab9ecba999ee920116c166aa1a72f0e4193 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,45 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f92b7bd072454a14ac8dc7db4298098543673f77 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,61 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4d89223149507ca727352284e9b31fb92197f503 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,62 @@ +/* + * 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 { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 0000000000000000000000000000000000000000..d7bc32507efcead9a811ada467661cb683992314 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * 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. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/utils/data.json b/security/security_huks_basic/utils/data.json similarity index 99% rename from security/security_huks/utils/data.json rename to security/security_huks_basic/utils/data.json index 58a84a288eaff79b4cb7c2fabfef614640404fb0..1c896754aa12c36d0606997da8d168fa6bbd2043 100644 --- a/security/security_huks/utils/data.json +++ b/security/security_huks_basic/utils/data.json @@ -1,6 +1,6 @@ { - "Date65KB": "ccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "Data65b": "eeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "Data63b": "eeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +} \ No newline at end of file diff --git a/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js new file mode 100644 index 0000000000000000000000000000000000000000..5281c557595d7910502ef4687f9ccd4eb013a577 --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js @@ -0,0 +1,270 @@ +/* + * 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 { HksTag, HksKeyStorageType, HksKeyAlg } from '../publicParam'; +import { HuksAgreeECDH } from './publicAgreeParam.js'; +import { stringToUint8Array } from '../publicFunc.js'; +import { expect } from 'deccjsunit/index'; +let exportKeyFrist; +let exportKeySecond; +let handle; + +async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { + await exportKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (exportKeys == 1) { + exportKeyFrist = data.outData; + } else { + exportKeySecond = data.outData; + } + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeUpdateFunc(HuksOptions, exportKey) { + let _inData = HuksOptions.inData; + if (exportKey == 1) { + HuksOptions.inData = exportKeySecond; + } else { + HuksOptions.inData = exportKeyFrist; + } + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _inData; +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeFinishAbortFunc( + HuksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` + ); + await finish(handle, HuksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let HuksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await abort(handle, HuksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +function abort(handle, HuksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +function finish(handle, HuksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test finish err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeFunc( + srcKeyAliesFrist, + srcKeyAliesSecond, + HuksOptions, + HuksOptionsFinish, + thirdInderfaceName +) { + try { + await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); + await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2); + + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_ECC) { + HuksOptions.properties.splice(0, 1, HuksAgreeECDH.HuksKeyAlgECDH); + HuksOptions.properties.splice(3, 1); + HuksOptions.properties.splice(4, 1); + HuksOptions.properties.splice(5, 1); + } + + await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 1); + await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); + + let tempHuksOptionsFinish = HuksOptionsFinish; + let HuksOptionsFinishSecond = tempHuksOptionsFinish; + HuksOptionsFinishSecond.properties.splice(6, 1, { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesSecond + 'final'), + }); + + await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 2); + await publicAgreeFinishAbortFunc( + HuksOptionsFinishSecond, + thirdInderfaceName + ); + + await publicAgreeDeleteFunc(srcKeyAliesFrist, HuksOptions); + if (thirdInderfaceName == 'finish') { + await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions); + } + await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} +export { publicAgreeFunc }; diff --git a/security/security_huks_basic/utils/param/agree/publicAgreeParam.js b/security/security_huks_basic/utils/param/agree/publicAgreeParam.js new file mode 100644 index 0000000000000000000000000000000000000000..73b72f03ba7f0393db363dca2dcb70629327617d --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreeParam.js @@ -0,0 +1,430 @@ +/* + * 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 * as param from '../publicParam'; + +let HuksAgreeDH = { + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_192, + }, + HuksKeyAlgDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DH, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeDH: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyDHSize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_2048, + }, + HuksKeyDHSize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_3072, + }, + HuksKeyDHSize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_4096, + }, +}; + +let HuksAgreeECDH = { + HuksKeyAlgECDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECDH, + }, + HuksKeyAlgECC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECC, + }, + HuksKeyECCSize224: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_224, + }, + HuksKeyECCSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeyECCSize384: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_384, + }, + HuksKeyECCSize521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyECCDIGEST: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyECCPADDING: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyECCBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_192, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeECDH: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, +}; + +let HuksKeyAlgX25519 = { + HuksKeyAlgX25519: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_X25519, + }, + HuksKeyPurposeAGREE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyCURVE25519Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_CURVE25519_KEY_SIZE_256, + }, + HuksKeyBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyPADDING: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyDIGEST: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_192, + }, + HuksKeyAlgDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DH, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeX25519: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyDHSize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_2048, + }, + HuksKeyDHSize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_3072, + }, + HuksKeyDHSize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_4096, + }, +}; +export { HuksAgreeDH, HuksAgreeECDH, HuksKeyAlgX25519 }; diff --git a/security/security_huks_basic/utils/param/agree/publicAgreePromise.js b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js new file mode 100644 index 0000000000000000000000000000000000000000..30361c3e60f6f1d3434e26d2e83abb900d583be4 --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js @@ -0,0 +1,185 @@ +/* + * 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 { HksTag, HksKeyStorageType, HksKeyAlg } from '../publicParam'; +import { HuksAgreeECDH } from './publicAgreeParam.js'; +import { stringToUint8Array } from '../publicFunc.js'; +import { expect } from 'deccjsunit/index'; +let exportKeyFrist; +let exportKeySecond; +let handle; + +async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { + await huks + .exportKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (exportKey == 1) { + exportKeyFrist = data.outData; + } else { + exportKeySecond = data.outData; + } + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeUpdateFunc(HuksOptions, exportKey) { + let _inData = HuksOptions.inData; + if (exportKey == 1) { + HuksOptions.inData = exportKeySecond; + } else { + HuksOptions.inData = exportKeyFrist; + } + await huks + .update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _inData; +} + +async function publicAgreeFinishAbortFunc( + HuksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` + ); + await huks + .finish(handle, HuksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let HuksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await huks + .abort(handle, HuksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeFunc( + srcKeyAliesFrist, + srcKeyAliesSecond, + HuksOptions, + HuksOptionsFinish, + thirdInderfaceName +) { + try { + await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); + await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2); + + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_ECC) { + HuksOptions.properties.splice(0, 1, HuksAgreeECDH.HuksKeyAlgECDH); + HuksOptions.properties.splice(3, 1); + HuksOptions.properties.splice(4, 1); + HuksOptions.properties.splice(5, 1); + } + + await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 1); + await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); + + let tempHuksOptionsFinish = HuksOptionsFinish; + let HuksOptionsFinishSecond = tempHuksOptionsFinish; + HuksOptionsFinishSecond.properties.splice(6, 1, { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesSecond + 'final'), + }); + + await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 2); + await publicAgreeFinishAbortFunc( + HuksOptionsFinishSecond, + thirdInderfaceName + ); + + await publicAgreeDeleteFunc(srcKeyAliesFrist, HuksOptions); + if (thirdInderfaceName == 'finish') { + await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions); + } + await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicAgreeFunc }; diff --git a/security/security_huks_basic/utils/param/cipher/publicCipherParam.js b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js new file mode 100644 index 0000000000000000000000000000000000000000..7f453f3d888933a3d0ad029e5fbe7ac845447c70 --- /dev/null +++ b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js @@ -0,0 +1,139 @@ +/* + * 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 * as param from '../publicParam'; + +let HuksCipherAES = { + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeENCRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, + }, + HuksKeyPurposeDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyAESSize128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyAESSize192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyAESSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyAESPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyAESPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyAESBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyAESBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyAESBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyAESDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, +}; + +let HuksCipherRSA = { + HuksKeyAlgRSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_RSA, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeENCRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, + }, + HuksKeyPurposeDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyRSASize512: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyRSAPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyRSAPADDINGPKCS1V15: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS1_V1_5, + }, + HuksKeyRSAPADDINGOAEP: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_OAEP, + }, + HuksKeyRSABLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyRSADIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyRSADIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyRSADIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyRSADIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyRSADIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyRSADIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { HuksCipherAES, HuksCipherRSA }; diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js new file mode 100644 index 0000000000000000000000000000000000000000..f2946776ecce96ada8c01e6a84a2a4990b8061b9 --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js @@ -0,0 +1,226 @@ +/* + * 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 { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import * as paramPublic from './publicDeriveParam.js'; +import { HksTag, HksKeyStorageType } from '../publicParam'; +let handle; + +async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + return HuksOptions; +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveUpdateFunc(HuksOptions) { + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveFinishAbortFunc( + huksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` + ); + await finish(handle, huksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let huksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await abort(handle, huksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +function abort(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +function finish(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { + console.log( + 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) + ); + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveFunc( + srcKeyAlies, + HuksOptions, + huksOptionsFinish, + thirdInderfaceName +) { + try { + await publicDeriveGenFunc(srcKeyAlies, HuksOptions); + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgHKDF + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE + ); + + await publicDeriveInitFunc(srcKeyAlies, HuksOptions); + await publicDeriveUpdateFunc(HuksOptions); + await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName); + + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgAES + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyHKDFSize128 + ); + await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicDeriveFunc }; diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveParam.js b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js new file mode 100644 index 0000000000000000000000000000000000000000..2bd05d7f1806bffc342d281afc5fe0cabb7dc0aa --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js @@ -0,0 +1,295 @@ +/* + * 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 * as param from '../publicParam'; + +let HuksDeriveHKDF = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_512, + }, + HuksKeyAlgHKDF: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HKDF, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurposeHKDF: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksTagHKDFDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagHKDFDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagHKDFDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyHKDFSize128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyHKDFSize192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyHKDFSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyDERIVEKEYSIZE: { + tag: param.HksTag.HKS_TAG_DERIVE_KEY_SIZE, + value: param.HksKeySize.DERIVE_KEY_SIZE_32, + }, + + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, +}; + +let HuksDerivePBKDF2 = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_512, + }, + HuksKeyAlgPBKDF2: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_PBKDF2, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurposePBKDF2: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksTagPBKDF2DigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPBKDF2DigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPBKDF2DigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPBKDF2Size128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyPBKDF2Size192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPBKDF2Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyDERIVEKEYSIZE: { + tag: param.HksTag.HKS_TAG_DERIVE_KEY_SIZE, + value: param.HksKeySize.DERIVE_KEY_SIZE_32, + }, + + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, +}; + +export { HuksDeriveHKDF, HuksDerivePBKDF2 }; diff --git a/security/security_huks_basic/utils/param/derive/publicDerivePromise.js b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js new file mode 100644 index 0000000000000000000000000000000000000000..b23ab18614fcb1d80084b493c8ac23a5bf906fd6 --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js @@ -0,0 +1,151 @@ +/* + * 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 { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import * as paramPublic from './publicDeriveParam.js'; +import { HksTag, HksKeyStorageType } from '../publicParam'; +let handle; +async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveUpdateFunc(HuksOptions) { + await huks + .update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveFinishAbortFunc( + huksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` + ); + await huks + .finish(handle, huksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let huksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await huks + .abort(handle, huksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { + console.log( + 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) + ); + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveFunc( + srcKeyAlies, + HuksOptions, + huksOptionsFinish, + thirdInderfaceName +) { + try { + await publicDeriveGenFunc(srcKeyAlies, HuksOptions); + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgHKDF + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE + ); + + await publicDeriveInitFunc(srcKeyAlies, HuksOptions); + await publicDeriveUpdateFunc(HuksOptions); + await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName); + + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgAES + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyHKDFSize128 + ); + await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicDeriveFunc }; diff --git a/security/security_huks_basic/utils/param/hmac/publicHmacParam.js b/security/security_huks_basic/utils/param/hmac/publicHmacParam.js new file mode 100644 index 0000000000000000000000000000000000000000..248eb36ea3b88f3123ae3442122496c133778abf --- /dev/null +++ b/security/security_huks_basic/utils/param/hmac/publicHmacParam.js @@ -0,0 +1,51 @@ +/* + * 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 * as param from '../publicParam'; + +let HuksHmac = { + HuksKeyAlg: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksTagDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { HuksHmac }; diff --git a/security/security_huks_basic/utils/param/publicFunc.js b/security/security_huks_basic/utils/param/publicFunc.js new file mode 100644 index 0000000000000000000000000000000000000000..3c71cb5ec2b060f074f731f1f286e4cb278d7376 --- /dev/null +++ b/security/security_huks_basic/utils/param/publicFunc.js @@ -0,0 +1,39 @@ +/* + * 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. + */ +function stringToArray(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return arr; +} + +function uint8ArrayToString(fileData) { + var dataString = ''; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} + +export { stringToArray, uint8ArrayToString, stringToUint8Array }; diff --git a/security/security_huks_basic/utils/param/publicParam.js b/security/security_huks_basic/utils/param/publicParam.js new file mode 100644 index 0000000000000000000000000000000000000000..350fbb7be77121dd5824f29ad18f6202e2e1d9f6 --- /dev/null +++ b/security/security_huks_basic/utils/param/publicParam.js @@ -0,0 +1,132 @@ +/* + * 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. + */ +let HksKeyAlg = { + HKS_ALG_ECDH: 100, + HKS_ALG_ECC: 2, + HKS_ALG_DH: 103, + HKS_ALG_AES: 20, + HKS_ALG_HMAC: 50, + HKS_ALG_X25519: 102, + HKS_ALG_RSA: 1, + HKS_ALG_PBKDF2: 52, + HKS_ALG_HKDF: 51, + HKS_ALG_DSA: 3, + HKS_ALG_ED25519: 102, +}; +let HksKeyPurpose = { + HKS_KEY_PURPOSE_AGREE: 256, + HKS_KEY_PURPOSE_DERIVE: 16, + HKS_KEY_PURPOSE_ENCRYPT: 1, + HKS_KEY_PURPOSE_DECRYPT: 2, + HKS_KEY_PURPOSE_MAC: 128, + HKS_KEY_PURPOSE_SIGN: 4, + HKS_KEY_PURPOSE_VERIFY: 8, +}; +let HksKeySize = { + HKS_ED25519_KEY_SIZE_512: 512, + HKS_RSA_KEY_SIZE_512: 512, + HKS_DH_KEY_SIZE_128: 128, + HKS_DH_KEY_SIZE_192: 192, + HKS_DH_KEY_SIZE_256: 256, + HKS_DH_KEY_SIZE_512: 512, + HKS_DH_KEY_SIZE_2048: 2048, + HKS_DH_KEY_SIZE_3072: 3072, + HKS_DH_KEY_SIZE_4096: 4096, + HKS_ECC_KEY_SIZE_128: 128, + HKS_ECC_KEY_SIZE_192: 192, + HKS_ECC_KEY_SIZE_224: 224, + HKS_ECC_KEY_SIZE_256: 256, + HKS_ECC_KEY_SIZE_384: 384, + HKS_ECC_KEY_SIZE_521: 521, + HKS_CURVE25519_KEY_SIZE_256: 256, + HKS_AES_KEY_SIZE_128: 128, + HKS_AES_KEY_SIZE_192: 192, + HKS_AES_KEY_SIZE_256: 256, + HKS_AES_KEY_SIZE_512: 512, + DERIVE_KEY_SIZE_32: 32, + HKS_RSA_KEY_SIZE_768: 768, + HKS_RSA_KEY_SIZE_1024: 1024, + HKS_RSA_KEY_SIZE_2048: 2048, + HKS_RSA_KEY_SIZE_3072: 3072, + HKS_RSA_KEY_SIZE_4096: 4096, + HKS_DSA_KEY_SIZE_512: 512, + HKS_DSA_KEY_SIZE_768: 768, + HKS_DSA_KEY_SIZE_1024: 1024, + HKS_DSA_KEY_SIZE_2048: 2048, + HKS_DSA_KEY_SIZE_3072: 3072, + HKS_DSA_KEY_SIZE_4096: 4096, +}; +let HksKeyStorageType = { + HKS_STORAGE_TEMP: 0, + HKS_STORAGE_PERSISTENT: 1, +}; +let HksTagType = { + HKS_TAG_TYPE_UINT: 2 << 28, + HKS_TAG_TYPE_BOOL: 4 << 28, + HKS_TAG_TYPE_BYTES: 5 << 28, +}; +let HksKeyDigest = { + HKS_DIGEST_NONE: 0, + HKS_DIGEST_MD5: 1, + HKS_DIGEST_SHA1: 10, + HKS_DIGEST_SHA224: 11, + HKS_DIGEST_SHA256: 12, + HKS_DIGEST_SHA384: 13, + HKS_DIGEST_SHA512: 14, +}; +let HksKeyPadding = { + HKS_PADDING_NONE: 0, + HKS_PADDING_OAEP: 1, + HKS_PADDING_PSS: 2, + HKS_PADDING_PKCS1_V1_5: 3, + HKS_PADDING_PKCS5: 4, + HKS_PADDING_PKCS7: 5, +}; +let HksCipherMode = { + HKS_MODE_ECB: 1, + HKS_MODE_CBC: 2, + HKS_MODE_CTR: 3, + HKS_MODE_OFB: 4, + HKS_MODE_CCM: 31, + HKS_MODE_GCM: 32, +}; +let HksTag = { + HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, + HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, + HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, + HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, + HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, + HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, + HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, + HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, + HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, + HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, + HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, + HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, + HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, + HKS_TAG_AE_TAG: HksTagType.HKS_TAG_TYPE_BYTES | 10009, + HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, +}; +export { + HksKeyPurpose, + HksKeyAlg, + HksTagType, + HksTag, + HksKeySize, + HksKeyDigest, + HksKeyStorageType, + HksCipherMode, + HksKeyPadding, +}; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js new file mode 100644 index 0000000000000000000000000000000000000000..bd489c6b02b0f71d8cf7e1fb1ab4e71ec23247c2 --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js @@ -0,0 +1,353 @@ +/* + * 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 { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HksKeyAlg } from '../publicParam.js'; +import { HuksSignVerifyDSA } from './publicSignverifyParam.js'; +import { stringToUint8Array, uint8ArrayToString } from '../publicFunc.js'; +let finishOutData; +let exportKey; +let handle; + +async function publicGenerateKeyFunc(keyAlias, HuksOptions) { + await generateKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicImportKey(keyAlias, HuksOptions) { + let _InData = HuksOptions.inData; + HuksOptions.inData = finishOutData; + console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await importKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _InData; +} + +function importKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test importKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test importKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicExportKey(keyAlias, HuksOptions) { + await exportkey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + finishOutData = data.outData; + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(keyAlias, HuksOptions) { + await init(keyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions, isBigData) { + let dateSize = 0; + if (isBigData) { + dateSize = 64 * 1024; + } else { + dateSize = 64; + } + let tempHuksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + if (uint8ArrayToString(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } else { + let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); + let remainder = uint8ArrayToString(inDataArray).length % dateSize; + console.log( + `test before update length: ${uint8ArrayToString(inDataArray).length}` + ); + console.log(`test before update count: ${count}`); + console.log(`test before update remainder: ${remainder}`); + for (let i = 0; i < count; i++) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishFunc(HuksOptions) { + await finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finish(handle, HuksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAbortFucn(HuksOptions) { + await abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abort(handle, HuksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { + await deleteKey(KeyAlias, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + thirdInderfaceName, + isSING, + isBigData +) { + try { + let keyAlias = srcKeyAlies; + if (isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 0, HuksSignVerifyDSA.HuksKeySIZE1024); + } + await publicGenerateKeyFunc(keyAlias, HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 1); + } + } else { + keyAlias = newSrcKeyAlies; + await publicImportKey(keyAlias, HuksOptions); + } + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await publicInitFunc(keyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions, isBigData); + if (thirdInderfaceName == 'finish') { + if (isSING) { + HuksOptions.outData = new Uint8Array(new Array(1024)); + await publicFinishFunc(HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + console.log( + `test before exportKey Gen_HuksOptions: ${JSON.stringify( + HuksOptions + )}` + ); + await publicExportKey(keyAlias, HuksOptions); + } else { + HuksOptions.outData = exportKey; + await publicFinishFunc(HuksOptions); + } + } else { + await publicAbortFucn(HuksOptions); + } + if (isSING && thirdInderfaceName == 'abort') { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } else if (!isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY + ); + await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions); + } + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicSignVerifyFunc }; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js new file mode 100644 index 0000000000000000000000000000000000000000..0eac5b2636ae86f6c3ea34b3f68a71d2f0e8099b --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js @@ -0,0 +1,277 @@ +/* + * 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 * as param from '../publicParam'; +let DSA_COMMON_SIZE = 1024; +let HuksSignVerifyDSA = { + HuksTagDSACOMMONSIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: DSA_COMMON_SIZE, + }, + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DSA_KEY_SIZE_512, + }, + HuksKeySIZE1024: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DSA_KEY_SIZE_1024, + }, + HuksKeyAlgDSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DSA, + }, + HuksKeyDSAPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyDSAPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagDSADigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagDSADigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagDSADigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagDSADigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagDSADigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, +}; + +let HuksSignVerifyECC = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyAlgECC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECC, + }, + HuksKeyECCPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyECCPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagECCDigestNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksTagECCDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagECCDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagECCDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagECCDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagECCDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyECCSize224: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_224, + }, + HuksKeyECCSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeyECCSize384: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_384, + }, + HuksKeyECCSize521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyECCPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, +}; + +let HuksSignVerifyED25519 = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ED25519_KEY_SIZE_512, + }, + HuksKeyAlgED25519: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ED25519, + }, + HuksKeyED25519Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_CURVE25519_KEY_SIZE_256, + }, + HuksKeyED25519PurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyED25519PurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, +}; + +let HuksSignVerifyRSA = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyAlgRSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_RSA, + }, + HuksKeyRSASize512: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyRSASize768: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_768, + }, + HuksKeyRSASize1024: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_1024, + }, + HuksKeyRSASize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_2048, + }, + HuksKeyRSASize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_3072, + }, + HuksKeyRSASize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_4096, + }, + HuksKeyRSAPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyRSAPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPADDINGPKCS1V15: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS1_V1_5, + }, + HuksKeyRSAPADDINGPSS: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PSS, + }, + HuksTagPKCS1DigestMD5: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_MD5, + }, + HuksTagPKCS1DigestNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksTagPKCS1DigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagPKCS1DigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagPKCS1DigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPKCS1DigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPKCS1DigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksTagPSSDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagPSSDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagPSSDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPSSDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPSSDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { + HuksSignVerifyRSA, + HuksSignVerifyDSA, + HuksSignVerifyECC, + HuksSignVerifyED25519, +}; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js new file mode 100644 index 0000000000000000000000000000000000000000..cb88c852b22a069b6f99f127f153c1b6230b2767 --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js @@ -0,0 +1,259 @@ +/* + * 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 { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HksKeyAlg } from '../publicParam.js'; +import { HuksSignVerifyDSA } from './publicSignverifyParam.js'; +import { stringToUint8Array, uint8ArrayToString } from '../publicFunc.js'; +let finishOutData; +let exportKey; +let handle; + +async function publicGenerateKeyFunc(keyAlias, HuksOptions) { + await huks + .generateKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicImportKey(keyAlias, HuksOptions) { + let _InData = HuksOptions.inData; + HuksOptions.inData = finishOutData; + console.log(`test ImportKey keyAlias: ${keyAlias}`); + console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .importKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _InData; +} + +async function publicExportKey(keyAlias, HuksOptions) { + await huks + .exportKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + finishOutData = data.outData; + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(keyAlias, HuksOptions) { + await huks + .init(keyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions, isBigData) { + let dateSize = 0; + if (isBigData) { + dateSize = 64 * 1024; + } else { + dateSize = 64; + } + let tempHuksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + if (uint8ArrayToString(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } else { + let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); + let remainder = uint8ArrayToString(inDataArray).length % dateSize; + console.log( + `test before update length: ${uint8ArrayToString(inDataArray).length}` + ); + console.log(`test before update count: ${count}`); + console.log(`test before update remainder: ${remainder}`); + for (let i = 0; i < count; i++) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishFunc(HuksOptions) { + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAbortFucn(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { + await huks + .deleteKey(KeyAlias, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + thirdInderfaceName, + isSING, + isBigData +) { + try { + let keyAlias = srcKeyAlies; + if (isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 0, HuksSignVerifyDSA.HuksKeySIZE1024); + } + await publicGenerateKeyFunc(keyAlias, HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 1); + } + } else { + keyAlias = newSrcKeyAlies; + await publicImportKey(keyAlias, HuksOptions); + } + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await publicInitFunc(keyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions, isBigData); + if (thirdInderfaceName == 'finish') { + if (isSING) { + HuksOptions.outData = new Uint8Array(new Array(1024).fill('')); + console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); + console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); + await publicFinishFunc(HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + console.log( + `test before exportKey Gen_HuksOptions: ${JSON.stringify( + HuksOptions + )}` + ); + await publicExportKey(keyAlias, HuksOptions); + } else { + HuksOptions.outData = exportKey; + console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); + console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); + await publicFinishFunc(HuksOptions); + } + } else { + await publicAbortFucn(HuksOptions); + } + if (isSING && thirdInderfaceName == 'abort') { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } else if (!isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY + ); + await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions); + } + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicSignVerifyFunc };