创建主密钥
<p class="shortdesc"></p>
<section class="section" id="CreateCMK__section_y35_dx3_mlb"><h2 class="doc-tairway">创建密钥:CreateCmk</h2>
<p class="p"><strong class="ph b">描述</strong></p>
<p class="p">创建用户主密钥(Customer Master Key,
CMK)。主密钥可以直接用来对小包数据进行加密(一般小于4KB),同时也用来产生数据密钥(DataKey,DK),该数据密钥可用来对本地大量磁盘数据进行加解密操作。</p>
<p class="p"><strong class="ph b">请求参数</strong></p>
<table class="table" id="CreateCMK__table_yp3_fx3_mlb"><caption></caption><colgroup><col><col><col><col></colgroup><thead class="thead">
<tr class="row">
<th class="entry" id="CreateCMK__table_yp3_fx3_mlb__entry__1">
<p class="p">名称</p>
</th>
<th class="entry" id="CreateCMK__table_yp3_fx3_mlb__entry__2">
<p class="p">类型</p>
</th>
<th class="entry" id="CreateCMK__table_yp3_fx3_mlb__entry__3">
<p class="p">是否必需</p>
</th>
<th class="entry" id="CreateCMK__table_yp3_fx3_mlb__entry__4">
<p class="p">描述</p>
</th>
</tr>
</thead><tbody class="tbody">
<tr class="row">
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__1 ">
<p class="p">description</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__3 ">
<p class="p">否</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__4 ">
<p class="p">密钥的描述</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__1 ">
<p class="p">keyUsage</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__2 ">
<p class="p">Integer</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__3 ">
<p class="p">是</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__4 ">
<p class="p">密钥用途。目前该版本仅支持值为0,默认传0。注:(0:"ENCRYPT/DECRYPT")</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__1 ">
<p class="p">alias</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__3 ">
<p class="p">是</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__4 ">
<p class="p">密钥名称。注:唯一,不能重复</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__1 ">
<p class="p">algorithm</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__3 ">
<p class="p">是</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__4 ">
<p class="p">加密算法。默认RSA(国际标准支持:RSA,国密标准支持SM2)</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__1 ">
<p class="p">origin</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__2 ">
<p class="p">Integer</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__3 ">
<p class="p">是</p>
</td>
<td class="entry" headers="CreateCMK__table_yp3_fx3_mlb__entry__4 ">
<p class="p">密钥材料来源。支持平安云KMS平台产生、外部导入两种来源。注:(0: "平台产生"),(1:"外部导入")</p>
</td>
</tr>
</tbody></table>
<p class="p"><strong class="ph b">返回参数</strong></p>
<table class="table" id="CreateCMK__table_zp3_fx3_mlb"><caption></caption><colgroup><col><col><col></colgroup><thead class="thead">
<tr class="row">
<th class="entry" id="CreateCMK__table_zp3_fx3_mlb__entry__1">
<p class="p">名称</p>
</th>
<th class="entry" id="CreateCMK__table_zp3_fx3_mlb__entry__2">
<p class="p">类型</p>
</th>
<th class="entry" id="CreateCMK__table_zp3_fx3_mlb__entry__3">
<p class="p">描述</p>
</th>
</tr>
</thead><tbody class="tbody">
<tr class="row">
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__1 ">
<p class="p">code</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__3 ">
<p class="p">返回码,成功返回"SUCCESS"</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__1 ">
<p class="p">keyMetadata</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__2 ">
<p class="p">KeyMetadata</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__3 ">
<p class="p">返回密钥信息</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__1 ">
<p class="p">requestId</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_zp3_fx3_mlb__entry__3 ">
<p class="p">当前请求Id</p>
</td>
</tr>
</tbody></table>
<p class="p"><strong class="ph b">KeyMetadata</strong></p>
<table class="table" id="CreateCMK__table_aq3_fx3_mlb"><caption></caption><colgroup><col><col><col></colgroup><thead class="thead">
<tr class="row">
<th class="entry" id="CreateCMK__table_aq3_fx3_mlb__entry__1">
<p class="p">名称</p>
</th>
<th class="entry" id="CreateCMK__table_aq3_fx3_mlb__entry__2">
<p class="p">类型</p>
</th>
<th class="entry" id="CreateCMK__table_aq3_fx3_mlb__entry__3">
<p class="p">描述</p>
</th>
</tr>
</thead><tbody class="tbody">
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">keyId</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥的全局唯一标识符</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">alias</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥名称</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">keyUsage</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥用途,加密/解密</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">description</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥描述</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">creationDate</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥创建时间(yyyy-MM-dd HH:mm:ss)</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">deleteDate</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥预计被删除时间(yyyy-MM-dd
HH:mm:ss)当该值为空时,表示密钥不会被删除。只有当密钥状态keyState是待删除PendingDeletion时,会返回这个参数</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">ownerId</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥拥有者</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">keyState</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥状态。0启用;1禁用;2待删除。</p>
</td>
</tr>
<tr class="row">
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__1 ">
<p class="p">origin</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__2 ">
<p class="p">String</p>
</td>
<td class="entry" headers="CreateCMK__table_aq3_fx3_mlb__entry__3 ">
<p class="p">密钥材料来源。</p>
</td>
</tr>
</tbody></table>
<p class="p"><strong class="ph b">请求示例</strong></p>
<pre class="pre codeblock"><code>https:// kms-cn-shanghai.yun.pingan.com/?action=CreateCmk
&keyUsage=0
&origin=<origin>
&alias=<your key alias>
&algorithm=<algorithm>
&description=<your key description>
&<公共请求参数></code></pre>
<p class="p"><strong class="ph b">返回示例</strong></p>
<pre class="pre codeblock"><code>{
"code":"SUCCESS",
"keyMetadata":{
"keyUsage":"ENCRYPT_DECRYPT",
"origin":"平安云产生",
"keyState":"ENABLE|已启用",
"keyId":"your key id",
"description":"key description example",
"alias":"your key alias",
"ownerId":"123456",
"creationDate":"2018-12-04 15:07:54"
}
"requestId":"53912b71-3435-409e-ad05-1882ced04f1f"
}</code></pre>
</section>
提交成功!非常感谢您的反馈,我们会继续努力做到更好!