Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e9d843eb
D
Docs
项目概览
OpenHarmony
/
Docs
12 个月 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e9d843eb
编写于
8月 17, 2022
作者:
scrawman
提交者:
Gitee
8月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/device-dev/subsystems/subsys-security-huks-guide.md.
Signed-off-by:
zqr2001
<
1805768383@qq.com
>
上级
c17484ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
59 deletion
+59
-59
zh-cn/device-dev/subsystems/subsys-security-huks-guide.md
zh-cn/device-dev/subsystems/subsys-security-huks-guide.md
+59
-59
未找到文件。
zh-cn/device-dev/subsystems/subsys-security-huks-guide.md
浏览文件 @
e9d843eb
...
...
@@ -720,68 +720,68 @@ return ret;
3.
结束密钥操作并取回结果,销毁句柄。
```
c
//三段式Finish接口
int32_t
HksCoreFinish
(
const
struct
HksBlob
*
handle
,
const
struct
HksParamSet
*
paramSet
,
const
struct
HksBlob
*
inData
,
//三段式Finish接口
int32_t
HksCoreFinish
(
const
struct
HksBlob
*
handle
,
const
struct
HksParamSet
*
paramSet
,
const
struct
HksBlob
*
inData
,
struct
HksBlob
*
outData
)
{
HKS_LOG_D
(
"HksCoreFinish in Core start"
);
uint32_t
pur
=
0
;
uint32_t
alg
=
0
;
//检查参数
if
(
handle
==
NULL
||
paramSet
==
NULL
||
inData
==
NULL
)
{
HKS_LOG_E
(
"the pointer param entered is invalid"
);
return
HKS_FAILURE
;
}
{
HKS_LOG_D
(
"HksCoreFinish in Core start"
);
uint32_t
pur
=
0
;
uint32_t
alg
=
0
;
//检查参数
if
(
handle
==
NULL
||
paramSet
==
NULL
||
inData
==
NULL
)
{
HKS_LOG_E
(
"the pointer param entered is invalid"
);
return
HKS_FAILURE
;
}
uint64_t
sessionId
;
struct
HuksKeyNode
*
keyNode
=
NULL
;
//根据handle获取本次三段式操作需要的上下文
int32_t
ret
=
GetParamsForUpdateAndFinish
(
handle
,
&
sessionId
,
&
keyNode
,
&
pur
,
&
alg
);
if
(
ret
!=
HKS_SUCCESS
)
{
HKS_LOG_E
(
"GetParamsForCoreUpdate failed"
);
return
ret
;
}
//校验密钥参数
ret
=
HksCoreSecureAccessVerifyParams
(
keyNode
,
paramSet
);
if
(
ret
!=
HKS_SUCCESS
)
{
HksDeleteKeyNode
(
sessionId
);
HKS_LOG_E
(
"HksCoreFinish secure access verify failed"
);
return
ret
;
}
//调用对应的算法库密钥处理函数
uint32_t
i
;
uint32_t
size
=
HKS_ARRAY_SIZE
(
g_hksCoreFinishHandler
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
if
(
g_hksCoreFinishHandler
[
i
].
pur
==
pur
)
{
uint32_t
outDataBufferSize
=
(
outData
==
NULL
)
?
0
:
outData
->
size
;
struct
HksBlob
appendInData
=
{
0
,
NULL
};
ret
=
HksCoreAppendAuthInfoBeforeFinish
(
keyNode
,
pur
,
paramSet
,
inData
,
&
appendInData
);
if
(
ret
!=
HKS_SUCCESS
)
{
HKS_LOG_E
(
"before finish: append auth info failed"
);
break
;
}
ret
=
g_hksCoreFinishHandler
[
i
].
handler
(
keyNode
,
paramSet
,
appendInData
.
data
==
NULL
?
inData
:
&
appendInData
,
outData
,
alg
);
if
(
appendInData
.
data
!=
NULL
)
{
HKS_FREE_BLOB
(
appendInData
);
}
if
(
ret
!=
HKS_SUCCESS
)
{
break
;
uint64_t
sessionId
;
struct
HuksKeyNode
*
keyNode
=
NULL
;
//根据handle获取本次三段式操作需要的上下文
int32_t
ret
=
GetParamsForUpdateAndFinish
(
handle
,
&
sessionId
,
&
keyNode
,
&
pur
,
&
alg
);
if
(
ret
!=
HKS_SUCCESS
)
{
HKS_LOG_E
(
"GetParamsForCoreUpdate failed"
);
return
ret
;
}
//校验密钥参数
ret
=
HksCoreSecureAccessVerifyParams
(
keyNode
,
paramSet
);
if
(
ret
!=
HKS_SUCCESS
)
{
HksDeleteKeyNode
(
sessionId
);
HKS_LOG_E
(
"HksCoreFinish secure access verify failed"
);
return
ret
;
}
//调用对应的算法库密钥处理函数
uint32_t
i
;
uint32_t
size
=
HKS_ARRAY_SIZE
(
g_hksCoreFinishHandler
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
if
(
g_hksCoreFinishHandler
[
i
].
pur
==
pur
)
{
uint32_t
outDataBufferSize
=
(
outData
==
NULL
)
?
0
:
outData
->
size
;
struct
HksBlob
appendInData
=
{
0
,
NULL
};
ret
=
HksCoreAppendAuthInfoBeforeFinish
(
keyNode
,
pur
,
paramSet
,
inData
,
&
appendInData
);
if
(
ret
!=
HKS_SUCCESS
)
{
HKS_LOG_E
(
"before finish: append auth info failed"
);
break
;
}
ret
=
g_hksCoreFinishHandler
[
i
].
handler
(
keyNode
,
paramSet
,
appendInData
.
data
==
NULL
?
inData
:
&
appendInData
,
outData
,
alg
);
if
(
appendInData
.
data
!=
NULL
)
{
HKS_FREE_BLOB
(
appendInData
);
}
if
(
ret
!=
HKS_SUCCESS
)
{
break
;
}
//添加密钥操作结束标签
ret
=
HksCoreAppendAuthInfoAfterFinish
(
keyNode
,
pur
,
paramSet
,
outDataBufferSize
,
outData
);
break
;
}
//添加密钥操作结束标签
ret
=
HksCoreAppendAuthInfoAfterFinish
(
keyNode
,
pur
,
paramSet
,
outDataBufferSize
,
outData
);
break
;
}
}
if
(
i
==
size
)
{
HKS_LOG_E
(
"don't found purpose, pur : %d"
,
pur
);
ret
=
HKS_FAILURE
;
}
//删除对应的session
HksDeleteKeyNode
(
sessionId
);
HKS_LOG_D
(
"HksCoreFinish in Core end"
);
return
ret
;
}
}
if
(
i
==
size
)
{
HKS_LOG_E
(
"don't found purpose, pur : %d"
,
pur
);
ret
=
HKS_FAILURE
;
}
//删除对应的session
HksDeleteKeyNode
(
sessionId
);
HKS_LOG_D
(
"HksCoreFinish in Core end"
);
return
ret
;
}
```
### 调测验证
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录