diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js index dcd18ff59d53e45b903eb1320e2118ab97c2dc38..f390ea5794b79fd279cf2652f40cb1cff96c1eb2 100644 --- a/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/src/main/js/test/HMAC/SecurityHuksImportJsunit.test.js @@ -25,64 +25,6 @@ import { HuksKeyAlgX25519, HuksAgreeECDH } from '../../../../../../utils/param/a let IV = '0000000000000000'; let srcData63 = Data.Data63b; let srcData63Kb = stringToUint8Array(srcData63); -let inputEccPair = new Uint8Array([ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0xa5, 0xb8, 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43, - 0x9d, 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d, - 0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a, - 0x10, 0xf0, 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b, - 0xad, 0xee, 0x34, 0x35, 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a, - 0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f, - 0x9e, 0x3c, 0xe5, 0xf9]); -let inputECCKey = new Uint8Array([ - 0x5b, 0x00, 0x00, 0x00, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, - 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc0, - 0xfe, 0x1c, 0x67, 0xde, 0x86, 0x0e, 0xfb, 0xaf, 0xb5, 0x85, 0x52, 0xb4, 0x0e, 0x1f, 0x6c, 0x6c, - 0xaa, 0xc5, 0xd9, 0xd2, 0x4d, 0xb0, 0x8a, 0x72, 0x24, 0xa1, 0x99, 0xaf, 0xfc, 0x3e, 0x55, 0x5a, - 0xac, 0x99, 0x3d, 0xe8, 0x34, 0x72, 0xb9, 0x47, 0x9c, 0xa6, 0xd8, 0xfb, 0x00, 0xa0, 0x1f, 0x9f, - 0x7a, 0x41, 0xe5, 0x44, 0x3e, 0xb2, 0x76, 0x08, 0xa2, 0xbd, 0xe9, 0x41, 0xd5, 0x2b, 0x9e, 0x10, - 0x00, 0x00, 0x00, 0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31, 0x35, 0x14, 0x69, 0x12, 0x57, - 0x9c, 0xc8, 0xb7, 0x10, 0x00, 0x00, 0x00, 0x2d, 0xb7, 0xf1, 0x5a, 0x0f, 0xb8, 0x20, 0xc5, 0x90, - 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x43, 0x25, 0x1b, 0x2f, 0x5b, - 0x86, 0xd8, 0x87, 0x04, 0x4d, 0x38, 0xc2, 0x65, 0xcc, 0x9e, 0xb7, 0x20, 0x00, 0x00, 0x00, 0xf4, - 0xe8, 0x93, 0x28, 0x0c, 0xfa, 0x4e, 0x11, 0x6b, 0xe8, 0xbd, 0xa8, 0xe9, 0x3f, 0xa7, 0x8f, 0x2f, - 0xe3, 0xb3, 0xbf, 0xaf, 0xce, 0xe5, 0x06, 0x2d, 0xe6, 0x45, 0x5d, 0x19, 0x26, 0x09, 0xe7, 0x10, - 0x00, 0x00, 0x00, 0xf4, 0x1e, 0x7b, 0x01, 0x7a, 0x84, 0x36, 0xa4, 0xa8, 0x1c, 0x0d, 0x3d, 0xde, - 0x57, 0x66, 0x73, 0x10, 0x00, 0x00, 0x00, 0xe3, 0xff, 0x29, 0x97, 0xad, 0xb3, 0x4a, 0x2c, 0x50, - 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x10, 0x00, 0x00, 0x00, 0x26, 0xae, 0xdc, 0x4e, 0xa5, - 0x6e, 0xb1, 0x38, 0x14, 0x24, 0x47, 0x1c, 0x41, 0x89, 0x63, 0x11, 0x04, 0x00, 0x00, 0x00, 0x20, - 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xcb, 0xa9, 0xa8, 0x5f, 0x5a, 0x9d, 0xbf, 0xa1, - 0xfc, 0x72, 0x74, 0x87, 0x79, 0xf2, 0xf4, 0x22, 0x0c, 0x8a, 0x4d, 0xd8, 0x7e, 0x10, 0xc8, 0x44, - 0x17, 0x95, 0xab, 0x3b, 0xd2, 0x8f, 0x0a -]); - -let inputX25519Pair = new Uint8Array([ - 0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x9c, 0xf6, 0x7a, 0x8d, 0xce, 0xc2, 0x7f, 0xa7, 0xd9, 0xfd, 0xf1, 0xad, - 0xac, 0xf0, 0xb3, 0x8c, 0xe8, 0x16, 0xa2, 0x65, 0xcc, 0x18, 0x55, 0x60, 0xcd, 0x2f, 0xf5, 0xe5, - 0x72, 0xc9, 0x3c, 0x54, 0x20, 0xd5, 0xbb, 0x54, 0x6f, 0x1f, 0x00, 0x30, 0x4e, 0x33, 0x38, 0xb9, - 0x8e, 0x6a, 0xdf, 0xad, 0x33, 0x6f, 0x51, 0x23, 0xff, 0x4d, 0x95, 0x26, 0xdc, 0xb0, 0x74, 0xb2, - 0x5c, 0x7e, 0x85, 0x6c]); -let inputX25519Key = new Uint8Array([ - 0x20, 0x00, 0x00, 0x00, 0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a, - 0x82, 0xe3, 0x35, 0xfb, 0xa8, 0x8e, 0x0e, 0x10, 0x71, 0x65, 0x22, 0x98, 0x8a, 0x75, 0x94, 0xeb, - 0x01, 0x32, 0xa0, 0x41, 0x10, 0x00, 0x00, 0x00, 0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31, - 0x35, 0x14, 0x69, 0x12, 0x57, 0x9c, 0xc8, 0xb7, 0x10, 0x00, 0x00, 0x00, 0x2d, 0xb7, 0xf1, 0x5a, - 0x0f, 0xb8, 0x20, 0xc5, 0x90, 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, - 0x4d, 0xcc, 0xa1, 0x39, 0x68, 0x38, 0xb7, 0x6b, 0xeb, 0xdc, 0x61, 0x6a, 0xe8, 0xe2, 0x47, 0x4b, - 0x20, 0x00, 0x00, 0x00, 0xfa, 0x88, 0xdb, 0x7b, 0x01, 0x89, 0xce, 0x6b, 0x86, 0x09, 0x0a, 0x3d, - 0x3d, 0xb0, 0x80, 0x2b, 0x35, 0x01, 0xdf, 0xa4, 0xb2, 0x3b, 0x58, 0xf3, 0xf2, 0x20, 0xcb, 0x42, - 0x71, 0xf8, 0x91, 0x73, 0x10, 0x00, 0x00, 0x00, 0xf4, 0x1e, 0x7b, 0x01, 0x7a, 0x84, 0x36, 0xa4, - 0xa8, 0x1c, 0x0d, 0x3d, 0xde, 0x57, 0x66, 0x73, 0x10, 0x00, 0x00, 0x00, 0xe3, 0xff, 0x29, 0x97, - 0xad, 0xb3, 0x4a, 0x2c, 0x50, 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x10, 0x00, 0x00, 0x00, - 0xed, 0x0e, 0x12, 0x2d, 0x6b, 0x3d, 0xb3, 0x44, 0xdc, 0x9f, 0xc3, 0xb8, 0xb7, 0x25, 0xff, 0x99, - 0x04, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x25, 0x78, 0xc2, 0xd2, - 0x91, 0x75, 0x1c, 0x82, 0xb9, 0xc9, 0x2b, 0xa8, 0x9e, 0xf3, 0x65, 0x0a, 0x02, 0x8a, 0xaa, 0x96, - 0x26, 0x81, 0x3c, 0x9b, 0xbe, 0x26, 0xfc, 0x7b, 0x7b, 0xca, 0x7d, 0xcb, 0x7e, 0x07, 0x0e, 0xdd, - 0xa3, 0x9b, 0xc5, 0x52, 0xff, 0x8c, 0xe2, 0x4f, 0x8d, 0x64, 0x04, 0x48, 0x79, 0x80, 0x1e, 0x44, - 0xc8, 0xf2, 0x49, 0x07, 0xfc, 0xaa, 0xd5, 0x7e, 0x4d, 0xf9, 0x72, 0x68, 0xda, 0x05, 0xb7, 0x1f, - 0xf8, 0xca, 0x75, 0xb8, 0x55, 0x14, 0xe9, 0xa4, 0x4b, 0xb1, 0x85, 0x28, 0xae, 0xe2, 0xb6, 0x1b -]); let aes128Key = new Uint8Array([ 0x20, 0x00, 0x00, 0x00, 0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a @@ -453,114 +395,6 @@ let dsa2048Key = new Uint8Array([ 0x62, 0x69, 0xce, 0xee, 0x53, 0x2a, 0x7c, 0xec, 0x46, 0x5c, 0x51, 0x33, ]); -function makeImportECCOptions() { - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ECC - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, - }; - let options = { properties: properties, inData: inputEccPair }; - return options; -}; - -function makeImportECCOptions2() { - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE - }; - properties[5] = { - tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, - value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING - }; - let options = { properties: properties }; - return options; -}; - -function makeImportX25519Options() { - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_X25519 - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256 - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, - }; - let options = { properties: properties, inData: inputX25519Pair }; - return options; -}; - -function makeImportX25519Options2() { - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_ED25519 - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256 - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE, - value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR, - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE, - value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING - }; - let options = { properties: properties }; - return options; -}; - async function publicGenerateKeyFunc(keyAlias, HuksOptions) { await huks .generateKey(keyAlias, HuksOptions) @@ -598,29 +432,6 @@ async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { }); } -async function TestImportWrappedFunc(alias, wrappingAlias, options) { - let result = await huks.importWrappedKey(alias, wrappingAlias, options); - if (result.errorCode === 0) { - console.error('test importWrappedKey success'); - expect(result.errorCode == 0).assertTrue(); - } else { - console.error('test importWrappedKey fail'); - expect(null).assertFail(); - } -} - -async function TestImportWrappedKeyECCFunc(alias, wrappingAlias, genOptions, importOptions) { - await publicImportKey(wrappingAlias, genOptions); - importOptions.inData = inputECCKey; - await TestImportWrappedFunc(alias, wrappingAlias, importOptions); -} - -async function TestImportWrappedKeyX25519Func(alias, wrappingAlias, genOptions, importOptions) { - await publicImportKey(wrappingAlias, genOptions); - importOptions.inData = inputX25519Key; - await TestImportWrappedFunc(alias, wrappingAlias, importOptions); -} - export function SecurityHuksImportJsunit() { describe('SecurityHuksImportJsunit', function () { it('HUKS_Basic_Capability_Import_0100', 0, async function (done) { @@ -666,28 +477,6 @@ describe('SecurityHuksImportJsunit', function () { done(); }); - it('HUKS_Basic_Capability_Import_0300', 0, async function (done) { - const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_0300'; - const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_0300Wrap'; - let genOptionsECC = makeImportECCOptions(); - let importOptionsECC = makeImportECCOptions2(); - await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC); - await publicDeleteKeyFunc(srcKeyAlies1, genOptionsECC); - await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC); - done(); - }); - - it('HUKS_Basic_Capability_Import_0400', 0, async function (done) { - const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_0400'; - const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_0400Wrap'; - let genOptionsX25519 = makeImportX25519Options(); - let importOptionsX25519 = makeImportX25519Options2(); - await TestImportWrappedKeyX25519Func(srcKeyAlies1, srcKeyAlies2, genOptionsX25519, importOptionsX25519); - await publicDeleteKeyFunc(srcKeyAlies1, genOptionsX25519); - await publicDeleteKeyFunc(srcKeyAlies2, importOptionsX25519); - done(); - }); - it('HUKS_Basic_Capability_Import_0500', 0, async function (done) { const srcKeyAlies = 'HUKS_Basic_Capability_Import_0500'; let HuksOptions = { @@ -1077,44 +866,6 @@ describe('SecurityHuksImportJsunit', function () { done(); }); - it('HUKS_Basic_Capability_Import_2600', 0, async function (done) { - const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_2600'; - const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_2600Wrap'; - let genOptionsECC = makeImportECCOptions(); - let importOptionsECC = makeImportECCOptions2(); - await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC); - await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC); - await publicDeleteKeyFunc(srcKeyAlies1, genOptionsECC); - await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC); - done(); - }); - - it('HUKS_Basic_Capability_Import_2700', 0, async function (done) { - const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_2700_ECC'; - const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_2700_ECCWrap'; - const srcKeyAlies4 = 'HUKS_Basic_Capability_Import_2700_X25519Wrap'; - let genOptionsECC = makeImportECCOptions(); - let importOptionsECC = makeImportECCOptions2(); - let genOptionsx25519 = makeImportX25519Options(); - let importOptionsx25519 = makeImportX25519Options2(); - await publicImportKey(srcKeyAlies2, genOptionsECC); - importOptionsECC.inData = inputECCKey; - await publicImportKey(srcKeyAlies4, genOptionsx25519); - importOptionsx25519.inData = inputECCKey; - await huks.importWrappedKey(srcKeyAlies1, srcKeyAlies2, importOptionsx25519) - .then((data) => { - console.error(`test ImportKey data: ${JSON.stringify(data)}`); - expect(data.errorCode == -31).assertTrue(); - }) - .catch((err) => { - console.error('test exportKey err information: ' + JSON.stringify(err)); - expect(err.code == -31).assertTrue(); - }); - await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC); - await publicDeleteKeyFunc(srcKeyAlies4, genOptionsx25519); - done(); - }); - it('HUKS_Basic_Capability_Import_2800', 0, async function (done) { const srcKeyAlies = 'HUKS_Basic_Capability_Import_2800'; let HuksOptions = { diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js deleted file mode 100644 index b8918dd754bcf019dc86bff49c9bcecdd21ae141..0000000000000000000000000000000000000000 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/HMAC/SecurityHuksFaceFingerNormalJsunit.test.js +++ /dev/null @@ -1,931 +0,0 @@ -/*software - * Copyright (C) 2022 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 systemTime from "@ohos.systemTime"; -import { describe, it, expect } from "@ohos/hypium"; - -let securityLevel = stringToUint8Array("sec_level"); -let challenge = stringToUint8Array("challenge_data"); -let versionInfo = stringToUint8Array("version_info"); -let keyAliasString = "key attest"; - -function attestKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.attestKey(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 stringToUint8Array(str) { - let arr = []; - for (let i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)); - } - let tmpUint8Array = new Uint8Array(arr); - return tmpUint8Array; -} - -function usePinNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFaceNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFingerNormal(inData) { - var propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - var aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function usePinAndFaceNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN | - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function usePinAndFingerNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN | - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFaceAndFingerNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE | - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function usePinFaceFingerNormal(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN | - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE | - huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NORMAL, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function usePinMulti(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_CUSTOM, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFaceMulti(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_CUSTOM, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFingerMulti(inData) { - var propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_CUSTOM, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: 0, - }; - var aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function usePinTime(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_PIN, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NONE, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_AUTH_TIMEOUT, - value: 10, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFaceTime(inData) { - let propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FACE, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NONE, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_AUTH_TIMEOUT, - value: 10, - }; - let aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -function useFingerTime(inData) { - var propertiesWithPin = new Array(); - propertiesWithPin[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_AES, - }; - propertiesWithPin[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256, - }; - propertiesWithPin[2] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | - huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT, - }; - propertiesWithPin[3] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_NONE, - }; - propertiesWithPin[4] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_CBC, - }; - propertiesWithPin[5] = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: huks.HuksUserAuthType.HUKS_USER_AUTH_TYPE_FINGERPRINT, - }; - propertiesWithPin[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - propertiesWithPin[7] = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: huks.HuksChallengeType.HUKS_CHALLENGE_TYPE_NONE, - }; - propertiesWithPin[8] = { - tag: huks.HuksTag.HUKS_TAG_AUTH_TIMEOUT, - value: 10, - }; - var aes256 = { - properties: propertiesWithPin, - inData: inData, - }; - return aes256; -} - -async function generateKeyAttest(alias) { - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ALGORITHM, - value: huks.HuksKeyAlg.HUKS_ALG_RSA, - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_KEY_STORAGE_FLAG, - value: huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT, - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_KEY_SIZE, - value: huks.HuksKeySize.HUKS_RSA_KEY_SIZE_2048, - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_PURPOSE, - value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY, - }; - properties[4] = { - tag: huks.HuksTag.HUKS_TAG_DIGEST, - value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256, - }; - properties[5] = { - tag: huks.HuksTag.HUKS_TAG_PADDING, - value: huks.HuksKeyPadding.HUKS_PADDING_PSS, - }; - properties[6] = { - tag: huks.HuksTag.HUKS_TAG_KEY_GENERATE_TYPE, - value: huks.HuksKeyGenerateType.HUKS_KEY_GENERATE_TYPE_DEFAULT, - }; - properties[7] = { - tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE, - value: huks.HuksCipherMode.HUKS_MODE_ECB, - }; - let options = { - properties: properties, - }; - await huks.generateKey(alias, options); -} - -export default function SecurityHuksFaceFingerNormalJsunit() { - describe("SecurityHuksFaceFingerNormalJsunit", function () { - /** - * @tc.number HUKS_Cipher_AuthToken_2900 - * @tc.name HUKS_Cipher_AuthToken_2900. - * @tc.desc HUKS_TAG_USER_AUTH_TYPE invalid and generate. - */ - it("HUKS_Cipher_AuthToken_2900", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_2900"; - let inData = new Uint8Array(new Array()); - let option = usePinNormal(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_USER_AUTH_TYPE, - value: -1, - }; - option.properties.splice(5, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -3).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_AuthToken_3000 - * @tc.name HUKS_Cipher_AuthToken_3000. - * @tc.desc HUKS_TAG_KEY_AUTH_ACCESS_TYPE invalid and generate. - */ - it("HUKS_Cipher_AuthToken_3000", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_3000"; - let inData = new Uint8Array(new Array()); - let option = usePinNormal(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: -1, - }; - option.properties.splice(6, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -4).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_AuthToken_3100 - * @tc.name HUKS_Cipher_AuthToken_3100. - * @tc.desc HUKS_TAG_CHALLENGE_TYPE invalid and generate. - */ - it("HUKS_Cipher_AuthToken_3100", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_3100"; - let inData = new Uint8Array(new Array()); - let option = usePinNormal(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_TYPE, - value: -1, - }; - option.properties.splice(7, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -3).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_AuthToken_3200 - * @tc.name HUKS_Cipher_AuthToken_3200. - * @tc.desc HUKS_TAG_CHALLENGE_POS invalid and generate. - */ - it("HUKS_Cipher_AuthToken_3200", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_3200"; - let inData = new Uint8Array(new Array()); - let option = usePinNormal(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_CHALLENGE_POS, - value: -1, - }; - option.properties.splice(8, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -4).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_AuthToken_3300 - * @tc.name HUKS_Cipher_AuthToken_3300. - * @tc.desc HUKS_TAG_AUTH_TIMEOUT invalid and generate. - */ - it("HUKS_Cipher_AuthToken_3300", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_3300"; - let inData = new Uint8Array(new Array()); - let option = usePinTime(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_AUTH_TIMEOUT, - value: -1, - }; - option.properties.splice(8, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -3).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_AuthToken_5500 - * @tc.name HUKS_Cipher_AuthToken_5500. - * @tc.desc use pin access type is HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL. - */ - it("HUKS_Cipher_AuthToken_5500", 0, async function (done) { - let alias = "HUKS_Cipher_AuthToken_5500"; - let inData = new Uint8Array(new Array()); - let option = usePinNormal(inData); - let err = { - tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE, - value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL, - }; - option.properties.splice(6, 1, err); - await huks - .generateKey(alias, option) - .then(async (data) => { - console.error(`generateKey success ${JSON.stringify(data)}`); - expect(data.errorCode == -3).assertTrue(); - }) - .catch((err) => { - console.error(`generateKey err: " + ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - done(); - }); - - /** - * @tc.number HUKS_Cipher_Attestation_0300 - * @tc.name HUKS_Cipher_Attestation_0300. - * @tc.desc attest key support. - */ - it("HUKS_Cipher_Attestation_0300", 0, async function (done) { - let aliasString = keyAliasString; - let aliasUint8 = stringToUint8Array(aliasString); - let properties = new Array(); - properties[0] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO, - value: securityLevel, - }; - properties[1] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_CHALLENGE, - value: challenge, - }; - properties[2] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_VERSION_INFO, - value: versionInfo, - }; - properties[3] = { - tag: huks.HuksTag.HUKS_TAG_ATTESTATION_ID_ALIAS, - value: aliasUint8, - }; - let options = { - properties: properties, - }; - await generateKeyAttest(aliasString); - await huks - .attestKey(aliasString, options) - .then((data) => { - console.log(`attest key data: ${JSON.stringify(data)}`); - expect(data.certChains.length > 0).assertTrue(); - expect(data.errorCode == 0).assertTrue(); - }) - .catch((err) => { - console.error(`attest key data: ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - - await attestKey(aliasString, options) - .then((data) => { - console.log("test generateKey data: " + JSON.stringify(data)); - expect(data.errorCode == 0).assertTrue(); - }) - .catch((err) => { - console.error(`test init err: ${JSON.stringify(err)}`); - expect(null).assertFail(); - }); - - done(); - }); - }); -} diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/List.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/List.test.js index 11afedb70673a5ea5dca25046869e38a2b629f47..fca2eeabca9e3957e7ccc86fe4171ce630cb1671 100644 --- a/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/src/main/js/test/List.test.js @@ -14,8 +14,6 @@ */ import SecurityHuksHmacBasicPromiseJsunit from './HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js' -import SecurityHuksFaceFingerNormalJsunit from './HMAC/SecurityHuksFaceFingerNormalJsunit.test.js' export default function testsuite() { SecurityHuksHmacBasicPromiseJsunit() -SecurityHuksFaceFingerNormalJsunit() }