---
title: KdcTrustedRequest
description: "kdc_proxy代理统一接口，支持查询多种可信属性。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/tee/kdcl/kdcl_kfzn_026.html
sourcePath: /source/zh/kunpengcctrustzone/tee/kdcl/kdcl_kfzn_026.html
indexId: 249f0c0859ce6456d2f157019a23a6016c9550f1c6193ca904fd8f570875bf2157
---
# KdcTrustedRequest

kdc_proxy代理统一接口，支持查询多种可信属性。

#### 函数原型

```
uint32_t KdcTrustedRequest(
uint32_t requestType,
const char *input,
uint32_t inputLen,
char **output,
uint32_t *outputLen
);
```


#### 参数说明

| 参数 | 参数类型 | 是否必选 | 描述 |
| --- | --- | --- | --- |
| requestType | uint32\_t | 是 | 查询类型，指定请求的可信属性类型 |
| input | const char\* | 是 | 输入参数，JSON格式字符串 |
| inputLen | uint32\_t | 是 | 输入参数长度 |
| output | char\*\* | 是（输出） | 输出参数，JSON格式字符串，需要调用KdcFreePtr释放 |
| outputLen | uint32\_t\* | 是（输出） | 输出参数长度 |


#### 返回值说明

| 返回值 | 含义 |
| --- | --- |
| 0 | 成功 |
| 非0 | 失败，返回错误码 |


#### RequestType类型定义

| 值 | 含义 |
| --- | --- |
| 0x0010 | 获取可信环境token |
| 0x0011 | 验证可信环境token |
| 0x0021 | 生成CSR |
| 0x0022 | 数据签名 |
| 0x0030 | 查询可信时间状态 |
| 0x0032 | 获取日志公钥 |
| 0x0033 | 日志数据签名 |
| 0x0034 | 上报文件访问信息 |
| 0x0035 | 查询文件访问次数 |


具体业务input和output格式参考内部业务restful接口的data对象。

- 在可信日志签名验签场景，需先获取日志公钥（0x0032），再请求日志数据签名（0x0033）。
- 在可信身份认证场景，需先生成CSR（0x0021），再请求数据签名（0x0022）。


#### input格式示例（查询文件访问次数）

```
{
"filename": "file1"
}
```


#### output格式示例

```
{
"times": 5
}
```


#### 使用示例

```
const char *input = "{\"filename\":\"file1\"}";
char *output = NULL;
uint32_t outputLen = 0;
uint32_t ret = KdcTrustedRequest(0x0035, input, strlen(input), &output, &outputLen);
if (ret == 0){
printf("Result: %s\n", output);
KdcFreePtr(output);
}
```
