From 1ccb73201d3cfca68c6b0930c86253bff7f5ceb6 Mon Sep 17 00:00:00 2001 From: qiaozzzh Date: Mon, 12 Jun 2023 17:32:05 +0800 Subject: [PATCH] XTS Adaptation requirements Signed-off-by: qiaozzzh Change-Id: I189771876a1e13340f7973360ccafc7682a4c371 --- .../src/main/js/test/AsymmetricCryptography.test.js | 1 + .../src/main/js/test/DigestAlgorithm.test.js | 8 ++++++++ .../src/main/js/test/SymmetricCryptography.test.js | 10 ++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js index 336213023..9fcb56678 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/AsymmetricCryptography.test.js @@ -404,6 +404,7 @@ export default function AsymmetricCryptographyJsunit() { let globalRsaKeyPair = rsaGenerator.generateKeyPair(); try { await cipherGeneratorEncrypt.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, globalRsaKeyPair, null); + expect(null).assertFail(); } catch (err) { console.error("err is:" + err.code); expect(err.code).assertEqual(401); diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/DigestAlgorithm.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/DigestAlgorithm.test.js index 7ae43e2cd..998f33be2 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/DigestAlgorithm.test.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/DigestAlgorithm.test.js @@ -204,16 +204,19 @@ export default function DigestAlgorithmJsunit() { } }) }) + expect(null).assertFail(); } catch (err) { expect(err.code).assertEqual(401); } try { await mdGenerator.update(0); + expect(null).assertFail(); } catch (err) { expect(err.code).assertEqual(401); } try { await mdGenerator.digest(); + expect(null).assertFail(); } catch (err) { console.error("err is " + err.code); expect(err.code).assertEqual(401) @@ -309,12 +312,14 @@ export default function DigestAlgorithmJsunit() { it("Security_crypto_framework_HMAC_0600", 0, async function (done) { try { cryptoFramework.createMac("SHA5"); + expect(null).assertFail(); } catch (err) { console.error("[Promise]: error code: " + err.code + ", message is: " + err.message); expect(err.code).assertEqual(801); } try { cryptoFramework.createMac(null); + expect(null).assertFail(); } catch (err) { console.error("[Promise]: error code: " + err.code + ", message is: " + err.message); expect(err.code).assertEqual(401); @@ -333,12 +338,14 @@ export default function DigestAlgorithmJsunit() { let key = globalsymKeyGenerator.generateKeyPair(); try { await globalHMAC.init(key); + expect(null).assertFail(); } catch (err) { console.error("[Promise]init(key): error code: " + err.code + ", message is: " + err.message); expect(err.code).assertEqual(401); }; try { await globalHMAC.init(null); + expect(null).assertFail(); } catch (err) { console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message); expect(err.code).assertEqual(401); @@ -358,6 +365,7 @@ export default function DigestAlgorithmJsunit() { await globalHMAC.init(key); try { await globalHMAC.update(null); + expect(null).assertFail(); } catch (err) { console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message); expect(err.code).assertEqual(401); diff --git a/security/cryptoFramework/js_api_test_one/src/main/js/test/SymmetricCryptography.test.js b/security/cryptoFramework/js_api_test_one/src/main/js/test/SymmetricCryptography.test.js index 74c57da69..a277f1281 100644 --- a/security/cryptoFramework/js_api_test_one/src/main/js/test/SymmetricCryptography.test.js +++ b/security/cryptoFramework/js_api_test_one/src/main/js/test/SymmetricCryptography.test.js @@ -647,13 +647,14 @@ export default function SymmetricCryptographyJsunit() { cryptoFramework.createCipher("3DES192|null|PKCS7"); expect(null).assertFail(); } catch (err) { - expect(err.code).assertEqual(801) + expect(err.code).assertEqual(801); + expect(null).assertFail(); } try { cryptoFramework.createCipher("3DES192|DDD|PKCS7"); expect(null).assertFail(); } catch (err) { - expect(err.code).assertEqual(801) + expect(err.code).assertEqual(801); } done(); } @@ -676,13 +677,13 @@ export default function SymmetricCryptographyJsunit() { cryptoFramework.createCipher("3DES192|ECB|null"); expect(null).assertFail(); } catch (err) { - expect(err.code).assertEqual(801) + expect(err.code).assertEqual(801); } try { cryptoFramework.createCipher("3DES192|ECB|CCCCC"); expect(null).assertFail(); } catch (err) { - expect(err.code).assertEqual(801) + expect(err.code).assertEqual(801); } done(); } @@ -735,6 +736,7 @@ export default function SymmetricCryptographyJsunit() { await cipherGenerator.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, publicModule.genCcmParamsSpec()); try { await cipherGenerator.update(null); + expect(null).assertFail(); } catch (err) { console.error("Security_crypto_framework_Symmetric_Encryption_AES_3000 catch error: " + err.code); expect(err.code).assertEqual(401); -- GitLab