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

!9888 XTS新增HUKS对init finish阶段的长度和算法校验

Merge pull request !9888 from WXY123456/master
...@@ -65,7 +65,7 @@ static struct OH_Huks_Param g_agreeParams01Init001[] = { ...@@ -65,7 +65,7 @@ static struct OH_Huks_Param g_agreeParams01Init001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_AGREE .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
}, { }, {
.tag = OH_HUKS_TAG_KEY_SIZE, .tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_DH_KEY_SIZE_2048 .uint32Param = OH_HUKS_AES_KEY_SIZE_256
} }
}; };
static struct OH_Huks_Param g_agreeParams01Finish001[] = { static struct OH_Huks_Param g_agreeParams01Finish001[] = {
...@@ -107,7 +107,7 @@ static struct OH_Huks_Param g_agreeParams02Init001[] = { ...@@ -107,7 +107,7 @@ static struct OH_Huks_Param g_agreeParams02Init001[] = {
.uint32Param = OH_HUKS_KEY_PURPOSE_AGREE .uint32Param = OH_HUKS_KEY_PURPOSE_AGREE
}, { }, {
.tag = OH_HUKS_TAG_KEY_SIZE, .tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = OH_HUKS_DH_KEY_SIZE_2048 .uint32Param = OH_HUKS_AES_KEY_SIZE_256
} }
}; };
static struct OH_Huks_Param g_agreeParams02Finish001[] = { static struct OH_Huks_Param g_agreeParams02Finish001[] = {
......
...@@ -89,10 +89,10 @@ static struct OH_Huks_Param g_hkdfFinishParams001[] = { ...@@ -89,10 +89,10 @@ static struct OH_Huks_Param g_hkdfFinishParams001[] = {
} }
}, { }, {
.tag = OH_HUKS_TAG_ALGORITHM, .tag = OH_HUKS_TAG_ALGORITHM,
.uint32Param = OH_HUKS_ALG_HKDF .uint32Param = OH_HUKS_ALG_AES
}, { }, {
.tag = OH_HUKS_TAG_KEY_SIZE, .tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = DERIVE_KEY_SIZE_32 .uint32Param = 256
}, { }, {
.tag = OH_HUKS_TAG_PURPOSE, .tag = OH_HUKS_TAG_PURPOSE,
.uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE
......
...@@ -118,7 +118,7 @@ static struct OH_Huks_Param g_pbkdf2FinishParams001[] = { ...@@ -118,7 +118,7 @@ static struct OH_Huks_Param g_pbkdf2FinishParams001[] = {
.uint32Param = OH_HUKS_ALG_AES .uint32Param = OH_HUKS_ALG_AES
}, { }, {
.tag = OH_HUKS_TAG_KEY_SIZE, .tag = OH_HUKS_TAG_KEY_SIZE,
.uint32Param = DERIVE_KEY_SIZE_32 .uint32Param = 256
}, { }, {
.tag = OH_HUKS_TAG_PURPOSE, .tag = OH_HUKS_TAG_PURPOSE,
.uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE .uint32Param = OH_HUKS_KEY_PURPOSE_DERIVE
......
...@@ -234,7 +234,10 @@ async function publicAgreeFunc( ...@@ -234,7 +234,10 @@ async function publicAgreeFunc(
HuksOptions.properties.splice(5, 1); HuksOptions.properties.splice(5, 1);
} }
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); let HuksOptionsInit = JSON.parse(JSON.stringify(HuksOptions));
HuksOptionsInit.properties.splice(2,1,HuksOptionsFinish.properties[3])
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 1); await publicAgreeUpdateFunc(HuksOptions, 1);
await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName);
...@@ -245,7 +248,7 @@ async function publicAgreeFunc( ...@@ -245,7 +248,7 @@ async function publicAgreeFunc(
value: stringToUint8Array(srcKeyAliesSecond + 'final'), value: stringToUint8Array(srcKeyAliesSecond + 'final'),
}); });
await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 2); await publicAgreeUpdateFunc(HuksOptions, 2);
await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName);
......
...@@ -148,7 +148,10 @@ async function publicAgreeFunc( ...@@ -148,7 +148,10 @@ async function publicAgreeFunc(
HuksOptions.properties.splice(5, 1); HuksOptions.properties.splice(5, 1);
} }
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); let HuksOptionsInit = JSON.parse(JSON.stringify(HuksOptions));
HuksOptionsInit.properties.splice(2,1,HuksOptionsFinish.properties[3])
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 1); await publicAgreeUpdateFunc(HuksOptions, 1);
await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName);
...@@ -159,7 +162,7 @@ async function publicAgreeFunc( ...@@ -159,7 +162,7 @@ async function publicAgreeFunc(
value: stringToUint8Array(srcKeyAliesSecond + 'final'), value: stringToUint8Array(srcKeyAliesSecond + 'final'),
}); });
await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 2); await publicAgreeUpdateFunc(HuksOptions, 2);
await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName);
......
...@@ -51,10 +51,10 @@ function makehuksOptionsFinish(srcKeyAliesFirst){ ...@@ -51,10 +51,10 @@ function makehuksOptionsFinish(srcKeyAliesFirst){
function makehuksOptionsDerive(srcKeyAliesFirst){ function makehuksOptionsDerive(srcKeyAliesFirst){
let huksOptionsFinish = { let huksOptionsFinish = {
properties: new Array( properties: new Array(
HuksAgreeDH.HuksKeyALGORITHMAES, HuksAgreeDH.HuksKeyALGORITHMAES,
HuksAgreeDH.HuksKeySIZE256,
HuksAgreeDH.HuksKeyPurposeDERIVE, HuksAgreeDH.HuksKeyPurposeDERIVE,
HuksAgreeDH.HuksKeyDIGESTSHA256, HuksAgreeDH.HuksKeyDIGESTSHA256,
HuksAgreeDH.HuksKeySIZE256,
HuksAgreeDH.HuksKeyPADDINGNONE, HuksAgreeDH.HuksKeyPADDINGNONE,
HuksAgreeDH.HuksKeyBLOCKMODEECB, HuksAgreeDH.HuksKeyBLOCKMODEECB,
{ {
...@@ -73,9 +73,9 @@ function makehuksOptionsHmac(srcKeyAliesFirst){ ...@@ -73,9 +73,9 @@ function makehuksOptionsHmac(srcKeyAliesFirst){
let huksOptionsFinish = { let huksOptionsFinish = {
properties: new Array( properties: new Array(
HuksAgreeDH.HuksKeyALGORITHMHMAC, HuksAgreeDH.HuksKeyALGORITHMHMAC,
HuksAgreeDH.HuksKeySIZE256,
HuksAgreeDH.HuksKeyPurposeMAC, HuksAgreeDH.HuksKeyPurposeMAC,
HuksAgreeDH.HuksKeyDIGESTSHA256, HuksAgreeDH.HuksKeyDIGESTSHA256,
HuksAgreeDH.HuksKeySIZE256,
HuksAgreeDH.HuksKeyPADDINGNONE, HuksAgreeDH.HuksKeyPADDINGNONE,
HuksAgreeDH.HuksKeyBLOCKMODEECB, HuksAgreeDH.HuksKeyBLOCKMODEECB,
{ {
......
...@@ -272,6 +272,7 @@ async function publicAgreeFunc( ...@@ -272,6 +272,7 @@ async function publicAgreeFunc(
thirdInderfaceName thirdInderfaceName
) { ) {
try { try {
await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions);
await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions);
await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1);
...@@ -284,7 +285,10 @@ async function publicAgreeFunc( ...@@ -284,7 +285,10 @@ async function publicAgreeFunc(
HuksOptions.properties.splice(5, 1); HuksOptions.properties.splice(5, 1);
} }
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); let HuksOptionsInit = JSON.parse(JSON.stringify(HuksOptions));
HuksOptionsInit.properties.splice(2,1,HuksOptionsFinish.properties[3])
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 1); await publicAgreeUpdateFunc(HuksOptions, 1);
await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName);
...@@ -295,7 +299,7 @@ async function publicAgreeFunc( ...@@ -295,7 +299,7 @@ async function publicAgreeFunc(
value: stringToUint8Array(srcKeyAliesSecond + 'final'), value: stringToUint8Array(srcKeyAliesSecond + 'final'),
}); });
await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 2); await publicAgreeUpdateFunc(HuksOptions, 2);
await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName);
......
...@@ -166,6 +166,7 @@ async function publicAgreeFunc( ...@@ -166,6 +166,7 @@ async function publicAgreeFunc(
thirdInderfaceName thirdInderfaceName
) { ) {
try { try {
await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions); await publicAgreeGenFunc(srcKeyAliesFrist, HuksOptions);
await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeGenFunc(srcKeyAliesSecond, HuksOptions);
await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1); await publicAgreeExport1Func(srcKeyAliesFrist, HuksOptions, 1);
...@@ -178,7 +179,10 @@ async function publicAgreeFunc( ...@@ -178,7 +179,10 @@ async function publicAgreeFunc(
HuksOptions.properties.splice(5, 1); HuksOptions.properties.splice(5, 1);
} }
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptions); let HuksOptionsInit = JSON.parse(JSON.stringify(HuksOptions));
HuksOptionsInit.properties.splice(2,1,HuksOptionsFinish.properties[3])
await publicAgreeInitFunc(srcKeyAliesFrist, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 1); await publicAgreeUpdateFunc(HuksOptions, 1);
await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinish, thirdInderfaceName);
...@@ -189,7 +193,7 @@ async function publicAgreeFunc( ...@@ -189,7 +193,7 @@ async function publicAgreeFunc(
value: stringToUint8Array(srcKeyAliesSecond + 'final'), value: stringToUint8Array(srcKeyAliesSecond + 'final'),
}); });
await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptions); await publicAgreeInitFunc(srcKeyAliesSecond, HuksOptionsInit);
await publicAgreeUpdateFunc(HuksOptions, 2); await publicAgreeUpdateFunc(HuksOptions, 2);
await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName); await publicAgreeFinishAbortFunc(HuksOptionsFinishSecond, thirdInderfaceName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册