From 03509522fafdd6bfdd1e4945d10872d0127c1f84 Mon Sep 17 00:00:00 2001 From: hu-jixiang1 Date: Wed, 27 Apr 2022 11:29:21 +0800 Subject: [PATCH] release 3.1basic Signed-off-by: hu-jixiang1 Change-Id: I7ce4dc50e00e1b4da37ccddf8936fa00b6f75d2e --- security/BUILD.gn | 2 +- .../huks_agree_callback_BasicTest/Test.json | 18 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...HuksDHBasicAbort63KBCallbackJsunit.test.js | 551 ------------- ...HuksDHBasicAbort65KBCallbackJsunit.test.js | 551 ------------- ...uksDHBasicFinish63KBCallbackJsunit.test.js | 554 -------------- ...uksDHBasicFinish65KBCallbackJsunit.test.js | 551 ------------- ...ksECDHBasicAbort63KBCallbackJsunit.test.js | 594 -------------- ...ksECDHBasicAbort65KBCallbackJsunit.test.js | 594 -------------- ...sECDHBasicFinish63KBCallbackJsunit.test.js | 595 -------------- ...sECDHBasicFinish65KBCallbackJsunit.test.js | 595 -------------- ...X25519BasicAbort63KBCallbackJsunit.test.js | 590 -------------- ...X25519BasicAbort65KBCallbackJsunit.test.js | 590 -------------- ...25519BasicFinish63KBCallbackJsunit.test.js | 591 -------------- ...25519BasicFinish65KBCallbackJsunit.test.js | 591 -------------- .../huks_agree_promise_BasicTest/Test.json | 18 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...AgreeDHBasicAbort63KBPromiseJsunit.test.js | 453 ----------- ...AgreeDHBasicAbort65KBPromiseJsunit.test.js | 453 ----------- ...greeDHBasicFinish63KBPromiseJsunit.test.js | 455 ----------- ...greeDHBasicFinish65KBPromiseJsunit.test.js | 453 ----------- ...reeECDHBasicAbort63KBPromiseJsunit.test.js | 498 ------------ ...reeECDHBasicAbort65KBPromiseJsunit.test.js | 499 ------------ ...eeECDHBasicFinish63KBPromiseJsunit.test.js | 511 ------------- ...eeECDHBasicFinish65KBPromiseJsunit.test.js | 500 ------------ ...eX25519BasicAbort63KBPromiseJsunit.test.js | 491 ------------ ...eX25519BasicAbort65KBPromiseJsunit.test.js | 491 ------------ ...X25519BasicFinish63KBPromiseJsunit.test.js | 492 ------------ ...X25519BasicFinish65KBPromiseJsunit.test.js | 492 ------------ .../huks_cipher_callback_BasicTest/Test.json | 18 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...SecurityHuksAESBasicCallbackJsunit.test.js | 674 ---------------- ...SecurityHuksRSABasicCallbackJsunit.test.js | 723 ------------------ .../huks_cipher_promise_BasicTest/Test.json | 18 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...ityHuksCipherAESBasicPromiseJsunit.test.js | 616 --------------- ...ityHuksCipherRSABasicPromiseJsunit.test.js | 662 ---------------- .../huks_derive_callback_BasicTest/Test.json | 18 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...ksHKDFBasicAbort63KBCallbackJsunit.test.js | 512 ------------- ...sHKDFBasicFinish63KBCallbackJsunit.test.js | 512 ------------- ...PBKDF2BasicAbort63KBCallbackJsunit.test.js | 512 ------------- ...BKDF2BasicFinish63KBCallbackJsunit.test.js | 512 ------------- .../entry/src/main/js/test/switchControl.js | 17 - .../huks_derive_promise_BasicTest/Test.json | 18 - .../entry/src/main/js/MainAbility/app.js | 23 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...iveHKDFBasicAbort63KBPromiseJsunit.test.js | 428 ----------- ...veHKDFBasicFinish63KBPromiseJsunit.test.js | 428 ----------- ...ePBKDF2BasicAbort63KBPromiseJsunit.test.js | 428 ----------- ...PBKDF2BasicFinish63KBPromiseJsunit.test.js | 428 ----------- .../entry/src/main/js/test/switchControl.js | 17 - .../huks_hmac_callback_BasicTest/Test.json | 18 - .../entry/src/main/js/MainAbility/app.js | 23 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...ecurityHuksHmacBasicCallbackJsunit.test.js | 432 ----------- .../entry/src/main/js/test/switchControl.js | 17 - .../huks_hmac_promise_BasicTest/Test.json | 18 - .../entry/src/main/js/MainAbility/app.js | 23 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - ...SecurityHuksHmacBasicPromiseJsunit.test.js | 291 ------- .../entry/src/main/js/test/switchControl.js | 17 - .../Test.json | 18 - .../entry/src/main/js/MainAbility/app.js | 23 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - .../entry/src/main/js/test/List.test.js | 28 - ...uksDSABasicAbort63KBCallbackJsunit.test.js | 509 ------------ ...uksDSABasicAbort65KBCallbackJsunit.test.js | 514 ------------- ...ksDSABasicFinish63KBCallbackJsunit.test.js | 531 ------------- ...ksDSABasicFinish65KBCallbackJsunit.test.js | 525 ------------- ...uksECCBasicAbort63KBCallbackJsunit.test.js | 526 ------------- ...uksECCBasicAbort65KBCallbackJsunit.test.js | 526 ------------- ...ksECCBasicFinish63KBCallbackJsunit.test.js | 542 ------------- ...ksECCBasicFinish65KBCallbackJsunit.test.js | 536 ------------- ...rityHuksED25519BasicCallbackJsunit.test.js | 606 --------------- ...uksRSABasicAbort63KBCallbackJsunit.test.js | 590 -------------- ...uksRSABasicAbort65KBCallbackJsunit.test.js | 590 -------------- ...ksRSABasicFinish63KBCallbackJsunit.test.js | 607 --------------- ...ksRSABasicFinish65KBCallbackJsunit.test.js | 608 --------------- .../entry/src/main/js/test/switchControl.js | 17 - .../Test.json | 18 - .../entry/src/main/js/MainAbility/app.js | 23 - .../main/js/MainAbility/pages/index/index.css | 46 -- .../main/js/MainAbility/pages/index/index.js | 41 - .../entry/src/main/js/test/List.test.js | 28 - ...HuksDSABasicAbort63KBPromiseJsunit.test.js | 409 ---------- ...HuksDSABasicAbort65KBPromiseJsunit.test.js | 410 ---------- ...uksDSABasicFinish63KBPromiseJsunit.test.js | 438 ----------- ...uksDSABasicFinish65KBPromiseJsunit.test.js | 426 ----------- ...HuksECCBasicAbort63KBPromiseJsunit.test.js | 425 ---------- ...HuksECCBasicAbort65KBPromiseJsunit.test.js | 425 ---------- ...uksECCBasicFinish63KBPromiseJsunit.test.js | 441 ----------- ...uksECCBasicFinish65KBPromiseJsunit.test.js | 435 ----------- ...urityHuksED25519BasicPromiseJsunit.test.js | 493 ------------ ...HuksRSABasicAbort63KBPromiseJsunit.test.js | 477 ------------ ...HuksRSABasicAbort65KBPromiseJsunit.test.js | 477 ------------ ...uksRSABasicFinish63KBPromiseJsunit.test.js | 494 ------------ ...uksRSABasicFinish65KBPromiseJsunit.test.js | 495 ------------ .../entry/src/main/js/test/switchControl.js | 17 - .../BUILD.gn | 2 +- .../huks_agree_callback_BasicTest/BUILD.gn | 0 .../huks_agree_callback_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 12 +- .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...HuksDHBasicAbort63KBCallbackJsunit.test.js | 65 ++ ...HuksDHBasicAbort65KBCallbackJsunit.test.js | 65 ++ ...uksDHBasicFinish63KBCallbackJsunit.test.js | 66 ++ ...uksDHBasicFinish65KBCallbackJsunit.test.js | 66 ++ ...ksECDHBasicAbort63KBCallbackJsunit.test.js | 69 ++ ...ksECDHBasicAbort65KBCallbackJsunit.test.js | 69 ++ ...sECDHBasicFinish63KBCallbackJsunit.test.js | 69 ++ ...sECDHBasicFinish65KBCallbackJsunit.test.js | 69 ++ ...X25519BasicAbort63KBCallbackJsunit.test.js | 69 ++ ...X25519BasicAbort65KBCallbackJsunit.test.js | 69 ++ ...25519BasicFinish63KBCallbackJsunit.test.js | 69 ++ ...25519BasicFinish65KBCallbackJsunit.test.js | 69 ++ .../entry/src/main/js/test/List.test.js | 24 +- .../entry/src/main/js/test/switchControl.js | 4 +- .../signature/openharmony_sx.p7b | Bin .../huks_agree_promise_BasicTest/BUILD.gn | 0 .../huks_agree_promise_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 12 +- .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...AgreeDHBasicAbort63KBPromiseJsunit.test.js | 65 ++ ...AgreeDHBasicAbort65KBPromiseJsunit.test.js | 65 ++ ...greeDHBasicFinish63KBPromiseJsunit.test.js | 66 ++ ...greeDHBasicFinish65KBPromiseJsunit.test.js | 66 ++ ...reeECDHBasicAbort63KBPromiseJsunit.test.js | 73 ++ ...reeECDHBasicAbort65KBPromiseJsunit.test.js | 74 ++ ...eeECDHBasicFinish63KBPromiseJsunit.test.js | 85 ++ ...eeECDHBasicFinish65KBPromiseJsunit.test.js | 74 ++ ...eX25519BasicAbort63KBPromiseJsunit.test.js | 70 ++ ...eX25519BasicAbort65KBPromiseJsunit.test.js | 69 ++ ...X25519BasicFinish63KBPromiseJsunit.test.js | 69 ++ ...X25519BasicFinish65KBPromiseJsunit.test.js | 69 ++ .../entry/src/main/js/test/List.test.js | 24 +- .../entry/src/main/js/test/switchControl.js | 4 +- .../signature/openharmony_sx.p7b | Bin .../huks_cipher_callback_BasicTest/BUILD.gn | 0 .../huks_cipher_callback_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 12 +- .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...SecurityHuksAESBasicCallbackJsunit.test.js | 484 ++++++++++++ ...SecurityHuksRSABasicCallbackJsunit.test.js | 539 +++++++++++++ .../entry/src/main/js/test/List.test.js | 4 +- .../entry/src/main/js/test/switchControl.js | 4 +- .../signature/openharmony_sx.p7b | Bin .../huks_cipher_promise_BasicTest/BUILD.gn | 0 .../huks_cipher_promise_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 12 +- .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...ityHuksCipherAESBasicPromiseJsunit.test.js | 430 +++++++++++ ...ityHuksCipherRSABasicPromiseJsunit.test.js | 478 ++++++++++++ .../entry/src/main/js/test/List.test.js | 4 +- .../entry/src/main/js/test/switchControl.js | 4 +- .../signature/openharmony_sx.p7b | Bin .../huks_derive_callback_BasicTest/BUILD.gn | 0 .../huks_derive_callback_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 12 +- .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...ksHKDFBasicAbort63KBCallbackJsunit.test.js | 64 ++ ...sHKDFBasicFinish63KBCallbackJsunit.test.js | 64 ++ ...PBKDF2BasicAbort63KBCallbackJsunit.test.js | 64 ++ ...BKDF2BasicFinish63KBCallbackJsunit.test.js | 64 ++ .../entry/src/main/js/test/List.test.js | 8 +- .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../huks_derive_promise_BasicTest/BUILD.gn | 0 .../huks_derive_promise_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 23 + .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...iveHKDFBasicAbort63KBPromiseJsunit.test.js | 65 ++ ...veHKDFBasicFinish63KBPromiseJsunit.test.js | 64 ++ ...ePBKDF2BasicAbort63KBPromiseJsunit.test.js | 64 ++ ...PBKDF2BasicFinish63KBPromiseJsunit.test.js | 65 ++ .../entry/src/main/js/test/List.test.js | 8 +- .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../huks_hmac_callback_BasicTest/BUILD.gn | 0 .../huks_hmac_callback_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 23 + .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...ecurityHuksHmacBasicCallbackJsunit.test.js | 314 ++++++++ .../entry/src/main/js/test/List.test.js | 2 +- .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../huks_hmac_promise_BasicTest/BUILD.gn | 0 .../huks_hmac_promise_BasicTest/Test.json | 18 + .../entry/src/main/config.json | 0 .../entry/src/main/js/MainAbility/app.js | 23 + .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin ...SecurityHuksHmacBasicPromiseJsunit.test.js | 206 +++++ .../entry/src/main/js/test/List.test.js | 2 +- .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../BUILD.gn | 0 .../Test.json | 18 + .../entry/src/main/config.json | 2 +- .../entry/src/main/js/MainAbility/app.js | 23 + .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin .../entry/src/main/js/test/List.test.js | 28 + ...uksDSABasicAbort63KBCallbackJsunit.test.js | 43 ++ ...uksDSABasicAbort65KBCallbackJsunit.test.js | 44 ++ ...ksDSABasicFinish63KBCallbackJsunit.test.js | 59 ++ ...ksDSABasicFinish65KBCallbackJsunit.test.js | 59 ++ ...uksECCBasicAbort63KBCallbackJsunit.test.js | 43 ++ ...uksECCBasicAbort65KBCallbackJsunit.test.js | 43 ++ ...ksECCBasicFinish63KBCallbackJsunit.test.js | 59 ++ ...ksECCBasicFinish65KBCallbackJsunit.test.js | 59 ++ ...rityHuksED25519BasicCallbackJsunit.test.js | 141 ++++ ...uksRSABasicAbort63KBCallbackJsunit.test.js | 47 ++ ...uksRSABasicAbort65KBCallbackJsunit.test.js | 44 ++ ...ksRSABasicFinish63KBCallbackJsunit.test.js | 61 ++ ...ksRSABasicFinish65KBCallbackJsunit.test.js | 61 ++ .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../BUILD.gn | 0 .../Test.json | 18 + .../entry/src/main/config.json | 2 +- .../entry/src/main/js/MainAbility/app.js | 23 + .../src/main/js/MainAbility/i18n/en-US.json | 0 .../src/main/js/MainAbility/i18n/zh-CN.json | 0 .../main/js/MainAbility/pages/index/index.css | 46 ++ .../main/js/MainAbility/pages/index/index.hml | 0 .../main/js/MainAbility/pages/index/index.js | 40 + .../js/resources/base/element/string.json | 0 .../src/main/js/resources/base/media/icon.png | Bin .../entry/src/main/js/test/List.test.js | 28 + ...HuksDSABasicAbort63KBPromiseJsunit.test.js | 43 ++ ...HuksDSABasicAbort65KBPromiseJsunit.test.js | 43 ++ ...uksDSABasicFinish63KBPromiseJsunit.test.js | 59 ++ ...uksDSABasicFinish65KBPromiseJsunit.test.js | 59 ++ ...HuksECCBasicAbort63KBPromiseJsunit.test.js | 43 ++ ...HuksECCBasicAbort65KBPromiseJsunit.test.js | 43 ++ ...uksECCBasicFinish63KBPromiseJsunit.test.js | 59 ++ ...uksECCBasicFinish65KBPromiseJsunit.test.js | 59 ++ ...urityHuksED25519BasicPromiseJsunit.test.js | 141 ++++ ...HuksRSABasicAbort63KBPromiseJsunit.test.js | 44 ++ ...HuksRSABasicAbort65KBPromiseJsunit.test.js | 45 ++ ...uksRSABasicFinish63KBPromiseJsunit.test.js | 61 ++ ...uksRSABasicFinish65KBPromiseJsunit.test.js | 62 ++ .../entry/src/main/js/test/switchControl.js | 17 + .../signature/openharmony_sx.p7b | Bin .../utils/data.json | 10 +- .../utils/param/agree/publicAgreeCallback.js | 270 +++++++ .../utils/param/agree/publicAgreeParam.js | 430 +++++++++++ .../utils/param/agree/publicAgreePromise.js | 185 +++++ .../utils/param/cipher/publicCipherParam.js | 139 ++++ .../param/derive/publicDeriveCallback.js | 226 ++++++ .../utils/param/derive/publicDeriveParam.js | 295 +++++++ .../utils/param/derive/publicDerivePromise.js | 151 ++++ .../utils/param/hmac/publicHmacParam.js | 51 ++ .../utils/param/publicFunc.js | 39 + .../utils/param/publicParam.js | 132 ++++ .../signverify/publicSignverifyCallback.js | 353 +++++++++ .../param/signverify/publicSignverifyParam.js | 277 +++++++ .../signverify/publicSignverifyPromise.js | 259 +++++++ 327 files changed, 10353 insertions(+), 34356 deletions(-) delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/Test.json delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/Test.json delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_cipher_callback_BasicTest/Test.json delete mode 100644 security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_cipher_promise_BasicTest/Test.json delete mode 100644 security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/Test.json delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/Test.json delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/Test.json delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/Test.json delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/Test.json delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/Test.json delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js delete mode 100644 security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/BUILD.gn (97%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/config.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js (81%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js (90%) rename security/{security_huks/huks_cipher_promise_BasicTest => security_huks_basic/huks_agree_callback_BasicTest}/entry/src/main/js/test/switchControl.js (90%) rename security/{security_huks => security_huks_basic}/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/config.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js (81%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js (87%) rename security/{security_huks/huks_agree_callback_BasicTest => security_huks_basic/huks_agree_promise_BasicTest}/entry/src/main/js/test/switchControl.js (90%) rename security/{security_huks => security_huks_basic}/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/config.json (100%) rename security/{security_huks/huks_cipher_promise_BasicTest => security_huks_basic/huks_cipher_callback_BasicTest}/entry/src/main/js/MainAbility/app.js (81%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js (80%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js (90%) rename security/{security_huks => security_huks_basic}/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/config.json (100%) rename security/{security_huks/huks_cipher_callback_BasicTest => security_huks_basic/huks_cipher_promise_BasicTest}/entry/src/main/js/MainAbility/app.js (81%) rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js (79%) rename security/{security_huks/huks_agree_promise_BasicTest => security_huks_basic/huks_cipher_promise_BasicTest}/entry/src/main/js/test/switchControl.js (90%) rename security/{security_huks => security_huks_basic}/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/config.json (100%) rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js (81%) rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js (65%) create mode 100644 security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/config.json (100%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js (64%) create mode 100644 security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/config.json (100%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js rename security/{security_huks/huks_hmac_promise_BasicTest => security_huks_basic/huks_hmac_callback_BasicTest}/entry/src/main/js/test/List.test.js (88%) create mode 100644 security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/config.json (100%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js rename security/{security_huks/huks_hmac_callback_BasicTest => security_huks_basic/huks_hmac_promise_BasicTest}/entry/src/main/js/test/List.test.js (88%) create mode 100644 security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/config.json (95%) create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/BUILD.gn (100%) create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/config.json (95%) create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json (100%) create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml (100%) create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json (100%) rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png (100%) create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js create mode 100644 security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js rename security/{security_huks => security_huks_basic}/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b (100%) rename security/{security_huks => security_huks_basic}/utils/data.json (99%) create mode 100644 security/security_huks_basic/utils/param/agree/publicAgreeCallback.js create mode 100644 security/security_huks_basic/utils/param/agree/publicAgreeParam.js create mode 100644 security/security_huks_basic/utils/param/agree/publicAgreePromise.js create mode 100644 security/security_huks_basic/utils/param/cipher/publicCipherParam.js create mode 100644 security/security_huks_basic/utils/param/derive/publicDeriveCallback.js create mode 100644 security/security_huks_basic/utils/param/derive/publicDeriveParam.js create mode 100644 security/security_huks_basic/utils/param/derive/publicDerivePromise.js create mode 100644 security/security_huks_basic/utils/param/hmac/publicHmacParam.js create mode 100644 security/security_huks_basic/utils/param/publicFunc.js create mode 100644 security/security_huks_basic/utils/param/publicParam.js create mode 100644 security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js create mode 100644 security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js create mode 100644 security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js diff --git a/security/BUILD.gn b/security/BUILD.gn index dc7ea7886..f77b8122f 100644 --- a/security/BUILD.gn +++ b/security/BUILD.gn @@ -20,7 +20,7 @@ group("security") { "access_token/AccessTokenTest_NoPermission_js:ActsAccessTokenJSApiTestNoPermission", "access_token/AccessTokenTest_Normal_js:ActsAccessTokenJSApiTestNormal", "huks_standard", - "security_huks", + "security_huks_basic", ] } } diff --git a/security/security_huks/huks_agree_callback_BasicTest/Test.json b/security/security_huks/huks_agree_callback_BasicTest/Test.json deleted file mode 100644 index 3a7a58c25..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksAgreeBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksagreebasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAgreeBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index ea2f6b3a7..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 4be2c143c..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 6af1de931..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHAbort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 09e5dddde..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,554 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 066b908dc..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHCallbackJsunit', function () { - it('testAgreeDHFinish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index f9034549b..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 11a0c0b9b..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHAbort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 86f192b62..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index f1cc789d1..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHCallbackJsunit', function () { - it('testAgreeECDHFinish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 34a09d8e5..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index c857833f5..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Abort65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index b6e2e942a..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index ef7f19f9d..000000000 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,591 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { - await exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKeys == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519CallbackJsunit', function () { - it('testAgreeX25519Finish65KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/Test.json b/security/security_huks/huks_agree_promise_BasicTest/Test.json deleted file mode 100644 index 577bcde43..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksAgreeBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksagreebasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksAgreeBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 713b3dbbf..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index d95faef73..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Abort63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 3051c64ab..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Abort65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 6241a63ce..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHFinish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 44d25f92a..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} -let HuksAgree002 = { - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} -let HuksOptions65kb = { - properties: new Array( - HuksAgree002.HuksKeyAlgDH, - HuksAgree002.HuksKeyPurposeDH, - HuksAgree002.HuksKeyDHSize2048 - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} -describe('SecurityHuksAgreeDHPromiseJsunit', function () { - it('testAgreeDHSize2048Finish65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree002.HuksKeySTORAGE, - HuksAgree002.HuksKeyISKEYALIAS, - HuksAgree002.HuksKeyALGORITHMAES, - HuksAgree002.HuksKeySIZE256, - HuksAgree002.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree002.HuksKeyPADDINGNONE, - HuksAgree002.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index c1575369b..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,498 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) -let HuksOptions63kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - } - console.info('test beforeEach called') - }) - it('testAgreeECDHFinish63KBAgree003', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4320931c6..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,499 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HuksOptions65kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree004', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index b20f8960b..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions63kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData63Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 591b7d8f9..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, beforeEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) -let HuksOptions65kb - -let HksKeyAlg = { - HKS_ALG_ECDH: 100, - HKS_ALG_ECC: 2, - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_128: 128, - HKS_ECC_KEY_SIZE_192: 192, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, - HKS_ECC_KEY_SIZE_521: 521, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree001 = { - HuksKeyAlgECDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECDH, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyECCPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyECCBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_192, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeECDH: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - HuksOptions.properties.splice(0, 1, HuksAgree001.HuksKeyAlgECDH) - HuksOptions.properties.splice(3, 1) - HuksOptions.properties.splice(4, 1) - HuksOptions.properties.splice(5, 1) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeECDHPromiseJsunit', function () { - beforeEach(function () { - HuksOptions65kb = { - properties: new Array( - HuksAgree001.HuksKeyAlgECC, - HuksAgree001.HuksKeyPurposeECDH, - HuksAgree001.HuksKeyECCSize224, - HuksAgree001.HuksKeyECCDIGEST, - HuksAgree001.HuksKeyECCPADDING, - HuksAgree001.HuksKeyECCBLOCKMODE - ), - inData: srcData65Kb, - } - console.info('test beforeEach called') - }) - - it('testAgreeECDHFinish63KBAgree002', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree001.HuksKeySTORAGE, - HuksAgree001.HuksKeyISKEYALIAS, - HuksAgree001.HuksKeyALGORITHMAES, - HuksAgree001.HuksKeySIZE256, - HuksAgree001.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree001.HuksKeyPADDINGNONE, - HuksAgree001.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index ccf94a17b..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Abort63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4c0442e8d..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Abort65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index e409b554b..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish63KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 86b3bc16e..000000000 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let exportKeyFrist -let exportKeySecond -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData65 = Data.Date65KB -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DH: 103, - HKS_ALG_AES: 20, - HKS_ALG_HMAC: 50, - HKS_ALG_X25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeySize = { - HKS_DH_KEY_SIZE_128: 128, - HKS_DH_KEY_SIZE_192: 192, - HKS_DH_KEY_SIZE_256: 256, - HKS_DH_KEY_SIZE_512: 512, - HKS_DH_KEY_SIZE_2048: 2048, - HKS_DH_KEY_SIZE_3072: 3072, - HKS_DH_KEY_SIZE_4096: 4096, - HKS_CURVE25519_KEY_SIZE_256: 256, -} -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksAgree003 = { - HuksKeyAlgX25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_X25519, - }, - HuksKeyPurposeAGREE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyCURVE25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyPADDING: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyDIGEST: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_192, - }, - HuksKeyAlgDH: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DH, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyAlgHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeX25519: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, - }, - HuksKeyDHSize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_2048, - }, - HuksKeyDHSize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_3072, - }, - HuksKeyDHSize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DH_KEY_SIZE_4096, - }, -} - -let HuksOptions65kb = { - properties: new Array( - HuksAgree003.HuksKeyAlgX25519, - HuksAgree003.HuksKeyPurposeAGREE, - HuksAgree003.HuksKeyCURVE25519Size256, - HuksAgree003.HuksKeyDIGEST, - HuksAgree003.HuksKeyPADDING, - HuksAgree003.HuksKeyBLOCKMODE - ), - inData: srcData65Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { - await huks - .exportKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (exportKey == 1) { - exportKeyFrist = data.outData - } else { - exportKeySecond = data.outData - } - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAgreeUpdateFunc(HuksOptions, exportKey) { - let _inData = HuksOptions.inData - if (exportKey == 1) { - HuksOptions.inData = exportKeySecond - } else { - HuksOptions.inData = exportKeyFrist - } - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - HuksOptions.inData = _inData -} - -async function publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - finishData -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - if (finishData == 1) { - finishDataFrist = data.outData - } else { - finishDataSecond = data.outData - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicAgreeGenFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeExport1Func(srcKeyAliesFirst, HuksOptions, 1) - await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2) - - await publicAgreeInitFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 1) - await publicAgreeFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName, - 1 - ) - - let _huksOptionsFinish = huksOptionsFinish - let huksOptionsFinishSecond = _huksOptionsFinish - huksOptionsFinishSecond.properties.splice(6, 1, { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesSecond + 'final'), - }) - - await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions) - await publicAgreeUpdateFunc(HuksOptions, 2) - await publicAgreeFinishAbortFunc( - huksOptionsFinishSecond, - thirdInderfaceName, - 2 - ) - - await publicAgreeDeleteFunc(srcKeyAliesFirst, HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions) - await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksAgreeX25519PromiseJsunit', function () { - it('testAgreeX25519Finish65KBAgree001', 0, async function (done) { - const srcKeyAliesFirst = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001' - const srcKeyAliesSecond = - 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001' - let huksOptionsFinish = { - properties: new Array( - HuksAgree003.HuksKeySTORAGE, - HuksAgree003.HuksKeyISKEYALIAS, - HuksAgree003.HuksKeyALGORITHMAES, - HuksAgree003.HuksKeySIZE256, - HuksAgree003.HuksKeyPurposeENCRYPTDECRYPT, - HuksAgree003.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksAgree003.HuksKeyPADDINGNONE, - HuksAgree003.HuksKeyBLOCKMODEECB - ), - inData: srcData65Kb, - } - await publicAgreeFunc( - srcKeyAliesFirst, - srcKeyAliesSecond, - HuksOptions65kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_callback_BasicTest/Test.json b/security/security_huks/huks_cipher_callback_BasicTest/Test.json deleted file mode 100644 index 5f20212e1..000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksCipherBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukscipherbasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksCipherBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 48c4a1965..000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js deleted file mode 100644 index d1e8765ee..000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js +++ /dev/null @@ -1,674 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let IV = '0000000000000000' -let AAD = '0000000000000000' -let NONCE = '000000000000' -let AEAD = '0000000000000000' - -let HksKeyAlg = { - HKS_ALG_AES: 20, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_PKCS7: 5, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, - HKS_TAG_AE_TAG: HksTagType.HKS_TAG_TYPE_BYTES | 10009, -} - -let HuksCipher001 = { - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyAESSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyAESSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyAESSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyAESPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyAESPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyAESBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyAESBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyAESBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyAESDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, -} -let defaultData = '0' - -let srcData65 = - 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string' -let srcData65Kb = stringToUint8Array(srcData65) - -let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string' -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let updateResult = new Array() -let encryptFinishData -let encryptedData -var handle = {} -var handle1 -var handle2 - -let genHuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurpose - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ) - await generateKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - // HuksOptions.inData = new Uint8Array(new Array()); - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - 0, - huksOptionsInData.length - ) - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - console.log('test count ' + count + 'remainder ' + remainder) - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - } - HuksOptions.inData = huksOptionsInData - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - huksOptionsInData.length - ) - } -} - -async function update(handle, HuksOptions) { - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - if (updateResult.length !== 0) { - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - updateResult = Array.from(data.outData) - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - dataLength -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - console.log(`test remainder ${remainder}`) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await finishCallback(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - let finishData - if (encryptedData.length > 64) { - finishData = uint8ArrayToString( - updateResult.concat(Array.from(data.outData)) - ) - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - finishData = uint8ArrayToString(updateResult) - } - if (isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - expect(data.errorCode == 0).assertTrue() - } else { - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finishCallback(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function abort(HuksOptions) { - await abortCallback(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abortCallback(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - await deleteKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicCipherFunc( - srcKeyAlies, - genHuksOptionsNONECBC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - try { - updateResult = new Array() - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - encryptedData = HuksOptions.inData - } - await publicInitFunc(srcKeyAlies, HuksOptions) - await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherAESCallbackJsunit', function () { - it('testCipherAES001', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - genHuksOptions.properties.splice(2, 1, HuksCipher001.HuksKeyAESSize128) - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher001.HuksKeyAESBLOCKMODE - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher001.HuksKeyAESPADDINGNONE - ) - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES002', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherAES003', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES004', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js deleted file mode 100644 index f4c437f37..000000000 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let gInData64 = - 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher002 = { - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSAPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGOAEP: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_OAEP, - }, - HuksKeyRSABLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyRSADIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyRSADIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyRSADIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyRSADIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyRSADIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyRSADIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} -let defaultData = '0' - -let gInData64Array = stringToUint8Array(gInData64) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let encryptFinishData -let encryptedData -let inputInData -var handle = {} -var handle1 -var handle2 -let updateResult = new Array() -let exportKey -let importKey - -let genHuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurpose, - HuksCipher002.HuksKeyRSASize512 - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await generateKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await exportkey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test ExportKey data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { - HuksOptions.inData = exportKey - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importkey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - importKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function importkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = stringToUint8Array('0') - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)) - HuksOptions.inData = new Uint8Array(new Array()) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await finishCallback(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - if (isEncrypt) { - updateResult = Array.from(data.outData) - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - expect(null).assertFail() - } else { - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - expect(data.errorCode == 0).assertTrue() - } else { - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finishCallback(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function abort(HuksOptions) { - await abortCallback(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abortCallback(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - await deleteKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} -async function publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptionsNONC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - inputInData = HuksOptions.inData - try { - updateResult = new Array() - let KeyAlias = srcKeyAlies - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) - encryptedData = HuksOptions.inData - await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicImportKeyFunc(newSrcKeyAlies, HuksOptions) - KeyAlias = newSrcKeyAlies - } - HuksOptions.inData = inputInData - await publicInitFunc(KeyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherRSACallbackJsunit', function () { - it('testCipherRSA001', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher002.HuksKeyRSABLOCKMODEECB - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher002.HuksKeyRSAPADDINGNONE - ) - genHuksOptions.properties.splice( - 5, - 1, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ) - - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA002', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherRSA003', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA004', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_promise_BasicTest/Test.json b/security/security_huks/huks_cipher_promise_BasicTest/Test.json deleted file mode 100644 index 09ddfbd58..000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksCipherBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukscipherbasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksCipherBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 48c4a1965..000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000 - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js deleted file mode 100644 index 30a582c71..000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' - -let IV = '0000000000000000' -let AAD = '0000000000000000' -let NONCE = '000000000000' -let AEAD = '0000000000000000' - -let HksKeyAlg = { - HKS_ALG_AES: 20, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_PKCS7: 5, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher001 = { - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyAESSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyAESSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyAESSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyAESPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyAESPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyAESBLOCKMODE: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyAESBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyAESBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyAESDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, -} -let defaultData = '0' -let srcData65 = - 'Hks_AES_Cipher_Test_00000000000000000000000000000000000000000000000000000_string' -let srcData65Kb = stringToUint8Array(srcData65) - -let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string' -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let updateResult = new Array() -let encryptFinishData -let encryptedData -var handle = {} -var handle1 -var handle2 - -let genHuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurpose - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - console.log( - `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` - ) - await huks - .generateKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = new Uint8Array(new Array()) - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - 0, - huksOptionsInData.length - ) - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - console.log('test count ' + count + 'remainder ' + remainder) - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - } - HuksOptions.inData = huksOptionsInData - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } else { - HuksOptions.inData = new Uint8Array(new Array()) - } - await publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - huksOptionsInData.length - ) - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - console.log(`test update data ${JSON.stringify(HuksOptions.inData.length)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - if (updateResult.length !== 0) { - console.log(`test update outDatalength ${updateResult.length}`) - updateResult = updateResult.concat(Array.from(data.outData)) - console.log(`test update outDatalength ${updateResult.length}`) - } else { - console.log(`test update outDatalength ${updateResult.length}`) - updateResult = Array.from(data.outData) - console.log(`test update outDatalength ${updateResult.length}`) - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt, - remainder, - dataLength -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - console.log(`test remainder ${remainder}`) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - HuksOptions.outData = new Uint8Array( - new Array(encryptedData.length * 2) - ) - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - let finishData - if (encryptedData.length > 64) { - finishData = uint8ArrayToString( - updateResult.concat(Array.from(data.outData)) - ) - updateResult = updateResult.concat(Array.from(data.outData)) - } else { - finishData = uint8ArrayToString(updateResult) - } - if (isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if (finishData === uint8ArrayToString(encryptedData)) { - console.log( - `test finish Decrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt success ${uint8ArrayToString( - finishData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } else { - console.log( - `test finish Decrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt fail ${uint8ArrayToString( - finishData - )}` - ) - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function abort(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { - await huks - .deleteKey(srcKeyAlies, genHuksOptionsNONECBC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicCipherFunc( - srcKeyAlies, - genHuksOptionsNONECBC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - try { - updateResult = new Array() - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - encryptedData = HuksOptions.inData - } - await publicInitFunc(srcKeyAlies, HuksOptions) - await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherAESPromiseJsunit', function () { - it('testCipherAES001', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - genHuksOptions.properties.splice(2, 1, HuksCipher001.HuksKeyAESSize128) - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher001.HuksKeyAESBLOCKMODE - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher001.HuksKeyAESPADDINGNONE - ) - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES002', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherAES003', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: srcData63Kb, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeDECRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherAES004', 0, async function (done) { - const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksCipher001.HuksKeyAlgAES, - HuksCipher001.HuksKeyPurposeENCRYPT, - HuksCipher001.HuksKeyAESSize128, - HuksCipher001.HuksKeyAESPADDINGNONE, - HuksCipher001.HuksKeyAESBLOCKMODE, - HuksCipher001.HuksKeyAESDIGESTNONE, - { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js deleted file mode 100644 index 01ba2241f..000000000 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js +++ /dev/null @@ -1,662 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' - -let gInData64 = - 'RSA_64_ttttttttttttttttttttttttttttttttttttttttttttttttttttttttt' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, - HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, - HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksCipher002 = { - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPurposeENCRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, - }, - HuksKeyPurposeDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSAPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGOAEP: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_OAEP, - }, - HuksKeyRSABLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyRSADIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyRSADIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyRSADIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyRSADIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyRSADIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyRSADIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} -let defaultData = '0' - -let gInData64Array = stringToUint8Array(gInData64) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -let encryptFinishData -let encryptedData -let inputInData -var handle = {} -var handle1 -var handle2 -let updateResult = new Array() -let exportKey -let importKey - -let genHuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurpose, - HuksCipher002.HuksKeyRSASize512 - ), - inData: new Uint8Array(defaultData), -} - -async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await huks - .generateKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - console.log( - `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` - ) - await huks - .exportKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test ExportKey data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { - HuksOptions.inData = exportKey - console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - importKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(srcKeyAlies, HuksOptions) { - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - console.log( - `test update before handle: ${JSON.stringify( - handle - )} HuksOptions: ${JSON.stringify(HuksOptions)}` - ) - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - console.log( - 'test update finish HuksOptions inData: ' + - Array.from(inDataArray).length - ) - if (Array.from(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = stringToUint8Array('0') - } else { - let count = Math.floor(Array.from(inDataArray).length / dateSize) - let remainder = Array.from(inDataArray).length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - console.log( - 'test ' + - uint8ArrayToString( - new Uint8Array( - Array.from(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - ) - ) - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishAbortFunc( - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - if (thirdInderfaceName == 'finish') { - HuksOptions.outData = new Uint8Array(new Array(1024)) - HuksOptions.inData = new Uint8Array(new Array()) - await finish(HuksOptions, isEncrypt) - } else if (thirdInderfaceName == 'abort') { - await abort(HuksOptions) - } -} - -async function finish(HuksOptions, isEncrypt) { - console.log('test before finish HuksOptions inData: ' + HuksOptions.inData) - console.log( - 'test before finish HuksOptions outData: ' + HuksOptions.outData - ) - console.log( - 'test before finish HuksOptions outData: ' + HuksOptions.outData.length - ) - console.log( - 'test before finish HuksOptions properties: ' + - JSON.stringify(HuksOptions.properties) - ) - - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - if (isEncrypt) { - updateResult = Array.from(data.outData) - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - data.outData - )}` - ) - expect(null).assertFail() - } else { - console.log( - `test finish Encrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt success ${uint8ArrayToString( - data.outData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } - } - if (!isEncrypt) { - if ( - uint8ArrayToString(data.outData) === - uint8ArrayToString(encryptedData) - ) { - console.log( - `test finish Decrypt success ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Decrypt success ${uint8ArrayToString( - data.outData - )}` - ) - expect(data.errorCode == 0).assertTrue() - } else { - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - encryptedData - )}` - ) - console.log( - `test finish Encrypt fail ${uint8ArrayToString( - data.outData - )}` - ) - expect(null).assertFail() - } - } - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function abort(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { - await huks - .deleteKey(srcKeyAlies, genHuksOptionsNONC) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptionsNONC, - HuksOptions, - thirdInderfaceName, - isEncrypt -) { - inputInData = HuksOptions.inData - try { - updateResult = new Array() - let KeyAlias = srcKeyAlies - if (isEncrypt) { - await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) - encryptedData = HuksOptions.inData - await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicImportKeyFunc(newSrcKeyAlies, HuksOptions) - KeyAlias = newSrcKeyAlies - } - HuksOptions.inData = inputInData - await publicInitFunc(KeyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt) - if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { - await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) - await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksCipherRSAPromiseJsunit', function () { - it('testCipherRSA001', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - genHuksOptions.properties.splice( - 3, - 1, - HuksCipher002.HuksKeyRSABLOCKMODEECB - ) - genHuksOptions.properties.splice( - 4, - 1, - HuksCipher002.HuksKeyRSAPADDINGNONE - ) - genHuksOptions.properties.splice( - 5, - 1, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ) - - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA002', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) - - it('testCipherRSA003', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias001' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeDECRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: new Uint8Array(updateResult), - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'finish', - false - ) - done() - }) - - it('testCipherRSA004', 0, async function (done) { - const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias002' - const newSrcKeyAlies = - 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksCipher002.HuksKeyAlgRSA, - HuksCipher002.HuksKeyPurposeENCRYPT, - HuksCipher002.HuksKeyRSASize512, - HuksCipher002.HuksKeyRSAPADDINGNONE, - HuksCipher002.HuksKeyRSABLOCKMODEECB, - HuksCipher002.HuksKeyRSADIGESTSHA256 - ), - inData: gInData64Array, - outData: stringToUint8Array('0'), - } - await publicCipherFunc( - srcKeyAlies, - newSrcKeyAlies, - genHuksOptions, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/Test.json b/security/security_huks/huks_derive_callback_BasicTest/Test.json deleted file mode 100644 index 999041316..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksDeriveBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksderivebasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksDeriveBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d3..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index bdf2d0717..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFAbort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 639d629dc..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { - it('testDeriveHKDFFinish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index f581619f4..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Abort63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index ed038dec9..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) - return HuksOptions -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { - it('testDerivePBKDF2Finish63KB001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 11f4277ab..000000000 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export {isOpenSSL} diff --git a/security/security_huks/huks_derive_promise_BasicTest/Test.json b/security/security_huks/huks_derive_promise_BasicTest/Test.json deleted file mode 100644 index 11ec956d7..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksDeriveBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksderivebasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksDeriveBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d3..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 39345dc89..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFAbort63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 8657d2906..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_HKDF: 51, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgHKDF: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HKDF, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposeHKDF: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagHKDFDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagHKDFDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagHKDFDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyHKDFSize128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyHKDFSize192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyHKDFSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive001.HuksKeyAlgAES, - HuksDerive001.HuksKeyPurposeHKDF, - HuksDerive001.HuksTagHKDFDigestSHA256, - HuksDerive001.HuksKeyHKDFSize128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgHKDF) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive001.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive001.HuksKeyHKDFSize128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { - it('testDeriveHKDFFinish63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive001.HuksKeySTORAGE, - HuksDerive001.HuksKeyISKEYALIAS, - HuksDerive001.HuksKeyALGORITHMAES, - HuksDerive001.HuksKeySIZE256, - HuksDerive001.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive001.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive001.HuksKeyPADDINGNONE, - HuksDerive001.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index c38e894c9..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Abort63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'abort' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 7d7cda1ca..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let handle1 -let handle2 -let finishDataFrist -let finishDataSecond -let srcData63 = Data.Date63KB -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_PBKDF2: 52, - HKS_ALG_AES: 20, - HKS_ALG_DH: 103, - HKS_ALG_HMAC: 50, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_AGREE: 256, - HKS_KEY_PURPOSE_DERIVE: 16, - HKS_KEY_PURPOSE_ENCRYPT: 1, - HKS_KEY_PURPOSE_DECRYPT: 2, - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyStorageType = { - HKS_STORAGE_TEMP: 0, - HKS_STORAGE_PERSISTENT: 1, -} - -let HksKeySize = { - HKS_AES_KEY_SIZE_128: 128, - HKS_AES_KEY_SIZE_192: 192, - HKS_AES_KEY_SIZE_256: 256, - HKS_AES_KEY_SIZE_512: 512, - DERIVE_KEY_SIZE_32: 32, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BOOL: 4 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksCipherMode = { - HKS_MODE_ECB: 1, - HKS_MODE_CBC: 2, - HKS_MODE_CTR: 3, - HKS_MODE_OFB: 4, - HKS_MODE_CCM: 31, - HKS_MODE_GCM: 32, -} - -let HksKeyPadding = { - HKS_PADDING_NONE: 0, - HKS_PADDING_OAEP: 1, - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, - HKS_PADDING_PKCS5: 4, - HKS_PADDING_PKCS7: 5, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, - HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, - HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, - HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, - HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, -} - -let HuksDerive002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_512, - }, - HuksKeyAlgPBKDF2: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_PBKDF2, - }, - HuksKeyAlgAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyPurposePBKDF2: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksTagPBKDF2DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPBKDF2DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPBKDF2DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyPBKDF2Size128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeyPBKDF2Size192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPBKDF2Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeyDERIVEKEYSIZE: { - tag: HksTag.HKS_TAG_DERIVE_KEY_SIZE, - value: HksKeySize.DERIVE_KEY_SIZE_32, - }, - - HuksKeyISKEYALIAS: { tag: HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, - HuksKeySTORAGE: { - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_PERSISTENT, - }, - HuksKeyALGORITHMAES: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_AES, - }, - HuksKeyALGORITHMHMAC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeySIZE256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_256, - }, - HuksKeySIZE128: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_128, - }, - HuksKeySIZE192: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_AES_KEY_SIZE_192, - }, - HuksKeyPurposeDERIVE: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, - }, - HuksKeyPurposeMAC: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeyPurposeENCRYPTDECRYPT: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | - HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, - }, - HuksKeyPADDINGNONE: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_NONE, - }, - HuksKeyPADDINGPKCS7: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS7, - }, - HuksKeyDIGESTNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksKeyDIGESTSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksKeyDIGESTSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksKeyDIGESTSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksKeyDIGESTSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksKeyDIGESTSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyBLOCKMODECBC: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CBC, - }, - HuksKeyBLOCKMODECCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CCM, - }, - HuksKeyBLOCKMODEECB: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_ECB, - }, - HuksKeyBLOCKMODECTR: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_CTR, - }, - HuksKeyBLOCKMODEGCM: { - tag: HksTag.HKS_TAG_BLOCK_MODE, - value: HksCipherMode.HKS_MODE_GCM, - }, -} - -let HuksOptions63kb = { - properties: new Array( - HuksDerive002.HuksKeyAlgAES, - HuksDerive002.HuksKeyPurposePBKDF2, - HuksDerive002.HuksTagPBKDF2DigestSHA256, - HuksDerive002.HuksKeyPBKDF2Size128 - ), - inData: srcData63Kb, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data ${JSON.stringify(data)}`) - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveUpdateFunc(HuksOptions) { - await huks - .update(handle, HuksOptions) - .then((data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeriveFinishAbortFunc( - huksOptionsFinish, - thirdInderfaceName -) { - if (thirdInderfaceName == 'finish') { - console.log( - `test befor finish huksOptionsFinish ${JSON.stringify( - huksOptionsFinish - )}` - ) - await huks - .finish(handle, huksOptionsFinish) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - let huksOptionsAbort = new Array({ - tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, - value: HksKeyStorageType.HKS_STORAGE_TEMP, - }) - await huks - .abort(handle, huksOptionsAbort) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } -} - -async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { - console.log( - 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) - ) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicDeriveFunc( - srcKeyAlies, - HuksOptions, - huksOptionsFinish, - thirdInderfaceName -) { - try { - await publicDeriveGenFunc(srcKeyAlies, HuksOptions) - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgPBKDF2) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyDERIVEKEYSIZE) - - await publicDeriveInitFunc(srcKeyAlies, HuksOptions) - await publicDeriveUpdateFunc(HuksOptions) - await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName) - - HuksOptions.properties.splice(0, 1, HuksDerive002.HuksKeyAlgAES) - HuksOptions.properties.splice(3, 1, HuksDerive002.HuksKeyPBKDF2Size128) - await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { - it('testDerivePBKDF2Finish63KBDerive001', 0, async function (done) { - const srcKeyAliesFirst = - 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_001' - let huksOptionsFinish = { - properties: new Array( - HuksDerive002.HuksKeySTORAGE, - HuksDerive002.HuksKeyISKEYALIAS, - HuksDerive002.HuksKeyALGORITHMAES, - HuksDerive002.HuksKeySIZE256, - HuksDerive002.HuksKeyPurposeENCRYPTDECRYPT, - HuksDerive002.HuksKeyDIGESTNONE, - { - tag: HksTag.HKS_TAG_KEY_ALIAS, - value: stringToUint8Array(srcKeyAliesFirst), - }, - HuksDerive002.HuksKeyPADDINGNONE, - HuksDerive002.HuksKeyBLOCKMODEECB - ), - inData: srcData63Kb, - } - await publicDeriveFunc( - srcKeyAliesFirst, - HuksOptions63kb, - huksOptionsFinish, - 'finish' - ) - done() - }) -}) diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b9..000000000 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_hmac_callback_BasicTest/Test.json b/security/security_huks/huks_hmac_callback_BasicTest/Test.json deleted file mode 100644 index edd5a3c52..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksHmacBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksHmacbasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksHmacBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index e402db6d3..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js deleted file mode 100644 index 05d3af51f..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyAlg = { - HKS_ALG_HMAC: 50, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksHmac = { - HuksKeyAlg: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let srcData63Kb = Data.Date63KB -let srcData65Kb = Data.Date65KB - -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -var handle = {} -var handleStart -var handleEnd - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + - JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log( - 'test generateKey err information: ' + JSON.stringify(e) - ) - reject(e) - } - }) - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test init err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - handleStart = data.handle1 - handleEnd = data.handle2 - handle = { - handle1: handleStart, - handle2: handleEnd, - } - resolve(data) - } - } catch (e) { - console.log('test init err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function update(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test update err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function finish(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.finish(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test finish err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test finish err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function abort(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.abort(handle, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log('test abort err information: ' + JSON.stringify(e)) - reject(e) - } - }) - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - try { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - } catch (e) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(e) - ) - reject(e) - } - }) - }) -} - -async function publicHmacUpdate(HuksOptions) { - let dateSize = 64 * 1024 - let huksOptionsInData = HuksOptions.inData - let inDataArray = stringToArray(HuksOptions.inData) - - if (HuksOptions.inData.length <= dateSize) { - HuksOptions.inData = new Uint8Array(inDataArray) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor(inDataArray.length / dateSize) - let remainder = inDataArray.length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * count, - inDataArray.length - ) - ) - console.log(`test update HuksOptions.inData ${HuksOptions.inData}`) - await update(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - } -} - -async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - console.log( - 'test before generateKey HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log('test generateKey data = ' + JSON.stringify(data)) - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) - - HuksOptions.properties.splice(1, 1) - console.log('test before init HuksOptions = ' + JSON.stringify(HuksOptions)) - await init(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) - console.log( - 'test before Update HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await publicHmacUpdate(HuksOptions) - - if (thirdInderfaceName == 'finish') { - HuksOptions.inData = new Uint8Array(stringToArray('0')) - console.log( - 'test before finish HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test update data: ${data}`) - }) - .catch((err) => { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } else { - console.log( - 'test before abort HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${data}`) - }) - .catch((err) => { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - } - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - console.log( - 'test before deleteKey HuksOptions = ' + JSON.stringify(HuksOptions) - ) - await deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${data}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -describe('SecurityHuksHmacCallbackJsunit', function () { - it('testHmacSHA1001', 0, async function (done) { - let srcKeyAlies = 'testHmacDigestSHA1KeyAlias001' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - - await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - 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() - }) -}) diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b9..000000000 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_hmac_promise_BasicTest/Test.json b/security/security_huks/huks_hmac_promise_BasicTest/Test.json deleted file mode 100644 index 3a98e1ac5..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksHmacBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.huksHmacbasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksHmacBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index ff144d1e0..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {Core, ExpectExtend} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this) - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js deleted file mode 100644 index a0050a3c6..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -var handle = {} -var handle1 -var handle2 -let srcData63Kb = Data.Date63KB -let srcData65Kb = Data.Date65KB -let HksKeyPurpose = { - HKS_KEY_PURPOSE_MAC: 128, -} - -let HksKeyAlg = { - HKS_ALG_HMAC: 50, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, -} - -let HuksHmac = { - HuksKeyAlg: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_HMAC, - }, - HuksKeyPurpose: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_MAC, - }, - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicHmacGenFunc(srcKeyAlies, HuksOptions) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - await huks - .generateKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test generateKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.properties.splice(1, 1) -} - -async function publicHmacInitFunc(srcKeyAlies, HuksOptions) { - await huks - .init(srcKeyAlies, HuksOptions) - .then(async (data) => { - handle1 = data.handle1 - handle2 = data.handle2 - handle = { - handle1: handle1, - handle2: handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log(`test init err: " + ${JSON.stringify(err)}`) - expect(null).assertFail() - }) -} - -async function publicHmacUpdateFunc(HuksOptions) { - let dateSize = 64 * 1024 - let huksOptionsInData = HuksOptions.inData - let inDataArray = stringToArray(HuksOptions.inData) - if (inDataArray.length < dateSize) { - HuksOptions.inData = new Uint8Array(inDataArray) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor(inDataArray.length / dateSize) - let remainder = inDataArray.length % dateSize - for (let i = 0; i < count; i++) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - } - if (remainder !== 0) { - HuksOptions.inData = new Uint8Array( - stringToArray(huksOptionsInData).slice( - dateSize * count, - inDataArray.length - ) - ) - await update(handle, HuksOptions) - } - } -} - -async function publicHmacFinish(HuksOptions, thirdInderfaceName) { - if (thirdInderfaceName == 'finish') { - HuksOptions.inData = new Uint8Array(stringToArray('0')) - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + err) - expect(null).assertFail() - }) - } else if (thirdInderfaceName == 'abort') { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + err) - expect(null).assertFail() - }) - } -} - -async function publicHmacDelete(srcKeyAlies, HuksOptions) { - HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE) - await huks - .deleteKey(srcKeyAlies, HuksOptions) - .then((data) => { - console.log(`test deleteKey data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicHmacFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { - try { - await publicHmacGenFunc(srcKeyAlies, HuksOptions) - await publicHmacInitFunc(srcKeyAlies, HuksOptions) - await publicHmacUpdateFunc(HuksOptions) - await publicHmacFinish(HuksOptions, thirdInderfaceName) - await publicHmacDelete(srcKeyAlies, HuksOptions) - } catch (e) { - expect(null).assertFail() - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -describe('SecurityHuksHmacBasicPromiseJsunit', function () { - it('testHmac001', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias101' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - it('testHmac002', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias102' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) - - it('testHmac003', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias103' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish') - done() - }) - - it('testHmac004', 0, async function (done) { - const srcKeyAlies = 'testHmacDigestSHA1KeyAlias104' - let HuksOptions = { - properties: new Array( - HuksHmac.HuksKeyAlg, - HuksHmac.HuksKeyPurpose, - HuksHmac.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort') - done() - }) -}) diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b9..000000000 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_signverify_callback_BasicTest/Test.json b/security/security_huks/huks_signverify_callback_BasicTest/Test.json deleted file mode 100644 index 4d9e4ea32..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksSignVerifyBasicCallback js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukssignverifybasiccallback", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksSignVerifyBasicCallbackJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 680546925..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js deleted file mode 100644 index 8ca9a6fab..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -require("./SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js") -require("./SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js") \ No newline at end of file diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 1212ab40e..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 356584740..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - it('testSignVerifyDSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index c6970b153..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,531 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let DSA_COMMON_SIZE = 1024 - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagDSACOMMONSIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: DSA_COMMON_SIZE, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let exportKey -var handle = {} -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksTagDSACOMMONSIZE - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 2b739bba1..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { - it('testSignVerifyDSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksKeySIZE1024 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 260d4aa59..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias002' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index 9c5a363d3..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias004' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index c20c2a3f7..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 1c24c25dd..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { - it('testSignVerifyECC103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias003' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js deleted file mode 100644 index dcdede377..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js +++ /dev/null @@ -1,606 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_ED25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeySize = { - HKS_CURVE25519_KEY_SIZE_256: 256, - HKS_ED25519_KEY_SIZE_512: 512, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksSignVerify004 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ED25519_KEY_SIZE_512, - }, - HuksKeyAlgED25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ED25519, - }, - HuksKeyED25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyED25519PurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyED25519PurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, -} - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyED25519CallbackJsunit', function () { - it('testSignVerifyED25519101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js deleted file mode 100644 index 7c14885c8..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js deleted file mode 100644 index a9ea8974c..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js deleted file mode 100644 index 967d3eff4..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js +++ /dev/null @@ -1,607 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js deleted file mode 100644 index 1c5022e4b..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function generateKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -function importKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test importKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test importKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicExportKey(keyAlias, HuksOptions) { - await exportkey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function exportkey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - if (err.code !== 0) { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function init(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.init(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log('test init err information: ' + JSON.stringify(err)) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await updateCallback(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -function updateCallback(handle, HuksOptions) { - return new Promise((resolve, reject) => { - huks.update(handle, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test update err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicFinishFunc(HuksOptions) { - await finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function finish(handle, huksOptionsFinish) { - return new Promise((resolve, reject) => { - huks.finish(handle, huksOptionsFinish, function (err, data) { - if (err.code !== 0) { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicAbortFucn(HuksOptions) { - await abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -function abort(handle, huksOptionsAbort) { - return new Promise((resolve, reject) => { - huks.abort(handle, huksOptionsAbort, function (err, data) { - if (err.code !== 0) { - console.log( - 'test abort err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -function deleteKey(srcKeyAlies, HuksOptions) { - return new Promise((resolve, reject) => { - huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { - if (err.code !== 0) { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - reject(err) - } else { - resolve(data) - } - }) - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { - it('testSignVerifyRSA103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b9..000000000 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/huks_signverify_promise_BasicTest/Test.json b/security/security_huks/huks_signverify_promise_BasicTest/Test.json deleted file mode 100644 index 8bf497f55..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/Test.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "Configuration for huksSignVerifyBasicPromise js api Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "180000", - "package": "com.example.hukssignverifybasicpromise", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsHuksSignVerifyBasicPromiseJSApiTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js deleted file mode 100644 index e423f4bce..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } -}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css deleted file mode 100644 index 5bd756702..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css +++ /dev/null @@ -1,46 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 100%; -} - -.title { - font-size: 40px; - color: #000000; - opacity: 0.9; -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } -} - -@media screen and (device-type: wearable) { - .title { - font-size: 28px; - color: #FFFFFF; - } -} - -@media screen and (device-type: tv) { - .container { - background-image: url("/common/images/Wallpaper.png"); - background-size: cover; - background-repeat: no-repeat; - background-position: center; - } - - .title { - font-size: 100px; - color: #FFFFFF; - } -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js deleted file mode 100644 index 680546925..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Core, ExpectExtend } from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - const core = Core.getInstance(); - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }); - core.addService('expect', expectExtend); - core.init(); - const configService = core.getDefaultService('config'); - this.timeout = 1500000; - configService.setConfig(this); - console.log("test start") - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js deleted file mode 100644 index 7a28d1bae..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -require("./SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js") -require("./SignVerify/SecurityHuksED25519BasicPromiseJsunit.test") \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 97fc6127e..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 4404963cc..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104' - const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - NewSrcKeyAlies, - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 72d9b443a..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let exportKey -let handle = {} -let srcData63 = Data.Data63b -console.log(`test srcData63 ${srcData63}`) -let srcData63Kb = stringToUint8Array(srcData63) -console.log(`test srcData63Kb ${JSON.stringify(srcData63Kb)}`) - -let DSA_COMMON_SIZE = 1024 - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagDSACOMMONSIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: DSA_COMMON_SIZE, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - console.log(`test stringToUint8Array arr ${JSON.stringify(arr)}`) - var tmpUint8Array = new Uint8Array(arr) - console.log( - `test stringToUint8Array tmpUint8Array ${JSON.stringify(tmpUint8Array)}` - ) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test ImportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksTagDSACOMMONSIZE - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 1e0a1f63c..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -var handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_DSA: 3, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeySize = { - HKS_DSA_KEY_SIZE_512: 512, - HKS_DSA_KEY_SIZE_768: 768, - HKS_DSA_KEY_SIZE_1024: 1024, - HKS_DSA_KEY_SIZE_2048: 2048, - HKS_DSA_KEY_SIZE_3072: 3072, - HKS_DSA_KEY_SIZE_4096: 4096, -} - -let HuksSignVerify002 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_512, - }, - HuksKeySIZE1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_DSA_KEY_SIZE_1024, - }, - HuksKeyAlgDSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_DSA, - }, - HuksKeyDSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyDSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDSADigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagDSADigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagDSADigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagDSADigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagDSADigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - HuksOptions.properties.splice( - 2, - 0, - HuksSignVerify002.HuksKeySIZE1024 - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeSIGN - ) - HuksOptions.properties.splice(2, 1) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { - it('testSignVerifyDSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103' - const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103' - let HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeSIGN, - HuksSignVerify002.HuksTagDSADigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify002.HuksKeyAlgDSA, - HuksSignVerify002.HuksKeyDSAPurposeVERIFY, - HuksSignVerify002.HuksTagDSADigestSHA1, - HuksSignVerify002.HuksKeySIZE1024 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 81863b702..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index 10d6d3b9d..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,425 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData65Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 025482f7d..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, afterEach, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - afterEach(function () { - finishOutData = 0 - exportKey = 0 - console.info('test afterEach called') - }) - - it('testSignVerifyECC001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index 38c7ddc8b..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_ECC: 2, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_ECC_KEY_SIZE_521: 521, - HKS_ECC_KEY_SIZE_224: 224, - HKS_ECC_KEY_SIZE_256: 256, - HKS_ECC_KEY_SIZE_384: 384, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify003 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyAlgECC: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ECC, - }, - HuksKeyECCPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyECCPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagECCDigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagECCDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagECCDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagECCDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagECCDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagECCDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksKeyECCSize224: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_224, - }, - HuksKeyECCSize256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_256, - }, - HuksKeyECCSize384: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_384, - }, - HuksKeyECCSize521: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ECC_KEY_SIZE_521, - }, - HuksKeyECCPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify003.HuksKeyECCPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { - it('testSignVerifyECC003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeSIGN, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify003.HuksKeyAlgECC, - HuksSignVerify003.HuksKeyECCPurposeVERIFY, - HuksSignVerify003.HuksTagECCDigestNONE, - HuksSignVerify003.HuksKeyECCSize224 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js deleted file mode 100644 index aaf10103a..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let finishOutData -let handle = {} -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_ED25519: 102, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeySize = { - HKS_CURVE25519_KEY_SIZE_256: 256, - HKS_ED25519_KEY_SIZE_512: 512, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HuksSignVerify004 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_ED25519_KEY_SIZE_512, - }, - HuksKeyAlgED25519: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_ED25519, - }, - HuksKeyED25519Size256: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_CURVE25519_KEY_SIZE_256, - }, - HuksKeyED25519PurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyED25519PurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksTagDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} - -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyED25519PromiseJsunit', function () { - it('testSignVerifyED25519Size256SIGN101', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN102', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN103', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeVERIFY, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - - finishOutData = 0 - exportKey = 0 - done() - }) - - it('testSignVerifyED25519Size256SIGN104', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify004.HuksKeyAlgED25519, - HuksSignVerify004.HuksKeyED25519PurposeSIGN, - HuksSignVerify004.HuksKeyED25519Size256, - HuksSignVerify004.HuksTagDigestSHA1 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js deleted file mode 100644 index 7fdce7580..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA002', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js deleted file mode 100644 index a0e4a8caf..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA004', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'abort', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js deleted file mode 100644 index 043fc11c4..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData63 = Data.Data63b -let srcData63Kb = stringToUint8Array(srcData63) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA001', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData63Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - false - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js deleted file mode 100644 index a19c44a75..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { describe, it, expect } from 'deccjsunit/index' -import huks from '@ohos.security.huks' -import Data from '../../../../../../../utils/data.json' - -let handle = {} -let finishOutData -let exportKey -let srcData65 = Data.Data65b -let srcData65Kb = stringToUint8Array(srcData65) - -let HksKeyAlg = { - HKS_ALG_RSA: 1, -} - -let HksKeyPurpose = { - HKS_KEY_PURPOSE_SIGN: 4, - HKS_KEY_PURPOSE_VERIFY: 8, -} - -let HksKeyPadding = { - HKS_PADDING_PSS: 2, - HKS_PADDING_PKCS1_V1_5: 3, -} - -let HksKeyDigest = { - HKS_DIGEST_NONE: 0, - HKS_DIGEST_MD5: 1, - HKS_DIGEST_SHA1: 10, - HKS_DIGEST_SHA224: 11, - HKS_DIGEST_SHA256: 12, - HKS_DIGEST_SHA384: 13, - HKS_DIGEST_SHA512: 14, -} - -let HksKeySize = { - HKS_RSA_KEY_SIZE_512: 512, - HKS_RSA_KEY_SIZE_768: 768, - HKS_RSA_KEY_SIZE_1024: 1024, - HKS_RSA_KEY_SIZE_2048: 2048, - HKS_RSA_KEY_SIZE_3072: 3072, - HKS_RSA_KEY_SIZE_4096: 4096, -} - -let HksTagType = { - HKS_TAG_TYPE_UINT: 2 << 28, - HKS_TAG_TYPE_BYTES: 5 << 28, -} - -let HksTag = { - HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, - HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, - HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, - HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, - HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, - HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, -} - -let HuksSignVerify001 = { - HuksKeySIZE: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyAlgRSA: { - tag: HksTag.HKS_TAG_ALGORITHM, - value: HksKeyAlg.HKS_ALG_RSA, - }, - HuksKeyRSASize512: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_512, - }, - HuksKeyRSASize768: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_768, - }, - HuksKeyRSASize1024: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_1024, - }, - HuksKeyRSASize2048: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_2048, - }, - HuksKeyRSASize3072: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_3072, - }, - HuksKeyRSASize4096: { - tag: HksTag.HKS_TAG_KEY_SIZE, - value: HksKeySize.HKS_RSA_KEY_SIZE_4096, - }, - HuksKeyRSAPurposeSIGN: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, - }, - HuksKeyRSAPurposeVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPurposeSINGVERIFY: { - tag: HksTag.HKS_TAG_PURPOSE, - value: - HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | - HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, - }, - HuksKeyRSAPADDINGPKCS1V15: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PKCS1_V1_5, - }, - HuksKeyRSAPADDINGPSS: { - tag: HksTag.HKS_TAG_PADDING, - value: HksKeyPadding.HKS_PADDING_PSS, - }, - HuksTagPKCS1DigestMD5: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_MD5, - }, - HuksTagPKCS1DigestNONE: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_NONE, - }, - HuksTagPKCS1DigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPKCS1DigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPKCS1DigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPKCS1DigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPKCS1DigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, - HuksTagPSSDigestSHA1: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA1, - }, - HuksTagPSSDigestSHA224: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA224, - }, - HuksTagPSSDigestSHA256: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA256, - }, - HuksTagPSSDigestSHA384: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA384, - }, - HuksTagPSSDigestSHA512: { - tag: HksTag.HKS_TAG_DIGEST, - value: HksKeyDigest.HKS_DIGEST_SHA512, - }, -} - -function stringToUint8Array(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - var tmpUint8Array = new Uint8Array(arr) - return tmpUint8Array -} -function uint8ArrayToString(fileData) { - var dataString = '' - for (var i = 0; i < fileData.length; i++) { - dataString += String.fromCharCode(fileData[i]) - } - return dataString -} -function stringToArray(str) { - var arr = [] - for (var i = 0, j = str.length; i < j; ++i) { - arr.push(str.charCodeAt(i)) - } - return arr -} - -async function publicGenerateKeyFunc(keyAlias, HuksOptions) { - await huks - .generateKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test generateKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test generateKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicImportKey(keyAlias, HuksOptions) { - let _InData = HuksOptions.inData - HuksOptions.inData = finishOutData - console.log(`test ImportKey keyAlias: ${keyAlias}`) - console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`) - await huks - .importKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test ImportKey data: ${JSON.stringify(data)}`) - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) - HuksOptions.inData = _InData -} - -async function publicExportKey(keyAlias, HuksOptions) { - await huks - .exportKey(keyAlias, HuksOptions) - .then((data) => { - console.log(`test exportKey data: ${JSON.stringify(data)}`) - finishOutData = data.outData - }) - .catch((err) => { - console.log( - 'test exportKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicInitFunc(keyAlias, HuksOptions) { - await huks - .init(keyAlias, HuksOptions) - .then((data) => { - console.log(`test init data: ${JSON.stringify(data)}`) - handle = { - handle1: data.handle1, - handle2: data.handle2, - } - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test init err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicUpdateFunc(HuksOptions) { - let dateSize = 64 - let huksOptionsInData = HuksOptions.inData - let inDataArray = HuksOptions.inData - if (uint8ArrayToString(inDataArray).length < dateSize) { - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } else { - let count = Math.floor( - uint8ArrayToString(inDataArray).length / dateSize - ) - let remainder = uint8ArrayToString(inDataArray).length % dateSize - console.log( - `test before update length: ${ - uint8ArrayToString(inDataArray).length - }` - ) - console.log(`test before update count: ${count}`) - console.log(`test before update remainder: ${remainder}`) - for (let i = 0; i < count; i++) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * i, - dateSize * (i + 1) - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - if (remainder !== 0) { - HuksOptions.inData = stringToUint8Array( - uint8ArrayToString(huksOptionsInData).slice( - dateSize * count, - uint8ArrayToString(inDataArray).length - ) - ) - await update(handle, HuksOptions) - HuksOptions.inData = huksOptionsInData - } - } -} - -async function update(handle, HuksOptions) { - console.log(`test update data ${JSON.stringify(HuksOptions)}`) - await huks - .update(handle, HuksOptions) - .then(async (data) => { - console.log(`test update data ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test update err information: ' + err) - expect(null).assertFail() - }) -} - -async function publicFinishFunc(HuksOptions) { - await huks - .finish(handle, HuksOptions) - .then((data) => { - console.log(`test finish data: ${JSON.stringify(data)}`) - exportKey = data.outData - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test finish err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicAbortFucn(HuksOptions) { - await huks - .abort(handle, HuksOptions) - .then((data) => { - console.log(`test abort data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log('test abort err information: ' + JSON.stringify(err)) - expect(null).assertFail() - }) -} - -async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { - await huks - .deleteKey(KeyAlias, HuksOptions) - .then((data) => { - console.log(`test deleteKey data: ${JSON.stringify(data)}`) - expect(data.errorCode == 0).assertTrue() - }) - .catch((err) => { - console.log( - 'test deleteKey err information: ' + JSON.stringify(err) - ) - expect(null).assertFail() - }) -} - -async function publicSignVerifyFunc( - srcKeyAlies, - newSrcKeyAlies, - HuksOptions, - thirdInderfaceName, - isSING -) { - try { - let keyAlias = srcKeyAlies - if (isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test publicSignVerifyFunc GenerateHuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicGenerateKeyFunc(keyAlias, HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSIGN - ) - } else { - keyAlias = newSrcKeyAlies - await publicImportKey(keyAlias, HuksOptions) - } - console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`) - await publicInitFunc(keyAlias, HuksOptions) - await publicUpdateFunc(HuksOptions) - if (thirdInderfaceName == 'finish') { - if (isSING) { - HuksOptions.outData = new Uint8Array(new Array(1024).fill('')) - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - console.log( - `test before exportKey Gen_HuksOptions: ${JSON.stringify( - HuksOptions - )}` - ) - await publicExportKey(keyAlias, HuksOptions) - } else { - HuksOptions.outData = exportKey - console.log( - `test before finish HuksOptions: ${HuksOptions.inData}` - ) - console.log( - `test before finish HuksOptions: ${HuksOptions.outData}` - ) - await publicFinishFunc(HuksOptions) - } - } else { - await publicAbortFucn(HuksOptions) - } - - if (isSING && thirdInderfaceName == 'abort') { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeSINGVERIFY - ) - await publicDeleteKeyFunc(srcKeyAlies, HuksOptions) - } else if (!isSING) { - HuksOptions.properties.splice( - 1, - 1, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY - ) - await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions) - } - } catch (e) { - expect(null).assertFail() - } -} - -describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { - it('testSignVerifyRSA003', 0, async function (done) { - const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103' - let HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeSIGN, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - - HuksOptions = { - properties: new Array( - HuksSignVerify001.HuksKeyAlgRSA, - HuksSignVerify001.HuksKeyRSAPurposeVERIFY, - HuksSignVerify001.HuksTagPKCS1DigestMD5, - HuksSignVerify001.HuksKeyRSAPADDINGPKCS1V15, - HuksSignVerify001.HuksKeyRSASize512 - ), - inData: srcData65Kb, - } - await publicSignVerifyFunc( - srcKeyAlies, - srcKeyAlies + 'New', - HuksOptions, - 'finish', - true - ) - finishOutData = 0 - exportKey = 0 - done() - }) -}) diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js deleted file mode 100644 index 1983248b9..000000000 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -let isOpenSSL = false -export { isOpenSSL } diff --git a/security/security_huks/BUILD.gn b/security/security_huks_basic/BUILD.gn similarity index 97% rename from security/security_huks/BUILD.gn rename to security/security_huks_basic/BUILD.gn index 259aa6502..e6b366c89 100644 --- a/security/security_huks/BUILD.gn +++ b/security/security_huks_basic/BUILD.gn @@ -12,7 +12,7 @@ # limitations under the License. import("//test/xts/tools/build/suite.gni") -group("security_huks") { +group("security_huks_basic") { testonly = true if (is_standard_system) { deps = [ diff --git a/security/security_huks/huks_agree_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_agree_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json b/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json new file mode 100644 index 000000000..d339724ca --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksAgreeBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksagreebasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksAgreeBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js index fe09ae65f..03bdca4c3 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..c50c0bca1 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..d537f0756 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..0f6e3beb8 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHAbort65KB001', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..ed856cd8a --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..38b37a112 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHCallbackJsunit', function () { + it('testAgreeDHFinish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..06ce05f18 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +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, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_02_001'; + 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, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..887cd2ab0 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHAbort65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_02_001'; + 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: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..ff5749455 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +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, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish63KBAgreeKeyAlias_02_001'; + 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(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..7a38031c3 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeECDHCallbackJsunit', function () { + it('testAgreeECDHFinish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_02_001'; + 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: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..7e8c2d57e --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Abort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..e89577713 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Abort65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..3537c2786 --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Finish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..42cb711cd --- /dev/null +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreeCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519CallbackJsunit', function () { + it('testAgreeX25519Finish65KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_001'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_001'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 90% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js index 83c693575..08f78e52c 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,15 +13,15 @@ * limitations under the License. */ -require('./Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js') -require('./Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js') +require('./Agree/SecurityHuksDHBasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksDHBasicAbort65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksECDHBasicAbort65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicFinish63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicFinish65KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicAbort63KBCallbackJsunit.test.js'); +require('./Agree/SecurityHuksX25519BasicAbort65KBCallbackJsunit.test.js'); diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b9..d7bc32507 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_agree_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_agree_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_agree_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json b/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json new file mode 100644 index 000000000..3aca2b281 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksAgreeBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksagreebasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksAgreeBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce..5a5f568df 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..37fcfbc58 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Abort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..ebc03048a --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Abort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Abort65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..e8415d016 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Finish63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..a5a9f8a15 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksAgreeDH.HuksKeyAlgDH, + HuksAgreeDH.HuksKeyPurposeDH, + HuksAgreeDH.HuksKeyDHSize2048 + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeDHPromiseJsunit', function () { + it('testAgreeDHSize2048Finish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeDHSize2048Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksAgreeDH.HuksKeySTORAGE, + HuksAgreeDH.HuksKeyISKEYALIAS, + HuksAgreeDH.HuksKeyALGORITHMAES, + HuksAgreeDH.HuksKeySIZE256, + HuksAgreeDH.HuksKeyPurposeENCRYPTDECRYPT, + HuksAgreeDH.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksAgreeDH.HuksKeyPADDINGNONE, + HuksAgreeDH.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..4cbafaef0 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', 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'); + }); + it('testAgreeECDHAbort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort63KBAgreeKeyAlias_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, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..d84c7ee11 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, + }; + console.info('test beforeEach called'); + }); + + it('testAgreeECDHAbort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Abort65KBAgreeKeyAlias_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: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..014451133 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +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, +}; + +describe('SecurityHuksAgreeECDHPromiseJsunit', 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'); + }); + + it('testAgreeECDHFinish63KBAgree101', 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(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..aa0ac398c --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, beforeEach } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksAgreeECDH } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb; + +describe('SecurityHuksAgreeECDHPromiseJsunit', function () { + beforeEach(function () { + HuksOptions65kb = { + properties: new Array( + HuksAgreeECDH.HuksKeyAlgECC, + HuksAgreeECDH.HuksKeyPurposeECDH, + HuksAgreeECDH.HuksKeyECCSize224, + HuksAgreeECDH.HuksKeyECCDIGEST, + HuksAgreeECDH.HuksKeyECCPADDING, + HuksAgreeECDH.HuksKeyECCBLOCKMODE + ), + inData: srcData65Kb, + }; + console.info('test beforeEach called'); + }); + + it('testAgreeECDHFinish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeECDHSize224Finish65KBAgreeKeyAlias_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: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..6cf0fb115 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Abort63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..66db29bb8 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); + +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Abort65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Abort65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..ee096574f --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData63Kb, +}; +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Finish63KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish63KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..2200d3718 --- /dev/null +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import * as Data from '../../../../../../../utils/data.json'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { HuksKeyAlgX25519 } from '../../../../../../../utils/param/agree/publicAgreeParam'; +import { publicAgreeFunc } from '../../../../../../../utils/param/agree/publicAgreePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData65 = Data.Date65KB; +let srcData65Kb = stringToUint8Array(srcData65); +let HuksOptions65kb = { + properties: new Array( + HuksKeyAlgX25519.HuksKeyAlgX25519, + HuksKeyAlgX25519.HuksKeyPurposeAGREE, + HuksKeyAlgX25519.HuksKeyCURVE25519Size256, + HuksKeyAlgX25519.HuksKeyDIGEST, + HuksKeyAlgX25519.HuksKeyPADDING, + HuksKeyAlgX25519.HuksKeyBLOCKMODE + ), + inData: srcData65Kb, +}; + +describe('SecurityHuksAgreeX25519PromiseJsunit', function () { + it('testAgreeX25519Finish65KBAgree101', 0, async function (done) { + const srcKeyAliesFirst = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_01_101'; + const srcKeyAliesSecond = + 'testAgreeX25519Size256Finish65KBAgreeKeyAlias_02_101'; + let huksOptionsFinish = { + properties: new Array( + HuksKeyAlgX25519.HuksKeySTORAGE, + HuksKeyAlgX25519.HuksKeyISKEYALIAS, + HuksKeyAlgX25519.HuksKeyALGORITHMAES, + HuksKeyAlgX25519.HuksKeySIZE256, + HuksKeyAlgX25519.HuksKeyPurposeENCRYPTDECRYPT, + HuksKeyAlgX25519.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksKeyAlgX25519.HuksKeyPADDINGNONE, + HuksKeyAlgX25519.HuksKeyBLOCKMODEECB + ), + inData: srcData65Kb, + }; + await publicAgreeFunc( + srcKeyAliesFirst, + srcKeyAliesSecond, + HuksOptions65kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 87% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js index 9ea8290ef..dd19bcc70 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,15 +13,15 @@ * limitations under the License. */ -require('./Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js') -require('./Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js') +require('./Agree/SecurityHuksAgreeDHBasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeDHBasicAbort65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeECDHBasicAbort65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicFinish63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicFinish65KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicAbort63KBPromiseJsunit.test.js'); +require('./Agree/SecurityHuksAgreeX25519BasicAbort65KBPromiseJsunit.test.js'); diff --git a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b9..d7bc32507 100644 --- a/security/security_huks/huks_agree_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_agree_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_cipher_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_cipher_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json new file mode 100644 index 000000000..f63b998e1 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksCipherBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukscipherbasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksCipherBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce..5a5f568df 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js new file mode 100644 index 000000000..3803e093e --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksAESBasicCallbackJsunit.test.js @@ -0,0 +1,484 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherAES } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let IV = '0000000000000000'; + +let defaultData = '0'; + +let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string'; +let srcData63Kb = stringToUint8Array(srcData63); +let updateResult = new Array(); +let encryptedData; +var handle; + +let genHuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurpose + ), + inData: new Uint8Array(defaultData), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + console.log( + `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` + ); + await generateKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + // HuksOptions.inData = new Uint8Array(new Array()); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt, 0); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + console.log('test count ' + count + 'remainder ' + remainder); + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + } + HuksOptions.inData = huksOptionsInData; + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + await publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder + ); + } +} + +async function update(handle, HuksOptions) { + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + if (updateResult.length !== 0) { + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + updateResult = Array.from(data.outData); + } + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + console.log(`test remainder ${remainder}`); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await finishCallback(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + let finishData; + if (encryptedData.length > 64) { + finishData = uint8ArrayToString( + updateResult.concat(Array.from(data.outData)) + ); + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + finishData = uint8ArrayToString(updateResult); + } + if (isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + expect(data.errorCode == 0).assertTrue(); + } else { + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finishCallback(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function abort(HuksOptions) { + await abortCallback(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abortCallback(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + await deleteKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + genHuksOptionsNONECBC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + try { + updateResult = new Array(); + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + encryptedData = HuksOptions.inData; + } + await publicInitFunc(srcKeyAlies, HuksOptions); + await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherAESCallbackJsunit', function () { + it('testCipherAES001', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias001'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES002', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherAES003', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES004', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js new file mode 100644 index 000000000..a4d564c3b --- /dev/null +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksRSABasicCallbackJsunit.test.js @@ -0,0 +1,539 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'deccjsunit/index'; +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 gInData64Array = stringToUint8Array(gInData64); +let encryptedData; +let inputInData; +var handle; +let updateResult = new Array(); +let exportKey; + +let genHuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize512 + ), + inData: new Uint8Array(new Array()), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await generateKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await exportkey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test ExportKey data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { + HuksOptions.inData = exportKey; + console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await importkey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function importkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test importKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test importKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = stringToUint8Array('0'); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(1024)); + HuksOptions.inData = new Uint8Array(new Array()); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await finishCallback(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + if (isEncrypt) { + updateResult = Array.from(data.outData); + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + expect(null).assertFail(); + } else { + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + expect(data.errorCode == 0).assertTrue(); + } else { + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finishCallback(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function abort(HuksOptions) { + await abortCallback(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abortCallback(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + await deleteKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} +async function publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptionsNONC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + inputInData = HuksOptions.inData; + try { + updateResult = new Array(); + let KeyAlias = srcKeyAlies; + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC); + encryptedData = HuksOptions.inData; + await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicImportKeyFunc(newSrcKeyAlies, HuksOptions); + KeyAlias = newSrcKeyAlies; + } + HuksOptions.inData = inputInData; + await publicInitFunc(KeyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherRSACallbackJsunit', 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 + ); + + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + 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), + outData: stringToUint8Array('0'), + }; + 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, + outData: stringToUint8Array('0'), + }; + 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, + outData: stringToUint8Array('0'), + }; + 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), + outData: stringToUint8Array('0'), + }; + 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, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 80% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js index 7cfeabde6..9aba31c2a 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,5 +13,5 @@ * limitations under the License. */ -require("./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js") -require("./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js") +require('./Cipher/SecurityHuksAESBasicCallbackJsunit.test.js'); +require('./Cipher/SecurityHuksRSABasicCallbackJsunit.test.js'); diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js index 1983248b9..d7bc32507 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_cipher_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export { isOpenSSL } +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_cipher_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_cipher_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_cipher_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json new file mode 100644 index 000000000..5d0b83066 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksCipherBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukscipherbasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksCipherBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce..5a5f568df 100644 --- a/security/security_huks/huks_cipher_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js new file mode 100644 index 000000000..218270015 --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js @@ -0,0 +1,430 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HuksCipherAES } from '../../../../../../../utils/param/cipher/publicCipherParam'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +import { + stringToUint8Array, + uint8ArrayToString, +} from '../../../../../../../utils/param/publicFunc'; +let IV = '0000000000000000'; + +let srcData63 = 'Hks_AES_Cipher_Test_000000000000000000000_string'; +let srcData63Kb = stringToUint8Array(srcData63); +let updateResult = new Array(); +let encryptedData; +var handle; + +let genHuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurpose + ), + inData: new Uint8Array(new Array()), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + console.log( + `test GenerateHuksOptions: ${JSON.stringify(genHuksOptionsNONECBC)}` + ); + await huks + .generateKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = new Uint8Array(new Array()); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt, 0); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + console.log('test count ' + count + 'remainder ' + remainder); + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + } + HuksOptions.inData = huksOptionsInData; + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } else { + HuksOptions.inData = new Uint8Array(new Array()); + } + await publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder + ); + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + console.log(`test update data ${JSON.stringify(HuksOptions.inData.length)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + if (updateResult.length !== 0) { + console.log(`test update outDatalength ${updateResult.length}`); + updateResult = updateResult.concat(Array.from(data.outData)); + console.log(`test update outDatalength ${updateResult.length}`); + } else { + console.log(`test update outDatalength ${updateResult.length}`); + updateResult = Array.from(data.outData); + console.log(`test update outDatalength ${updateResult.length}`); + } + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt, + remainder +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + console.log(`test remainder ${remainder}`); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + HuksOptions.outData = new Uint8Array(new Array(encryptedData.length * 2)); + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + let finishData; + if (encryptedData.length > 64) { + finishData = uint8ArrayToString( + updateResult.concat(Array.from(data.outData)) + ); + updateResult = updateResult.concat(Array.from(data.outData)); + } else { + finishData = uint8ArrayToString(updateResult); + } + if (isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if (finishData === uint8ArrayToString(encryptedData)) { + console.log( + `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt success ${uint8ArrayToString(finishData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } else { + console.log( + `test finish Decrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt fail ${uint8ArrayToString(finishData)}` + ); + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function abort(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC) { + await huks + .deleteKey(srcKeyAlies, genHuksOptionsNONECBC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + genHuksOptionsNONECBC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + try { + updateResult = new Array(); + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + encryptedData = HuksOptions.inData; + } + await publicInitFunc(srcKeyAlies, HuksOptions); + await publicUpdateFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONECBC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherAESPromiseJsunit', function () { + it('testCipherAES101', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias101'; + genHuksOptions.properties.splice(2, 1, HuksCipherAES.HuksKeyAESSize128); + genHuksOptions.properties.splice(3, 1, HuksCipherAES.HuksKeyAESBLOCKMODE); + genHuksOptions.properties.splice(4, 1, HuksCipherAES.HuksKeyAESPADDINGNONE); + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES102', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherAES103', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: srcData63Kb, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeDECRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherAES104', 0, async function (done) { + const srcKeyAlies = 'testCipherAESSize128PADDINGNONEMODECBCKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksCipherAES.HuksKeyAlgAES, + HuksCipherAES.HuksKeyPurposeENCRYPT, + HuksCipherAES.HuksKeyAESSize128, + HuksCipherAES.HuksKeyAESPADDINGNONE, + HuksCipherAES.HuksKeyAESBLOCKMODE, + HuksCipherAES.HuksKeyAESDIGESTNONE, + { tag: HksTag.HKS_TAG_IV, value: stringToUint8Array(IV) } + ), + inData: new Uint8Array(updateResult), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js new file mode 100644 index 000000000..085596fdd --- /dev/null +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js @@ -0,0 +1,478 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'deccjsunit/index'; +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 defaultData = '0'; + +let gInData64Array = stringToUint8Array(gInData64); + +let encryptedData; +let inputInData; +var handle; +let updateResult = new Array(); +let exportKey; + +let genHuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurpose, + HuksCipherRSA.HuksKeyRSASize512 + ), + inData: new Uint8Array(defaultData), +}; + +async function publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test Generate HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await huks + .generateKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + console.log( + `test ExportKey HuksOptions: ${JSON.stringify(genHuksOptionsNONC)}` + ); + await huks + .exportKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test ExportKey data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicImportKeyFunc(srcKeyAlies, HuksOptions) { + HuksOptions.inData = exportKey; + console.log(`test importKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .importKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(srcKeyAlies, HuksOptions) { + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions) { + console.log( + `test update before handle: ${JSON.stringify( + handle + )} HuksOptions: ${JSON.stringify(HuksOptions)}` + ); + let dateSize = 64; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + console.log( + 'test update finish HuksOptions inData: ' + Array.from(inDataArray).length + ); + if (Array.from(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = stringToUint8Array('0'); + } else { + let count = Math.floor(Array.from(inDataArray).length / dateSize); + let remainder = Array.from(inDataArray).length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + console.log( + 'test ' + + uint8ArrayToString( + new Uint8Array( + Array.from(huksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ) + ) + ); + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishAbortFunc( + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + if (thirdInderfaceName == 'finish') { + HuksOptions.outData = new Uint8Array(new Array(1024)); + HuksOptions.inData = new Uint8Array(new Array()); + await finish(HuksOptions, isEncrypt); + } else if (thirdInderfaceName == 'abort') { + await abort(HuksOptions); + } +} + +async function finish(HuksOptions, isEncrypt) { + console.log('test before finish HuksOptions inData: ' + HuksOptions.inData); + console.log('test before finish HuksOptions outData: ' + HuksOptions.outData); + console.log( + 'test before finish HuksOptions outData: ' + HuksOptions.outData.length + ); + console.log( + 'test before finish HuksOptions properties: ' + + JSON.stringify(HuksOptions.properties) + ); + + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + if (isEncrypt) { + updateResult = Array.from(data.outData); + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` + ); + expect(null).assertFail(); + } else { + console.log( + `test finish Encrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt success ${uint8ArrayToString(data.outData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } + } + if (!isEncrypt) { + if ( + uint8ArrayToString(data.outData) === uint8ArrayToString(encryptedData) + ) { + console.log( + `test finish Decrypt success ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Decrypt success ${uint8ArrayToString(data.outData)}` + ); + expect(data.errorCode == 0).assertTrue(); + } else { + console.log( + `test finish Encrypt fail ${uint8ArrayToString(encryptedData)}` + ); + console.log( + `test finish Encrypt fail ${uint8ArrayToString(data.outData)}` + ); + expect(null).assertFail(); + } + } + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function abort(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC) { + await huks + .deleteKey(srcKeyAlies, genHuksOptionsNONC) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptionsNONC, + HuksOptions, + thirdInderfaceName, + isEncrypt +) { + inputInData = HuksOptions.inData; + try { + updateResult = new Array(); + let KeyAlias = srcKeyAlies; + if (isEncrypt) { + await publicGenerateKeyFunc(srcKeyAlies, genHuksOptionsNONC); + encryptedData = HuksOptions.inData; + await publicExportKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicImportKeyFunc(newSrcKeyAlies, HuksOptions); + KeyAlias = newSrcKeyAlies; + } + HuksOptions.inData = inputInData; + await publicInitFunc(KeyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions); + await publicFinishAbortFunc(HuksOptions, thirdInderfaceName, isEncrypt); + if (!isEncrypt || (isEncrypt && thirdInderfaceName == 'abort')) { + await publicDeleteKeyFunc(srcKeyAlies, genHuksOptionsNONC); + await publicDeleteKeyFunc(newSrcKeyAlies, genHuksOptionsNONC); + } + } catch (e) { + expect(null).assertFail(); + } +} + +describe('SecurityHuksCipherRSAPromiseJsunit', function () { + it('testCipherRSA101', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias101'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + 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, + outData: stringToUint8Array('0'), + }; + 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), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA102', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias102'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testCipherRSA103', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias103'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + 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), + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testCipherRSA104', 0, async function (done) { + const srcKeyAlies = 'testCipherRSASize512PADDINGNONESHA256KeyAlias104'; + const newSrcKeyAlies = + 'testCipherRSASize512PADDINGNONESHA256NewKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksCipherRSA.HuksKeyAlgRSA, + HuksCipherRSA.HuksKeyPurposeENCRYPT, + HuksCipherRSA.HuksKeyRSASize512, + HuksCipherRSA.HuksKeyRSAPADDINGNONE, + HuksCipherRSA.HuksKeyRSABLOCKMODEECB, + HuksCipherRSA.HuksKeyRSADIGESTSHA256 + ), + inData: gInData64Array, + outData: stringToUint8Array('0'), + }; + await publicCipherFunc( + srcKeyAlies, + newSrcKeyAlies, + genHuksOptions, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 79% rename from security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js index 7137ae0dc..bac533622 100644 --- a/security/security_huks/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,5 +13,5 @@ * limitations under the License. */ -require("./Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js") -require("./Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js") +require('./Cipher/SecurityHuksCipherAESBasicPromiseJsunit.test.js'); +require('./Cipher/SecurityHuksCipherRSABasicPromiseJsunit.test.js'); diff --git a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js similarity index 90% rename from security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js rename to security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js index 11f4277ab..d7bc32507 100644 --- a/security/security_huks/huks_agree_promise_BasicTest/entry/src/main/js/test/switchControl.js +++ b/security/security_huks_basic/huks_cipher_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -13,5 +13,5 @@ * limitations under the License. */ -let isOpenSSL = false -export {isOpenSSL} +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_cipher_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_derive_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_derive_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json b/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json new file mode 100644 index 000000000..182fb0f29 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksDeriveBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksderivebasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksDeriveBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js similarity index 81% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js index e423f4bce..5a5f568df 100644 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -14,10 +14,10 @@ */ export default { - onCreate() { - console.info('AceApplication onCreate'); - }, - onDestroy() { - console.info('AceApplication onDestroy'); - } + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, }; diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..49ceea6b5 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { + it('testDeriveHKDFAbort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..248e202e7 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFCallbackJsunit', function () { + it('testDeriveHKDFFinish63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_001'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..eaa617a58 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { + it('testDerivePBKDF2Abort63KB001', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_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, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..d28f8b735 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDeriveCallback'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2CallbackJsunit', function () { + it('testDerivePBKDF2Finish63KB001', 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, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 65% rename from security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js index 270b033be..95e7d79eb 100644 --- a/security/security_huks/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ -require("./Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js") -require("./Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js") +require('./Derive/SecurityHuksHKDFBasicFinish63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksHKDFBasicAbort63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksPBKDF2BasicFinish63KBCallbackJsunit.test.js'); +require('./Derive/SecurityHuksPBKDF2BasicAbort63KBCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_derive_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_derive_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_derive_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_derive_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json b/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json new file mode 100644 index 000000000..dc27c0af8 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksDeriveBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksderivebasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksDeriveBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..5a5f568df --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, +}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..b02bb8d19 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { + it('testDeriveHKDFAbort63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Abort63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..bcb9b2123 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDeriveHKDF } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); +let HuksOptions63kb = { + properties: new Array( + HuksDeriveHKDF.HuksKeyAlgAES, + HuksDeriveHKDF.HuksKeyPurposeHKDF, + HuksDeriveHKDF.HuksTagHKDFDigestSHA256, + HuksDeriveHKDF.HuksKeyHKDFSize128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDeriveHKDFPromiseJsunit', function () { + it('testDeriveHKDFFinish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDeriveHKDFSize128SHA256Finish63KBDeriveKeyAlias_01_101'; + let huksOptionsFinish = { + properties: new Array( + HuksDeriveHKDF.HuksKeySTORAGE, + HuksDeriveHKDF.HuksKeyISKEYALIAS, + HuksDeriveHKDF.HuksKeyALGORITHMAES, + HuksDeriveHKDF.HuksKeySIZE256, + HuksDeriveHKDF.HuksKeyPurposeENCRYPTDECRYPT, + HuksDeriveHKDF.HuksKeyDIGESTNONE, + { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesFirst), + }, + HuksDeriveHKDF.HuksKeyPADDINGNONE, + HuksDeriveHKDF.HuksKeyBLOCKMODEECB + ), + inData: srcData63Kb, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..f788979f2 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; +describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { + it('testDerivePBKDF2Abort63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Abort63KBDeriveKeyAlias_01_101'; + 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, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'abort' + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..77f71810a --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksDerivePBKDF2 } from '../../../../../../../utils/param/derive/publicDeriveParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicDeriveFunc } from '../../../../../../../utils/param/derive/publicDerivePromise'; +import { HksTag } from '../../../../../../../utils/param/publicParam'; + +let srcData63 = Data.Date63KB; +let srcData63Kb = stringToUint8Array(srcData63); + +let HuksOptions63kb = { + properties: new Array( + HuksDerivePBKDF2.HuksKeyAlgAES, + HuksDerivePBKDF2.HuksKeyPurposePBKDF2, + HuksDerivePBKDF2.HuksTagPBKDF2DigestSHA256, + HuksDerivePBKDF2.HuksKeyPBKDF2Size128 + ), + inData: srcData63Kb, +}; + +describe('SecurityHuksDerivePBKDF2PromiseJsunit', function () { + it('testDerivePBKDF2Finish63KBDerive101', 0, async function (done) { + const srcKeyAliesFirst = + 'testDerivePBKDF2Size128SHA256Finish63KBDeriveKeyAlias_01_101'; + 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, + }; + await publicDeriveFunc( + srcKeyAliesFirst, + HuksOptions63kb, + huksOptionsFinish, + 'finish' + ); + done(); + }); +}); diff --git a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 64% rename from security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js index 621001093..25ac4070b 100644 --- a/security/security_huks/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ -require("./Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js") -require("./Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js") +require('./Derive/SecurityHuksDeriveHKDFBasicFinish63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDeriveHKDFBasicAbort63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDerivePBKDF2BasicFinish63KBPromiseJsunit.test.js'); +require('./Derive/SecurityHuksDerivePBKDF2BasicAbort63KBPromiseJsunit.test.js'); diff --git a/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_derive_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_derive_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_hmac_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_hmac_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json new file mode 100644 index 000000000..14b835e98 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksHmacBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksHmacbasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksHmacBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..5a5f568df --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, +}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js new file mode 100644 index 000000000..8bfe363a9 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js @@ -0,0 +1,314 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import Data from '../../../../../../../utils/data.json'; +import { HuksHmac } from '../../../../../../../utils/param/hmac/publicHmacParam.js'; +import { stringToArray } from '../../../../../../../utils/param/publicFunc.js'; + +var handle; +let srcData63Kb = Data.Date63KB; +let srcData65Kb = Data.Date65KB; + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log( + 'test generateKey err information: ' + JSON.stringify(err) + ); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test generateKey err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + handle = data.handle; + resolve(data); + } + } catch (e) { + console.log('test init err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test update err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function finish(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test finish err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test finish err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function abort(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test abort err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + try { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + } catch (e) { + console.log('test deleteKey err information: ' + JSON.stringify(e)); + reject(e); + } + }); + }); +} + +async function publicHmacUpdate(HuksOptions) { + let dateSize = 64 * 1024; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = stringToArray(HuksOptions.inData); + + if (HuksOptions.inData.length <= dateSize) { + HuksOptions.inData = new Uint8Array(inDataArray); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = huksOptionsInData; + } else { + let count = Math.floor(inDataArray.length / dateSize); + let remainder = inDataArray.length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice( + dateSize * count, + inDataArray.length + ) + ); + console.log(`test update HuksOptions.inData ${HuksOptions.inData}`); + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + } +} + +async function publicHmacGenFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + console.log( + 'test before generateKey HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log('test generateKey data = ' + JSON.stringify(data)); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); + + HuksOptions.properties.splice(1, 1); + console.log('test before init HuksOptions = ' + JSON.stringify(HuksOptions)); + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); + console.log( + 'test before Update HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await publicHmacUpdate(HuksOptions); + + if (thirdInderfaceName == 'finish') { + HuksOptions.inData = new Uint8Array(stringToArray('0')); + console.log( + 'test before finish HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await finish(handle, HuksOptions) + .then((data) => { + console.log(`test update data: ${data}`); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + console.log( + 'test before abort HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${data}`); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + console.log( + 'test before deleteKey HuksOptions = ' + JSON.stringify(HuksOptions) + ); + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${data}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +describe('SecurityHuksHmacCallbackJsunit', function () { + it('testHmacSHA1001', 0, async function (done) { + let srcKeyAlies = 'testHmacDigestSHA1KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + + await publicHmacGenFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + 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(); + }); +}); diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js similarity index 88% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js index 6eec73e0c..c1577523b 100644 --- a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require("./HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js") \ No newline at end of file +require('./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_hmac_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_hmac_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_hmac_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json new file mode 100644 index 000000000..ce4accfe9 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksHmacBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.huksHmacbasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksHmacBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/config.json diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..5a5f568df --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, +}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js new file mode 100644 index 000000000..dc07a6421 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import Data from '../../../../../../../utils/data.json'; +import { HuksHmac } from '../../../../../../../utils/param/hmac/publicHmacParam.js'; +import { stringToArray } from '../../../../../../../utils/param/publicFunc.js'; + +var handle; +let srcData63Kb = Data.Date63KB; +let srcData65Kb = Data.Date65KB; + +async function publicHmacGenFunc(srcKeyAlies, HuksOptions) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.properties.splice(1, 1); +} + +async function publicHmacInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then(async (data) => { + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log(`test init err: " + ${JSON.stringify(err)}`); + expect(null).assertFail(); + }); +} + +async function publicHmacUpdateFunc(HuksOptions) { + let dateSize = 64 * 1024; + let huksOptionsInData = HuksOptions.inData; + let inDataArray = stringToArray(HuksOptions.inData); + if (inDataArray.length < dateSize) { + HuksOptions.inData = new Uint8Array(inDataArray); + await update(handle, HuksOptions); + HuksOptions.inData = huksOptionsInData; + } else { + let count = Math.floor(inDataArray.length / dateSize); + let remainder = inDataArray.length % dateSize; + for (let i = 0; i < count; i++) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice(dateSize * i, dateSize * (i + 1)) + ); + await update(handle, HuksOptions); + } + if (remainder !== 0) { + HuksOptions.inData = new Uint8Array( + stringToArray(huksOptionsInData).slice( + dateSize * count, + inDataArray.length + ) + ); + await update(handle, HuksOptions); + } + } +} + +async function publicHmacFinish(HuksOptions, thirdInderfaceName) { + if (thirdInderfaceName == 'finish') { + HuksOptions.inData = new Uint8Array(stringToArray('0')); + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + err); + expect(null).assertFail(); + }); + } else if (thirdInderfaceName == 'abort') { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + err); + expect(null).assertFail(); + }); + } +} + +async function publicHmacDelete(srcKeyAlies, HuksOptions) { + HuksOptions.properties.splice(1, 0, HuksHmac.HuksKeySIZE); + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicHmacFunc(srcKeyAlies, HuksOptions, thirdInderfaceName) { + try { + await publicHmacGenFunc(srcKeyAlies, HuksOptions); + await publicHmacInitFunc(srcKeyAlies, HuksOptions); + await publicHmacUpdateFunc(HuksOptions); + await publicHmacFinish(HuksOptions, thirdInderfaceName); + await publicHmacDelete(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +describe('SecurityHuksHmacBasicPromiseJsunit', function () { + it('testHmac101', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + it('testHmac102', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); + + it('testHmac103', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'finish'); + done(); + }); + + it('testHmac104', 0, async function (done) { + const srcKeyAlies = 'testHmacDigestSHA1KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksHmac.HuksKeyAlg, + HuksHmac.HuksKeyPurpose, + HuksHmac.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicHmacFunc(srcKeyAlies, HuksOptions, 'abort'); + done(); + }); +}); diff --git a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js similarity index 88% rename from security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js rename to security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js index 102a1825c..7fcc13c26 100644 --- a/security/security_huks/huks_hmac_callback_BasicTest/entry/src/main/js/test/List.test.js +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require("./HMAC/SecurityHuksHmacBasicCallbackJsunit.test.js") \ No newline at end of file +require('./HMAC/SecurityHuksHmacBasicPromiseJsunit.test.js'); diff --git a/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_hmac_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_hmac_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_signverify_callback_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_signverify_callback_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json new file mode 100644 index 000000000..c33854cb2 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksSignVerifyBasicCallback js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukssignverifybasiccallback", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksSignVerifyBasicCallbackJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json similarity index 95% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json index 4b8cd464b..43adac6f3 100644 --- a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/config.json @@ -61,4 +61,4 @@ } ] } -} +} \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..5a5f568df --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, +}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js new file mode 100644 index 000000000..4487b0266 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/List.test.js @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +require('./SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js'); +require('./SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js'); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..035fc8051 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias002'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..95895d8d4 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); + +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias004'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..7bff51dc6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias001'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..490b801c3 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSACallbackJsunit', function () { + it('testSignVerifyDSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias003'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..d8a9591ec --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..cb986da79 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..45db6668f --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..279d6b8bf --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCCallbackJsunit', function () { + it('testSignVerifyECC003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js new file mode 100644 index 000000000..36f4de923 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicCallbackJsunit.test.js @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyED25519 } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyED25519CallbackJsunit', function () { + it('testSignVerifyED25519001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testSignVerifyED25519003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js new file mode 100644 index 000000000..61fc28e2a --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBCallbackJsunit.test.js @@ -0,0 +1,47 @@ +/* + + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); + +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA002', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias002'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js new file mode 100644 index 000000000..f0945bfad --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBCallbackJsunit.test.js @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA004', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias004'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js new file mode 100644 index 000000000..de55c6474 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBCallbackJsunit.test.js @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA001', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias001'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js new file mode 100644 index 000000000..dce3cdd51 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBCallbackJsunit.test.js @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSACallbackJsunit', function () { + it('testSignVerifyRSA003', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias003'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_callback_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_signverify_callback_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/huks_signverify_promise_BasicTest/BUILD.gn b/security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/BUILD.gn rename to security/security_huks_basic/huks_signverify_promise_BasicTest/BUILD.gn diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json new file mode 100644 index 000000000..8375b5d60 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for huksSignVerifyBasicPromise js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.hukssignverifybasicpromise", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsHuksSignVerifyBasicPromiseJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json similarity index 95% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json index 2f8af3d84..f0674418e 100644 --- a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/config.json +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/config.json @@ -61,4 +61,4 @@ } ] } -} +} \ No newline at end of file diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js new file mode 100644 index 000000000..5a5f568df --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + }, +}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/en-US.json diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/i18n/zh-CN.json diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css new file mode 100644 index 000000000..f42c43b7c --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.css @@ -0,0 +1,46 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #ffffff; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url('/common/images/Wallpaper.png'); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #ffffff; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.hml diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js new file mode 100644 index 000000000..b73c0cda6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/MainAbility/pages/index/index.js @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Core, ExpectExtend } from 'deccjsunit/index'; + +export default { + data: { + title: '', + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + id: 'extend', + }); + core.addService('expect', expectExtend); + core.init(); + const configService = core.getDefaultService('config'); + this.timeout = 1500000; + configService.setConfig(this); + console.log('test start'); + require('../../../test/List.test'); + core.execute(); + }, + onReady() {}, +}; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/element/string.json diff --git a/security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png rename to security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/resources/base/media/icon.png diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js new file mode 100644 index 000000000..94a5e5897 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/List.test.js @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +require('./SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js'); +require('./SignVerify/SecurityHuksED25519BasicPromiseJsunit.test'); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..ee369309d --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias102'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..3f76d1261 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias104'; + const NewSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + NewSrcKeyAlies, + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..6eb95fec6 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias101'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksTagDSACOMMONSIZE + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..db70b9f29 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksDSABasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyDSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyDSAPromiseJsunit', function () { + it('testSignVerifyDSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAlias103'; + const newSrcKeyAlies = 'testSignVerifyDSASIGNSHA1KeyAliasNew103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN, + HuksSignVerifyDSA.HuksTagDSADigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyDSA.HuksKeyAlgDSA, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY, + HuksSignVerifyDSA.HuksTagDSADigestSHA1, + HuksSignVerifyDSA.HuksKeySIZE1024 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..8ce919a55 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..e56659629 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..54882eaf9 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..5e579de45 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksECCBasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyECC } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyECCPromiseJsunit', function () { + it('testSignVerifyECC103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyECCSize224SIGNNONEKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeSIGN, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyECC.HuksKeyAlgECC, + HuksSignVerifyECC.HuksKeyECCPurposeVERIFY, + HuksSignVerifyECC.HuksTagECCDigestNONE, + HuksSignVerifyECC.HuksKeyECCSize224 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js new file mode 100644 index 000000000..3bba46b1d --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksED25519BasicPromiseJsunit.test.js @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyED25519 } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyED25519PromiseJsunit', function () { + it('testSignVerifyED25519101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); + + it('testSignVerifyED25519103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeVERIFY, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); + + it('testSignVerifyED25519104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyED25519Size256SIGNKeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyED25519.HuksKeyAlgED25519, + HuksSignVerifyED25519.HuksKeyED25519PurposeSIGN, + HuksSignVerifyED25519.HuksKeyED25519Size256, + HuksSignVerifyED25519.HuksTagDigestSHA1 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js new file mode 100644 index 000000000..09aee608b --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort63KBPromiseJsunit.test.js @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA102', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias102'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js new file mode 100644 index 000000000..c0c5cab9e --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicAbort65KBPromiseJsunit.test.js @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA104', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias104'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'abort', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js new file mode 100644 index 000000000..f92b7bd07 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish63KBPromiseJsunit.test.js @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData63 = Data.Data63b; +let srcData63Kb = stringToUint8Array(srcData63); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA101', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias101'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData63Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + false + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js new file mode 100644 index 000000000..4d8922314 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/SignVerify/SecurityHuksRSABasicFinish65KBPromiseJsunit.test.js @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it } from 'deccjsunit/index'; +import Data from '../../../../../../../utils/data.json'; +import { HuksSignVerifyRSA } from '../../../../../../../utils/param/signverify/publicSignverifyParam'; +import { stringToUint8Array } from '../../../../../../../utils/param/publicFunc'; +import { publicSignVerifyFunc } from '../../../../../../../utils/param/signverify/publicSignverifyPromise.js'; +let srcData65 = Data.Data65b; +let srcData65Kb = stringToUint8Array(srcData65); +describe('SecurityHuksSignVerifyRSAPromiseJsunit', function () { + it('testSignVerifyRSA103', 0, async function (done) { + const srcKeyAlies = 'testSignVerifyRSASize512SIGNPKCS1MD5KeyAlias103'; + let HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeSIGN, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + + HuksOptions = { + properties: new Array( + HuksSignVerifyRSA.HuksKeyAlgRSA, + HuksSignVerifyRSA.HuksKeyRSAPurposeVERIFY, + HuksSignVerifyRSA.HuksTagPKCS1DigestMD5, + HuksSignVerifyRSA.HuksKeyRSAPADDINGPKCS1V15, + HuksSignVerifyRSA.HuksKeyRSASize512 + ), + inData: srcData65Kb, + }; + await publicSignVerifyFunc( + srcKeyAlies, + srcKeyAlies + 'New', + HuksOptions, + 'finish', + true + ); + done(); + }); +}); diff --git a/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js new file mode 100644 index 000000000..d7bc32507 --- /dev/null +++ b/security/security_huks_basic/huks_signverify_promise_BasicTest/entry/src/main/js/test/switchControl.js @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let isOpenSSL = false; +export { isOpenSSL }; diff --git a/security/security_huks/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b b/security/security_huks_basic/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b similarity index 100% rename from security/security_huks/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b rename to security/security_huks_basic/huks_signverify_promise_BasicTest/signature/openharmony_sx.p7b diff --git a/security/security_huks/utils/data.json b/security/security_huks_basic/utils/data.json similarity index 99% rename from security/security_huks/utils/data.json rename to security/security_huks_basic/utils/data.json index 58a84a288..1c896754a 100644 --- a/security/security_huks/utils/data.json +++ b/security/security_huks_basic/utils/data.json @@ -1,6 +1,6 @@ { - "Date65KB": "ccccccaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "Data65b": "eeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "Data63b": "eeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +} \ No newline at end of file diff --git a/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js new file mode 100644 index 000000000..5281c5575 --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreeCallback.js @@ -0,0 +1,270 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import huks from '@ohos.security.huks'; +import { HksTag, HksKeyStorageType, HksKeyAlg } from '../publicParam'; +import { HuksAgreeECDH } from './publicAgreeParam.js'; +import { stringToUint8Array } from '../publicFunc.js'; +import { expect } from 'deccjsunit/index'; +let exportKeyFrist; +let exportKeySecond; +let handle; + +async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKeys) { + await exportKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (exportKeys == 1) { + exportKeyFrist = data.outData; + } else { + exportKeySecond = data.outData; + } + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeUpdateFunc(HuksOptions, exportKey) { + let _inData = HuksOptions.inData; + if (exportKey == 1) { + HuksOptions.inData = exportKeySecond; + } else { + HuksOptions.inData = exportKeyFrist; + } + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _inData; +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeFinishAbortFunc( + HuksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` + ); + await finish(handle, HuksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let HuksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await abort(handle, HuksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +function abort(handle, HuksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +function finish(handle, HuksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test finish err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAgreeFunc( + srcKeyAliesFrist, + srcKeyAliesSecond, + HuksOptions, + HuksOptionsFinish, + thirdInderfaceName +) { + try { + await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); + await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2); + + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_ECC) { + HuksOptions.properties.splice(0, 1, HuksAgreeECDH.HuksKeyAlgECDH); + HuksOptions.properties.splice(3, 1); + HuksOptions.properties.splice(4, 1); + HuksOptions.properties.splice(5, 1); + } + + await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 1); + await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); + + let tempHuksOptionsFinish = HuksOptionsFinish; + let HuksOptionsFinishSecond = tempHuksOptionsFinish; + HuksOptionsFinishSecond.properties.splice(6, 1, { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesSecond + 'final'), + }); + + await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 2); + await publicAgreeFinishAbortFunc( + HuksOptionsFinishSecond, + thirdInderfaceName + ); + + await publicAgreeDeleteFunc(srcKeyAliesFrist, HuksOptions); + if (thirdInderfaceName == 'finish') { + await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions); + } + await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} +export { publicAgreeFunc }; diff --git a/security/security_huks_basic/utils/param/agree/publicAgreeParam.js b/security/security_huks_basic/utils/param/agree/publicAgreeParam.js new file mode 100644 index 000000000..73b72f03b --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreeParam.js @@ -0,0 +1,430 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import * as param from '../publicParam'; + +let HuksAgreeDH = { + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_192, + }, + HuksKeyAlgDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DH, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeDH: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyDHSize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_2048, + }, + HuksKeyDHSize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_3072, + }, + HuksKeyDHSize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_4096, + }, +}; + +let HuksAgreeECDH = { + HuksKeyAlgECDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECDH, + }, + HuksKeyAlgECC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECC, + }, + HuksKeyECCSize224: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_224, + }, + HuksKeyECCSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeyECCSize384: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_384, + }, + HuksKeyECCSize521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyECCDIGEST: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyECCPADDING: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyECCBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_192, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeECDH: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, +}; + +let HuksKeyAlgX25519 = { + HuksKeyAlgX25519: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_X25519, + }, + HuksKeyPurposeAGREE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyCURVE25519Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_CURVE25519_KEY_SIZE_256, + }, + HuksKeyBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyPADDING: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyDIGEST: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_192, + }, + HuksKeyAlgDH: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DH, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyAlgHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeX25519: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_AGREE, + }, + HuksKeyDHSize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_2048, + }, + HuksKeyDHSize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_3072, + }, + HuksKeyDHSize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DH_KEY_SIZE_4096, + }, +}; +export { HuksAgreeDH, HuksAgreeECDH, HuksKeyAlgX25519 }; diff --git a/security/security_huks_basic/utils/param/agree/publicAgreePromise.js b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js new file mode 100644 index 000000000..30361c3e6 --- /dev/null +++ b/security/security_huks_basic/utils/param/agree/publicAgreePromise.js @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import huks from '@ohos.security.huks'; +import { HksTag, HksKeyStorageType, HksKeyAlg } from '../publicParam'; +import { HuksAgreeECDH } from './publicAgreeParam.js'; +import { stringToUint8Array } from '../publicFunc.js'; +import { expect } from 'deccjsunit/index'; +let exportKeyFrist; +let exportKeySecond; +let handle; + +async function publicAgreeGenFunc(srcKeyAlies, HuksOptions) { + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeExport1Func(srcKeyAlies, HuksOptions, exportKey) { + await huks + .exportKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (exportKey == 1) { + exportKeyFrist = data.outData; + } else { + exportKeySecond = data.outData; + } + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeUpdateFunc(HuksOptions, exportKey) { + let _inData = HuksOptions.inData; + if (exportKey == 1) { + HuksOptions.inData = exportKeySecond; + } else { + HuksOptions.inData = exportKeyFrist; + } + await huks + .update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _inData; +} + +async function publicAgreeFinishAbortFunc( + HuksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish HuksOptionsFinish ${JSON.stringify(HuksOptionsFinish)}` + ); + await huks + .finish(handle, HuksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let HuksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await huks + .abort(handle, HuksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +async function publicAgreeDeleteFunc(srcKeyAlies, HuksOptions) { + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAgreeFunc( + srcKeyAliesFrist, + srcKeyAliesSecond, + HuksOptions, + HuksOptionsFinish, + thirdInderfaceName +) { + try { + await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); + await publicAgreeExport1Func(srcKeyAliesSecond, HuksOptions, 2); + + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_ECC) { + HuksOptions.properties.splice(0, 1, HuksAgreeECDH.HuksKeyAlgECDH); + HuksOptions.properties.splice(3, 1); + HuksOptions.properties.splice(4, 1); + HuksOptions.properties.splice(5, 1); + } + + await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 1); + await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); + + let tempHuksOptionsFinish = HuksOptionsFinish; + let HuksOptionsFinishSecond = tempHuksOptionsFinish; + HuksOptionsFinishSecond.properties.splice(6, 1, { + tag: HksTag.HKS_TAG_KEY_ALIAS, + value: stringToUint8Array(srcKeyAliesSecond + 'final'), + }); + + await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); + await publicAgreeUpdateFunc(HuksOptions, 2); + await publicAgreeFinishAbortFunc( + HuksOptionsFinishSecond, + thirdInderfaceName + ); + + await publicAgreeDeleteFunc(srcKeyAliesFrist, HuksOptions); + if (thirdInderfaceName == 'finish') { + await publicAgreeDeleteFunc(srcKeyAliesSecond + 'final', HuksOptions); + } + await publicAgreeDeleteFunc(srcKeyAliesSecond, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicAgreeFunc }; diff --git a/security/security_huks_basic/utils/param/cipher/publicCipherParam.js b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js new file mode 100644 index 000000000..7f453f3d8 --- /dev/null +++ b/security/security_huks_basic/utils/param/cipher/publicCipherParam.js @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as param from '../publicParam'; + +let HuksCipherAES = { + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeENCRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, + }, + HuksKeyPurposeDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyAESSize128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyAESSize192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyAESSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyAESPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyAESPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyAESBLOCKMODE: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyAESBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyAESBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyAESDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, +}; + +let HuksCipherRSA = { + HuksKeyAlgRSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_RSA, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPurposeENCRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT, + }, + HuksKeyPurposeDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyRSASize512: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyRSAPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyRSAPADDINGPKCS1V15: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS1_V1_5, + }, + HuksKeyRSAPADDINGOAEP: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_OAEP, + }, + HuksKeyRSABLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyRSADIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyRSADIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyRSADIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyRSADIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyRSADIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyRSADIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { HuksCipherAES, HuksCipherRSA }; diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js new file mode 100644 index 000000000..f2946776e --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDeriveCallback.js @@ -0,0 +1,226 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import * as paramPublic from './publicDeriveParam.js'; +import { HksTag, HksKeyStorageType } from '../publicParam'; +let handle; + +async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { + await generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { + await init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + return HuksOptions; +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveUpdateFunc(HuksOptions) { + await update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function update(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveFinishAbortFunc( + huksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` + ); + await finish(handle, huksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let huksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await abort(handle, huksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +function abort(handle, huksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, huksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +function finish(handle, huksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, huksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { + console.log( + 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) + ); + await deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeriveFunc( + srcKeyAlies, + HuksOptions, + huksOptionsFinish, + thirdInderfaceName +) { + try { + await publicDeriveGenFunc(srcKeyAlies, HuksOptions); + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgHKDF + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE + ); + + await publicDeriveInitFunc(srcKeyAlies, HuksOptions); + await publicDeriveUpdateFunc(HuksOptions); + await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName); + + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgAES + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyHKDFSize128 + ); + await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicDeriveFunc }; diff --git a/security/security_huks_basic/utils/param/derive/publicDeriveParam.js b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js new file mode 100644 index 000000000..2bd05d7f1 --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDeriveParam.js @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import * as param from '../publicParam'; + +let HuksDeriveHKDF = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_512, + }, + HuksKeyAlgHKDF: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HKDF, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurposeHKDF: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksTagHKDFDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagHKDFDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagHKDFDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyHKDFSize128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyHKDFSize192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyHKDFSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyDERIVEKEYSIZE: { + tag: param.HksTag.HKS_TAG_DERIVE_KEY_SIZE, + value: param.HksKeySize.DERIVE_KEY_SIZE_32, + }, + + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, +}; + +let HuksDerivePBKDF2 = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_512, + }, + HuksKeyAlgPBKDF2: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_PBKDF2, + }, + HuksKeyAlgAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyPurposePBKDF2: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksTagPBKDF2DigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPBKDF2DigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPBKDF2DigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyPBKDF2Size128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeyPBKDF2Size192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPBKDF2Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeyDERIVEKEYSIZE: { + tag: param.HksTag.HKS_TAG_DERIVE_KEY_SIZE, + value: param.HksKeySize.DERIVE_KEY_SIZE_32, + }, + + HuksKeyISKEYALIAS: { tag: param.HksTag.HKS_TAG_IS_KEY_ALIAS, value: true }, + HuksKeySTORAGE: { + tag: param.HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: param.HksKeyStorageType.HKS_STORAGE_PERSISTENT, + }, + HuksKeyALGORITHMAES: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_AES, + }, + HuksKeyALGORITHMHMAC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeySIZE256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_256, + }, + HuksKeySIZE128: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_128, + }, + HuksKeySIZE192: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_AES_KEY_SIZE_192, + }, + HuksKeyPurposeDERIVE: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_DERIVE, + }, + HuksKeyPurposeMAC: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeyPurposeENCRYPTDECRYPT: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_ENCRYPT | + param.HksKeyPurpose.HKS_KEY_PURPOSE_DECRYPT, + }, + HuksKeyPADDINGNONE: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_NONE, + }, + HuksKeyPADDINGPKCS7: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS7, + }, + HuksKeyDIGESTNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksKeyDIGESTSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksKeyDIGESTSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksKeyDIGESTSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksKeyDIGESTSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksKeyDIGESTSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyBLOCKMODECBC: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CBC, + }, + HuksKeyBLOCKMODECCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CCM, + }, + HuksKeyBLOCKMODEECB: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_ECB, + }, + HuksKeyBLOCKMODECTR: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_CTR, + }, + HuksKeyBLOCKMODEGCM: { + tag: param.HksTag.HKS_TAG_BLOCK_MODE, + value: param.HksCipherMode.HKS_MODE_GCM, + }, +}; + +export { HuksDeriveHKDF, HuksDerivePBKDF2 }; diff --git a/security/security_huks_basic/utils/param/derive/publicDerivePromise.js b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js new file mode 100644 index 000000000..b23ab1861 --- /dev/null +++ b/security/security_huks_basic/utils/param/derive/publicDerivePromise.js @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import * as paramPublic from './publicDeriveParam.js'; +import { HksTag, HksKeyStorageType } from '../publicParam'; +let handle; +async function publicDeriveGenFunc(srcKeyAlies, HuksOptions) { + await huks + .generateKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveInitFunc(srcKeyAlies, HuksOptions) { + await huks + .init(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test init data ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveUpdateFunc(HuksOptions) { + await huks + .update(handle, HuksOptions) + .then((data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveFinishAbortFunc( + huksOptionsFinish, + thirdInderfaceName +) { + if (thirdInderfaceName == 'finish') { + console.log( + `test befor finish huksOptionsFinish ${JSON.stringify(huksOptionsFinish)}` + ); + await huks + .finish(handle, huksOptionsFinish) + .then((data) => { + console.log(`test finish data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } else { + let huksOptionsAbort = new Array({ + tag: HksTag.HKS_TAG_KEY_STORAGE_FLAG, + value: HksKeyStorageType.HKS_STORAGE_TEMP, + }); + await huks + .abort(handle, huksOptionsAbort) + .then((data) => { + console.log(`test abort data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + } +} + +async function publicDeriveDeleteFunc(srcKeyAlies, HuksOptions) { + console.log( + 'test before deleteKey HuksOptions: ' + JSON.stringify(HuksOptions) + ); + await huks + .deleteKey(srcKeyAlies, HuksOptions) + .then((data) => { + console.log(`test deleteKey data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeriveFunc( + srcKeyAlies, + HuksOptions, + huksOptionsFinish, + thirdInderfaceName +) { + try { + await publicDeriveGenFunc(srcKeyAlies, HuksOptions); + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgHKDF + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyDERIVEKEYSIZE + ); + + await publicDeriveInitFunc(srcKeyAlies, HuksOptions); + await publicDeriveUpdateFunc(HuksOptions); + await publicDeriveFinishAbortFunc(huksOptionsFinish, thirdInderfaceName); + + HuksOptions.properties.splice( + 0, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyAlgAES + ); + HuksOptions.properties.splice( + 3, + 1, + paramPublic.HuksDeriveHKDF.HuksKeyHKDFSize128 + ); + await publicDeriveDeleteFunc(srcKeyAlies, HuksOptions); + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicDeriveFunc }; diff --git a/security/security_huks_basic/utils/param/hmac/publicHmacParam.js b/security/security_huks_basic/utils/param/hmac/publicHmacParam.js new file mode 100644 index 000000000..248eb36ea --- /dev/null +++ b/security/security_huks_basic/utils/param/hmac/publicHmacParam.js @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import * as param from '../publicParam'; + +let HuksHmac = { + HuksKeyAlg: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_HMAC, + }, + HuksKeyPurpose: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_MAC, + }, + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksTagDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { HuksHmac }; diff --git a/security/security_huks_basic/utils/param/publicFunc.js b/security/security_huks_basic/utils/param/publicFunc.js new file mode 100644 index 000000000..3c71cb5ec --- /dev/null +++ b/security/security_huks_basic/utils/param/publicFunc.js @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +function stringToArray(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return arr; +} + +function uint8ArrayToString(fileData) { + var dataString = ''; + for (var i = 0; i < fileData.length; i++) { + dataString += String.fromCharCode(fileData[i]); + } + return dataString; +} +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} + +export { stringToArray, uint8ArrayToString, stringToUint8Array }; diff --git a/security/security_huks_basic/utils/param/publicParam.js b/security/security_huks_basic/utils/param/publicParam.js new file mode 100644 index 000000000..350fbb7be --- /dev/null +++ b/security/security_huks_basic/utils/param/publicParam.js @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +let HksKeyAlg = { + HKS_ALG_ECDH: 100, + HKS_ALG_ECC: 2, + HKS_ALG_DH: 103, + HKS_ALG_AES: 20, + HKS_ALG_HMAC: 50, + HKS_ALG_X25519: 102, + HKS_ALG_RSA: 1, + HKS_ALG_PBKDF2: 52, + HKS_ALG_HKDF: 51, + HKS_ALG_DSA: 3, + HKS_ALG_ED25519: 102, +}; +let HksKeyPurpose = { + HKS_KEY_PURPOSE_AGREE: 256, + HKS_KEY_PURPOSE_DERIVE: 16, + HKS_KEY_PURPOSE_ENCRYPT: 1, + HKS_KEY_PURPOSE_DECRYPT: 2, + HKS_KEY_PURPOSE_MAC: 128, + HKS_KEY_PURPOSE_SIGN: 4, + HKS_KEY_PURPOSE_VERIFY: 8, +}; +let HksKeySize = { + HKS_ED25519_KEY_SIZE_512: 512, + HKS_RSA_KEY_SIZE_512: 512, + HKS_DH_KEY_SIZE_128: 128, + HKS_DH_KEY_SIZE_192: 192, + HKS_DH_KEY_SIZE_256: 256, + HKS_DH_KEY_SIZE_512: 512, + HKS_DH_KEY_SIZE_2048: 2048, + HKS_DH_KEY_SIZE_3072: 3072, + HKS_DH_KEY_SIZE_4096: 4096, + HKS_ECC_KEY_SIZE_128: 128, + HKS_ECC_KEY_SIZE_192: 192, + HKS_ECC_KEY_SIZE_224: 224, + HKS_ECC_KEY_SIZE_256: 256, + HKS_ECC_KEY_SIZE_384: 384, + HKS_ECC_KEY_SIZE_521: 521, + HKS_CURVE25519_KEY_SIZE_256: 256, + HKS_AES_KEY_SIZE_128: 128, + HKS_AES_KEY_SIZE_192: 192, + HKS_AES_KEY_SIZE_256: 256, + HKS_AES_KEY_SIZE_512: 512, + DERIVE_KEY_SIZE_32: 32, + HKS_RSA_KEY_SIZE_768: 768, + HKS_RSA_KEY_SIZE_1024: 1024, + HKS_RSA_KEY_SIZE_2048: 2048, + HKS_RSA_KEY_SIZE_3072: 3072, + HKS_RSA_KEY_SIZE_4096: 4096, + HKS_DSA_KEY_SIZE_512: 512, + HKS_DSA_KEY_SIZE_768: 768, + HKS_DSA_KEY_SIZE_1024: 1024, + HKS_DSA_KEY_SIZE_2048: 2048, + HKS_DSA_KEY_SIZE_3072: 3072, + HKS_DSA_KEY_SIZE_4096: 4096, +}; +let HksKeyStorageType = { + HKS_STORAGE_TEMP: 0, + HKS_STORAGE_PERSISTENT: 1, +}; +let HksTagType = { + HKS_TAG_TYPE_UINT: 2 << 28, + HKS_TAG_TYPE_BOOL: 4 << 28, + HKS_TAG_TYPE_BYTES: 5 << 28, +}; +let HksKeyDigest = { + HKS_DIGEST_NONE: 0, + HKS_DIGEST_MD5: 1, + HKS_DIGEST_SHA1: 10, + HKS_DIGEST_SHA224: 11, + HKS_DIGEST_SHA256: 12, + HKS_DIGEST_SHA384: 13, + HKS_DIGEST_SHA512: 14, +}; +let HksKeyPadding = { + HKS_PADDING_NONE: 0, + HKS_PADDING_OAEP: 1, + HKS_PADDING_PSS: 2, + HKS_PADDING_PKCS1_V1_5: 3, + HKS_PADDING_PKCS5: 4, + HKS_PADDING_PKCS7: 5, +}; +let HksCipherMode = { + HKS_MODE_ECB: 1, + HKS_MODE_CBC: 2, + HKS_MODE_CTR: 3, + HKS_MODE_OFB: 4, + HKS_MODE_CCM: 31, + HKS_MODE_GCM: 32, +}; +let HksTag = { + HKS_TAG_ALGORITHM: HksTagType.HKS_TAG_TYPE_UINT | 1, + HKS_TAG_PURPOSE: HksTagType.HKS_TAG_TYPE_UINT | 2, + HKS_TAG_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 3, + HKS_TAG_DIGEST: HksTagType.HKS_TAG_TYPE_UINT | 4, + HKS_TAG_PADDING: HksTagType.HKS_TAG_TYPE_UINT | 5, + HKS_TAG_BLOCK_MODE: HksTagType.HKS_TAG_TYPE_UINT | 6, + HKS_TAG_KEY_STORAGE_FLAG: HksTagType.HKS_TAG_TYPE_UINT | 1002, + HKS_TAG_IS_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BOOL | 1001, + HKS_TAG_KEY_ALIAS: HksTagType.HKS_TAG_TYPE_BYTES | 23, + HKS_TAG_ASSOCIATED_DATA: HksTagType.HKS_TAG_TYPE_BYTES | 8, + HKS_TAG_NONCE: HksTagType.HKS_TAG_TYPE_BYTES | 9, + HKS_TAG_IV: HksTagType.HKS_TAG_TYPE_BYTES | 10, + HKS_TAG_AGREE_PUBLIC_KEY: HksTagType.HKS_TAG_TYPE_BYTES | 22, + HKS_TAG_AE_TAG: HksTagType.HKS_TAG_TYPE_BYTES | 10009, + HKS_TAG_DERIVE_KEY_SIZE: HksTagType.HKS_TAG_TYPE_UINT | 24, +}; +export { + HksKeyPurpose, + HksKeyAlg, + HksTagType, + HksTag, + HksKeySize, + HksKeyDigest, + HksKeyStorageType, + HksCipherMode, + HksKeyPadding, +}; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js new file mode 100644 index 000000000..bd489c6b0 --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyCallback.js @@ -0,0 +1,353 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HksKeyAlg } from '../publicParam.js'; +import { HuksSignVerifyDSA } from './publicSignverifyParam.js'; +import { stringToUint8Array, uint8ArrayToString } from '../publicFunc.js'; +let finishOutData; +let exportKey; +let handle; + +async function publicGenerateKeyFunc(keyAlias, HuksOptions) { + await generateKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function generateKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.generateKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicImportKey(keyAlias, HuksOptions) { + let _InData = HuksOptions.inData; + HuksOptions.inData = finishOutData; + console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await importKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log('test ImportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _InData; +} + +function importKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.importKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test importKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test importKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicExportKey(keyAlias, HuksOptions) { + await exportkey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + finishOutData = data.outData; + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function exportkey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.exportKey(srcKeyAlies, HuksOptions, function (err, data) { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + if (err.code !== 0) { + console.log('test exportKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicInitFunc(keyAlias, HuksOptions) { + await init(keyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function init(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.init(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test init err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicUpdateFunc(HuksOptions, isBigData) { + let dateSize = 0; + if (isBigData) { + dateSize = 64 * 1024; + } else { + dateSize = 64; + } + let tempHuksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + if (uint8ArrayToString(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } else { + let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); + let remainder = uint8ArrayToString(inDataArray).length % dateSize; + console.log( + `test before update length: ${uint8ArrayToString(inDataArray).length}` + ); + console.log(`test before update count: ${count}`); + console.log(`test before update remainder: ${remainder}`); + for (let i = 0; i < count; i++) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await updateCallback(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +function updateCallback(handle, HuksOptions) { + return new Promise((resolve, reject) => { + huks.update(handle, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test update err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicFinishFunc(HuksOptions) { + await finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function finish(handle, HuksOptionsFinish) { + return new Promise((resolve, reject) => { + huks.finish(handle, HuksOptionsFinish, function (err, data) { + if (err.code !== 0) { + console.log('test generateKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicAbortFucn(HuksOptions) { + await abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function abort(handle, HuksOptionsAbort) { + return new Promise((resolve, reject) => { + huks.abort(handle, HuksOptionsAbort, function (err, data) { + if (err.code !== 0) { + console.log('test abort err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { + await deleteKey(KeyAlias, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +function deleteKey(srcKeyAlies, HuksOptions) { + return new Promise((resolve, reject) => { + huks.deleteKey(srcKeyAlies, HuksOptions, function (err, data) { + if (err.code !== 0) { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + reject(err); + } else { + resolve(data); + } + }); + }); +} + +async function publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + thirdInderfaceName, + isSING, + isBigData +) { + try { + let keyAlias = srcKeyAlies; + if (isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 0, HuksSignVerifyDSA.HuksKeySIZE1024); + } + await publicGenerateKeyFunc(keyAlias, HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 1); + } + } else { + keyAlias = newSrcKeyAlies; + await publicImportKey(keyAlias, HuksOptions); + } + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await publicInitFunc(keyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions, isBigData); + if (thirdInderfaceName == 'finish') { + if (isSING) { + HuksOptions.outData = new Uint8Array(new Array(1024)); + await publicFinishFunc(HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + console.log( + `test before exportKey Gen_HuksOptions: ${JSON.stringify( + HuksOptions + )}` + ); + await publicExportKey(keyAlias, HuksOptions); + } else { + HuksOptions.outData = exportKey; + await publicFinishFunc(HuksOptions); + } + } else { + await publicAbortFucn(HuksOptions); + } + if (isSING && thirdInderfaceName == 'abort') { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } else if (!isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY + ); + await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions); + } + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicSignVerifyFunc }; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js new file mode 100644 index 000000000..0eac5b263 --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyParam.js @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import * as param from '../publicParam'; +let DSA_COMMON_SIZE = 1024; +let HuksSignVerifyDSA = { + HuksTagDSACOMMONSIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: DSA_COMMON_SIZE, + }, + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DSA_KEY_SIZE_512, + }, + HuksKeySIZE1024: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_DSA_KEY_SIZE_1024, + }, + HuksKeyAlgDSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_DSA, + }, + HuksKeyDSAPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyDSAPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagDSADigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagDSADigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagDSADigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagDSADigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagDSADigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, +}; + +let HuksSignVerifyECC = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyAlgECC: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ECC, + }, + HuksKeyECCPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyECCPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagECCDigestNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksTagECCDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagECCDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagECCDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagECCDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagECCDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksKeyECCSize224: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_224, + }, + HuksKeyECCSize256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_256, + }, + HuksKeyECCSize384: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_384, + }, + HuksKeyECCSize521: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ECC_KEY_SIZE_521, + }, + HuksKeyECCPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, +}; + +let HuksSignVerifyED25519 = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_ED25519_KEY_SIZE_512, + }, + HuksKeyAlgED25519: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_ED25519, + }, + HuksKeyED25519Size256: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_CURVE25519_KEY_SIZE_256, + }, + HuksKeyED25519PurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyED25519PurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksTagDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, +}; + +let HuksSignVerifyRSA = { + HuksKeySIZE: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyAlgRSA: { + tag: param.HksTag.HKS_TAG_ALGORITHM, + value: param.HksKeyAlg.HKS_ALG_RSA, + }, + HuksKeyRSASize512: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_512, + }, + HuksKeyRSASize768: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_768, + }, + HuksKeyRSASize1024: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_1024, + }, + HuksKeyRSASize2048: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_2048, + }, + HuksKeyRSASize3072: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_3072, + }, + HuksKeyRSASize4096: { + tag: param.HksTag.HKS_TAG_KEY_SIZE, + value: param.HksKeySize.HKS_RSA_KEY_SIZE_4096, + }, + HuksKeyRSAPurposeSIGN: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN, + }, + HuksKeyRSAPurposeVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPurposeSINGVERIFY: { + tag: param.HksTag.HKS_TAG_PURPOSE, + value: + param.HksKeyPurpose.HKS_KEY_PURPOSE_SIGN | + param.HksKeyPurpose.HKS_KEY_PURPOSE_VERIFY, + }, + HuksKeyRSAPADDINGPKCS1V15: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PKCS1_V1_5, + }, + HuksKeyRSAPADDINGPSS: { + tag: param.HksTag.HKS_TAG_PADDING, + value: param.HksKeyPadding.HKS_PADDING_PSS, + }, + HuksTagPKCS1DigestMD5: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_MD5, + }, + HuksTagPKCS1DigestNONE: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_NONE, + }, + HuksTagPKCS1DigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagPKCS1DigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagPKCS1DigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPKCS1DigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPKCS1DigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, + HuksTagPSSDigestSHA1: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA1, + }, + HuksTagPSSDigestSHA224: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA224, + }, + HuksTagPSSDigestSHA256: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA256, + }, + HuksTagPSSDigestSHA384: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA384, + }, + HuksTagPSSDigestSHA512: { + tag: param.HksTag.HKS_TAG_DIGEST, + value: param.HksKeyDigest.HKS_DIGEST_SHA512, + }, +}; +export { + HuksSignVerifyRSA, + HuksSignVerifyDSA, + HuksSignVerifyECC, + HuksSignVerifyED25519, +}; diff --git a/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js new file mode 100644 index 000000000..cb88c852b --- /dev/null +++ b/security/security_huks_basic/utils/param/signverify/publicSignverifyPromise.js @@ -0,0 +1,259 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect } from 'deccjsunit/index'; +import huks from '@ohos.security.huks'; +import { HksKeyAlg } from '../publicParam.js'; +import { HuksSignVerifyDSA } from './publicSignverifyParam.js'; +import { stringToUint8Array, uint8ArrayToString } from '../publicFunc.js'; +let finishOutData; +let exportKey; +let handle; + +async function publicGenerateKeyFunc(keyAlias, HuksOptions) { + await huks + .generateKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test generateKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test generateKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicImportKey(keyAlias, HuksOptions) { + let _InData = HuksOptions.inData; + HuksOptions.inData = finishOutData; + console.log(`test ImportKey keyAlias: ${keyAlias}`); + console.log(`test ImportKey HuksOptions: ${JSON.stringify(HuksOptions)}`); + await huks + .importKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test ImportKey data: ${JSON.stringify(data)}`); + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); + HuksOptions.inData = _InData; +} + +async function publicExportKey(keyAlias, HuksOptions) { + await huks + .exportKey(keyAlias, HuksOptions) + .then((data) => { + console.log(`test exportKey data: ${JSON.stringify(data)}`); + finishOutData = data.outData; + }) + .catch((err) => { + console.log('test exportKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicInitFunc(keyAlias, HuksOptions) { + await huks + .init(keyAlias, HuksOptions) + .then((data) => { + console.log(`test init data: ${JSON.stringify(data)}`); + handle = data.handle; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test init err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicUpdateFunc(HuksOptions, isBigData) { + let dateSize = 0; + if (isBigData) { + dateSize = 64 * 1024; + } else { + dateSize = 64; + } + let tempHuksOptionsInData = HuksOptions.inData; + let inDataArray = HuksOptions.inData; + if (uint8ArrayToString(inDataArray).length < dateSize) { + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } else { + let count = Math.floor(uint8ArrayToString(inDataArray).length / dateSize); + let remainder = uint8ArrayToString(inDataArray).length % dateSize; + console.log( + `test before update length: ${uint8ArrayToString(inDataArray).length}` + ); + console.log(`test before update count: ${count}`); + console.log(`test before update remainder: ${remainder}`); + for (let i = 0; i < count; i++) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * i, + dateSize * (i + 1) + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + if (remainder !== 0) { + HuksOptions.inData = stringToUint8Array( + uint8ArrayToString(tempHuksOptionsInData).slice( + dateSize * count, + uint8ArrayToString(inDataArray).length + ) + ); + await update(handle, HuksOptions); + HuksOptions.inData = tempHuksOptionsInData; + } + } +} + +async function update(handle, HuksOptions) { + console.log(`test update data ${JSON.stringify(HuksOptions)}`); + await huks + .update(handle, HuksOptions) + .then(async (data) => { + console.log(`test update data ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test update err information: ' + err); + expect(null).assertFail(); + }); +} + +async function publicFinishFunc(HuksOptions) { + await huks + .finish(handle, HuksOptions) + .then((data) => { + console.log(`test finish data: ${JSON.stringify(data)}`); + exportKey = data.outData; + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test finish err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicAbortFucn(HuksOptions) { + await huks + .abort(handle, HuksOptions) + .then((data) => { + console.log(`test abort data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test abort err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicDeleteKeyFunc(KeyAlias, HuksOptions) { + await huks + .deleteKey(KeyAlias, HuksOptions) + .then((data) => { + console.log(`test deleteKey data: ${JSON.stringify(data)}`); + expect(data.errorCode == 0).assertTrue(); + }) + .catch((err) => { + console.log('test deleteKey err information: ' + JSON.stringify(err)); + expect(null).assertFail(); + }); +} + +async function publicSignVerifyFunc( + srcKeyAlies, + newSrcKeyAlies, + HuksOptions, + thirdInderfaceName, + isSING, + isBigData +) { + try { + let keyAlias = srcKeyAlies; + if (isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 0, HuksSignVerifyDSA.HuksKeySIZE1024); + } + await publicGenerateKeyFunc(keyAlias, HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeSIGN + ); + if (HuksOptions.properties[0].value == HksKeyAlg.HKS_ALG_DSA) { + HuksOptions.properties.splice(2, 1); + } + } else { + keyAlias = newSrcKeyAlies; + await publicImportKey(keyAlias, HuksOptions); + } + console.log(`test init HuksOptions: ${JSON.stringify(HuksOptions)}`); + await publicInitFunc(keyAlias, HuksOptions); + await publicUpdateFunc(HuksOptions, isBigData); + if (thirdInderfaceName == 'finish') { + if (isSING) { + HuksOptions.outData = new Uint8Array(new Array(1024).fill('')); + console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); + console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); + await publicFinishFunc(HuksOptions); + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + console.log( + `test before exportKey Gen_HuksOptions: ${JSON.stringify( + HuksOptions + )}` + ); + await publicExportKey(keyAlias, HuksOptions); + } else { + HuksOptions.outData = exportKey; + console.log(`test before finish HuksOptions: ${HuksOptions.inData}`); + console.log(`test before finish HuksOptions: ${HuksOptions.outData}`); + await publicFinishFunc(HuksOptions); + } + } else { + await publicAbortFucn(HuksOptions); + } + if (isSING && thirdInderfaceName == 'abort') { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyRSAPurposeSINGVERIFY + ); + await publicDeleteKeyFunc(srcKeyAlies, HuksOptions); + } else if (!isSING) { + HuksOptions.properties.splice( + 1, + 1, + HuksSignVerifyDSA.HuksKeyDSAPurposeVERIFY + ); + await publicDeleteKeyFunc(newSrcKeyAlies, HuksOptions); + } + } catch (e) { + expect(null).assertFail(); + } +} + +export { publicSignVerifyFunc }; -- GitLab