提交 483ffc59 编写于 作者: Q Qwink2016

modify huks case number

Signed-off-by: NQwink2016 <714794360@qq.com>
上级 43da29a8
......@@ -854,6 +854,8 @@ export function SecurityHuksAccessControlJsunit() {
expect(1342197283).assertEqual(
huks.HuksTag.HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA
);
expect(0).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_TEMP );
expect(1).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT);
done();
});
});
......
......@@ -13,11 +13,11 @@
* limitations under the License.
*/
import { describe, it, expect } from '@ohos/hypium';
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';
import { describe, it, expect } from "@ohos/hypium";
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;
......@@ -28,13 +28,15 @@ function generateKey(srcKeyAlies, HuksOptions) {
huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test generateKey err information: ' + JSON.stringify(err));
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));
console.log("test generateKey err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -46,14 +48,14 @@ function init(srcKeyAlies, HuksOptions) {
huks.init(srcKeyAlies, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test init err information: ' + JSON.stringify(err));
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));
console.log("test init err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -65,13 +67,13 @@ function update(handle, HuksOptions) {
huks.update(handle, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test update err information: ' + JSON.stringify(err));
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));
console.log("test update err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -83,13 +85,13 @@ function finish(handle, HuksOptions) {
huks.finish(handle, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test finish err information: ' + JSON.stringify(err));
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));
console.log("test finish err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -101,13 +103,13 @@ function abort(handle, HuksOptions) {
huks.abort(handle, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test abort err information: ' + JSON.stringify(err));
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));
console.log("test abort err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -119,13 +121,13 @@ function deleteKey(srcKeyAlies, HuksOptions) {
huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) {
try {
if (err.code !== 0) {
console.log('test deleteKey err information: ' + JSON.stringify(err));
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));
console.log("test deleteKey err information: " + JSON.stringify(e));
reject(e);
}
});
......@@ -144,7 +146,7 @@ async function publicHmacUpdate(HuksOptions) {
console.log(`test update data: ${data}`);
})
.catch((err) => {
console.log('test update err information: ' + JSON.stringify(err));
console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail();
});
HuksOptions.inData = huksOptionsInData;
......@@ -152,25 +154,32 @@ async function publicHmacUpdate(HuksOptions) {
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)));
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));
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));
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));
console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail();
});
}
......@@ -181,7 +190,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE);
await generateKey(srcKeyAlies, HuksOptions)
.then((data) => {
console.log('test generateKey data = ' + JSON.stringify(data));
console.log("test generateKey data = " + JSON.stringify(data));
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
......@@ -199,14 +208,14 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
});
await publicHmacUpdate(HuksOptions);
if (thirdInderfaceName == 'finish') {
HuksOptions.inData = new Uint8Array(stringToArray('0'));
if (thirdInderfaceName == "finish") {
HuksOptions.inData = new Uint8Array(stringToArray("0"));
await finish(handle, HuksOptions)
.then((data) => {
console.log(`test update data: ${data}`);
})
.catch((err) => {
console.log('test update err information: ' + JSON.stringify(err));
console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail();
});
} else {
......@@ -215,7 +224,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
console.log(`test abort data: ${data}`);
})
.catch((err) => {
console.log('test abort err information: ' + JSON.stringify(err));
console.log("test abort err information: " + JSON.stringify(err));
expect(null).assertFail();
});
}
......@@ -226,161 +235,120 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test deleteKey err information: ' + JSON.stringify(err));
console.log("test deleteKey err information: " + JSON.stringify(err));
expect(null).assertFail();
});
}
export function SecurityHuksHmacBasicCallbackJsunit_test() {
describe('SecurityHuksHmacBasicCallbackJsunit_test', 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();
});
});
}
export function SecurityHuksHmacCallbackJsunit() {
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,
};
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();
});
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();
});
it('testHmacSM3001', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias001';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
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();
});
it("testHmacSM3001", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias001";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish');
done();
});
await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done();
});
it('testHmacSM3002', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias002';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort');
done();
});
it('testHmacSM3003', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias003';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish');
done();
});
it('testHmacSM3004', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias004';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort');
done();
it("testHmacSM3002", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias002";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done();
});
it("testHmacSM3003", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias003";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done();
});
it("testHmacSM3004", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias004";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done();
});
});
});
}
......@@ -13,12 +13,11 @@
* limitations under the License.
*/
import {SecurityHuksAccessControlJsunit} from './HMAC/SecurityHuksAccessControlJsunit.test.js'
import {SecurityHuksHmacBasicCallbackJsunit_test, SecurityHuksHmacCallbackJsunit} from './HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js'
import {SecurityHuksImportJsunit} from './HMAC/SecurityHuksImportJsunit.test.js'
import { SecurityHuksAccessControlJsunit } from "./HMAC/SecurityHuksAccessControlJsunit.test.js";
import { SecurityHuksHmacCallbackJsunit } from "./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js";
import { SecurityHuksImportJsunit } from "./HMAC/SecurityHuksImportJsunit.test.js";
export default function testsuite() {
SecurityHuksAccessControlJsunit()
SecurityHuksHmacBasicCallbackJsunit_test()
SecurityHuksHmacCallbackJsunit()
SecurityHuksImportJsunit()
SecurityHuksAccessControlJsunit();
SecurityHuksHmacCallbackJsunit();
SecurityHuksImportJsunit();
}
......@@ -12,1923 +12,1397 @@
* 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';
import huks from "@ohos.security.huks";
import systemTime from "@ohos.systemTime";
import { describe, it, expect } from "@ohos/hypium";
let hks_default_auth_token_key = 'huks_default_user_auth_token_key';
let hks_default_auth_token_key = "huks_default_user_auth_token_key";
const authTokenSize = 116;
let authToken = new Uint8Array(authTokenSize);
let authTokenData = new Uint8Array(authTokenSize - 32);
let aes256Key = new Uint8Array([
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
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,
]);
let securityLevel = stringToUint8Array('sec_level');
let challenge = stringToUint8Array('challenge_data');
let versionInfo = stringToUint8Array('version_info');
let securityLevel = stringToUint8Array("sec_level");
let challenge = stringToUint8Array("challenge_data");
let versionInfo = stringToUint8Array("version_info");
let keyAliasString = "key attest";
function stringToArray(str) {
let arr = [];
for (let i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
return arr;
};
let arr = [];
for (let i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
return arr;
}
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;
};
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 makeEmptyOption() {
let emptyOption = {
properties: []
};
return emptyOption;
};
let emptyOption = {
properties: [],
};
return emptyOption;
}
function uintXToBytes(value, Xbit, buffer, index) {
let bytes = Xbit / 8;
let bytes = Xbit / 8;
for (let i = 1; i <= bytes; i++) {
buffer[index++] = (value >> ((i - 1) * 8)) & 0xFF;
}
};
for (let i = 1; i <= bytes; i++) {
buffer[index++] = (value >> ((i - 1) * 8)) & 0xff;
}
}
function copyBytes(bytesBuffer, byteLen, buffer, index) {
for (let i = 0; i < byteLen; i++) {
buffer[index++] = bytesBuffer[i];
}
};
for (let i = 0; i < byteLen; i++) {
buffer[index++] = bytesBuffer[i];
}
}
function copyByteTo(bytesBuffer, pos, start, end) {
for (let i = start; i <= end; i++) {
pos[i] = bytesBuffer[i];
}
for (let i = start; i <= end; i++) {
pos[i] = bytesBuffer[i];
}
}
function makeAESKeyOptions() {
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
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_NONE
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_IV,
value: new Uint8Array(16)
};
let options = {
properties: properties
};
return options;
};
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,
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC,
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_IV,
value: new Uint8Array(16),
};
let options = {
properties: properties,
};
return options;
}
function makeAESKeyOptionsWithAuthToken(authToken) {
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
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_NONE
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_AUTH_TOKEN,
value: authToken
};
let options = {
properties: properties
};
return options;
};
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,
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_NONE,
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC,
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_AUTH_TOKEN,
value: authToken,
};
let options = {
properties: properties,
};
return options;
}
async function generateAuthToken(
importAliasHmac,
importHmacOption,
challenge,
secureUid,
authType,
enrollId,
time
importAliasHmac,
importHmacOption,
challenge,
secureUid,
authType,
enrollId,
time
) {
uintXToBytes(0, 32, authTokenData, 0); // version
uintXToBytes(secureUid, 32, authTokenData, 36);
uintXToBytes(0, 32, authTokenData, 40);
uintXToBytes(enrollId, 32, authTokenData, 44);
uintXToBytes(0, 32, authTokenData, 48);
uintXToBytes(0, 64, authTokenData, 52);
uintXToBytes(time, 32, authTokenData, 60);
uintXToBytes(0, 32, authTokenData, 64);
uintXToBytes(0, 32, authTokenData, 68);
uintXToBytes(authType, 32, authTokenData, 72);
uintXToBytes(0, 32, authTokenData, 76);
uintXToBytes(0, 32, authTokenData, 80);
// 导入Hmac key
await huks.importKey(importAliasHmac, importHmacOption).then(async (data) => {
console.error(`generateAuthToken importKey data ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`generateAuthToken importKey err: " + ${JSON.stringify(err)}`);
uintXToBytes(0, 32, authTokenData, 0); // version
uintXToBytes(secureUid, 32, authTokenData, 36);
uintXToBytes(0, 32, authTokenData, 40);
uintXToBytes(enrollId, 32, authTokenData, 44);
uintXToBytes(0, 32, authTokenData, 48);
uintXToBytes(0, 64, authTokenData, 52);
uintXToBytes(time, 32, authTokenData, 60);
uintXToBytes(0, 32, authTokenData, 64);
uintXToBytes(0, 32, authTokenData, 68);
uintXToBytes(authType, 32, authTokenData, 72);
uintXToBytes(0, 32, authTokenData, 76);
uintXToBytes(0, 32, authTokenData, 80);
// 导入Hmac key
await huks
.importKey(importAliasHmac, importHmacOption)
.then(async (data) => {
console.error(`generateAuthToken importKey data ${JSON.stringify(data)}`);
})
.catch((err) => {
console.error(
`generateAuthToken importKey err: " + ${JSON.stringify(err)}`
);
});
// 使用三段式对Authtoken进行HMAC
let handle;
// HksInit初始化key
let initHmacOption = makeHmacKeyOption(false, null);
await huks.init(importAliasHmac, initHmacOption).then(async (data) => {
handle = data.handle;
}).catch((err) => {
console.error(`generateAuthToken test init err: " + ${JSON.stringify(err)}`);
// 使用三段式对Authtoken进行HMAC
let handle;
// HksInit初始化key
let initHmacOption = makeHmacKeyOption(false, null);
await huks
.init(importAliasHmac, initHmacOption)
.then(async (data) => {
handle = data.handle;
})
.catch((err) => {
console.error(
`generateAuthToken test init err: " + ${JSON.stringify(err)}`
);
});
copyBytes(challenge, 32, authTokenData, 4);
// finish完成签名
let finishHmacOption = makeHmacKeyOption(true, authTokenData);
await huks.finish(handle, finishHmacOption).then((data) => {
console.error(`generateAuthToken test finish data ${JSON.stringify(data)}`);
copyBytes(data.outData, 32, authToken, 84); // copy sign to authToken
copyBytes(authTokenData, 84, authToken, 0); // copy authToken data to authToken
}).catch((err) => {
console.error('generateAuthToken test finish err information: ' + err);
copyBytes(challenge, 32, authTokenData, 4);
// finish完成签名
let finishHmacOption = makeHmacKeyOption(true, authTokenData);
await huks
.finish(handle, finishHmacOption)
.then((data) => {
console.error(
`generateAuthToken test finish data ${JSON.stringify(data)}`
);
copyBytes(data.outData, 32, authToken, 84); // copy sign to authToken
copyBytes(authTokenData, 84, authToken, 0); // copy authToken data to authToken
})
.catch((err) => {
console.error("generateAuthToken test finish err information: " + err);
});
};
}
function makeHmacKeyOption(isImportKey, inKey) {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_HMAC
};
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_MAC
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
if (isImportKey) {
let optionsWithIndata = {
properties: properties,
inData: inKey
};
return optionsWithIndata;
} else {
let optionsWithoutIndata = {
properties: properties,
};
return optionsWithoutIndata;
}
};
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_HMAC,
};
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_MAC,
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256,
};
if (isImportKey) {
let optionsWithIndata = {
properties: properties,
inData: inKey,
};
return optionsWithIndata;
} else {
let optionsWithoutIndata = {
properties: properties,
};
return optionsWithoutIndata;
}
}
async function generateAndInit(mode, alies, aes256) {
console.error(`${alies} sudato!`);
if (mode == 'generate') {
await huks.generateKey(alies, aes256).then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
};
if (mode == 'import') {
await huks.importKey(alies, aes256).then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
};
await huks.getKeyProperties(alies, makeEmptyOption()).then(async (data) => {
console.error(`test finish data ${JSON.stringify(data)}`);
console.error(`${alies} sudato!`);
if (mode == "generate") {
await huks
.generateKey(alies, aes256)
.then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
})
.catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
}
if (mode == "import") {
await huks
.importKey(alies, aes256)
.then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
}
await huks
.getKeyProperties(alies, makeEmptyOption())
.then(async (data) => {
console.error(`test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
let initAesOption = makeAESKeyOptions();
// HksInit初始化key
let data = await huks.init(alies, initAesOption).then(async (data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(data)}`);
return data;
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
return err;
let initAesOption = makeAESKeyOptions();
// HksInit初始化key
let data = await huks
.init(alies, initAesOption)
.then(async (data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(
data
)}`
);
return data;
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
return err;
});
console.error(`${alies} doing!`);
return data;
console.error(`${alies} doing!`);
return data;
}
async function multiIdentify(
importAliasHmac,
importHmacOption,
alies,
aes256,
authMode
importAliasHmac,
importHmacOption,
alies,
aes256,
authMode
) {
await huks.generateKey(alies, aes256).then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
await huks
.generateKey(alies, aes256)
.then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error(`generateKey err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
let challengeAll = new Uint8Array(32);
let handle1, challenge1;
let handle2, challenge2;
let handle3, challenge3;
let handle4, challenge4;
let initAesOption = makeAESKeyOptions();
await huks.init(alies, initAesOption).then(async (data) => {
handle1 = data.handle;
challenge1 = data.token;
copyByteTo(challenge1, challengeAll, 0, 7);
console.error(`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
let challengeAll = new Uint8Array(32);
let handle1, challenge1;
let handle2, challenge2;
let handle3, challenge3;
let handle4, challenge4;
let initAesOption = makeAESKeyOptions();
await huks
.init(alies, initAesOption)
.then(async (data) => {
handle1 = data.handle;
challenge1 = data.token;
copyByteTo(challenge1, challengeAll, 0, 7);
console.error(
`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
await huks.init(alies, initAesOption).then(async (data) => {
handle2 = data.handle;
challenge2 = data.token;
copyByteTo(challenge2, challengeAll, 8, 16);
console.error(`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
await huks
.init(alies, initAesOption)
.then(async (data) => {
handle2 = data.handle;
challenge2 = data.token;
copyByteTo(challenge2, challengeAll, 8, 16);
console.error(
`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
await huks.init(alies, initAesOption).then(async (data) => {
handle3 = data.handle;
challenge3 = data.token;
copyByteTo(challenge3, challengeAll, 17, 24);
console.error(`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
await huks
.init(alies, initAesOption)
.then(async (data) => {
handle3 = data.handle;
challenge3 = data.token;
copyByteTo(challenge3, challengeAll, 17, 24);
console.error(
`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
await huks.init(alies, initAesOption).then(async (data) => {
handle4 = data.handle;
challenge4 = data.token;
copyByteTo(challenge4, challengeAll, 25, 32);
console.error(`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
await huks
.init(alies, initAesOption)
.then(async (data) => {
handle4 = data.handle;
challenge4 = data.token;
copyByteTo(challenge4, challengeAll, 25, 32);
console.error(
`HuksTest_AlgCompletion_AccessControl test init success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`test init err: " + ${JSON.stringify(err)}`);
expect(null).assertFail();
});
if (authMode == 'pin') {
await generateAuthToken(importAliasHmac, importHmacOption, challengeAll, 1, 1, 1, 0);
}
if (authMode == 'face') {
await generateAuthToken(importAliasHmac, importHmacOption, challengeAll, 1, 2, 3, 0);
}
if (authMode == 'finger') {
await generateAuthToken(importAliasHmac, importHmacOption, challengeAll, 1, 4, 2, 0);
}
let finishOption = makeAESKeyOptionsWithAuthToken(authToken);
await huks.finish(handle1, finishOption).then((data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error('test finish err information: ' + err);
expect(null).assertFail();
if (authMode == "pin") {
await generateAuthToken(
importAliasHmac,
importHmacOption,
challengeAll,
1,
1,
1,
0
);
}
if (authMode == "face") {
await generateAuthToken(
importAliasHmac,
importHmacOption,
challengeAll,
1,
2,
3,
0
);
}
if (authMode == "finger") {
await generateAuthToken(
importAliasHmac,
importHmacOption,
challengeAll,
1,
4,
2,
0
);
}
let finishOption = makeAESKeyOptionsWithAuthToken(authToken);
await huks
.finish(handle1, finishOption)
.then((data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(
data
)}`
);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error("test finish err information: " + err);
expect(null).assertFail();
});
await huks.finish(handle2, finishOption).then((data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error('test finish err information: ' + err);
expect(null).assertFail();
await huks
.finish(handle2, finishOption)
.then((data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(
data
)}`
);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error("test finish err information: " + err);
expect(null).assertFail();
});
await huks.finish(handle3, finishOption).then((data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error('test finish err information: ' + err);
expect(null).assertFail();
await huks
.finish(handle3, finishOption)
.then((data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(
data
)}`
);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error("test finish err information: " + err);
expect(null).assertFail();
});
await huks.finish(handle4, finishOption).then((data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err) => {
console.error('test finish err information: ' + err);
expect(null).assertFail();
await huks
.finish(handle4, finishOption)
.then((data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(
data
)}`
);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error("test finish err information: " + err);
expect(null).assertFail();
});
let deleteKeyOption = makeEmptyOption();
await huks.deleteKey(alies, deleteKeyOption).then(async (data) => {
console.error(`HuksTest_AlgCompletion_AccessControl deleteKey success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`deleteKey err: " + ${JSON.stringify(err)}`);
let deleteKeyOption = makeEmptyOption();
await huks
.deleteKey(alies, deleteKeyOption)
.then(async (data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl deleteKey success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`deleteKey err: " + ${JSON.stringify(err)}`);
});
}
async function finishStep(handle, alies, errCode) {
let finishOption = makeAESKeyOptionsWithAuthToken(authToken);
await huks.finish(handle, finishOption)
.then((data) => {
console.error(`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(data)}`);
expect(data.errorCode == errCode).assertTrue();
})
.catch((err) => {
console.error('test finish err information: ' + err);
expect(err.code == errCode).assertTrue();
});
let deleteKeyOption = makeEmptyOption();
let finishOption = makeAESKeyOptionsWithAuthToken(authToken);
await huks
.finish(handle, finishOption)
.then((data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl test finish data ${JSON.stringify(
data
)}`
);
expect(data.errorCode == errCode).assertTrue();
})
.catch((err) => {
console.error("test finish err information: " + err);
expect(err.code == errCode).assertTrue();
});
await huks.deleteKey(alies, deleteKeyOption).then(async (data) => {
console.error(`HuksTest_AlgCompletion_AccessControl deleteKey success ${JSON.stringify(data)}`);
}).catch((err) => {
console.error(`deleteKey err: " + ${JSON.stringify(err)}`);
let deleteKeyOption = makeEmptyOption();
await huks
.deleteKey(alies, deleteKeyOption)
.then(async (data) => {
console.error(
`HuksTest_AlgCompletion_AccessControl deleteKey success ${JSON.stringify(
data
)}`
);
})
.catch((err) => {
console.error(`deleteKey err: " + ${JSON.stringify(err)}`);
});
console.error(`${alies} end!`);
console.error(`${alies} end!`);
}
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
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_0100
* @tc.name HUKS_Cipher_AuthToken_0100.
* @tc.desc Generate Key and verify with PIN,use pin.
*/
it('HUKS_Cipher_AuthToken_0100', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0100';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0100_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0200
* @tc.name HUKS_Cipher_AuthToken_0200.
* @tc.desc Generate Key and verify with Face,use face.
*/
it('HUKS_Cipher_AuthToken_0200', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0200';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0200_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0300
* @tc.name HUKS_Cipher_AuthToken_0300.
* @tc.desc Generate Key and verify with Finger,use finger.
*/
it('HUKS_Cipher_AuthToken_0300', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0300';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0300_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0400
* @tc.name HUKS_Cipher_AuthToken_0400.
* @tc.desc Import Key and verify with PIN,use pin.
*/
it('HUKS_Cipher_AuthToken_0400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0400_HMAC';
let data = await generateAndInit('import', alias, usePinNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0500
* @tc.name HUKS_Cipher_AuthToken_0500.
* @tc.desc Import Key and verify with Face,use face.
*/
it('HUKS_Cipher_AuthToken_0500', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0500';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0500_HMAC';
let data = await generateAndInit('import', alias, useFaceNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0600
* @tc.name HUKS_Cipher_AuthToken_0600.
* @tc.desc Import Key and verify with Finger,use finger.
*/
it('HUKS_Cipher_AuthToken_0600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0600';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0600_HMAC';
let data = await generateAndInit('import', alias, useFingerNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0700
* @tc.name HUKS_Cipher_AuthToken_0700.
* @tc.desc Generate Key with PIN,falsify while verifying.
*/
it('HUKS_Cipher_AuthToken_0700', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0700';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0700_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
uintXToBytes(1, 32, authToken, 76);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_0900
* @tc.name HUKS_Cipher_AuthToken_0900.
* @tc.desc Imput a wrong PIN and could not verify.
*/
it('HUKS_Cipher_AuthToken_0900', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_0900';
let aliasHMAC = 'HUKS_Cipher_AuthToken_0900_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, aes256Key);
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1000
* @tc.name HUKS_Cipher_AuthToken_1000.
* @tc.desc Set a PIN and use fingerprint, could not verify.
*/
it('HUKS_Cipher_AuthToken_1000', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1000';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1000_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1100
* @tc.name HUKS_Cipher_AuthToken_1100.
* @tc.desc Clear Password,bio fail.
*/
it('HUKS_Cipher_AuthToken_1100', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1100';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1100_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 0, 1, 1, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1200
* @tc.name HUKS_Cipher_AuthToken_1200.
* @tc.desc Add a fingerprint,cound not verify.
*/
it('HUKS_Cipher_AuthToken_1200', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1200';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1200_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1300
* @tc.name HUKS_Cipher_AuthToken_1300.
* @tc.desc verify once and multi authorize with PIN.
*/
it('HUKS_Cipher_AuthToken_1300', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1300';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1300_HMAC';
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
multiIdentify(aliasHMAC, importHmacOption, alias, usePinMulti(inData), 'pin');
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1400
* @tc.name HUKS_Cipher_AuthToken_1400.
* @tc.desc verify once and multi authorize with finger.
*/
it('HUKS_Cipher_AuthToken_1400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1400_HMAC';
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
multiIdentify(aliasHMAC, importHmacOption, alias, useFingerMulti(inData), 'finger');
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1500
* @tc.name HUKS_Cipher_AuthToken_1500.
* @tc.desc verify once and multi authorize with face.
*/
it('HUKS_Cipher_AuthToken_1500', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1500';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1500_HMAC';
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
multiIdentify(aliasHMAC, importHmacOption, alias, useFaceMulti(inData), 'face');
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1600
* @tc.name HUKS_Cipher_AuthToken_1600.
* @tc.desc timestap based access control with pin,accessable in specified time.
*/
it('HUKS_Cipher_AuthToken_1600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1600';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1600_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinTime(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
let curTime = await systemTime.getRealTime(false);
await generateAuthToken(aliasHMAC, importHmacOption, curTime, 1, 1, 1, curTime + 10);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1700
* @tc.name HUKS_Cipher_AuthToken_1700.
* @tc.desc timestap based access control with pin,unaccessable outside specified time.
*/
it('HUKS_Cipher_AuthToken_1700', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_1700';
let aliasHMAC = 'HUKS_Cipher_AuthToken_1700_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinTime(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
let curTime = await systemTime.getRealTime(false);
await generateAuthToken(aliasHMAC, importHmacOption, curTime, 1, 1, 1, curTime + 12000);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2100
* @tc.name HUKS_Cipher_AuthToken_2100.
* @tc.desc Generate Key and verify with PIN and face,use pin.
*/
it('HUKS_Cipher_AuthToken_2100', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2100';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2100_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2200
* @tc.name HUKS_Cipher_AuthToken_2200.
* @tc.desc Generate Key and verify with PIN and finger,use pin.
*/
it('HUKS_Cipher_AuthToken_2200', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2200';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2200_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2300
* @tc.name HUKS_Cipher_AuthToken_2300.
* @tc.desc Generate Key and verify with face and finger,use face.
*/
it('HUKS_Cipher_AuthToken_2300', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2300';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2300_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2400
* @tc.name HUKS_Cipher_AuthToken_2400.
* @tc.desc Generate Key and verify with pin,face and finger,use pin.
*/
it('HUKS_Cipher_AuthToken_2400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2400_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinFaceFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2500
* @tc.name HUKS_Cipher_AuthToken_2500.
* @tc.desc Import Key and verify with pin and face,use pin.
*/
it('HUKS_Cipher_AuthToken_2500', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2500';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2500_HMAC';
let data = await generateAndInit('import', alias, usePinAndFaceNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2600
* @tc.name HUKS_Cipher_AuthToken_2600.
* @tc.desc Import Key and verify with pin and finger,use pin.
*/
it('HUKS_Cipher_AuthToken_2600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2600';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2600_HMAC';
let data = await generateAndInit('import', alias, usePinAndFingerNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2700
* @tc.name HUKS_Cipher_AuthToken_2700.
* @tc.desc Import Key and verify with face and finger,use face.
*/
it('HUKS_Cipher_AuthToken_2700', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2700';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2700_HMAC';
let data = await generateAndInit('import', alias, useFaceAndFingerNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_2800
* @tc.name HUKS_Cipher_AuthToken_2800.
* @tc.desc Import Key and verify with pin,face and finger,use finger.
*/
it('HUKS_Cipher_AuthToken_2800', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_2800';
let aliasHMAC = 'HUKS_Cipher_AuthToken_2800_HMAC';
let data = await generateAndInit('import', alias, usePinFaceFingerNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @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 == 0).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 == 0).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_3400
* @tc.name HUKS_Cipher_AuthToken_3400.
* @tc.desc input wrong face and unaccessable.
*/
it('HUKS_Cipher_AuthToken_3400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_3400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_3400_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, aes256Key);
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_3500
* @tc.name HUKS_Cipher_AuthToken_3500.
* @tc.desc input wrong finger and unaccessable.
*/
it('HUKS_Cipher_AuthToken_3500', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_3500';
let aliasHMAC = 'HUKS_Cipher_AuthToken_3500_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, aes256Key);
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_3600
* @tc.name HUKS_Cipher_AuthToken_3600.
* @tc.desc input key with pin,falsify while verifying.
*/
it('HUKS_Cipher_AuthToken_3600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_3600';
let aliasHMAC = 'HUKS_Cipher_AuthToken_3600_HMAC';
let data = await generateAndInit('import', alias, useFingerNormal(aes256Key));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
uintXToBytes(1, 32, authToken, 76);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4000
* @tc.name HUKS_Cipher_AuthToken_4000.
* @tc.desc generate with pin,use face.
*/
it('HUKS_Cipher_AuthToken_4000', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4000';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4000_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4100
* @tc.name HUKS_Cipher_AuthToken_4100.
* @tc.desc generate with face,use pin.
*/
it('HUKS_Cipher_AuthToken_4100', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4100';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4100_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4200
* @tc.name HUKS_Cipher_AuthToken_4200.
* @tc.desc generate with face,use finger.
*/
it('HUKS_Cipher_AuthToken_4200', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4200';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4200_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4300
* @tc.name HUKS_Cipher_AuthToken_4300.
* @tc.desc generate with finger,use pin.
*/
it('HUKS_Cipher_AuthToken_4300', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4300';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4300_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4400
* @tc.name HUKS_Cipher_AuthToken_4400.
* @tc.desc generate with finger,use face.
*/
it('HUKS_Cipher_AuthToken_4400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4400_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4500
* @tc.name HUKS_Cipher_AuthToken_4500.
* @tc.desc generate with face and finger,use pin.
*/
it('HUKS_Cipher_AuthToken_4500', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4500';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4500_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 1, 1, 0);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4600
* @tc.name HUKS_Cipher_AuthToken_4600.
* @tc.desc generate with face and finger,use finger
*/
it('HUKS_Cipher_AuthToken_4600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4600';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4600_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4700
* @tc.name HUKS_Cipher_AuthToken_4700.
* @tc.desc generate with pin and face,use finger.
*/
it('HUKS_Cipher_AuthToken_4700', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4700';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4700_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4800
* @tc.name HUKS_Cipher_AuthToken_4800.
* @tc.desc generate with pin and face,use face.
*/
it('HUKS_Cipher_AuthToken_4800', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4800';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4800_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFaceNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_4900
* @tc.name HUKS_Cipher_AuthToken_4900.
* @tc.desc generate with pin and finger,use finger.
*/
it('HUKS_Cipher_AuthToken_4900', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_4900';
let aliasHMAC = 'HUKS_Cipher_AuthToken_4900_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_5000
* @tc.name HUKS_Cipher_AuthToken_5000.
* @tc.desc generate with pin and finger,use face.
*/
it('HUKS_Cipher_AuthToken_5000', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5000';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5000_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinAndFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_5100
* @tc.name HUKS_Cipher_AuthToken_5100.
* @tc.desc generate with pin face and finger,use finger.
*/
it('HUKS_Cipher_AuthToken_5100', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5100';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5100_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinFaceFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 2, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_5200
* @tc.name HUKS_Cipher_AuthToken_5200.
* @tc.desc generate with pin face and finger,use face.
*/
it('HUKS_Cipher_AuthToken_5200', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5200';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5200_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinFaceFingerNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 2, 3, 0);
await finishStep(data.handle, alias, 0);
done();
});
describe("SecurityHuksFaceFingerNormalJsunit", function () {
/**
* @tc.number HUKS_Cipher_AuthToken_1300
* @tc.name HUKS_Cipher_AuthToken_1300.
* @tc.desc verify once and multi authorize with PIN.
*/
it("HUKS_Cipher_AuthToken_1300", 0, async function (done) {
let alias = "HUKS_Cipher_AuthToken_1300";
let aliasHMAC = "HUKS_Cipher_AuthToken_1300_HMAC";
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(
true,
stringToUint8Array(hks_default_auth_token_key)
);
multiIdentify(
aliasHMAC,
importHmacOption,
alias,
usePinMulti(inData),
"pin"
);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_5300
* @tc.name HUKS_Cipher_AuthToken_5300.
* @tc.desc add face ,could not verify.
*/
it('HUKS_Cipher_AuthToken_5300', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5300';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5300_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinNormal(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
await generateAuthToken(aliasHMAC, importHmacOption, data.token, 1, 4, 1, 0);
await finishStep(data.handle, alias, 0);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1400
* @tc.name HUKS_Cipher_AuthToken_1400.
* @tc.desc verify once and multi authorize with finger.
*/
it("HUKS_Cipher_AuthToken_1400", 0, async function (done) {
let alias = "HUKS_Cipher_AuthToken_1400";
let aliasHMAC = "HUKS_Cipher_AuthToken_1400_HMAC";
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(
true,
stringToUint8Array(hks_default_auth_token_key)
);
multiIdentify(
aliasHMAC,
importHmacOption,
alias,
useFingerMulti(inData),
"finger"
);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_5400
* @tc.name HUKS_Cipher_AuthToken_5400.
* @tc.desc timebased access,time before generate.
*/
it('HUKS_Cipher_AuthToken_5400', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5400';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5400_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, usePinTime(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
let curTime = systemTime.getRealTime(false).then(data => { return data; });
await generateAuthToken(aliasHMAC, importHmacOption, curTime, 1, 1, 1, curTime - 100000);
await finishStep(data.handle, alias, huks.HuksErrorCode.HUKS_ERROR_KEY_AUTH_FAILED);
done();
});
/**
* @tc.number HUKS_Cipher_AuthToken_1500
* @tc.name HUKS_Cipher_AuthToken_1500.
* @tc.desc verify once and multi authorize with face.
*/
it("HUKS_Cipher_AuthToken_1500", 0, async function (done) {
let alias = "HUKS_Cipher_AuthToken_1500";
let aliasHMAC = "HUKS_Cipher_AuthToken_1500_HMAC";
let inData = new Uint8Array(new Array());
let importHmacOption = makeHmacKeyOption(
true,
stringToUint8Array(hks_default_auth_token_key)
);
multiIdentify(
aliasHMAC,
importHmacOption,
alias,
useFaceMulti(inData),
"face"
);
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_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_5600
* @tc.name HUKS_Cipher_AuthToken_5600.
* @tc.desc use finger access type is HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD.
*/
it('HUKS_Cipher_AuthToken_5600', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5600';
let inData = new Uint8Array(new Array());
let option = useFaceNormal(inData);
let err = {
tag: huks.HuksTag.HUKS_TAG_KEY_AUTH_ACCESS_TYPE,
value: huks.HuksAuthAccessType.HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD
};
option.properties.splice(6, 1, err);
await huks.generateKey(alias, option).then(async (data) => {
console.error(`generateKey success ${JSON.stringify(data)}`);
expect(data.errorCode == 0).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_5700
* @tc.name HUKS_Cipher_AuthToken_5700.
* @tc.desc time based access finger,accessable in specified time.
*/
it('HUKS_Cipher_AuthToken_5700', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5700';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5700_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFingerTime(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
let curTime = await systemTime.getRealTime(false);
await generateAuthToken(aliasHMAC, importHmacOption, curTime, 1, 4, 2, curTime + 10);
await finishStep(data.handle, alias, 0);
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_5800
* @tc.name HUKS_Cipher_AuthToken_5800.
* @tc.desc time based access face,accessable in specified time.
*/
it('HUKS_Cipher_AuthToken_5800', 0, async function (done) {
let alias = 'HUKS_Cipher_AuthToken_5800';
let aliasHMAC = 'HUKS_Cipher_AuthToken_5800_HMAC';
let inData = new Uint8Array(new Array());
let data = await generateAndInit('generate', alias, useFaceTime(inData));
let importHmacOption = makeHmacKeyOption(true, stringToUint8Array(hks_default_auth_token_key));
let curTime = await systemTime.getRealTime(false);
await generateAuthToken(aliasHMAC, importHmacOption, curTime, 1, 2, 3, curTime + 10);
await finishStep(data.handle, alias, 0);
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.error(`attest key data: ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
}).catch((err)=>{
console.error(`attest key data: ${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.error(`attest key data: ${JSON.stringify(data)}`);
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.error(`attest key data: ${JSON.stringify(err)}`);
expect(null).assertFail();
});
done();
});
}
\ No newline at end of file
});
}
......@@ -13,11 +13,11 @@
* limitations under the License.
*/
import { describe, it, expect } from '@ohos/hypium';
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';
import { describe, it, expect } from "@ohos/hypium";
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;
......@@ -32,7 +32,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test generateKey err information: ' + JSON.stringify(err));
console.log("test generateKey err information: " + JSON.stringify(err));
expect(null).assertFail();
});
HuksOptions.properties.splice(1, 1);
......@@ -63,19 +63,26 @@ async function publicHmacUpdateFunc(HuksOptions) {
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)));
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));
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'));
if (thirdInderfaceName == "finish") {
HuksOptions.inData = new Uint8Array(stringToArray("0"));
await huks
.finish(handle, HuksOptions)
.then((data) => {
......@@ -83,10 +90,10 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test finish err information: ' + err);
console.log("test finish err information: " + err);
expect(null).assertFail();
});
} else if (thirdInderfaceName == 'abort') {
} else if (thirdInderfaceName == "abort") {
await huks
.abort(handle, HuksOptions)
.then((data) => {
......@@ -94,7 +101,7 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test abort err information: ' + err);
console.log("test abort err information: " + err);
expect(null).assertFail();
});
}
......@@ -109,7 +116,7 @@ async function publicHmacDelete(srcKeyAlies, HuksOptions) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test deleteKey err information: ' + JSON.stringify(err));
console.log("test deleteKey err information: " + JSON.stringify(err));
expect(null).assertFail();
});
}
......@@ -134,105 +141,124 @@ async function update(handle, HuksOptions) {
expect(data.errorCode == 0).assertTrue();
})
.catch((err) => {
console.log('test update err information: ' + err);
console.log("test update err information: " + err);
expect(null).assertFail();
});
}
export default function SecurityHuksHmacBasicPromiseJsunit() {
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();
});
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("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("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();
});
it('testHmacSM3001', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias001';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
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();
});
it('testHmacSM3002', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias002';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort');
done();
});
it('testHmacSM3003', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias003';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish');
done();
});
it('testHmacSM3004', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias004';
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort');
done();
it("testHmacSM3101", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias001";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done();
});
it("testHmacSM3102", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias002";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData63Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done();
});
it("testHmacSM3103", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias003";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done();
});
it("testHmacSM3104", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias004";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSM3
),
inData: srcData65Kb,
};
await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done();
});
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册