doc-exports/docs/kms/api-ref/kms_02_0020.html
Li, Qiao dfe65b9551 KMS API 20230817 version.
Reviewed-by: Belejkanic, Lukas <lukas.belejkanic@t-systems.com>
Co-authored-by: Li, Qiao <qiaoli@huawei.com>
Co-committed-by: Li, Qiao <qiaoli@huawei.com>
2024-04-02 13:42:22 +00:00

178 lines
17 KiB
HTML

<a name="kms_02_0020"></a><a name="kms_02_0020"></a>
<h1 class="topictitle1">Creating a DEK</h1>
<div id="body1474684560499"><div class="section" id="kms_02_0020__en-us_topic_0112992330_s1731a14fb0144c79bf0fa90c694f34f7"><h4 class="sectiontitle">Function</h4><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0020091565_p23115188">This API allows you to create a DEK. A returned result includes the plaintext and the ciphertext of a DEK.</p>
<div class="note" id="kms_02_0020__en-us_topic_0112992330_note127157632918"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="kms_02_0020__en-us_topic_0112992330_p571614611294">By default, the performance threshold for creating DEKs is 1000 TPS per customer. To apply for higher performance, submit a service ticket.</p>
</div></div>
</div>
<div class="section" id="kms_02_0020__en-us_topic_0112992330_se70c3e5518a04f60b06032524dddfef4"><h4 class="sectiontitle">URI</h4><ul id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0020091565_ul60390938"><li id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0020091565_li6647531">URI format<p id="kms_02_0020__en-us_topic_0112992330_p138073181080"><a name="kms_02_0020__en-us_topic_0112992330_en-us_topic_0020091565_li6647531"></a><a name="en-us_topic_0112992330_en-us_topic_0020091565_li6647531"></a>POST /v1.0/{project_id}/kms/create-datakey</p>
</li><li id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0020091565_li14211994">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0020__en-us_topic_0112992330_t982da1e0196d4ec1a28d1fbff2cc8191" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="kms_02_0020__en-us_topic_0112992330_r6e963322c1e740d181726d2f0e91df5a"><th align="left" class="cellrowborder" valign="top" width="22.737726227377262%" id="mcps1.3.2.2.2.1.2.5.1.1"><p id="kms_02_0020__en-us_topic_0112992330_a3b5bbe5a7f644fd3a74cecbfb3f7ed60">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.11798820117988%" id="mcps1.3.2.2.2.1.2.5.1.2"><p id="kms_02_0020__en-us_topic_0112992330_ad98d2f62bd064b4e96ea922645197c24">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.91830816918308%" id="mcps1.3.2.2.2.1.2.5.1.3"><p id="kms_02_0020__en-us_topic_0112992330_a3becf0b3aec9468984c2efc8d5abbea5">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40.22597740225977%" id="mcps1.3.2.2.2.1.2.5.1.4"><p id="kms_02_0020__en-us_topic_0112992330_a6bb6f1fe56a2454982832e8d56d354d8">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0020__en-us_topic_0112992330_r69bf37b65d3f446eab7b3f4d1b2fcec0"><td class="cellrowborder" valign="top" width="22.737726227377262%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_ae42d73592f58424ea93a11e52d2478dd">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="20.11798820117988%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_a56440c0f0ae34ba3b8033d1247673984">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_a1a4a71c11a4a45a58d0de2fbe009e9d9">String</p>
</td>
<td class="cellrowborder" valign="top" width="40.22597740225977%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_a1314869d2dc147b38461e037d622f7b4">Project ID</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="kms_02_0020__en-us_topic_0112992330_seb7b7901701247fab30a59b76f1c7f93"><h4 class="sectiontitle">Requests</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0020__en-us_topic_0112992330_table46221022101230" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request parameters</caption><thead align="left"><tr id="kms_02_0020__en-us_topic_0112992330_row9315574101230"><th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.3.2.2.5.1.1"><p id="kms_02_0020__en-us_topic_0112992330_p16364058101230">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16%" id="mcps1.3.3.2.2.5.1.2"><p id="kms_02_0020__en-us_topic_0112992330_p57514295101230"><strong id="kms_02_0020__en-us_topic_0112992330_b842352706183936">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.3.2.2.5.1.3"><p id="kms_02_0020__en-us_topic_0112992330_p50420322101230"><strong id="kms_02_0020__en-us_topic_0112992330_b842352706183933">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.2.2.5.1.4"><p id="kms_02_0020__en-us_topic_0112992330_p28146304101230">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0020__en-us_topic_0112992330_row57603225101653"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p16662451112314">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p2004950112314">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p7481292112314">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p28183289112314">36-byte ID of a CMK that matches the regular expression <span class="parmvalue" id="kms_02_0020__en-us_topic_0112992330_parmvalue1797768134611"><b>^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$</b></span> Example: 0d0466b0-e727-4d9c-b35d-f84bb474a37f</p>
</td>
</tr>
<tr id="kms_02_0020__en-us_topic_0112992330_row5309884015325"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p529241015328">encryption_context</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p2822056515328">No</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p2603204115328">Object</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p1658175312419">Key-value pairs with a maximum length of 8192 characters. This parameter is used to record resource context information, excluding sensitive information, to ensure data integrity.</p>
<p id="kms_02_0020__en-us_topic_0112992330_p10713871141">If this parameter is specified during encryption, it is also required for decryption.</p>
<p id="kms_02_0020__en-us_topic_0112992330_p416438915328">Example: {"<strong id="kms_02_0020__en-us_topic_0112992330_b12744192710130">Key1</strong>":"<strong id="kms_02_0020__en-us_topic_0112992330_b77441427181310">Value1</strong>","<strong id="kms_02_0020__en-us_topic_0112992330_b674416275134">Key2</strong>":"<strong id="kms_02_0020__en-us_topic_0112992330_b207441927121311">Value2</strong>"}</p>
</td>
</tr>
<tr id="kms_02_0020__en-us_topic_0112992330_row2638193101722"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p32137860112326">datakey_length</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p1517917412382">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p53029852112326">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p19885746392">Number of bits of a key. The value is <strong id="kms_02_0020__en-us_topic_0112992330_b10480199183519">512</strong>.</p>
</td>
</tr>
<tr id="kms_02_0020__en-us_topic_0112992330_row35142504101726"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p269135101746">sequence</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p20967256101746">No</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p21799971101746">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p12977434172135">36-byte serial number of a request message</p>
<p id="kms_02_0020__en-us_topic_0112992330_p20626198101746">Example: 919c82d4-8046-4722-9094-35c3c6524cff</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="kms_02_0020__en-us_topic_0112992330_sfadd53a5f4714e8f87811818d62d0296"><h4 class="sectiontitle">Responses</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0020__en-us_topic_0112992330_t98d238e10953421e84a073707024c329" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Response parameters</caption><thead align="left"><tr id="kms_02_0020__en-us_topic_0112992330_r144a2c52c5054c6d9243eb2ef3875a21"><th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.4.2.2.5.1.1"><p id="kms_02_0020__en-us_topic_0112992330_a9156e0b03f054d4e8547e0787f88a51b">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16%" id="mcps1.3.4.2.2.5.1.2"><p id="kms_02_0020__en-us_topic_0112992330_a1851157c81e14d7f82db752a5737195a"><strong id="kms_02_0020__en-us_topic_0112992330_b842352706184023">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.4.2.2.5.1.3"><p id="kms_02_0020__en-us_topic_0112992330_a39360acf5daf4c01a1ebddeff5d68a1c"><strong id="kms_02_0020__en-us_topic_0112992330_b842352706184020">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.2.2.5.1.4"><p id="kms_02_0020__en-us_topic_0112992330_a0097000016b14857972b7929bcaaa038">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0020__en-us_topic_0112992330_r3c4af7b36e9240d197ab56255e37b83c"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p43705601102713">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.4.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p63384753102713">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p50492797102713">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p33891398102713">CMK ID</p>
</td>
</tr>
<tr id="kms_02_0020__en-us_topic_0112992330_row49143924112419"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p41535243112430">plain_text</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.4.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p50742623112430">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p8911497112430">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p16511798112430">The plaintext of a DEK is expressed in hexadecimal format, and two characters indicate one byte.</p>
</td>
</tr>
<tr id="kms_02_0020__en-us_topic_0112992330_row59157744112423"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_p54991495112437">cipher_text</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.4.2.2.5.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_p21950354112437">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_p25126126112437">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.2.5.1.4 "><p id="kms_02_0020__en-us_topic_0112992330_p33148250112437">The ciphertext of a DEK is expressed in hexadecimal format, and two characters indicate one byte.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="kms_02_0020__en-us_topic_0112992330_section110811433011"><h4 class="sectiontitle">Examples</h4><p id="kms_02_0020__en-us_topic_0112992330_p270663320300">The following example describes how to create a DEK whose ID is <span class="parmvalue" id="kms_02_0020__en-us_topic_0112992330_parmvalue19739413241729"><b>0d0466b0-e727-4d9c-b35d-f84bb474a37f</b></span> and length is <span class="parmvalue" id="kms_02_0020__en-us_topic_0112992330_parmvalue86183886184227"><b>512</b></span> bits.</p>
<ul id="kms_02_0020__en-us_topic_0112992330_ul3147714143013"><li id="kms_02_0020__en-us_topic_0112992330_li101471714143019">Example request<pre class="screen" id="kms_02_0020__en-us_topic_0112992330_screen71474149301">{
"key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f",
"datakey_length": "512"
}</pre>
</li><li id="kms_02_0020__en-us_topic_0112992330_li101479144303">Example response<pre class="screen" id="kms_02_0020__en-us_topic_0112992330_screen21471314133017">{
"key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f",
"plain_text": "8151014275E426C72EE7D44267EF11590DCE0089E19863BA8CC832187B156A72A5A17F17B5EF0D525872C59ECEB72948AF85E18427F8BE0D46545C979306C08D",
"cipher_text": "020098009EEAFCE122CAA5927D2E020086F9548BA1675FDB022E4ECC01B96F2189CF4B85E78357E73E1CEB518DAF7A4960E7C7DE8885ED3FB2F1471ABF400119CC1B20BD3C4A9B80AF590EFD0AEDABFDBB0E2B689DA7B6C9E7D3C5645FCD9274802586BE63779471F9156F2CDF07CD8412FFBE9230643034363662302D653732372D346439632D623335642D6638346262343734613337660000000045B05321483BD9F9561865EE7DFE9BE267A42EB104E98C16589CE46940B18E52"
}</pre>
<p id="kms_02_0020__en-us_topic_0112992330_p1214771433015">or</p>
<pre class="screen" id="kms_02_0020__en-us_topic_0112992330_screen91479140302">{
"error": {
"error_code": "KMS.XXXX",
"error_msg": "XXX"
}
}</pre>
</li></ul>
</div>
<div class="section" id="kms_02_0020__en-us_topic_0112992330_section3454223421"><h4 class="sectiontitle">Status Codes</h4><div class="p" id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_p17772351"><a href="#kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_table20596071">Table 4</a> lists the normal status code returned by the response.
<div class="tablenoborder"><a name="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_table20596071"></a><a name="en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_table20596071"></a><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_table20596071" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Status codes</caption><thead align="left"><tr id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_row9746163"><th align="left" class="cellrowborder" valign="top" width="16.16%" id="mcps1.3.6.2.2.2.4.1.1"><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p57545694203043">Status Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="28.28%" id="mcps1.3.6.2.2.2.4.1.2"><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p4531342288">Status</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="55.559999999999995%" id="mcps1.3.6.2.2.2.4.1.3"><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p30689603203043">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_row48621261"><td class="cellrowborder" valign="top" width="16.16%" headers="mcps1.3.6.2.2.2.4.1.1 "><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_en-us_topic_0079615001_p46008046">200</p>
</td>
<td class="cellrowborder" valign="top" width="28.28%" headers="mcps1.3.6.2.2.2.4.1.2 "><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p7538425819">OK</p>
</td>
<td class="cellrowborder" valign="top" width="55.559999999999995%" headers="mcps1.3.6.2.2.2.4.1.3 "><p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p1885682315512">Request processed successfully.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p id="kms_02_0020__en-us_topic_0112992330_en-us_topic_0112992294_p5626181018551">Exception status code. For details, see <a href="kms_02_0301.html#kms_02_0301">Status Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="kms_02_0011.html">CMK Management</a></div>
</div>
</div>