未验证 提交 dd14b5d7 编写于 作者: O openharmony_ci 提交者: Gitee

!6616 【OpenHarmony 3.2.9.1】【安全子系统】新增非对称加解密用例

Merge pull request !6616 from qiaozzzh/1121_1
......@@ -4,6 +4,7 @@
"type": "OHJSUnitTest",
"test-timeout": "900000",
"shell-timeout": "900000",
"testcase-timeout": "180000",
"bundle-name": "com.openharmony.cryptoFramework1",
"package-name": "com.openharmony.cryptoFramework1"
},
......
......@@ -79,23 +79,891 @@ export default function AsymmetricCryptographyJsunit() {
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0300
* @tc.name Test RSA3072 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0300",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA3072",
"RSA3072|PKCS1|SHA224"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0300 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0400
* @tc.name Test RSA4096 normal encryption and decryption
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0400",
0,
async function (done) {
await asyPromise
.encryptAndDecryptNormalProcess(
"RSA4096",
"RSA4096|PKCS1_OAEP|MD5|MGF1_SHA512"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0500
* @tc.name Test RSA3072 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0500",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA8192",
"RSA8192|PKCS1_OAEP|SHA1|MGF1_SHA384"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0500 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0600
* @tc.name Test RSA3072|PKCS1|SHA256 normal encryption and decryption
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0600",
0,
async function (done) {
await asyPromise
.encryptAndDecryptNormalProcess(
"RSA3072|PRIMES_3",
"RSA3072|PKCS1|SHA256"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0600 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0700
* @tc.name Test RSA3072|PKCS1|SHA512 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0700",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA3072",
"RSA3072|PKCS1|SHA512"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0700 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0800
* @tc.name Test RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA256 normal encryption and decryption
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0800",
0,
async function (done) {
await asyPromise
.encryptAndDecryptNormalProcess(
"RSA3072",
"RSA3072|PKCS1_OAEP|SHA224|MGF1_SHA256"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0800 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_0900
* @tc.name Test RSA512|PKCS1_OAEP|SHA256|MGF1_SHA224 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0900",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA1024",
"RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA224"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_0900 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_1000
* @tc.name Test RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA1 normal encryption and decryption
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1000",
0,
async function (done) {
await asyPromise
.encryptAndDecryptNormalProcess(
"RSA3072|PRIMES_3",
"RSA3072|PKCS1_OAEP|SHA384|MGF1_SHA1"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1000 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_1100
* @tc.name Test RSA3072|PKCS1_OAEP|SHA512|MGF1_MD5 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1100",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA3072",
"RSA3072|PKCS1_OAEP|SHA512|MGF1_MD5"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1100 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_1200
* @tc.name Test RSA3072|PKCS1 normal encryption and decryption
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1200",
0,
async function (done) {
await asyPromise
.encryptAndDecryptNormalProcess(
"RSA3072",
"RSA3072|PKCS1"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1200 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_1300
* @tc.name Test RSA4096|PKCS1 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1300",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcess(
"RSA4096",
"RSA4096|PKCS1"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1300 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_1400
* @tc.name Test RSA4096|PKCS1 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1400",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcessNull(
"RSA4096",
"RSA4096|PKCS1"
)
.then((data) => {
expect(data == "Error: doFinal failed.").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_1400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0100
* @tc.name Test RSA1024|PKCS1|MD5 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0100",
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0100",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA1024|PRIMES_2", "RSA1024|PKCS1|MD5")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0100 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0200
* @tc.name Test RSA2048|PKCS1|SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0200",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA2048|PRIMES_2", "RSA2048|PKCS1|SHA1")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0200 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0300
* @tc.name Test RSA3072|PKCS1|SHA224 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0300",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA3072|PRIMES_2", "RSA3072|PKCS1|SHA224")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0300 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0400
* @tc.name Test RSA2048|PKCS1|SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0400",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA4096|PRIMES_2", "RSA4096|PKCS1|SHA256")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0500
* @tc.name Test RSA8192|PKCS1|SHA384 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0500",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA8192|PRIMES_3", "RSA8192|PKCS1|SHA384")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0500 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0600
* @tc.name Test RSA512|PKCS1|SHA512 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0600",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA512|PRIMES_2", "RSA512|PKCS1|SHA256")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0600 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0700
* @tc.name Test RSA1024|PKCS1|MD5|MGF1_MD5 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0700",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA1024", "RSA1024|PKCS1|MD5|MGF1_MD5")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0700 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0800
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0800",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA2048", "RSA2048|PSS|SHA1|MGF1_SHA1")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0800 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0900
* @tc.name Test RSA3072|PSS|SHA224|MGF1_SHA224 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0900",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA3072", "RSA3072|PSS|SHA224|MGF1_SHA224")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0900 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1000
* @tc.name Test RSA4096|PSS|SHA256|MGF1_SHA256 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1000",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA4096", "RSA4096|PSS|SHA256|MGF1_SHA256")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1000 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1100
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1100",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA8192", "RSA8192|PSS|SHA512|MGF1_SHA512")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1100 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1200
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1200",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA512", "RSA512|PSS|SHA384|MGF1_SHA384")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1200 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_5000
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_5000",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcessDataException("RSA512", "RSA512|PSS|SHA384|MGF1_SHA384", "null")
.then((data) => {
expect(data == "Error: [Data]: must be of the DataBlob type.").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_5000 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1300
* @tc.name Test RSA256 or null normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1300",
0,
async function (done) {
await asyPromise
.createAsyKeyGeneratorFail("RSA256")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of null").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1300 catch error: " +
err
);
expect(null).assertFail();
});
await asyPromise
.createAsyKeyGeneratorFail("null")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of null").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1300 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1400
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1400",
0,
async function (done) {
await asyPromise
.createAsySignFail(
"RSA3072",
"RSA4096|null|SHA256",
"RSA4096|PKCS1|null",
"RSA4096|PKCS1|SHA122",
"RSA4096|PKCS3|SHA256"
)
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_2000
* @tc.name Test RSA4096|PKCS1 normal encryption and decryption
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_Encryption_RSA_2000",
0,
async function (done) {
await asyCallback
.encryptAndDecryptNormalProcessSuperdata(
"RSA4096",
"RSA4096|PKCS1",
"490"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_Encryption_RSA_2000 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_2100
* @tc.name Test RSA3072|PKCS1|SHA224 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_2100",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcessSuperdata(
"RSA3072",
"RSA3072|PKCS1|SHA224",
"350"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_2100 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_1500
* @tc.name Test RSA2048|PSS|SHA1|MGF1_SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1500",
0,
async function (done) {
await asyPromise
.createAsyVerifyFail(
"RSA3072",
"RSA4096|null|SHA256",
"RSA4096|PKCS1|null",
"RSA4096|PKCS1|SHA122",
"RSA4096|PKCS3|SHA256"
)
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_1500 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0100
* @tc.name Test ECC224|SHA256 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0100",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("ECC224", "ECC224|SHA256")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0100 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0200
* @tc.name Test ECC256|SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0200",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("ECC256", "ECC256|SHA1")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0200 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0300
* @tc.name Test ECC224|SHA256 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0300",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcess("RSA1024|PRIMES_2", "RSA1024|PKCS1|MD5")
.signAndVerifyNormalProcess("ECC384", "ECC384|SHA224")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0100 catch error: " +
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0300 catch error: " +
err
);
expect(null).assertFail();
......@@ -105,22 +973,175 @@ export default function AsymmetricCryptographyJsunit() {
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_RSA_0200
* @tc.name Test RSA2048|PKCS1|SHA1 normal sign and verify
* @tc.desc Use the Promise Style of Interface
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0400
* @tc.name Test ECC521|SHA384 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0200",
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0400",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("RSA2048|PRIMES_2", "RSA2048|PKCS1|SHA1")
.signAndVerifyNormalProcess("ECC512", "ECC512|SHA384")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_RSA_0200 catch error: " +
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0500
* @tc.name Test ECC224|SHA512 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0500",
0,
async function (done) {
await asyPromise
.signAndVerifyNormalProcess("ECC224", "ECC224|SHA512")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0500 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0600
* @tc.name Test ECC1 or NULL normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0600",
0,
async function (done) {
await asyCallback
.createAsyKeyGeneratorFail("ECC1")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of null").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0600 catch error: " +
err
);
expect(null).assertFail();
});
await asyCallback
.createAsyKeyGeneratorFail("null")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of null").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0600 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0700
* @tc.name Test ECC224 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0700",
0,
async function (done) {
await asyPromise
.createAsySignFail(
"ECC224",
"ECC224|SHA257",
"ECC224|NULL",
"NULL|SHA1",
"ECC|SHA"
)
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0700: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0800
* @tc.name Test RSA3072 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0800",
0,
async function (done) {
await asyPromise
.createAsyVerifyFail(
"ECC224",
"ECC1|SHA256",
"NULL|SHA256",
"ECC224|SHA122",
"ECC224|NULL"
)
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0800 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0900
* @tc.name Test ECC224|SHA512 normal sign and verify
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0900",
0,
async function (done) {
await asyCallback
.signAndVerifyNormalProcessSuperdata(
"ECC224",
"ECC224|SHA512",
"350"
)
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDSA_0900 catch error: " +
err
);
expect(null).assertFail();
......@@ -179,6 +1200,143 @@ export default function AsymmetricCryptographyJsunit() {
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0300
* @tc.name Test ECC384 SignVerify ECDH
* @tc.desc Use the Promise Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0300",
0,
async function (done) {
await asyPromise
.keyAgreementProcess("ECC384")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0300 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0400
* @tc.name Test ECC512 SignVerify ECDH
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0400",
0,
async function (done) {
await asyCallback
.keyAgreementProcess("ECC512")
.then((data) => {
expect(data == null).assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0400 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0500
* @tc.name Test ECC5 or null SignVerify ECDH
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0500",
0,
async function (done) {
await asyCallback
.createAsyKeyAgreementFail("ECC5")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0500 catch error: " +
err
);
expect(null).assertFail();
});
await asyCallback
.createAsyKeyAgreementFail("null")
.then((data) => {
expect(data == "TypeError: Cannot read property algName of undefined").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0500 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0600
* @tc.name Test ECC256 SignVerify ECDH
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0600",
0,
async function (done) {
await asyCallback
.keyAgreementProcessParameterException("ECC256")
.then((data) => {
expect(data == "Error: [PriKey]: param unwarp error.").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0600 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_SignVerify_ECDH_0700
* @tc.name Test RSA3072 SignVerify ECDH
* @tc.desc Use the Callback Style of Interface
*/
it(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0700",
0,
async function (done) {
await asyCallback
.keyAgreementProcessFail("RSA3072", "ECC512")
.then((data) => {
expect(data == "Error: An exception occurs.").assertTrue();
})
.catch((err) => {
console.error(
"Security_crypto_framework_ASymmetric_SignVerify_ECDH_0700 catch error: " +
err
);
expect(null).assertFail();
});
done();
}
);
/**
* @tc.number Security_crypto_framework_ASymmetric_Encryption_RSA_3300
* @tc.name Test convertKey
......
......@@ -391,6 +391,17 @@ async function convertKeyEncryptAndDecryptProcess(asyAlgoName) {
});
}
async function createAsyKeyAgreementFail(ECDHAlgoName) {
return new Promise((resolve, reject) => {
var globalECDHData = createAsyKeyAgreement(ECDHAlgoName);
resolve(globalECDHData);
expect(globalECDHData == "TypeError: Cannot read property algName of undefined").assertTrue();
if (globalECDHData != "TypeError: Cannot read property algName of undefined"){
reject();
}
});
}
async function keyAgreementProcess(ECDHAlgoName) {
var globalPubKey;
var globalPriKey;
......@@ -420,9 +431,328 @@ async function keyAgreementProcess(ECDHAlgoName) {
});
}
async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
var globalPubKey;
var globalPriKey;
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
expect(rsaGenerator != null).assertTrue();
var globalECDHData = createAsyKeyAgreement(ECDHAlgoName1);
expect(globalECDHData != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return generateAsySecret(globalECDHData, globalPriKey, globalPubKey);
})
.then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data));
expect(result != null).assertTrue();
reject();
})
.catch((err) => {
console.error("[Callback] keyAgreementProcess catch err:" + err);
resolve(err);
});
});
}
async function keyAgreementProcessParameterException(ECDHAlgoName) {
var globalPubKey;
var globalPriKey;
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
expect(rsaGenerator != null).assertTrue();
var globalECDHData = createAsyKeyAgreement(ECDHAlgoName);
expect(globalECDHData != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return generateAsySecret(globalECDHData, null, null);
})
.then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data));
expect(result != null).assertTrue();
})
.catch((err) => {
expect(err == "Error: [PriKey]: param unwarp error.").assertTrue();
});
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return generateAsySecret(globalECDHData, globalPubKey, null);
})
.then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data));
expect(result != null).assertTrue();
})
.catch((err) => {
expect(err == "Error: [PubKey]: param unwarp error.").assertTrue();
});
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return generateAsySecret(globalECDHData, null, globalPriKey);
})
.then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data));
expect(result != null).assertTrue();
reject();
})
.catch((err) => {
expect(err == "Error: [PriKey]: param unwarp error.").assertTrue();
resolve(err);
});
});
}
async function createAsyKeyGeneratorFail(asyAlgoName) {
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
resolve(rsaGenerator);
expect(rsaGenerator == "TypeError: Cannot read property algName of null").assertTrue();
if (rsaGenerator != "TypeError: Cannot read property algName of null") {
reject();
}
});
}
async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoName, globalTextLen) {
var globalCipherText;
var globalPubKey;
var globalPriKey;
var globalText;
var i;
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
var decryptMode = cryptoFramework.CryptoMode.DECRYPT_MODE;
var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",n = t.length,s="";
for (i = 0; i < globalTextLen; i++) {
globalText += t.charAt(Math.floor(Math.random() * n));
}
var input = { data: stringTouInt8Array(globalText) };
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var cipherGeneratorEncrypt = createAsyCipher(cipherAlgoName);
expect(cipherGeneratorEncrypt != null).assertTrue();
var cipherGeneratorDecrypt = createAsyCipher(cipherAlgoName);
expect(cipherGeneratorDecrypt != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return initCipher(
cipherGeneratorEncrypt,
encryptMode,
globalPubKey,
null
);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return doFinalCipher(cipherGeneratorEncrypt, encryptMode, input);
})
.then((finalOutput) => {
expect(finalOutput != null).assertTrue();
globalCipherText = finalOutput;
console.log(
"cipherOutput: " + uInt8ArrayToShowStr(globalCipherText.data)
);
return initCipher(
cipherGeneratorDecrypt,
decryptMode,
globalPriKey,
null
);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return doFinalCipher(
cipherGeneratorDecrypt,
decryptMode,
globalCipherText
);
})
.then((finalOutput) => {
if (finalOutput == null) {
console.error("[Callback]decrypt doFinal out is null");
} else {
console.log(
"[Callback]decrypt doFinal out hex: " +
uInt8ArrayToShowStr(finalOutput.data)
);
}
let decryptData = uInt8ArrayToString(finalOutput.data);
expect(decryptData == globalText).assertTrue();
resolve();
})
.catch((err) => {
console.error(
"[Callback] encryptAndDecryptNormalProcess catch err:" + err
);
reject(err);
});
});
}
async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoName, globalTextLen) {
var globalSignBlob;
var globalPubKey;
var globalPriKey;
var globalText;
var i;
var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",n = t.length,s="";
for (i = 0; i < globalTextLen; i++) {
globalText += t.charAt(Math.floor(Math.random() * n));
}
var input = { data: stringTouInt8Array(globalText) };
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName);
expect(signGenerator != null).assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName);
expect(verifyGenerator != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return initSign(signGenerator, globalPriKey);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return updateSign(signGenerator, input);
})
.then((updateData) => {
expect(updateData === "update success").assertTrue();
return signForSign(signGenerator, input);
})
.then((finalOutput) => {
expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return updateVerify(verifyGenerator, input);
})
.then((updateData) => {
expect(updateData === "update success").assertTrue();
return verifyForVerify(verifyGenerator, input, globalSignBlob);
})
.then((finalStatus) => {
expect(finalStatus).assertTrue();
resolve();
})
.catch((err) => {
console.error("[Callback] signAndVerifyNormalProcess catch err:" + err);
reject(err);
});
});
}
async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
var globalCipherText;
var globalPubKey;
var globalPriKey;
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
var decryptMode = cryptoFramework.CryptoMode.DECRYPT_MODE;
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var cipherGeneratorEncrypt = createAsyCipher(cipherAlgoName);
expect(cipherGeneratorEncrypt != null).assertTrue();
var cipherGeneratorDecrypt = createAsyCipher(cipherAlgoName);
expect(cipherGeneratorDecrypt != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return initCipher(
cipherGeneratorEncrypt,
encryptMode,
globalPubKey,
null
);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return doFinalCipher(cipherGeneratorEncrypt, encryptMode, null);
})
.then((finalOutput) => {
expect(finalOutput != null).assertTrue();
globalCipherText = finalOutput;
console.log(
"cipherOutput: " + uInt8ArrayToShowStr(globalCipherText.data)
);
return initCipher(
cipherGeneratorDecrypt,
decryptMode,
globalPriKey,
null
);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return doFinalCipher(
cipherGeneratorDecrypt,
decryptMode,
globalCipherText
);
})
.then((finalOutput) => {
if (finalOutput == null) {
console.error("[Callback]decrypt doFinal out is null");
} else {
console.log(
"[Callback]decrypt doFinal out hex: " +
uInt8ArrayToShowStr(finalOutput.data)
);
}
let decryptData = uInt8ArrayToString(finalOutput.data);
expect(decryptData == globalText).assertTrue();
reject();
})
.catch((err) => {
console.error(
"[Callback] encryptAndDecryptNormalProcess catch err:" + err
);
resolve(err);
});
});
}
export {
encryptAndDecryptNormalProcess,
signAndVerifyNormalProcess,
convertKeyEncryptAndDecryptProcess,
keyAgreementProcess,
createAsyKeyAgreementFail,
keyAgreementProcessFail,
keyAgreementProcessParameterException,
createAsyKeyGeneratorFail,
encryptAndDecryptNormalProcessSuperdata,
signAndVerifyNormalProcessSuperdata,
encryptAndDecryptNormalProcessNull,
};
......@@ -351,6 +351,74 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
});
}
async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAlgoName, dataType) {
var globalPubKey;
var globalPriKey;
var globalSignBlob;
var globalText = "This is a sign test";
var input;
if (dataType == "null") {
input = null;
} else {
input = { data: stringTouInt8Array(globalText) };
};
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName);
expect(signGenerator != null).assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName);
expect(verifyGenerator != null).assertTrue();
generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey;
globalPriKey = rsaKeyPair.priKey;
return initSign(signGenerator, globalPriKey);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return updateSign(signGenerator, input);
})
.then((updateData) => {
expect(updateData === "update success").assertTrue();
return signForSign(signGenerator, input);
})
.then((finalOutput) => {
expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey);
})
.then((initData) => {
expect(initData === "init success").assertTrue();
return updateVerify(verifyGenerator, input);
})
.then((updateData) => {
expect(updateData === "update success").assertTrue();
return verifyForVerify(verifyGenerator, input, globalSignBlob);
})
.then((finalStatus) => {
expect(finalStatus).assertTrue();
if (dataType == "null") {
reject();
} else {
resolve();
}
})
.catch((err) => {
console.error("[promise] signAndVerifyNormalProcess catch err:" + err);
if (dataType =="null") {
resolve(err);
} else {
reject(err);
}
});
});
}
async function convertKeyEncryptAndDecryptProcess(asyAlgoName) {
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
......@@ -445,10 +513,84 @@ async function AsyPriKeyClearProcess(asyAlgoName) {
});
}
async function createAsyKeyGeneratorFail(asyAlgoName) {
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
resolve(rsaGenerator);
expect(rsaGenerator == "TypeError: Cannot read property algName of null").assertTrue();
if (rsaGenerator != "TypeError: Cannot read property algName of null") {
reject();
}
});
}
async function createAsySignFail(
asyAlgoName,
signVerifyAlgoName,
signVerifyAlgoName1,
signVerifyAlgoName2,
signVerifyAlgoName3
) {
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var rsaKeyPair = generateAsyKeyPair(rsaGenerator);
expect(rsaKeyPair != null).assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName);
expect(signGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName1);
expect(signGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName2);
expect(signGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var signGenerator = createAsySign(signVerifyAlgoName3);
resolve(signGenerator);
expect(signGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
if (signGenerator != "TypeError: Cannot read property algName of undefined") {
reject();
}
});
}
async function createAsyVerifyFail(
asyAlgoName,
signVerifyAlgoName,
signVerifyAlgoName1,
signVerifyAlgoName2,
signVerifyAlgoName3
) {
return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(asyAlgoName);
expect(rsaGenerator != null).assertTrue();
var rsaKeyPair = generateAsyKeyPair(rsaGenerator);
expect(rsaKeyPair != null).assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName);
expect(verifyGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName1);
expect(verifyGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName2);
expect(verifyGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
var verifyGenerator = createAsyVerify(signVerifyAlgoName3);
resolve(verifyGenerator);
expect(verifyGenerator == "TypeError: Cannot read property algName of undefined").assertTrue();
if (verifyGenerator != "TypeError: Cannot read property algName of undefined") {
reject();
}
});
}
export {
encryptAndDecryptNormalProcess,
signAndVerifyNormalProcess,
convertKeyEncryptAndDecryptProcess,
keyAgreementProcess,
AsyPriKeyClearProcess,
signAndVerifyNormalProcessDataException,
createAsyKeyGeneratorFail,
createAsySignFail,
createAsyVerifyFail,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册