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

!5336 修改daily构建huks的异常用例

Merge pull request !5336 from Qwink2016/qwink20220831_0816
...@@ -854,6 +854,8 @@ export function SecurityHuksAccessControlJsunit() { ...@@ -854,6 +854,8 @@ export function SecurityHuksAccessControlJsunit() {
expect(1342197283).assertEqual( expect(1342197283).assertEqual(
huks.HuksTag.HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA 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(); done();
}); });
}); });
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, it, expect } from '@ohos/hypium'; import { describe, it, expect } from "@ohos/hypium";
import huks from '@ohos.security.huks'; import huks from "@ohos.security.huks";
import Data from '../../../../../../utils/data.json'; import Data from "../../../../../../utils/data.json";
import { HuksHmac } from '../../../../../../utils/param/hmac/publicHmacParam.js'; import { HuksHmac } from "../../../../../../utils/param/hmac/publicHmacParam.js";
import { stringToArray } from '../../../../../../utils/param/publicFunc.js'; import { stringToArray } from "../../../../../../utils/param/publicFunc.js";
var handle; var handle;
let srcData63Kb = Data.Date63KB; let srcData63Kb = Data.Date63KB;
...@@ -28,13 +28,15 @@ function generateKey(srcKeyAlies, HuksOptions) { ...@@ -28,13 +28,15 @@ function generateKey(srcKeyAlies, HuksOptions) {
huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test generateKey err information: ' + JSON.stringify(err)); console.log(
"test generateKey err information: " + JSON.stringify(err)
);
reject(err); reject(err);
} else { } else {
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test generateKey err information: ' + JSON.stringify(e)); console.log("test generateKey err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -46,14 +48,14 @@ function init(srcKeyAlies, HuksOptions) { ...@@ -46,14 +48,14 @@ function init(srcKeyAlies, HuksOptions) {
huks.init(srcKeyAlies, HuksOptions, function (err, data) { huks.init(srcKeyAlies, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test init err information: ' + JSON.stringify(err)); console.log("test init err information: " + JSON.stringify(err));
reject(err); reject(err);
} else { } else {
handle = data.handle; handle = data.handle;
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test init err information: ' + JSON.stringify(e)); console.log("test init err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -65,13 +67,13 @@ function update(handle, HuksOptions) { ...@@ -65,13 +67,13 @@ function update(handle, HuksOptions) {
huks.update(handle, HuksOptions, function (err, data) { huks.update(handle, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test update err information: ' + JSON.stringify(err)); console.log("test update err information: " + JSON.stringify(err));
reject(err); reject(err);
} else { } else {
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test update err information: ' + JSON.stringify(e)); console.log("test update err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -83,13 +85,13 @@ function finish(handle, HuksOptions) { ...@@ -83,13 +85,13 @@ function finish(handle, HuksOptions) {
huks.finish(handle, HuksOptions, function (err, data) { huks.finish(handle, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test finish err information: ' + JSON.stringify(err)); console.log("test finish err information: " + JSON.stringify(err));
reject(err); reject(err);
} else { } else {
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test finish err information: ' + JSON.stringify(e)); console.log("test finish err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -101,13 +103,13 @@ function abort(handle, HuksOptions) { ...@@ -101,13 +103,13 @@ function abort(handle, HuksOptions) {
huks.abort(handle, HuksOptions, function (err, data) { huks.abort(handle, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test abort err information: ' + JSON.stringify(err)); console.log("test abort err information: " + JSON.stringify(err));
reject(err); reject(err);
} else { } else {
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test abort err information: ' + JSON.stringify(e)); console.log("test abort err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -119,13 +121,13 @@ function deleteKey(srcKeyAlies, HuksOptions) { ...@@ -119,13 +121,13 @@ function deleteKey(srcKeyAlies, HuksOptions) {
huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) {
try { try {
if (err.code !== 0) { if (err.code !== 0) {
console.log('test deleteKey err information: ' + JSON.stringify(err)); console.log("test deleteKey err information: " + JSON.stringify(err));
reject(err); reject(err);
} else { } else {
resolve(data); resolve(data);
} }
} catch (e) { } catch (e) {
console.log('test deleteKey err information: ' + JSON.stringify(e)); console.log("test deleteKey err information: " + JSON.stringify(e));
reject(e); reject(e);
} }
}); });
...@@ -144,7 +146,7 @@ async function publicHmacUpdate(HuksOptions) { ...@@ -144,7 +146,7 @@ async function publicHmacUpdate(HuksOptions) {
console.log(`test update data: ${data}`); console.log(`test update data: ${data}`);
}) })
.catch((err) => { .catch((err) => {
console.log('test update err information: ' + JSON.stringify(err)); console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
HuksOptions.inData = huksOptionsInData; HuksOptions.inData = huksOptionsInData;
...@@ -152,25 +154,32 @@ async function publicHmacUpdate(HuksOptions) { ...@@ -152,25 +154,32 @@ async function publicHmacUpdate(HuksOptions) {
let count = Math.floor(inDataArray.length / dateSize); let count = Math.floor(inDataArray.length / dateSize);
let remainder = inDataArray.length % dateSize; let remainder = inDataArray.length % dateSize;
for (let i = 0; i < count; i++) { 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) await update(handle, HuksOptions)
.then((data) => { .then((data) => {
console.log(`test update data: ${data}`); console.log(`test update data: ${data}`);
}) })
.catch((err) => { .catch((err) => {
console.log('test update err information: ' + JSON.stringify(err)); console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
if (remainder !== 0) { 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}`); console.log(`test update HuksOptions.inData ${HuksOptions.inData}`);
await update(handle, HuksOptions) await update(handle, HuksOptions)
.then((data) => { .then((data) => {
console.log(`test update data: ${data}`); console.log(`test update data: ${data}`);
}) })
.catch((err) => { .catch((err) => {
console.log('test update err information: ' + JSON.stringify(err)); console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
...@@ -181,7 +190,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { ...@@ -181,7 +190,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE);
await generateKey(srcKeyAlies, HuksOptions) await generateKey(srcKeyAlies, HuksOptions)
.then((data) => { .then((data) => {
console.log('test generateKey data = ' + JSON.stringify(data)); console.log("test generateKey data = " + JSON.stringify(data));
}) })
.catch((err) => { .catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`); console.log(`test init err: " + ${JSON.stringify(err)}`);
...@@ -199,14 +208,14 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { ...@@ -199,14 +208,14 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
}); });
await publicHmacUpdate(HuksOptions); await publicHmacUpdate(HuksOptions);
if (thirdInderfaceName == 'finish') { if (thirdInderfaceName == "finish") {
HuksOptions.inData = new Uint8Array(stringToArray('0')); HuksOptions.inData = new Uint8Array(stringToArray("0"));
await finish(handle, HuksOptions) await finish(handle, HuksOptions)
.then((data) => { .then((data) => {
console.log(`test update data: ${data}`); console.log(`test update data: ${data}`);
}) })
.catch((err) => { .catch((err) => {
console.log('test update err information: ' + JSON.stringify(err)); console.log("test update err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
} else { } else {
...@@ -215,7 +224,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { ...@@ -215,7 +224,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
console.log(`test abort data: ${data}`); console.log(`test abort data: ${data}`);
}) })
.catch((err) => { .catch((err) => {
console.log('test abort err information: ' + JSON.stringify(err)); console.log("test abort err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
...@@ -226,56 +235,15 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { ...@@ -226,56 +235,15 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test deleteKey err information: ' + JSON.stringify(err)); console.log("test deleteKey err information: " + JSON.stringify(err));
expect(null).assertFail(); 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() { export function SecurityHuksHmacCallbackJsunit() {
describe('SecurityHuksHmacCallbackJsunit', function () { describe("SecurityHuksHmacCallbackJsunit", function () {
it('testHmacSHA1001', 0, async function (done) { it("testHmacSHA1001", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSHA1KeyAlias001'; let srcKeyAlies = "testHmacDigestSHA1KeyAlias001";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -285,12 +253,12 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -285,12 +253,12 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSHA1002', 0, async function (done) { it("testHmacSHA1002", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSHA1KeyAlias002'; let srcKeyAlies = "testHmacDigestSHA1KeyAlias002";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -299,11 +267,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -299,11 +267,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmacSHA1003', 0, async function (done) { it("testHmacSHA1003", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSHA1KeyAlias003'; let srcKeyAlies = "testHmacDigestSHA1KeyAlias003";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -312,11 +280,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -312,11 +280,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSHA1004', 0, async function (done) { it("testHmacSHA1004", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSHA1KeyAlias004'; let srcKeyAlies = "testHmacDigestSHA1KeyAlias004";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -325,11 +293,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -325,11 +293,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmacSM3001', 0, async function (done) { it("testHmacSM3001", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias001'; let srcKeyAlies = "testHmacDigestSM3KeyAlias001";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -339,12 +307,12 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -339,12 +307,12 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSM3002', 0, async function (done) { it("testHmacSM3002", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias002'; let srcKeyAlies = "testHmacDigestSM3KeyAlias002";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -353,11 +321,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -353,11 +321,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmacSM3003', 0, async function (done) { it("testHmacSM3003", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias003'; let srcKeyAlies = "testHmacDigestSM3KeyAlias003";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -366,11 +334,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -366,11 +334,11 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSM3004', 0, async function (done) { it("testHmacSM3004", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias004'; let srcKeyAlies = "testHmacDigestSM3KeyAlias004";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -379,8 +347,8 @@ describe('SecurityHuksHmacCallbackJsunit', function () { ...@@ -379,8 +347,8 @@ describe('SecurityHuksHmacCallbackJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacGenFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
}); });
} }
...@@ -13,12 +13,11 @@ ...@@ -13,12 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import {SecurityHuksAccessControlJsunit} from './HMAC/SecurityHuksAccessControlJsunit.test.js' import { SecurityHuksAccessControlJsunit } from "./HMAC/SecurityHuksAccessControlJsunit.test.js";
import {SecurityHuksHmacBasicCallbackJsunit_test, SecurityHuksHmacCallbackJsunit} from './HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js' import { SecurityHuksHmacCallbackJsunit } from "./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js";
import {SecurityHuksImportJsunit} from './HMAC/SecurityHuksImportJsunit.test.js' import { SecurityHuksImportJsunit } from "./HMAC/SecurityHuksImportJsunit.test.js";
export default function testsuite() { export default function testsuite() {
SecurityHuksAccessControlJsunit() SecurityHuksAccessControlJsunit();
SecurityHuksHmacBasicCallbackJsunit_test() SecurityHuksHmacCallbackJsunit();
SecurityHuksHmacCallbackJsunit() SecurityHuksImportJsunit();
SecurityHuksImportJsunit()
} }
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { describe, it, expect } from '@ohos/hypium'; import { describe, it, expect } from "@ohos/hypium";
import huks from '@ohos.security.huks'; import huks from "@ohos.security.huks";
import Data from '../../../../../../utils/data.json'; import Data from "../../../../../../utils/data.json";
import { HuksHmac } from '../../../../../../utils/param/hmac/publicHmacParam.js'; import { HuksHmac } from "../../../../../../utils/param/hmac/publicHmacParam.js";
import { stringToArray } from '../../../../../../utils/param/publicFunc.js'; import { stringToArray } from "../../../../../../utils/param/publicFunc.js";
var handle; var handle;
let srcData63Kb = Data.Date63KB; let srcData63Kb = Data.Date63KB;
...@@ -32,7 +32,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions) { ...@@ -32,7 +32,7 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test generateKey err information: ' + JSON.stringify(err)); console.log("test generateKey err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
HuksOptions.properties.splice(1, 1); HuksOptions.properties.splice(1, 1);
...@@ -63,19 +63,26 @@ async function publicHmacUpdateFunc(HuksOptions) { ...@@ -63,19 +63,26 @@ async function publicHmacUpdateFunc(HuksOptions) {
let count = Math.floor(inDataArray.length / dateSize); let count = Math.floor(inDataArray.length / dateSize);
let remainder = inDataArray.length % dateSize; let remainder = inDataArray.length % dateSize;
for (let i = 0; i < count; i++) { 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); await update(handle, HuksOptions);
} }
if (remainder !== 0) { 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); await update(handle, HuksOptions);
} }
} }
} }
async function publicHmacFinish(HuksOptions, thirdInderfaceName) { async function publicHmacFinish(HuksOptions, thirdInderfaceName) {
if (thirdInderfaceName == 'finish') { if (thirdInderfaceName == "finish") {
HuksOptions.inData = new Uint8Array(stringToArray('0')); HuksOptions.inData = new Uint8Array(stringToArray("0"));
await huks await huks
.finish(handle, HuksOptions) .finish(handle, HuksOptions)
.then((data) => { .then((data) => {
...@@ -83,10 +90,10 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) { ...@@ -83,10 +90,10 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test finish err information: ' + err); console.log("test finish err information: " + err);
expect(null).assertFail(); expect(null).assertFail();
}); });
} else if (thirdInderfaceName == 'abort') { } else if (thirdInderfaceName == "abort") {
await huks await huks
.abort(handle, HuksOptions) .abort(handle, HuksOptions)
.then((data) => { .then((data) => {
...@@ -94,7 +101,7 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) { ...@@ -94,7 +101,7 @@ async function publicHmacFinish(HuksOptions, thirdInderfaceName) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test abort err information: ' + err); console.log("test abort err information: " + err);
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
...@@ -109,7 +116,7 @@ async function publicHmacDelete(srcKeyAlies, HuksOptions) { ...@@ -109,7 +116,7 @@ async function publicHmacDelete(srcKeyAlies, HuksOptions) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test deleteKey err information: ' + JSON.stringify(err)); console.log("test deleteKey err information: " + JSON.stringify(err));
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
...@@ -134,54 +141,71 @@ async function update(handle, HuksOptions) { ...@@ -134,54 +141,71 @@ async function update(handle, HuksOptions) {
expect(data.errorCode == 0).assertTrue(); expect(data.errorCode == 0).assertTrue();
}) })
.catch((err) => { .catch((err) => {
console.log('test update err information: ' + err); console.log("test update err information: " + err);
expect(null).assertFail(); expect(null).assertFail();
}); });
} }
export default function SecurityHuksHmacBasicPromiseJsunit() { export default function SecurityHuksHmacBasicPromiseJsunit() {
describe('SecurityHuksHmacBasicPromiseJsunit', function () { describe("SecurityHuksHmacBasicPromiseJsunit", function () {
it('testHmac101', 0, async function (done) { it("testHmac101", 0, async function (done) {
const srcKeyAlies = 'testHmacDigestSHA1KeyAlias101'; const srcKeyAlies = "testHmacDigestSHA1KeyAlias101";
let HuksOptions = { let HuksOptions = {
properties: new Array(HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, HuksHmac.HuksTagDigestSHA1), properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
),
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmac102', 0, async function (done) { it("testHmac102", 0, async function (done) {
const srcKeyAlies = 'testHmacDigestSHA1KeyAlias102'; const srcKeyAlies = "testHmacDigestSHA1KeyAlias102";
let HuksOptions = { let HuksOptions = {
properties: new Array(HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, HuksHmac.HuksTagDigestSHA1), properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
),
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmac103', 0, async function (done) { it("testHmac103", 0, async function (done) {
const srcKeyAlies = 'testHmacDigestSHA1KeyAlias103'; const srcKeyAlies = "testHmacDigestSHA1KeyAlias103";
let HuksOptions = { let HuksOptions = {
properties: new Array(HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, HuksHmac.HuksTagDigestSHA1), properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmac104', 0, async function (done) { it("testHmac104", 0, async function (done) {
const srcKeyAlies = 'testHmacDigestSHA1KeyAlias104'; const srcKeyAlies = "testHmacDigestSHA1KeyAlias104";
let HuksOptions = { let HuksOptions = {
properties: new Array(HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyPurpose, HuksHmac.HuksTagDigestSHA1), properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmacSM3001', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias001'; it("testHmacSM3101", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias001";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -191,12 +215,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () { ...@@ -191,12 +215,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () {
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSM3002', 0, async function (done) { it("testHmacSM3102", 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias002'; let srcKeyAlies = "testHmacDigestSM3KeyAlias002";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -205,11 +229,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () { ...@@ -205,11 +229,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () {
), ),
inData: srcData63Kb, inData: srcData63Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
it('testHmacSM3003', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias003'; it("testHmacSM3103", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias003";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -218,11 +243,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () { ...@@ -218,11 +243,12 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); await publicHmacFunc(srcKeyAlies, HuksOptions, "finish");
done(); done();
}); });
it('testHmacSM3004', 0, async function (done) {
let srcKeyAlies = 'testHmacDigestSM3KeyAlias004'; it("testHmacSM3104", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSM3KeyAlias004";
let HuksOptions = { let HuksOptions = {
properties: new Array( properties: new Array(
HuksHmac.HuksKeyAlg, HuksHmac.HuksKeyAlg,
...@@ -231,8 +257,8 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () { ...@@ -231,8 +257,8 @@ describe('SecurityHuksHmacBasicPromiseJsunit', function () {
), ),
inData: srcData65Kb, inData: srcData65Kb,
}; };
await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); await publicHmacFunc(srcKeyAlies, HuksOptions, "abort");
done(); done();
}); });
}); });
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册