提交 11a94508 编写于 作者: 伞木希美

asdafd

Signed-off-by: N伞木希美 <zhanghanlin9@huawei.com>
上级 995db16d
......@@ -25,64 +25,6 @@ import { HuksKeyAlgX25519, HuksAgreeECDH } from '../../../../../../utils/param/a
let IV = '0000000000000000';
let srcData63 = Data.Data63b;
let srcData63Kb = stringToUint8Array(srcData63);
let inputEccPair = new Uint8Array([
0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0xa5, 0xb8, 0xa3, 0x78, 0x1d, 0x6d, 0x76, 0xe0, 0xb3, 0xf5, 0x6f, 0x43,
0x9d, 0xcf, 0x60, 0xf6, 0x0b, 0x3f, 0x64, 0x45, 0xa8, 0x3f, 0x1a, 0x96, 0xf1, 0xa1, 0xa4, 0x5d,
0x3e, 0x2c, 0x3f, 0x13, 0xd7, 0x81, 0xf7, 0x2a, 0xb5, 0x8d, 0x19, 0x3d, 0x9b, 0x96, 0xc7, 0x6a,
0x10, 0xf0, 0xaa, 0xbc, 0x91, 0x6f, 0x4d, 0xa7, 0x09, 0xb3, 0x57, 0x88, 0x19, 0x6f, 0x00, 0x4b,
0xad, 0xee, 0x34, 0x35, 0xfb, 0x8b, 0x9f, 0x12, 0xa0, 0x83, 0x19, 0xbe, 0x6a, 0x6f, 0x63, 0x2a,
0x7c, 0x86, 0xba, 0xca, 0x64, 0x0b, 0x88, 0x96, 0xe2, 0xfa, 0x77, 0xbc, 0x71, 0xe3, 0x0f, 0x0f,
0x9e, 0x3c, 0xe5, 0xf9]);
let inputECCKey = new Uint8Array([
0x5b, 0x00, 0x00, 0x00, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc0,
0xf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29, 0x97, 0xad, 0xb3, 0x4a, 0x2c, 0x50,
0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x10, 0x00, 0x00, 0x00, 0x26, 0xae, 0xdc, 0x4e, 0xa5,
0x6e, 0xb1, 0x38, 0x14, 0x24, 0x47, 0x1c, 0x41, 0x89, 0x63, 0x11, 0x04, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xcb, 0xa9, 0xa8, 0x5f, 0x5a, 0x9d, 0xbf, 0xa1,
0xfc, 0x72, 0x74, 0x87, 0x79, 0xf2, 0xf4, 0x22, 0x0c, 0x8a, 0x4d, 0xd8, 0x7e, 0x10, 0xc8, 0x44,
0x17, 0x95, 0xab, 0x3b, 0xd2, 0x8f, 0x0a
]);
let inputX25519Pair = new Uint8Array([
0x65, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x9c, 0xf6, 0x7a, 0x8d, 0xce, 0xc2, 0x7f, 0xa7, 0xd9, 0xfd, 0xf1, 0xad,
0xac, 0xf0, 0xb3, 0x8c, 0xe8, 0x16, 0xa2, 0x65, 0xcc, 0x18, 0x55, 0x60, 0xcd, 0x2f, 0xf5, 0xe5,
0x72, 0xc9, 0x3c, 0x54, 0x20, 0xd5, 0xbb, 0x54, 0x6f, 0x1f, 0x00, 0x30, 0x4e, 0x33, 0x38, 0xb9,
0x8e, 0x6a, 0xdf, 0xad, 0x33, 0x6f, 0x51, 0x23, 0xff, 0x4d, 0x95, 0x26, 0xdc, 0xb0, 0x74, 0xb2,
0x5c, 0x7e, 0x85, 0x6c]);
let inputX25519Key = new Uint8Array([
0x20, 0x00, 0x00, 0x00, 0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a,
0x82, 0xe3, 0x35, 0xfb, 0xa8, 0x8e, 0x0e, 0x10, 0x71, 0x65, 0x22, 0x98, 0x8a, 0x75, 0x94, 0xeb,
0x01, 0x32, 0xa0, 0x41, 0x10, 0x00, 0x00, 0x00, 0xbf, 0xf9, 0x69, 0x41, 0xf5, 0x49, 0x85, 0x31,
0x35, 0x14, 0x69, 0x12, 0x57, 0x9c, 0xc8, 0xb7, 0x10, 0x00, 0x00, 0x00, 0x2d, 0xb7, 0xf1, 0x5a,
0x0f, 0xb8, 0x20, 0xc5, 0x90, 0xe5, 0xca, 0x45, 0x84, 0x5c, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00,
0x4d, 0xcc, 0xa1, 0x39, 0x68, 0x38, 0xb7, 0x6b, 0xeb, 0xdc, 0x61, 0x6a, 0xe8, 0xe2, 0x47, 0x4b,
0x20, 0x00, 0x00, 0x00, 0xfa, 0x88, 0xdb, 0x7b, 0x01, 0x89, 0xce, 0x6b, 0x86, 0x09, 0x0a, 0x3d,
0x3d, 0xb0, 0x80, 0x2b, 0x35, 0x01, 0xdf, 0xa4, 0xb2, 0x3b, 0x58, 0xf3, 0xf2, 0x20, 0xcb, 0x42,
0x71, 0xf8, 0x91, 0x73, 0x10, 0x00, 0x00, 0x00, 0xf4, 0x1e, 0x7b, 0x01, 0x7a, 0x84, 0x36, 0xa4,
0xa8, 0x1c, 0x0d, 0x3d, 0xde, 0x57, 0x66, 0x73, 0x10, 0x00, 0x00, 0x00, 0xe3, 0xff, 0x29, 0x97,
0xad, 0xb3, 0x4a, 0x2c, 0x50, 0x08, 0xb5, 0x68, 0xe1, 0x90, 0x5a, 0xdc, 0x10, 0x00, 0x00, 0x00,
0xed, 0x0e, 0x12, 0x2d, 0x6b, 0x3d, 0xb3, 0x44, 0xdc, 0x9f, 0xc3, 0xb8, 0xb7, 0x25, 0xff, 0x99,
0x04, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x25, 0x78, 0xc2, 0xd2,
0x91, 0x75, 0x1c, 0x82, 0xb9, 0xc9, 0x2b, 0xa8, 0x9e, 0xf3, 0x65, 0x0a, 0x02, 0x8a, 0xaa, 0x96,
0x26, 0x81, 0x3c, 0x9b, 0xbe, 0x26, 0xfc, 0x7b, 0x7b, 0xca, 0x7d, 0xcb, 0x7e, 0x07, 0x0e, 0xdd,
0xa3, 0x9b, 0xc5, 0x52, 0xff, 0x8c, 0xe2, 0x4f, 0x8d, 0x64, 0x04, 0x48, 0x79, 0x80, 0x1e, 0x44,
0xc8, 0xf2, 0x49, 0x07, 0xfc, 0xaa, 0xd5, 0x7e, 0x4d, 0xf9, 0x72, 0x68, 0xda, 0x05, 0xb7, 0x1f,
0xf8, 0xca, 0x75, 0xb8, 0x55, 0x14, 0xe9, 0xa4, 0x4b, 0xb1, 0x85, 0x28, 0xae, 0xe2, 0xb6, 0x1b
]);
let aes128Key = new Uint8Array([
0x20, 0x00, 0x00, 0x00, 0xdc, 0xa3, 0xe3, 0xec, 0xa3, 0x99, 0x06, 0x59, 0xc8, 0x7f, 0xb8, 0x6a
......@@ -453,114 +395,6 @@ let dsa2048Key = new Uint8Array([
0x62, 0x69, 0xce, 0xee, 0x53, 0x2a, 0x7c, 0xec, 0x46, 0x5c, 0x51, 0x33,
]);
function makeImportECCOptions() {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_ECC
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_ECC_KEY_SIZE_256
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR,
};
let options = { properties: properties, inData: inputEccPair };
return options;
};
function makeImportECCOptions2() {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_AES
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_AES_KEY_SIZE_256
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_ENCRYPT | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_DECRYPT
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_BLOCK_MODE,
value: huks.HuksCipherMode.HUKS_MODE_CBC
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_PADDING,
value: huks.HuksKeyPadding.HUKS_PADDING_NONE
};
properties[5] = {
tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE,
value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING
};
let options = { properties: properties };
return options;
};
function makeImportX25519Options() {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_X25519
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_UNWRAP
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_DIGEST,
value: huks.HuksKeyDigest.HUKS_DIGEST_SHA256
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR,
};
let options = { properties: properties, inData: inputX25519Pair };
return options;
};
function makeImportX25519Options2() {
let properties = new Array();
properties[0] = {
tag: huks.HuksTag.HUKS_TAG_ALGORITHM,
value: huks.HuksKeyAlg.HUKS_ALG_ED25519
};
properties[1] = {
tag: huks.HuksTag.HUKS_TAG_KEY_SIZE,
value: huks.HuksKeySize.HUKS_CURVE25519_KEY_SIZE_256
};
properties[2] = {
tag: huks.HuksTag.HUKS_TAG_PURPOSE,
value: huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_SIGN | huks.HuksKeyPurpose.HUKS_KEY_PURPOSE_VERIFY
};
properties[3] = {
tag: huks.HuksTag.HUKS_TAG_IMPORT_KEY_TYPE,
value: huks.HuksImportKeyType.HUKS_KEY_TYPE_KEY_PAIR,
};
properties[4] = {
tag: huks.HuksTag.HUKS_TAG_UNWRAP_ALGORITHM_SUITE,
value: huks.HuksUnwrapSuite.HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING
};
let options = { properties: properties };
return options;
};
async function publicGenerateKeyFunc(keyAlias, HuksOptions) {
await huks
.generateKey(keyAlias, HuksOptions)
......@@ -598,29 +432,6 @@ async function publicDeleteKeyFunc(KeyAlias, HuksOptions) {
});
}
async function TestImportWrappedFunc(alias, wrappingAlias, options) {
let result = await huks.importWrappedKey(alias, wrappingAlias, options);
if (result.errorCode === 0) {
console.error('test importWrappedKey success');
expect(result.errorCode == 0).assertTrue();
} else {
console.error('test importWrappedKey fail');
expect(null).assertFail();
}
}
async function TestImportWrappedKeyECCFunc(alias, wrappingAlias, genOptions, importOptions) {
await publicImportKey(wrappingAlias, genOptions);
importOptions.inData = inputECCKey;
await TestImportWrappedFunc(alias, wrappingAlias, importOptions);
}
async function TestImportWrappedKeyX25519Func(alias, wrappingAlias, genOptions, importOptions) {
await publicImportKey(wrappingAlias, genOptions);
importOptions.inData = inputX25519Key;
await TestImportWrappedFunc(alias, wrappingAlias, importOptions);
}
export function SecurityHuksImportJsunit() {
describe('SecurityHuksImportJsunit', function () {
it('HUKS_Basic_Capability_Import_0100', 0, async function (done) {
......@@ -666,28 +477,6 @@ describe('SecurityHuksImportJsunit', function () {
done();
});
it('HUKS_Basic_Capability_Import_0300', 0, async function (done) {
const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_0300';
const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_0300Wrap';
let genOptionsECC = makeImportECCOptions();
let importOptionsECC = makeImportECCOptions2();
await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC);
await publicDeleteKeyFunc(srcKeyAlies1, genOptionsECC);
await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC);
done();
});
it('HUKS_Basic_Capability_Import_0400', 0, async function (done) {
const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_0400';
const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_0400Wrap';
let genOptionsX25519 = makeImportX25519Options();
let importOptionsX25519 = makeImportX25519Options2();
await TestImportWrappedKeyX25519Func(srcKeyAlies1, srcKeyAlies2, genOptionsX25519, importOptionsX25519);
await publicDeleteKeyFunc(srcKeyAlies1, genOptionsX25519);
await publicDeleteKeyFunc(srcKeyAlies2, importOptionsX25519);
done();
});
it('HUKS_Basic_Capability_Import_0500', 0, async function (done) {
const srcKeyAlies = 'HUKS_Basic_Capability_Import_0500';
let HuksOptions = {
......@@ -1077,44 +866,6 @@ describe('SecurityHuksImportJsunit', function () {
done();
});
it('HUKS_Basic_Capability_Import_2600', 0, async function (done) {
const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_2600';
const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_2600Wrap';
let genOptionsECC = makeImportECCOptions();
let importOptionsECC = makeImportECCOptions2();
await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC);
await TestImportWrappedKeyECCFunc(srcKeyAlies1, srcKeyAlies2, genOptionsECC, importOptionsECC);
await publicDeleteKeyFunc(srcKeyAlies1, genOptionsECC);
await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC);
done();
});
it('HUKS_Basic_Capability_Import_2700', 0, async function (done) {
const srcKeyAlies1 = 'HUKS_Basic_Capability_Import_2700_ECC';
const srcKeyAlies2 = 'HUKS_Basic_Capability_Import_2700_ECCWrap';
const srcKeyAlies4 = 'HUKS_Basic_Capability_Import_2700_X25519Wrap';
let genOptionsECC = makeImportECCOptions();
let importOptionsECC = makeImportECCOptions2();
let genOptionsx25519 = makeImportX25519Options();
let importOptionsx25519 = makeImportX25519Options2();
await publicImportKey(srcKeyAlies2, genOptionsECC);
importOptionsECC.inData = inputECCKey;
await publicImportKey(srcKeyAlies4, genOptionsx25519);
importOptionsx25519.inData = inputECCKey;
await huks.importWrappedKey(srcKeyAlies1, srcKeyAlies2, importOptionsx25519)
.then((data) => {
console.error(`test ImportKey data: ${JSON.stringify(data)}`);
expect(data.errorCode == -31).assertTrue();
})
.catch((err) => {
console.error('test exportKey err information: ' + JSON.stringify(err));
expect(err.code == -31).assertTrue();
});
await publicDeleteKeyFunc(srcKeyAlies2, importOptionsECC);
await publicDeleteKeyFunc(srcKeyAlies4, genOptionsx25519);
done();
});
it('HUKS_Basic_Capability_Import_2800', 0, async function (done) {
const srcKeyAlies = 'HUKS_Basic_Capability_Import_2800';
let HuksOptions = {
......
......@@ -14,8 +14,6 @@
*/
import SecurityHuksHmacBasicPromiseJsunit from './HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js'
import SecurityHuksFaceFingerNormalJsunit from './HMAC/SecurityHuksFaceFingerNormalJsunit.test.js'
export default function testsuite() {
SecurityHuksHmacBasicPromiseJsunit()
SecurityHuksFaceFingerNormalJsunit()
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册