提交 aa21adad 编写于 作者: 伞木希美
上级 fc48ccb8
......@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/security/huks/build/config.gni")
import("//base/security/huks/huks.gni")
import("//test/xts/tools/build/suite.gni")
......@@ -39,8 +40,6 @@ ohos_moduletest_suite("ActsHuksNAPITest") {
"src/huks_agree_ecdh_test.cpp",
"src/huks_agree_ecdh_test_common.cpp",
"src/huks_agree_x25519_test.cpp",
"src/huks_attest_test.cpp",
"src/huks_attest_test_common.cpp",
"src/huks_cipher_aes_test.cpp",
"src/huks_cipher_aes_test_common.cpp",
"src/huks_cipher_rsa_test.cpp",
......@@ -55,7 +54,6 @@ ohos_moduletest_suite("ActsHuksNAPITest") {
"src/huks_mem.cpp",
"src/huks_misc_test.cpp",
"src/huks_nullptr_test.cpp",
"src/huks_signverify_dsa_test.cpp",
"src/huks_signverify_ecc_test.cpp",
"src/huks_signverify_ecc_test_common.cpp",
"src/huks_signverify_ed25519_test.cpp",
......@@ -67,6 +65,14 @@ ohos_moduletest_suite("ActsHuksNAPITest") {
"src/huks_wrapped_test_common.cpp",
]
if (huks_security_level != "trusted_environment") {
sources += [
"src/huks_attest_test.cpp",
"src/huks_attest_test_common.cpp",
"src/huks_signverify_dsa_test.cpp",
]
}
include_dirs = [
"//test/xts/acts/security/security_huks_basic/huks_napi_BasicTest/include",
"include",
......
......@@ -72,7 +72,7 @@ static struct OH_Huks_Param g_genParams001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_ECC_KEY_SIZE_224
.uint32Param = OH_HUKS_ECC_KEY_SIZE_256
}, {
.tag = OH_HUKS_TAG_DIGEST,
.uint32Param = OH_HUKS_DIGEST_NONE
......@@ -93,7 +93,7 @@ static struct OH_Huks_Param g_agreeParams01Init001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_ECC_KEY_SIZE_224
.uint32Param = OH_HUKS_ECC_KEY_SIZE_256
}
};
static struct OH_Huks_Param g_agreeParams01Finish001[] = {
......@@ -135,7 +135,7 @@ static struct OH_Huks_Param g_agreeParams02Init001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_ECC_KEY_SIZE_224
.uint32Param = OH_HUKS_ECC_KEY_SIZE_256
}
};
static struct OH_Huks_Param g_agreeParams02Finish001[] = {
......@@ -199,8 +199,8 @@ HWTEST_F(HuksAgreeECDHTest, Security_HUKS_NAPI_Agree_ECDH_0100, TestSize.Level0)
ret1 = OH_Huks_GenerateKeyItem(&g_keyAlias02001, genParamSet, nullptr);
EXPECT_EQ(ret1.errorCode, (int32_t)OH_HUKS_SUCCESS) << "GenerateKey02 failed.";
struct OH_Huks_Blob publicKey01 = { .size = OH_HUKS_ECC_KEY_SIZE_224, .data = nullptr };
struct OH_Huks_Blob publicKey02 = { .size = OH_HUKS_ECC_KEY_SIZE_224, .data = nullptr };
struct OH_Huks_Blob publicKey01 = { .size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr };
struct OH_Huks_Blob publicKey02 = { .size = OH_HUKS_ECC_KEY_SIZE_256, .data = nullptr };
ret = MallocAndCheckBlobData(&publicKey01, publicKey01.size);
EXPECT_EQ(ret.errorCode, (int32_t)OH_HUKS_SUCCESS) << "Malloc publicKey01 failed.";
ret = MallocAndCheckBlobData(&publicKey02, publicKey02.size);
......
......@@ -60,7 +60,7 @@ static struct OH_Huks_Param g_genParams001[] = {
.uint32Param = OH_HUKS_SM4_KEY_SIZE_128
}, {
.tag = OH_HUKS_TAG_PADDING,
.uint32Param = OH_HUKS_PADDING_PKCS7
.uint32Param = OH_HUKS_PADDING_NONE
}, {
.tag = OH_HUKS_TAG_BLOCK_MODE,
.uint32Param = OH_HUKS_MODE_CBC
......@@ -81,7 +81,7 @@ static struct OH_Huks_Param g_encryptParams001[] = {
.uint32Param = OH_HUKS_SM4_KEY_SIZE_128
}, {
.tag = OH_HUKS_TAG_PADDING,
.uint32Param = OH_HUKS_PADDING_PKCS7
.uint32Param = OH_HUKS_PADDING_NONE
}, {
.tag = OH_HUKS_TAG_BLOCK_MODE,
.uint32Param = OH_HUKS_MODE_CBC
......@@ -106,7 +106,7 @@ static struct OH_Huks_Param g_decryptParams001[] = {
.uint32Param = OH_HUKS_SM4_KEY_SIZE_128
}, {
.tag = OH_HUKS_TAG_PADDING,
.uint32Param = OH_HUKS_PADDING_PKCS7
.uint32Param = OH_HUKS_PADDING_NONE
}, {
.tag = OH_HUKS_TAG_BLOCK_MODE,
.uint32Param = OH_HUKS_MODE_CBC
......
......@@ -59,7 +59,7 @@ static struct OH_Huks_Param g_genParams001[] = {
.uint32Param = OH_HUKS_DIGEST_SHA256
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_AES_KEY_SIZE_128
.uint32Param = OH_HUKS_AES_KEY_SIZE_256
}
};
static struct OH_Huks_Param g_hkdfParams001[] = {
......
......@@ -49,6 +49,9 @@ void HuksDerivePBKDFTest::TearDown()
}
uint8_t g_saltdata1[16] = {0};
uint8_t g_saltgen[16] = {
0x14, 0x10, 0x11, 0x3a, 0x27, 0x9e, 0xc8, 0x5f, 0xe0, 0xf3, 0x36, 0x17, 0x57, 0x42, 0x8e, 0xff
};
static struct OH_Huks_Param g_genParams001[] = {
{
......@@ -62,7 +65,16 @@ static struct OH_Huks_Param g_genParams001[] = {
.uint32Param = OH_HUKS_DIGEST_SHA256
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = 256
.uint32Param = OH_HUKS_AES_KEY_SIZE_256
}, {
.tag = OH_HUKS_TAG_ITERATION,
.uint32Param = 1000
}, {
.tag = OH_HUKS_TAG_SALT,
.blob = {
sizeof(g_saltgen),
(uint8_t *)g_saltgen
}
}
};
static struct OH_Huks_Param g_pbkdf2Params001[] = {
......
......@@ -56,7 +56,7 @@ static struct OH_Huks_Param g_genParams001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_MAC
}, {
.tag = OH_HUKS_TAG_DIGEST,
.uint32Param = OH_HUKS_DIGEST_SHA1
.uint32Param = OH_HUKS_DIGEST_SHA384
}, {
.tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = Unittest::Hmac::COMMON_SIZE
......@@ -71,7 +71,7 @@ static struct OH_Huks_Param g_hmacParams001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_MAC
}, {
.tag = OH_HUKS_TAG_DIGEST,
.uint32Param = OH_HUKS_DIGEST_SHA1
.uint32Param = OH_HUKS_DIGEST_SHA384
}
};
......@@ -141,7 +141,7 @@ static OH_Huks_Result HksHmacTestCase(const struct OH_Huks_Blob *keyAlias, struc
/**
* @tc.name: HksHmacTest.Security_HUKS_NAPI_HMAC_hmac_0100
* @tc.desc: alg-HMAC pur-MAC dig-SHA1.
* @tc.desc: alg-HMAC pur-MAC dig-SHA384.
* @tc.type: FUNC
*/
HWTEST_F(HksHmacTest, Security_HUKS_NAPI_HMAC_hmac_0100, TestSize.Level0)
......
......@@ -26,7 +26,7 @@ let HuksOptions63kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -37,8 +37,8 @@ let HuksOptions63kb = {
export default function SecurityHuksECDHBasicAbort63KBCallbackJsunit() {
describe('SecurityHuksECDHBasicAbort63KBCallbackJsunit', function () {
it('testAgreeEDCH002', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001';
const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_001';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -26,7 +26,7 @@ let HuksOptions65kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -37,8 +37,8 @@ let HuksOptions65kb = {
export default function SecurityHuksECDHBasicAbort65KBCallbackJsunit() {
describe('SecurityHuksECDHBasicAbort65KBCallbackJsunit', function () {
it('testAgreeEDCH004', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001';
const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_001';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -26,7 +26,7 @@ let HuksOptions63kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -37,8 +37,8 @@ let HuksOptions63kb = {
export default function SecurityHuksECDHBasicFinish63KBCallbackJsunit() {
describe('SecurityHuksECDHBasicFinish63KBCallbackJsunit', function () {
it('testAgreeEDCH001', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001';
const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_001';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -26,7 +26,7 @@ let HuksOptions65kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -37,8 +37,8 @@ let HuksOptions65kb = {
export default function SecurityHuksECDHBasicFinish65KBCallbackJsunit() {
describe('SecurityHuksECDHBasicFinish65KBCallbackJsunit', function () {
it('testAgreeEDCH003', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001';
const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_001';
const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_001';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -41,8 +41,8 @@ describe('SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit', function () {
console.info('test beforeEach called');
});
it('testAgreeECDH102', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_101';
const srcKeyAliesFirst = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize256Abort63KBAgreeKeyAlias_02_101';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit', function () {
});
it('testAgreeECDH104', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_101';
const srcKeyAliesFirst = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize256Abort65KBAgreeKeyAlias_02_101';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -22,58 +22,47 @@ import { HksTag } from '../../../../../../utils/param/publicParam';
let srcData63 = Data.Date63KB;
let srcData63Kb = stringToUint8Array(srcData63);
let HuksOptions63kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
),
inData: srcData63Kb,
};
let HuksOptions63kb = {};
export default function SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit() {
describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () {
beforeEach(function () {
HuksOptions63kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
),
inData: srcData63Kb,
};
console.info('test beforeEach called');
});
describe('SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit', function () {
beforeEach(function () {
HuksOptions63kb = {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
),
inData: srcData63Kb,
};
console.info('test beforeEach called');
});
it('testAgreeECDH101', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_101';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
HuksAgreeECDH.HuksKeyISKEYALIAS,
HuksAgreeECDH.HuksKeyALGORITHMAES,
HuksAgreeECDH.HuksKeySIZE256,
HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT,
HuksAgreeECDH.HuksKeyDIGESTNONE,
{
tag: HksTag.HKS_TAG_KEY_ALIAS,
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksAgreeECDH.HuksKeyPADDINGNONE,
HuksAgreeECDH.HuksKeyBLOCKMODEECB
),
inData: srcData63Kb,
};
await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish');
done();
it('testAgreeECDH101', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize256Finish63KBAgreeKeyAlias_02_101';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
HuksAgreeECDH.HuksKeyISKEYALIAS,
HuksAgreeECDH.HuksKeyALGORITHMAES,
HuksAgreeECDH.HuksKeySIZE256,
HuksAgreeECDH.HuksKeyPurposeENCRYPTDECRYPT,
HuksAgreeECDH.HuksKeyDIGESTNONE,
{
tag: HksTag.HKS_TAG_KEY_ALIAS,
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksAgreeECDH.HuksKeyPADDINGNONE,
HuksAgreeECDH.HuksKeyBLOCKMODEECB
),
inData: srcData63Kb,
};
await publicAgreeFunc(srcKeyAliesFirst, srcKeyAliesSecond, HuksOptions63kb, huksOptionsFinish, 'finish');
done();
});
});
});
}
......@@ -31,7 +31,7 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize256,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -42,8 +42,8 @@ describe('SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit', function () {
});
it('testAgreeECDH103', 0, async function (done) {
const srcKeyAliesFirst = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_101';
const srcKeyAliesFirst = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_01_101';
const srcKeyAliesSecond = 'testAgreeECDHSize256Finish65KBAgreeKeyAlias_02_101';
let huksOptionsFinish = {
properties: new Array(
HuksAgreeECDH.HuksKeySTORAGE,
......
......@@ -17,7 +17,15 @@ import { describe, it, expect } from '@ohos/hypium';
import huks from '@ohos.security.huks';
import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam';
import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc';
let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt';
let gInData64 =
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt';
let gInData64Array = stringToUint8Array(gInData64);
let encryptedData;
......@@ -27,7 +35,11 @@ let updateResult = new Array();
let exportKey;
let genHuksOptions = {
properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512),
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurpose,
HuksCipherRSA.HuksKeyRSASize4096
),
inData: new Uint8Array(new Array()),
};
......@@ -319,105 +331,105 @@ async function publicCipherFunc(
}
export default function SecurityHuksRSABasicCallbackJsunit() {
describe('SecurityHuksRSABasicCallbackJsunit', function () {
it('testCipherRSA001', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001';
genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB);
genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE);
genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256);
describe('SecurityHuksRSABasicCallbackJsunit', function () {
it('testCipherRSA001', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias001';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias001';
genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB);
genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE);
genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256);
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true);
HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: new Uint8Array(updateResult),
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false);
done();
});
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true);
HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: new Uint8Array(updateResult),
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false);
done();
});
it('testCipherRSA002', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias002';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true);
done();
});
it('testCipherRSA002', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias002';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias002';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true);
done();
});
it('testCipherRSA003', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias003';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias003';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true);
HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: new Uint8Array(updateResult),
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false);
done();
});
it('testCipherRSA003', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias003';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias003';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', true);
HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: new Uint8Array(updateResult),
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'finish', false);
done();
});
it('testCipherRSA004', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias004';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias004';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true);
done();
it('testCipherRSA004', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias004';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias004';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
),
inData: gInData64Array,
};
await publicCipherFunc(srcKeyAlies, newSrcKeyAlies, genHuksOptions, HuksOptions, 'abort', true);
done();
});
});
});
}
......@@ -17,7 +17,15 @@ import { describe, it, expect } from '@ohos/hypium';
import huks from '@ohos.security.huks';
import { HuksCipherRSA } from '../../../../../../utils/param/cipher/publicCipherParam';
import { stringToUint8Array, uint8ArrayToString } from '../../../../../../utils/param/publicFunc';
let gInData64 = 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt';
let gInData64 =
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' +
'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt';
let defaultData = '0';
......@@ -30,7 +38,7 @@ let updateResult = new Array();
let exportKey;
let genHuksOptions = {
properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize512),
properties: new Array(HuksCipherRSA.HuksKeyAlgRSA, HuksCipherRSA.HuksKeyPurpose, HuksCipherRSA.HuksKeyRSASize4096),
inData: new Uint8Array(defaultData),
};
......@@ -224,8 +232,8 @@ async function publicCipherFunc(
export default function SecurityHuksCipherRSABasicPromiseJsunit() {
describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
it('testCipherRSA101', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias101';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101';
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias101';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101';
genHuksOptions.properties.splice(3, 1, HuksCipherRSA.HuksKeyRSABLOCKMODEECB);
genHuksOptions.properties.splice(4, 1, HuksCipherRSA.HuksKeyRSAPADDINGNONE);
genHuksOptions.properties.splice(5, 1, HuksCipherRSA.HuksKeyRSADIGESTSHA256);
......@@ -234,7 +242,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......@@ -246,7 +254,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......@@ -258,13 +266,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
});
it('testCipherRSA102', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias102';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101';
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias102';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias101';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......@@ -276,13 +284,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
});
it('testCipherRSA103', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias103';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias103';
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias103';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias103';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......@@ -294,7 +302,7 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeDECRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......@@ -306,13 +314,13 @@ describe('SecurityHuksCipherRSABasicPromiseJsunit', function () {
});
it('testCipherRSA104', 0, async function (done) {
const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias104';
const newSrcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias104';
const srcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256KeyAlias104';
const newSrcKeyAlies = 'testCipherRSASize4096PADDINGNONESHA256NewKeyAlias104';
let HuksOptions = {
properties: new Array(
HuksCipherRSA.HuksKeyAlgRSA,
HuksCipherRSA.HuksKeyPurposeENCRYPT,
HuksCipherRSA.HuksKeyRSASize512,
HuksCipherRSA.HuksKeyRSASize4096,
HuksCipherRSA.HuksKeyRSAPADDINGNONE,
HuksCipherRSA.HuksKeyRSABLOCKMODEECB,
HuksCipherRSA.HuksKeyRSADIGESTSHA256
......
......@@ -27,7 +27,7 @@ let HuksOptions63kb = {
HuksDeriveHKDF.HuksKeyAlgAES,
HuksDeriveHKDF.HuksKeyPurposeHKDF,
HuksDeriveHKDF.HuksTagHKDFDigestSHA256,
HuksDeriveHKDF.HuksKeyHKDFSize128
HuksDeriveHKDF.HuksKeyHKDFSize256
),
inData: srcData63Kb,
};
......@@ -35,7 +35,7 @@ let HuksOptions63kb = {
export default function SecurityHuksHKDFBasicAbort63KBCallbackJsunit() {
describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () {
it('testDeriveHKDF002', 0, async function (done) {
const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001';
const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Abort63KBDeriveKeyAlias_01_001';
let huksOptionsFinish = {
properties: new Array(
HuksDeriveHKDF.HuksKeySTORAGE,
......@@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicAbort63KBCallbackJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDeriveHKDF.HuksKeyPADDINGNONE,
HuksDeriveHKDF.HuksKeyBLOCKMODEECB
HuksDeriveHKDF.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -27,7 +27,7 @@ let HuksOptions63kb = {
HuksDeriveHKDF.HuksKeyAlgAES,
HuksDeriveHKDF.HuksKeyPurposeHKDF,
HuksDeriveHKDF.HuksTagHKDFDigestSHA256,
HuksDeriveHKDF.HuksKeyHKDFSize128
HuksDeriveHKDF.HuksKeyHKDFSize256
),
inData: srcData63Kb,
};
......@@ -35,7 +35,7 @@ let HuksOptions63kb = {
export default function SecurityHuksHKDFBasicFinish63KBCallbackJsunit() {
describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () {
it('testDeriveHKDF001', 0, async function (done) {
const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001';
const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_001';
let huksOptionsFinish = {
properties: new Array(
HuksDeriveHKDF.HuksKeySTORAGE,
......@@ -49,7 +49,7 @@ describe('SecurityHuksHKDFBasicFinish63KBCallbackJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDeriveHKDF.HuksKeyPADDINGNONE,
HuksDeriveHKDF.HuksKeyBLOCKMODEECB
HuksDeriveHKDF.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -27,7 +27,9 @@ let HuksOptions63kb = {
HuksDerivePBKDF2.HuksKeyAlgAES,
HuksDerivePBKDF2.HuksKeyPurposePBKDF2,
HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256,
HuksDerivePBKDF2.HuksKeyPBKDF2Size128
HuksDerivePBKDF2.HuksKeyPBKDF2Size256,
HuksDerivePBKDF2.HuksKeyPBKDF2Iteration,
HuksDerivePBKDF2.HuksKeyPBKDF2Salt
),
inData: srcData63Kb,
};
......@@ -35,7 +37,7 @@ let HuksOptions63kb = {
export default function SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit() {
describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () {
it('testDerivePBKDF2002', 0, async function (done) {
const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001';
const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Abort63KBDeriveKeyAlias_01_001';
let huksOptionsFinish = {
properties: new Array(
HuksDerivePBKDF2.HuksKeySTORAGE,
......@@ -49,7 +51,7 @@ describe('SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDerivePBKDF2.HuksKeyPADDINGNONE,
HuksDerivePBKDF2.HuksKeyBLOCKMODEECB
HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -27,35 +27,37 @@ let HuksOptions63kb = {
HuksDerivePBKDF2.HuksKeyAlgAES,
HuksDerivePBKDF2.HuksKeyPurposePBKDF2,
HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256,
HuksDerivePBKDF2.HuksKeyPBKDF2Size128
HuksDerivePBKDF2.HuksKeyPBKDF2Size256,
HuksDerivePBKDF2.HuksKeyPBKDF2Iteration,
HuksDerivePBKDF2.HuksKeyPBKDF2Salt
),
inData: srcData63Kb,
};
export default function SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit() {
describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () {
it('testDerivePBKDF2001', 0, async function (done) {
const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001';
let huksOptionsFinish = {
properties: new Array(
HuksDerivePBKDF2.HuksKeySTORAGE,
HuksDerivePBKDF2.HuksKeyISKEYALIAS,
HuksDerivePBKDF2.HuksKeyALGORITHMAES,
HuksDerivePBKDF2.HuksKeySIZE256,
HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT,
HuksDerivePBKDF2.HuksKeyDIGESTNONE,
{
tag: HksTag.HKS_TAG_KEY_ALIAS,
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDerivePBKDF2.HuksKeyPADDINGNONE,
HuksDerivePBKDF2.HuksKeyBLOCKMODEECB
),
inData: srcData63Kb,
};
let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2,HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE);
await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish');
done();
describe('SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit', function () {
it('testDerivePBKDF2001', 0, async function (done) {
const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_001';
let huksOptionsFinish = {
properties: new Array(
HuksDerivePBKDF2.HuksKeySTORAGE,
HuksDerivePBKDF2.HuksKeyISKEYALIAS,
HuksDerivePBKDF2.HuksKeyALGORITHMAES,
HuksDerivePBKDF2.HuksKeySIZE256,
HuksDerivePBKDF2.HuksKeyPurposeENCRYPTDECRYPT,
HuksDerivePBKDF2.HuksKeyDIGESTNONE,
{
tag: HksTag.HKS_TAG_KEY_ALIAS,
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDerivePBKDF2.HuksKeyPADDINGNONE,
HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
let deriveArray = new Array(HuksDerivePBKDF2.HuksKeyAlgPBKDF2, HuksDerivePBKDF2.HuksKeyDERIVEKEYSIZE);
await publicDeriveFunc(srcKeyAliesFirst, HuksOptions63kb, huksOptionsFinish, deriveArray, 'finish');
done();
});
});
});
}
......@@ -28,7 +28,7 @@ let HuksOptions63kb = {
HuksDeriveHKDF.HuksKeyAlgAES,
HuksDeriveHKDF.HuksKeyPurposeHKDF,
HuksDeriveHKDF.HuksTagHKDFDigestSHA256,
HuksDeriveHKDF.HuksKeyHKDFSize128
HuksDeriveHKDF.HuksKeyHKDFSize256
),
inData: srcData63Kb,
};
......@@ -36,7 +36,7 @@ let HuksOptions63kb = {
export default function SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit() {
describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () {
it('testDeriveHKDF102', 0, async function (done) {
const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101';
const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Abort63KBDeriveKeyAlias_01_101';
let huksOptionsFinish = {
properties: new Array(
HuksDeriveHKDF.HuksKeySTORAGE,
......@@ -50,7 +50,7 @@ describe('SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDeriveHKDF.HuksKeyPADDINGNONE,
HuksDeriveHKDF.HuksKeyBLOCKMODEECB
HuksDeriveHKDF.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -27,7 +27,7 @@ let HuksOptions63kb = {
HuksDeriveHKDF.HuksKeyAlgAES,
HuksDeriveHKDF.HuksKeyPurposeHKDF,
HuksDeriveHKDF.HuksTagHKDFDigestSHA256,
HuksDeriveHKDF.HuksKeyHKDFSize128
HuksDeriveHKDF.HuksKeyHKDFSize256
),
inData: srcData63Kb,
};
......@@ -35,7 +35,7 @@ let HuksOptions63kb = {
export default function SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit() {
describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () {
it('testDeriveHKDF101', 0, async function (done) {
const srcKeyAliesFirst = 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101';
const srcKeyAliesFirst = 'testDeriveHKDFSize256SHA256Finish63KBDeriveKeyAlias_01_101';
let huksOptionsFinish = {
properties: new Array(
HuksDeriveHKDF.HuksKeySTORAGE,
......@@ -49,7 +49,7 @@ describe('SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDeriveHKDF.HuksKeyPADDINGNONE,
HuksDeriveHKDF.HuksKeyBLOCKMODEECB
HuksDeriveHKDF.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -28,14 +28,16 @@ let HuksOptions63kb = {
HuksDerivePBKDF2.HuksKeyAlgAES,
HuksDerivePBKDF2.HuksKeyPurposePBKDF2,
HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256,
HuksDerivePBKDF2.HuksKeyPBKDF2Size128
HuksDerivePBKDF2.HuksKeyPBKDF2Size256,
HuksDerivePBKDF2.HuksKeyPBKDF2Iteration,
HuksDerivePBKDF2.HuksKeyPBKDF2Salt
),
inData: srcData63Kb,
};
export default function SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit() {
describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () {
it('testDerivePBKDF2102', 0, async function (done) {
const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101';
const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Abort63KBDeriveKeyAlias_01_101';
let huksOptionsFinish = {
properties: new Array(
HuksDerivePBKDF2.HuksKeySTORAGE,
......@@ -49,7 +51,7 @@ describe('SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDerivePBKDF2.HuksKeyPADDINGNONE,
HuksDerivePBKDF2.HuksKeyBLOCKMODEECB
HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -28,7 +28,9 @@ let HuksOptions63kb = {
HuksDerivePBKDF2.HuksKeyAlgAES,
HuksDerivePBKDF2.HuksKeyPurposePBKDF2,
HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256,
HuksDerivePBKDF2.HuksKeyPBKDF2Size128
HuksDerivePBKDF2.HuksKeyPBKDF2Size256,
HuksDerivePBKDF2.HuksKeyPBKDF2Iteration,
HuksDerivePBKDF2.HuksKeyPBKDF2Salt
),
inData: srcData63Kb,
};
......@@ -36,7 +38,7 @@ let HuksOptions63kb = {
export default function SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit() {
describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () {
it('testDerivePBKDF2101', 0, async function (done) {
const srcKeyAliesFirst = 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101';
const srcKeyAliesFirst = 'testDerivePBKDF2Size256SHA256Finish63KBDeriveKeyAlias_01_101';
let huksOptionsFinish = {
properties: new Array(
HuksDerivePBKDF2.HuksKeySTORAGE,
......@@ -50,7 +52,7 @@ describe('SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit', function () {
value: stringToUint8Array(srcKeyAliesFirst),
},
HuksDerivePBKDF2.HuksKeyPADDINGNONE,
HuksDerivePBKDF2.HuksKeyBLOCKMODEECB
HuksDerivePBKDF2.HuksKeyBLOCKMODEGCM
),
inData: srcData63Kb,
};
......
......@@ -12,10 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect } from "@ohos/hypium";
import { describe, it, expect, beforeAll } from "@ohos/hypium";
import huks from "@ohos.security.huks";
import Data from "../../../../../../utils/data.json";
import { stringToUint8Array } from "../../../../../../utils/param/publicFunc";
import { stringToUint8Array, checkSoftware } from "../../../../../../utils/param/publicFunc";
import {
HuksSignVerifyDSA,
HuksSignVerifyRSA,
......@@ -33,6 +33,7 @@ import { HuksHmac } from "../../../../../../utils/param/hmac/publicHmacParam";
let srcData63 = Data.Data63b;
let srcData63Kb = stringToUint8Array(srcData63);
let useSoftware = true;
function generateKey(srcKeyAlies, HuksOptions) {
return new Promise((resolve, reject) => {
......@@ -126,6 +127,11 @@ async function exportKeyFunc(srcKeyAlias, HuksOptions) {
export function SecurityHuksAccessControlJsunit() {
describe("SecurityHuksAccessControlJsunit", function () {
beforeAll(async function (done) {
useSoftware = await checkSoftware();
done();
})
it("HUKS_Basic_Capability_AccessControl_0100", 0, async function (done) {
let srcKeyAlias = "HUKS_Basic_Capability_AccessControl_0100";
let HuksOptions = {
......@@ -137,22 +143,24 @@ export function SecurityHuksAccessControlJsunit() {
),
inData: srcData63Kb,
};
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH);
HuksOptions.properties.splice(3, 1);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(data.errorCode == -112).assertTrue();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
if (useSoftware) {
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH);
HuksOptions.properties.splice(3, 1);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(data.errorCode == -112).assertTrue();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
}
done();
});
......@@ -162,7 +170,7 @@ export function SecurityHuksAccessControlJsunit() {
properties: new Array(
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeSINGVERIFY,
HuksSignVerifyECC.HuksKeyECCSize224,
HuksSignVerifyECC.HuksKeyECCSize384,
HuksSignVerifyECC.HuksTagECCDigestNONE
),
inData: srcData63Kb,
......@@ -196,32 +204,34 @@ export function SecurityHuksAccessControlJsunit() {
),
inData: srcData63Kb,
};
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
if (useSoftware) {
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeENCRYPT);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
HuksOptions.properties.splice(1, 1, HuksCipherAES.HuksKeyPurposeDECRYPT);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
}
done();
});
......@@ -233,7 +243,7 @@ export function SecurityHuksAccessControlJsunit() {
HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize3072
),
inData: srcData63Kb,
};
......@@ -315,21 +325,23 @@ export function SecurityHuksAccessControlJsunit() {
),
inData: srcData63Kb,
};
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
if (useSoftware) {
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksHmac.HuksKeyPurpose);
await init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(null).assertFail();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
}
done();
});
......@@ -391,7 +403,7 @@ export function SecurityHuksAccessControlJsunit() {
properties: new Array(
HuksAgreeECDH.HuksKeyAlgECC,
HuksAgreeECDH.HuksKeyPurposeECDH,
HuksAgreeECDH.HuksKeyECCSize224,
HuksAgreeECDH.HuksKeyECCSize384,
HuksAgreeECDH.HuksKeyECCDIGEST,
HuksAgreeECDH.HuksKeyECCPADDING,
HuksAgreeECDH.HuksKeyECCBLOCKMODE
......@@ -448,23 +460,25 @@ export function SecurityHuksAccessControlJsunit() {
),
inData: srcData63Kb,
};
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH);
HuksOptions.properties.splice(3, 1);
await huks
.init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(data.errorCode == -112).assertTrue();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
if (useSoftware) {
await generateKeyFunc(srcKeyAlias, HuksOptions);
await exportKeyFunc(srcKeyAlias, HuksOptions);
HuksOptions.properties.splice(1, 1, HuksAgreeDH.HuksKeyPurposeDH);
HuksOptions.properties.splice(3, 1);
await huks
.init(srcKeyAlias, HuksOptions)
.then((data) => {
console.log(`test init data: ${JSON.stringify(data)}`);
expect(data.errorCode == -112).assertTrue();
})
.catch((err) => {
console.log(`test init err: " + ${JSON.stringify(err)}`);
expect(err.code == -112).assertTrue();
});
await deleteKeyFunc(srcKeyAlias, HuksOptions);
}
done();
});
......@@ -835,7 +849,7 @@ export function SecurityHuksAccessControlJsunit() {
expect(1342197283).assertEqual(
huks.HuksTag.HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA
);
expect(0).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_TEMP );
expect(0).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_TEMP);
expect(1).assertEqual(huks.HuksKeyStorageType.HUKS_STORAGE_PERSISTENT);
done();
});
......
......@@ -243,12 +243,12 @@ async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) {
export function SecurityHuksHmacCallbackJsunit() {
describe("SecurityHuksHmacCallbackJsunit", function () {
it("testHmacSHA1001", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSHA1KeyAlias001";
let srcKeyAlies = "testHmacDigestSHA256KeyAlias001";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData63Kb,
};
......@@ -258,12 +258,12 @@ export function SecurityHuksHmacCallbackJsunit() {
});
it("testHmacSHA1002", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSHA1KeyAlias002";
let srcKeyAlies = "testHmacDigestSHA256KeyAlias002";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData63Kb,
};
......@@ -271,12 +271,12 @@ export function SecurityHuksHmacCallbackJsunit() {
done();
});
it("testHmacSHA1003", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSHA1KeyAlias003";
let srcKeyAlies = "testHmacDigestSHA256KeyAlias003";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData65Kb,
};
......@@ -284,12 +284,12 @@ export function SecurityHuksHmacCallbackJsunit() {
done();
});
it("testHmacSHA1004", 0, async function (done) {
let srcKeyAlies = "testHmacDigestSHA1KeyAlias004";
let srcKeyAlies = "testHmacDigestSHA256KeyAlias004";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData65Kb,
};
......
......@@ -234,12 +234,12 @@ async function update(handle, HuksOptions) {
export default function SecurityHuksHmacBasicPromiseJsunit() {
describe("SecurityHuksHmacBasicPromiseJsunit", function () {
it("testHmac101", 0, async function (done) {
const srcKeyAlies = "testHmacDigestSHA1KeyAlias101";
const srcKeyAlies = "testHmacDigestSHA256KeyAlias101";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData63Kb,
};
......@@ -248,12 +248,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() {
});
it("testHmac102", 0, async function (done) {
const srcKeyAlies = "testHmacDigestSHA1KeyAlias102";
const srcKeyAlies = "testHmacDigestSHA256KeyAlias102";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData63Kb,
};
......@@ -262,12 +262,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() {
});
it("testHmac103", 0, async function (done) {
const srcKeyAlies = "testHmacDigestSHA1KeyAlias103";
const srcKeyAlies = "testHmacDigestSHA256KeyAlias103";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData65Kb,
};
......@@ -276,12 +276,12 @@ export default function SecurityHuksHmacBasicPromiseJsunit() {
});
it("testHmac104", 0, async function (done) {
const srcKeyAlies = "testHmacDigestSHA1KeyAlias104";
const srcKeyAlies = "testHmacDigestSHA256KeyAlias104";
let HuksOptions = {
properties: new Array(
HuksHmac.HuksKeyAlg,
HuksHmac.HuksKeyPurpose,
HuksHmac.HuksTagDigestSHA1
HuksHmac.HuksTagDigestSHA256
),
inData: srcData65Kb,
};
......
......@@ -15,24 +15,27 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData63 = Data.Data63b;
let srcData63Kb = stringToUint8Array(srcData63);
export default function SecurityHuksDSABasicAbort63KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () {
it('testSignVerifyDSA002', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb);
done();
describe('SecurityHuksDSABasicAbort63KBCallbackJsunit', function () {
it('testSignVerifyDSA002', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb);
}
done();
});
});
});
}
......@@ -15,25 +15,28 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
export default function SecurityHuksDSABasicAbort65KBCallbackJsunit() {
describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () {
it('testSignVerifyDSA004', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb);
done();
describe('SecurityHuksDSABasicAbort65KBCallbackJsunit', function () {
it('testSignVerifyDSA004', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb);
}
done();
});
});
});
}
......@@ -15,35 +15,38 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData63 = Data.Data63b;
let srcData63Kb = stringToUint8Array(srcData63);
let finishOutData;
export default function SecurityHuksDSABasicFinish63KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () {
it('testSignVerifyDSA001', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY,
HuksSignVerifyDSA.HuksTagDSADigestSHA1,
HuksSignVerifyDSA.HuksTagDSACOMMONSIZE
),
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb);
done();
describe('SecurityHuksDSABasicFinish63KBCallbackJsunit', function () {
it('testSignVerifyDSA001', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData63Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY,
HuksSignVerifyDSA.HuksTagDSADigestSHA1,
HuksSignVerifyDSA.HuksTagDSACOMMONSIZE
),
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData63Kb);
}
done();
});
});
});
}
......@@ -15,35 +15,38 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
let finishOutData;
export default function SecurityHuksDSABasicFinish65KBCallbackJsunit() {
describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () {
it('testSignVerifyDSA003', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY,
HuksSignVerifyDSA.HuksTagDSADigestSHA1,
HuksSignVerifyDSA.HuksKeySIZE1024
),
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
done();
describe('SecurityHuksDSABasicFinish65KBCallbackJsunit', function () {
it('testSignVerifyDSA003', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
finishOutData = await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', true, srcData65Kb);
HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY,
HuksSignVerifyDSA.HuksTagDSADigestSHA1,
HuksSignVerifyDSA.HuksKeySIZE1024
),
inData: finishOutData,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'finish', false, srcData65Kb);
}
done();
});
});
});
}
......@@ -32,7 +32,7 @@ describe('SecurityHuksECCBasicAbort63KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeSIGN,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: srcData63AfterSha256,
};
......
......@@ -32,7 +32,7 @@ describe('SecurityHuksECCBasicAbort65KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeSIGN,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: srcData65Sha256,
};
......
......@@ -33,7 +33,7 @@ describe('SecurityHuksECCBasicFinish63KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeSIGN,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: srcData63AfterSha256,
};
......@@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish63KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeVERIFY,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: finishOutData,
};
......
......@@ -33,7 +33,7 @@ describe('SecurityHuksECCBasicFinish65KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeSIGN,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: srcData65Sha256,
};
......@@ -43,7 +43,7 @@ describe('SecurityHuksECCBasicFinish65KBCallbackJsunit', function () {
HuksSignVerifyECC.HuksKeyAlgECC,
HuksSignVerifyECC.HuksKeyECCPurposeVERIFY,
HuksSignVerifyECC.HuksTagECCDigestNONE,
HuksSignVerifyECC.HuksKeyECCSize224
HuksSignVerifyECC.HuksKeyECCSize256
),
inData: finishOutData,
};
......
......@@ -25,14 +25,14 @@ let srcData63Kb = stringToUint8Array(srcData63);
export default function SecurityHuksRSABasicAbort63KBCallbackJsunit() {
describe('SecurityHuksRSABasicAbort63KBCallbackJsunit', function () {
it('testSignVerifyRSA002', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002';
const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias002';
let HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: srcData63Kb,
};
......
......@@ -22,14 +22,14 @@ let srcData65Kb = stringToUint8Array(srcData65);
export default function SecurityHuksRSABasicAbort65KBCallbackJsunit() {
describe('SecurityHuksRSABasicAbort65KBCallbackJsunit', function () {
it('testSignVerifyRSA004', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004';
const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias004';
let HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: srcData65Kb,
};
......
......@@ -23,14 +23,14 @@ let finishOutData;
export default function SecurityHuksRSABasicFinish63KBCallbackJsunit() {
describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () {
it('testSignVerifyRSA001', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001';
const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias001';
let HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: srcData63Kb,
};
......@@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish63KBCallbackJsunit', function () {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: finishOutData,
};
......
......@@ -23,14 +23,14 @@ let finishOutData;
export default function SecurityHuksRSABasicFinish65KBCallbackJsunit() {
describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () {
it('testSignVerifyRSA003', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003';
const srcKeyAlies = 'testSignVerifyRSASize4096SIGNPKCS1SHA512KeyAlias003';
let HuksOptions = {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: srcData65Kb,
};
......@@ -39,9 +39,9 @@ describe('SecurityHuksRSABasicFinish65KBCallbackJsunit', function () {
properties: new Array(
HuksSignVerifyRSA.HuksKeyAlgRSA,
HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY,
HuksSignVerifyRSA.HuksTagPKCS1DigestMD5,
HuksSignVerifyRSA.HuksTagPKCS1DigestSHA512,
HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15,
HuksSignVerifyRSA.HuksKeyRSASize512
HuksSignVerifyRSA.HuksKeyRSASize4096
),
inData: finishOutData,
};
......
......@@ -15,24 +15,27 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData63 = Data.Data63b;
let srcData63Kb = stringToUint8Array(srcData63);
export default function SecurityHuksDSABasicAbort63KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () {
it('testSignVerifyDSA102', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb);
done();
describe('SecurityHuksDSABasicAbort63KBPromiseJsunit', function () {
it('testSignVerifyDSA102', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData63Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData63Kb);
}
done();
});
});
});
}
......@@ -15,24 +15,27 @@
import { describe, it } from '@ohos/hypium';
import Data from '../../../../../../utils/data.json';
import { HuksSignVerifyDSA } from '../../../../../../utils/param/signverify/publicSignverifyParam';
import { stringToUint8Array } from '../../../../../../utils/param/publicFunc';
import { stringToUint8Array, checkSoftware } from '../../../../../../utils/param/publicFunc';
import { publicSignVerifyFunc } from '../../../../../../utils/param/signverify/publicSignverifyPromise.js';
let srcData65 = Data.Data65b;
let srcData65Kb = stringToUint8Array(srcData65);
export default function SecurityHuksDSABasicAbort65KBPromiseJsunit() {
describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () {
it('testSignVerifyDSA104', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb);
done();
describe('SecurityHuksDSABasicAbort65KBPromiseJsunit', function () {
it('testSignVerifyDSA104', 0, async function (done) {
const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104';
let HuksOptions = {
properties: new Array(
HuksSignVerifyDSA.HuksKeyAlgDSA,
HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN,
HuksSignVerifyDSA.HuksTagDSADigestSHA1
),
inData: srcData65Kb,
};
let useSoftware = await checkSoftware();
if (useSoftware) {
await publicSignVerifyFunc(srcKeyAlies, HuksOptions, 'abort', true, srcData65Kb);
}
done();
});
});
});
}
......@@ -157,6 +157,10 @@ let HuksSignVerifyED25519 = {
tag: param.HksTag.HKS_TAG_DIGEST,
value: param.HksKeyDigest.HKS_DIGEST_SHA1,
},
HuksTagDigestSHA256: {
tag: param.HksTag.HKS_TAG_DIGEST,
value: param.HksKeyDigest.HKS_DIGEST_SHA256,
},
};
let HuksSignVerifyRSA = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册