提交 1ccb7320 编写于 作者: Q qiaozzzh

XTS Adaptation requirements

Signed-off-by: Nqiaozzzh <qiaozhang@huawei.com>
Change-Id: I189771876a1e13340f7973360ccafc7682a4c371
上级 70aa7282
...@@ -404,6 +404,7 @@ export default function AsymmetricCryptographyJsunit() { ...@@ -404,6 +404,7 @@ export default function AsymmetricCryptographyJsunit() {
let globalRsaKeyPair = rsaGenerator.generateKeyPair(); let globalRsaKeyPair = rsaGenerator.generateKeyPair();
try { try {
await cipherGeneratorEncrypt.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, globalRsaKeyPair, null); await cipherGeneratorEncrypt.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, globalRsaKeyPair, null);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("err is:" + err.code); console.error("err is:" + err.code);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
......
...@@ -204,16 +204,19 @@ export default function DigestAlgorithmJsunit() { ...@@ -204,16 +204,19 @@ export default function DigestAlgorithmJsunit() {
} }
}) })
}) })
expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
} }
try { try {
await mdGenerator.update(0); await mdGenerator.update(0);
expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
} }
try { try {
await mdGenerator.digest(); await mdGenerator.digest();
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("err is " + err.code); console.error("err is " + err.code);
expect(err.code).assertEqual(401) expect(err.code).assertEqual(401)
...@@ -309,12 +312,14 @@ export default function DigestAlgorithmJsunit() { ...@@ -309,12 +312,14 @@ export default function DigestAlgorithmJsunit() {
it("Security_crypto_framework_HMAC_0600", 0, async function (done) { it("Security_crypto_framework_HMAC_0600", 0, async function (done) {
try { try {
cryptoFramework.createMac("SHA5"); cryptoFramework.createMac("SHA5");
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("[Promise]: error code: " + err.code + ", message is: " + err.message); console.error("[Promise]: error code: " + err.code + ", message is: " + err.message);
expect(err.code).assertEqual(801); expect(err.code).assertEqual(801);
} }
try { try {
cryptoFramework.createMac(null); cryptoFramework.createMac(null);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("[Promise]: error code: " + err.code + ", message is: " + err.message); console.error("[Promise]: error code: " + err.code + ", message is: " + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
...@@ -333,12 +338,14 @@ export default function DigestAlgorithmJsunit() { ...@@ -333,12 +338,14 @@ export default function DigestAlgorithmJsunit() {
let key = globalsymKeyGenerator.generateKeyPair(); let key = globalsymKeyGenerator.generateKeyPair();
try { try {
await globalHMAC.init(key); await globalHMAC.init(key);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("[Promise]init(key): error code: " + err.code + ", message is: " + err.message); console.error("[Promise]init(key): error code: " + err.code + ", message is: " + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
}; };
try { try {
await globalHMAC.init(null); await globalHMAC.init(null);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message); console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
...@@ -358,6 +365,7 @@ export default function DigestAlgorithmJsunit() { ...@@ -358,6 +365,7 @@ export default function DigestAlgorithmJsunit() {
await globalHMAC.init(key); await globalHMAC.init(key);
try { try {
await globalHMAC.update(null); await globalHMAC.update(null);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message); console.error("[Promise]init(null): error code: " + err.code + ", message is: " + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
......
...@@ -647,13 +647,14 @@ export default function SymmetricCryptographyJsunit() { ...@@ -647,13 +647,14 @@ export default function SymmetricCryptographyJsunit() {
cryptoFramework.createCipher("3DES192|null|PKCS7"); cryptoFramework.createCipher("3DES192|null|PKCS7");
expect(null).assertFail(); expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(801) expect(err.code).assertEqual(801);
expect(null).assertFail();
} }
try { try {
cryptoFramework.createCipher("3DES192|DDD|PKCS7"); cryptoFramework.createCipher("3DES192|DDD|PKCS7");
expect(null).assertFail(); expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(801) expect(err.code).assertEqual(801);
} }
done(); done();
} }
...@@ -676,13 +677,13 @@ export default function SymmetricCryptographyJsunit() { ...@@ -676,13 +677,13 @@ export default function SymmetricCryptographyJsunit() {
cryptoFramework.createCipher("3DES192|ECB|null"); cryptoFramework.createCipher("3DES192|ECB|null");
expect(null).assertFail(); expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(801) expect(err.code).assertEqual(801);
} }
try { try {
cryptoFramework.createCipher("3DES192|ECB|CCCCC"); cryptoFramework.createCipher("3DES192|ECB|CCCCC");
expect(null).assertFail(); expect(null).assertFail();
} catch (err) { } catch (err) {
expect(err.code).assertEqual(801) expect(err.code).assertEqual(801);
} }
done(); done();
} }
...@@ -735,6 +736,7 @@ export default function SymmetricCryptographyJsunit() { ...@@ -735,6 +736,7 @@ export default function SymmetricCryptographyJsunit() {
await cipherGenerator.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, publicModule.genCcmParamsSpec()); await cipherGenerator.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, publicModule.genCcmParamsSpec());
try { try {
await cipherGenerator.update(null); await cipherGenerator.update(null);
expect(null).assertFail();
} catch (err) { } catch (err) {
console.error("Security_crypto_framework_Symmetric_Encryption_AES_3000 catch error: " + err.code); console.error("Security_crypto_framework_Symmetric_Encryption_AES_3000 catch error: " + err.code);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册