Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
59582868
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
59582868
编写于
12月 22, 2022
作者:
Q
qiaozzzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
e8ab3c95
from
https://gitee.com/qiaozzzh/xts_acts/pulls/6985
加解密测试套优化 Signed-off-by:
N
qiaozzzh
<
qiaozhang@huawei.com
>
上级
6c2c65cb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
73 deletion
+47
-73
security/cryptoFramework/js_api_test_one/src/main/js/test/utils/asymmetric/publicAsymmetricCallback.js
...main/js/test/utils/asymmetric/publicAsymmetricCallback.js
+32
-50
security/cryptoFramework/js_api_test_one/src/main/js/test/utils/asymmetric/publicAsymmetricPromise.js
.../main/js/test/utils/asymmetric/publicAsymmetricPromise.js
+15
-23
未找到文件。
security/cryptoFramework/js_api_test_one/src/main/js/test/utils/asymmetric/publicAsymmetricCallback.js
浏览文件 @
59582868
...
...
@@ -217,8 +217,7 @@ async function generateAsySecret(generator, priKey, pubKey) {
async
function
encryptAndDecryptNormalProcess
(
asyAlgoName
,
cipherAlgoName
)
{
var
globalCipherText
;
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalText
=
"
This is a cipher test
"
;
var
input
=
{
data
:
stringTouInt8Array
(
globalText
)
};
var
encryptMode
=
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
;
...
...
@@ -235,12 +234,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
globalRsaKeyPair
=
rsaKeyPair
;
return
initCipher
(
cipherGeneratorEncrypt
,
encryptMode
,
global
P
ubKey
,
global
RsaKeyPair
.
p
ubKey
,
null
);
})
...
...
@@ -257,7 +255,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
return
initCipher
(
cipherGeneratorDecrypt
,
decryptMode
,
global
P
riKey
,
global
RsaKeyPair
.
p
riKey
,
null
);
})
...
...
@@ -292,8 +290,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
}
async
function
signAndVerifyNormalProcess
(
asyAlgoName
,
signVerifyAlgoName
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalSignBlob
;
var
globalText
=
"
This is a sign test
"
;
var
input
=
{
data
:
stringTouInt8Array
(
globalText
)
};
...
...
@@ -309,9 +306,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
initSign
(
signGenerator
,
globalPriKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
initSign
(
signGenerator
,
globalRsaKeyPair
.
priKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -325,7 +321,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
expect
(
finalOutput
!=
null
).
assertTrue
();
globalSignBlob
=
finalOutput
;
console
.
log
(
"
signOutput:
"
+
uInt8ArrayToShowStr
(
globalSignBlob
.
data
));
return
initVerify
(
verifyGenerator
,
global
P
ubKey
);
return
initVerify
(
verifyGenerator
,
global
RsaKeyPair
.
p
ubKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -403,8 +399,7 @@ async function createAsyKeyAgreementFail(ECDHAlgoName) {
}
async
function
keyAgreementProcess
(
ECDHAlgoName
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
return
new
Promise
((
resolve
,
reject
)
=>
{
var
rsaGenerator
=
createAsyKeyGenerator
(
ECDHAlgoName
);
...
...
@@ -415,9 +410,8 @@ async function keyAgreementProcess(ECDHAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
generateAsySecret
(
globalECDHData
,
globalPriKey
,
globalPubKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
globalRsaKeyPair
.
priKey
,
globalRsaKeyPair
.
pubKey
);
})
.
then
((
result
)
=>
{
console
.
warn
(
"
result data is
"
+
uInt8ArrayToShowStr
(
result
.
data
));
...
...
@@ -432,8 +426,7 @@ async function keyAgreementProcess(ECDHAlgoName) {
}
async
function
keyAgreementProcessFail
(
ECDHAlgoName
,
ECDHAlgoName1
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
return
new
Promise
((
resolve
,
reject
)
=>
{
var
rsaGenerator
=
createAsyKeyGenerator
(
ECDHAlgoName
);
...
...
@@ -444,9 +437,8 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
generateAsySecret
(
globalECDHData
,
globalPriKey
,
globalPubKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
globalRsaKeyPair
.
priKey
,
globalRsaKeyPair
.
pubKey
);
})
.
then
((
result
)
=>
{
console
.
warn
(
"
result data is
"
+
uInt8ArrayToShowStr
(
result
.
data
));
...
...
@@ -461,8 +453,7 @@ async function keyAgreementProcessFail(ECDHAlgoName, ECDHAlgoName1) {
}
async
function
keyAgreementProcessParameterException
(
ECDHAlgoName
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
return
new
Promise
((
resolve
,
reject
)
=>
{
var
rsaGenerator
=
createAsyKeyGenerator
(
ECDHAlgoName
);
...
...
@@ -473,8 +464,7 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
null
,
null
);
})
.
then
((
result
)
=>
{
...
...
@@ -487,9 +477,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
generateAsySecret
(
globalECDHData
,
globalPubKey
,
null
);
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
globalRsaKeyPair
.
pubKey
,
null
);
})
.
then
((
result
)
=>
{
console
.
warn
(
"
result data is
"
+
uInt8ArrayToShowStr
(
result
.
data
));
...
...
@@ -501,9 +490,8 @@ async function keyAgreementProcessParameterException(ECDHAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
generateAsySecret
(
globalECDHData
,
null
,
globalPriKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
null
,
globalRsaKeyPair
.
priKey
);
})
.
then
((
result
)
=>
{
console
.
warn
(
"
result data is
"
+
uInt8ArrayToShowStr
(
result
.
data
));
...
...
@@ -531,8 +519,7 @@ async function createAsyKeyGeneratorFail(asyAlgoName) {
async
function
encryptAndDecryptNormalProcessSuperdata
(
asyAlgoName
,
cipherAlgoName
,
globalTextLen
)
{
var
globalCipherText
;
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalText
;
var
i
;
var
encryptMode
=
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
;
...
...
@@ -554,12 +541,11 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
globalRsaKeyPair
=
rsaKeyPair
;
return
initCipher
(
cipherGeneratorEncrypt
,
encryptMode
,
global
P
ubKey
,
global
RsaKeyPair
.
p
ubKey
,
null
);
})
...
...
@@ -576,7 +562,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
return
initCipher
(
cipherGeneratorDecrypt
,
decryptMode
,
global
P
riKey
,
global
RsaKeyPair
.
p
riKey
,
null
);
})
...
...
@@ -612,8 +598,7 @@ async function encryptAndDecryptNormalProcessSuperdata(asyAlgoName, cipherAlgoNa
async
function
signAndVerifyNormalProcessSuperdata
(
asyAlgoName
,
signVerifyAlgoName
,
globalTextLen
)
{
var
globalSignBlob
;
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalText
;
var
i
;
var
t
=
"
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz
"
,
n
=
t
.
length
,
s
=
""
;
...
...
@@ -633,9 +618,8 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
initSign
(
signGenerator
,
globalPriKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
initSign
(
signGenerator
,
globalRsaKeyPair
.
priKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -649,7 +633,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
expect
(
finalOutput
!=
null
).
assertTrue
();
globalSignBlob
=
finalOutput
;
console
.
log
(
"
signOutput:
"
+
uInt8ArrayToShowStr
(
globalSignBlob
.
data
));
return
initVerify
(
verifyGenerator
,
global
P
ubKey
);
return
initVerify
(
verifyGenerator
,
global
RsaKeyPair
.
p
ubKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -672,8 +656,7 @@ async function signAndVerifyNormalProcessSuperdata(asyAlgoName, signVerifyAlgoNa
async
function
encryptAndDecryptNormalProcessNull
(
asyAlgoName
,
cipherAlgoName
)
{
var
globalCipherText
;
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
encryptMode
=
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
;
var
decryptMode
=
cryptoFramework
.
CryptoMode
.
DECRYPT_MODE
;
...
...
@@ -688,12 +671,11 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
globalRsaKeyPair
=
rsaKeyPair
;
return
initCipher
(
cipherGeneratorEncrypt
,
encryptMode
,
global
P
ubKey
,
global
RsaKeyPair
.
p
ubKey
,
null
);
})
...
...
@@ -710,7 +692,7 @@ async function encryptAndDecryptNormalProcessNull(asyAlgoName, cipherAlgoName) {
return
initCipher
(
cipherGeneratorDecrypt
,
decryptMode
,
global
P
riKey
,
global
RsaKeyPair
.
p
riKey
,
null
);
})
...
...
security/cryptoFramework/js_api_test_one/src/main/js/test/utils/asymmetric/publicAsymmetricPromise.js
浏览文件 @
59582868
...
...
@@ -222,8 +222,7 @@ async function generateAsySecret(generator, priKey, pubKey) {
async
function
encryptAndDecryptNormalProcess
(
asyAlgoName
,
cipherAlgoName
)
{
var
globalCipherText
;
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalText
=
"
This is a cipher test
"
;
var
input
=
{
data
:
stringTouInt8Array
(
globalText
)
};
var
encryptMode
=
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
;
...
...
@@ -240,12 +239,11 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
globalRsaKeyPair
=
rsaKeyPair
;
return
initCipher
(
cipherGeneratorEncrypt
,
encryptMode
,
global
P
ubKey
,
global
RsaKeyPair
.
p
ubKey
,
null
);
})
...
...
@@ -262,7 +260,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
return
initCipher
(
cipherGeneratorDecrypt
,
decryptMode
,
global
P
riKey
,
global
RsaKeyPair
.
p
riKey
,
null
);
})
...
...
@@ -297,8 +295,7 @@ async function encryptAndDecryptNormalProcess(asyAlgoName, cipherAlgoName) {
}
async
function
signAndVerifyNormalProcess
(
asyAlgoName
,
signVerifyAlgoName
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalSignBlob
;
var
globalText
=
"
This is a sign test
"
;
var
input
=
{
data
:
stringTouInt8Array
(
globalText
)
};
...
...
@@ -314,9 +311,8 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
initSign
(
signGenerator
,
globalPriKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
initSign
(
signGenerator
,
globalRsaKeyPair
.
priKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -330,7 +326,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
expect
(
finalOutput
!=
null
).
assertTrue
();
globalSignBlob
=
finalOutput
;
console
.
log
(
"
signOutput:
"
+
uInt8ArrayToShowStr
(
globalSignBlob
.
data
));
return
initVerify
(
verifyGenerator
,
global
P
ubKey
);
return
initVerify
(
verifyGenerator
,
global
RsaKeyPair
.
p
ubKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -352,8 +348,7 @@ async function signAndVerifyNormalProcess(asyAlgoName, signVerifyAlgoName) {
}
async
function
signAndVerifyNormalProcessDataException
(
asyAlgoName
,
signVerifyAlgoName
,
dataType
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
var
globalSignBlob
;
var
globalText
=
"
This is a sign test
"
;
var
input
;
...
...
@@ -374,9 +369,8 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
initSign
(
signGenerator
,
globalPriKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
initSign
(
signGenerator
,
globalRsaKeyPair
.
priKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -390,7 +384,7 @@ async function signAndVerifyNormalProcessDataException(asyAlgoName, signVerifyAl
expect
(
finalOutput
!=
null
).
assertTrue
();
globalSignBlob
=
finalOutput
;
console
.
log
(
"
signOutput:
"
+
uInt8ArrayToShowStr
(
globalSignBlob
.
data
));
return
initVerify
(
verifyGenerator
,
global
P
ubKey
);
return
initVerify
(
verifyGenerator
,
global
RsaKeyPair
.
p
ubKey
);
})
.
then
((
initData
)
=>
{
expect
(
initData
===
"
init success
"
).
assertTrue
();
...
...
@@ -465,8 +459,7 @@ async function convertKeyEncryptAndDecryptProcess(asyAlgoName) {
}
async
function
keyAgreementProcess
(
ECDHAlgoName
)
{
var
globalPubKey
;
var
globalPriKey
;
var
globalRsaKeyPair
;
return
new
Promise
((
resolve
,
reject
)
=>
{
var
rsaGenerator
=
createAsyKeyGenerator
(
ECDHAlgoName
);
...
...
@@ -477,9 +470,8 @@ async function keyAgreementProcess(ECDHAlgoName) {
generateAsyKeyPair
(
rsaGenerator
)
.
then
((
rsaKeyPair
)
=>
{
expect
(
rsaKeyPair
!=
null
).
assertTrue
();
globalPubKey
=
rsaKeyPair
.
pubKey
;
globalPriKey
=
rsaKeyPair
.
priKey
;
return
generateAsySecret
(
globalECDHData
,
globalPriKey
,
globalPubKey
);
globalRsaKeyPair
=
rsaKeyPair
;
return
generateAsySecret
(
globalECDHData
,
globalRsaKeyPair
.
priKey
,
globalRsaKeyPair
.
pubKey
);
})
.
then
((
result
)
=>
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录