提交 e8ab3c95 编写于 作者: Q qiaozzzh

加解密测试套优化

Signed-off-by: Nqiaozzzh <qiaozhang@huawei.com>
上级 4a1acc29
...@@ -217,8 +217,7 @@ async function generateAsySecret(generator, priKey, pubKey) { ...@@ -217,8 +217,7 @@ async function generateAsySecret(generator, priKey, pubKey) {
async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
var globalCipherText; var globalCipherText;
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalText = "This is a cipher test"; var globalText = "This is a cipher test";
var input = { data: stringTouInt8Array(globalText) }; var input = { data: stringTouInt8Array(globalText) };
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE; var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
...@@ -235,12 +234,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -235,12 +234,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey;
return initCipher( return initCipher(
cipherGeneratorEncrypt, cipherGeneratorEncrypt,
encryptMode, encryptMode,
globalPubKey, globalRsaKeyPair.pubKey,
null null
); );
}) })
...@@ -257,7 +255,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -257,7 +255,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
return initCipher( return initCipher(
cipherGeneratorDecrypt, cipherGeneratorDecrypt,
decryptMode, decryptMode,
globalPriKey, globalRsaKeyPair.priKey,
null null
); );
}) })
...@@ -292,8 +290,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -292,8 +290,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
} }
async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalSignBlob; var globalSignBlob;
var globalText = "This is a sign test"; var globalText = "This is a sign test";
var input = { data: stringTouInt8Array(globalText) }; var input = { data: stringTouInt8Array(globalText) };
...@@ -309,9 +306,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { ...@@ -309,9 +306,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return initSign(signGenerator, globalRsaKeyPair.priKey);
return initSign(signGenerator, globalPriKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -325,7 +321,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { ...@@ -325,7 +321,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
expect(finalOutput != null).assertTrue(); expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput; globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data)); console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey); return initVerify(verifyGenerator, globalRsaKeyPair.pubKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -403,8 +399,7 @@ async function createAsyKeyAgreementFail(ECDHAlgoName) { ...@@ -403,8 +399,7 @@ async function createAsyKeyAgreementFail(ECDHAlgoName) {
} }
async function keyAgreementProcess(ECDHAlgoName) { async function keyAgreementProcess(ECDHAlgoName) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName); var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
...@@ -415,9 +410,8 @@ async function keyAgreementProcess(ECDHAlgoName) { ...@@ -415,9 +410,8 @@ async function keyAgreementProcess(ECDHAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return generateAsySecret(globalECDHData, globalRsaKeyPair.priKey, globalRsaKeyPair.pubKey);
return generateAsySecret(globalECDHData, globalPriKey, globalPubKey);
}) })
.then((result) => { .then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data)); console.warn("result data is " + uInt8ArrayToShowStr(result.data));
...@@ -432,8 +426,7 @@ async function keyAgreementProcess(ECDHAlgoName) { ...@@ -432,8 +426,7 @@ async function keyAgreementProcess(ECDHAlgoName) {
} }
async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) { async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName); var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
...@@ -444,9 +437,8 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) { ...@@ -444,9 +437,8 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return generateAsySecret(globalECDHData, globalRsaKeyPair.priKey, globalRsaKeyPair.pubKey);
return generateAsySecret(globalECDHData, globalPriKey, globalPubKey);
}) })
.then((result) => { .then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data)); console.warn("result data is " + uInt8ArrayToShowStr(result.data));
...@@ -461,8 +453,7 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) { ...@@ -461,8 +453,7 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
} }
async function keyAgreementProcessParameterException(ECDHAlgoName) { async function keyAgreementProcessParameterException(ECDHAlgoName) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName); var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
...@@ -473,8 +464,7 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) { ...@@ -473,8 +464,7 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey;
return generateAsySecret(globalECDHData, null, null); return generateAsySecret(globalECDHData, null, null);
}) })
.then((result) => { .then((result) => {
...@@ -487,9 +477,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) { ...@@ -487,9 +477,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return generateAsySecret(globalECDHData, globalRsaKeyPair.pubKey, null);
return generateAsySecret(globalECDHData, globalPubKey, null);
}) })
.then((result) => { .then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data)); console.warn("result data is " + uInt8ArrayToShowStr(result.data));
...@@ -501,9 +490,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) { ...@@ -501,9 +490,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return generateAsySecret(globalECDHData, null, globalRsaKeyPair.priKey);
return generateAsySecret(globalECDHData, null, globalPriKey);
}) })
.then((result) => { .then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data)); console.warn("result data is " + uInt8ArrayToShowStr(result.data));
...@@ -531,8 +519,7 @@ async function createAsyKeyGeneratorFail(asyAlgoName) { ...@@ -531,8 +519,7 @@ async function createAsyKeyGeneratorFail(asyAlgoName) {
async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoName, globalTextLen) { async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoName, globalTextLen) {
var globalCipherText; var globalCipherText;
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalText; var globalText;
var i; var i;
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE; var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
...@@ -554,12 +541,11 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa ...@@ -554,12 +541,11 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey;
return initCipher( return initCipher(
cipherGeneratorEncrypt, cipherGeneratorEncrypt,
encryptMode, encryptMode,
globalPubKey, globalRsaKeyPair.pubKey,
null null
); );
}) })
...@@ -576,7 +562,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa ...@@ -576,7 +562,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
return initCipher( return initCipher(
cipherGeneratorDecrypt, cipherGeneratorDecrypt,
decryptMode, decryptMode,
globalPriKey, globalRsaKeyPair.priKey,
null null
); );
}) })
...@@ -612,8 +598,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa ...@@ -612,8 +598,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoName, globalTextLen) { async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoName, globalTextLen) {
var globalSignBlob; var globalSignBlob;
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalText; var globalText;
var i; var i;
var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",n = t.length,s=""; var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",n = t.length,s="";
...@@ -633,9 +618,8 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa ...@@ -633,9 +618,8 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return initSign(signGenerator, globalRsaKeyPair.priKey);
return initSign(signGenerator, globalPriKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -649,7 +633,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa ...@@ -649,7 +633,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
expect(finalOutput != null).assertTrue(); expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput; globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data)); console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey); return initVerify(verifyGenerator, globalRsaKeyPair.pubKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -672,8 +656,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa ...@@ -672,8 +656,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) { async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
var globalCipherText; var globalCipherText;
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE; var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
var decryptMode = cryptoFramework.CryptoMode.DECRYPT_MODE; var decryptMode = cryptoFramework.CryptoMode.DECRYPT_MODE;
...@@ -688,12 +671,11 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) { ...@@ -688,12 +671,11 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey;
return initCipher( return initCipher(
cipherGeneratorEncrypt, cipherGeneratorEncrypt,
encryptMode, encryptMode,
globalPubKey, globalRsaKeyPair.pubKey,
null null
); );
}) })
...@@ -710,7 +692,7 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) { ...@@ -710,7 +692,7 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
return initCipher( return initCipher(
cipherGeneratorDecrypt, cipherGeneratorDecrypt,
decryptMode, decryptMode,
globalPriKey, globalRsaKeyPair.priKey,
null null
); );
}) })
......
...@@ -222,8 +222,7 @@ async function generateAsySecret(generator, priKey, pubKey) { ...@@ -222,8 +222,7 @@ async function generateAsySecret(generator, priKey, pubKey) {
async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
var globalCipherText; var globalCipherText;
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalText = "This is a cipher test"; var globalText = "This is a cipher test";
var input = { data: stringTouInt8Array(globalText) }; var input = { data: stringTouInt8Array(globalText) };
var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE; var encryptMode = cryptoFramework.CryptoMode.ENCRYPT_MODE;
...@@ -240,12 +239,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -240,12 +239,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey;
return initCipher( return initCipher(
cipherGeneratorEncrypt, cipherGeneratorEncrypt,
encryptMode, encryptMode,
globalPubKey, globalRsaKeyPair.pubKey,
null null
); );
}) })
...@@ -262,7 +260,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -262,7 +260,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
return initCipher( return initCipher(
cipherGeneratorDecrypt, cipherGeneratorDecrypt,
decryptMode, decryptMode,
globalPriKey, globalRsaKeyPair.priKey,
null null
); );
}) })
...@@ -297,8 +295,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) { ...@@ -297,8 +295,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
} }
async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalSignBlob; var globalSignBlob;
var globalText = "This is a sign test"; var globalText = "This is a sign test";
var input = { data: stringTouInt8Array(globalText) }; var input = { data: stringTouInt8Array(globalText) };
...@@ -314,9 +311,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { ...@@ -314,9 +311,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return initSign(signGenerator, globalRsaKeyPair.priKey);
return initSign(signGenerator, globalPriKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -330,7 +326,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { ...@@ -330,7 +326,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
expect(finalOutput != null).assertTrue(); expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput; globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data)); console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey); return initVerify(verifyGenerator, globalRsaKeyPair.pubKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -352,8 +348,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) { ...@@ -352,8 +348,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
} }
async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAlgoName, dataType) { async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAlgoName, dataType) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
var globalSignBlob; var globalSignBlob;
var globalText = "This is a sign test"; var globalText = "This is a sign test";
var input; var input;
...@@ -374,9 +369,8 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl ...@@ -374,9 +369,8 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return initSign(signGenerator, globalRsaKeyPair.priKey);
return initSign(signGenerator, globalPriKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -390,7 +384,7 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl ...@@ -390,7 +384,7 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl
expect(finalOutput != null).assertTrue(); expect(finalOutput != null).assertTrue();
globalSignBlob = finalOutput; globalSignBlob = finalOutput;
console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data)); console.log("signOutput: " + uInt8ArrayToShowStr(globalSignBlob.data));
return initVerify(verifyGenerator, globalPubKey); return initVerify(verifyGenerator, globalRsaKeyPair.pubKey);
}) })
.then((initData) => { .then((initData) => {
expect(initData === "init success").assertTrue(); expect(initData === "init success").assertTrue();
...@@ -465,8 +459,7 @@ async function convertKeyEncryptAndDecryptProcess(asyAlgoName) { ...@@ -465,8 +459,7 @@ async function convertKeyEncryptAndDecryptProcess(asyAlgoName) {
} }
async function keyAgreementProcess(ECDHAlgoName) { async function keyAgreementProcess(ECDHAlgoName) {
var globalPubKey; var globalRsaKeyPair;
var globalPriKey;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName); var rsaGenerator = createAsyKeyGenerator(ECDHAlgoName);
...@@ -477,9 +470,8 @@ async function keyAgreementProcess(ECDHAlgoName) { ...@@ -477,9 +470,8 @@ async function keyAgreementProcess(ECDHAlgoName) {
generateAsyKeyPair(rsaGenerator) generateAsyKeyPair(rsaGenerator)
.then((rsaKeyPair) => { .then((rsaKeyPair) => {
expect(rsaKeyPair != null).assertTrue(); expect(rsaKeyPair != null).assertTrue();
globalPubKey = rsaKeyPair.pubKey; globalRsaKeyPair = rsaKeyPair;
globalPriKey = rsaKeyPair.priKey; return generateAsySecret(globalECDHData, globalRsaKeyPair.priKey, globalRsaKeyPair.pubKey);
return generateAsySecret(globalECDHData, globalPriKey, globalPubKey);
}) })
.then((result) => { .then((result) => {
console.warn("result data is " + uInt8ArrayToShowStr(result.data)); console.warn("result data is " + uInt8ArrayToShowStr(result.data));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册