doc-exports/docs/kms/api-ref/kms_02_0019.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

135 lines
12 KiB
HTML

<a name="kms_02_0019"></a><a name="kms_02_0019"></a>
<h1 class="topictitle1">Creating a Random Number</h1>
<div id="body1474684560498"><div class="section" id="kms_02_0019__en-us_topic_0112992308_s1731a14fb0144c79bf0fa90c694f34f7"><h4 class="sectiontitle">Function</h4><p id="kms_02_0019__en-us_topic_0112992308_p19841010114614">This API generates a 512-bit random number.</p>
</div>
<div class="section" id="kms_02_0019__en-us_topic_0112992308_se70c3e5518a04f60b06032524dddfef4"><h4 class="sectiontitle">URI</h4><ul id="kms_02_0019__en-us_topic_0112992308_en-us_topic_0020091565_ul60390938"><li id="kms_02_0019__en-us_topic_0112992308_en-us_topic_0020091565_li6647531">URI format<p id="kms_02_0019__en-us_topic_0112992308_p138073181080"><a name="kms_02_0019__en-us_topic_0112992308_en-us_topic_0020091565_li6647531"></a><a name="en-us_topic_0112992308_en-us_topic_0020091565_li6647531"></a>POST /v1.0/{project_id}/kms/gen-random</p>
</li><li id="kms_02_0019__en-us_topic_0112992308_en-us_topic_0020091565_li14211994">Parameter description
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0019__en-us_topic_0112992308_t982da1e0196d4ec1a28d1fbff2cc8191" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="kms_02_0019__en-us_topic_0112992308_r6e963322c1e740d181726d2f0e91df5a"><th align="left" class="cellrowborder" valign="top" width="22.74227422742274%" id="mcps1.3.2.2.2.1.2.5.1.1"><p id="kms_02_0019__en-us_topic_0112992308_a3b5bbe5a7f644fd3a74cecbfb3f7ed60">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.062406240624064%" id="mcps1.3.2.2.2.1.2.5.1.2"><p id="kms_02_0019__en-us_topic_0112992308_ad98d2f62bd064b4e96ea922645197c24">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.862086208620862%" id="mcps1.3.2.2.2.1.2.5.1.3"><p id="kms_02_0019__en-us_topic_0112992308_a3becf0b3aec9468984c2efc8d5abbea5">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="32.33323332333234%" id="mcps1.3.2.2.2.1.2.5.1.4"><p id="kms_02_0019__en-us_topic_0112992308_a6bb6f1fe56a2454982832e8d56d354d8">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0019__en-us_topic_0112992308_r69bf37b65d3f446eab7b3f4d1b2fcec0"><td class="cellrowborder" valign="top" width="22.74227422742274%" headers="mcps1.3.2.2.2.1.2.5.1.1 "><p id="kms_02_0019__en-us_topic_0112992308_ae42d73592f58424ea93a11e52d2478dd">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="24.062406240624064%" headers="mcps1.3.2.2.2.1.2.5.1.2 "><p id="kms_02_0019__en-us_topic_0112992308_a56440c0f0ae34ba3b8033d1247673984">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.862086208620862%" headers="mcps1.3.2.2.2.1.2.5.1.3 "><p id="kms_02_0019__en-us_topic_0112992308_a1a4a71c11a4a45a58d0de2fbe009e9d9">String</p>
</td>
<td class="cellrowborder" valign="top" width="32.33323332333234%" headers="mcps1.3.2.2.2.1.2.5.1.4 "><p id="kms_02_0019__en-us_topic_0112992308_a1314869d2dc147b38461e037d622f7b4">Project ID</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="kms_02_0019__en-us_topic_0112992308_seb7b7901701247fab30a59b76f1c7f93"><h4 class="sectiontitle">Requests</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0019__en-us_topic_0112992308_table46221022101230" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request parameters</caption><thead align="left"><tr id="kms_02_0019__en-us_topic_0112992308_row9315574101230"><th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.3.2.2.5.1.1"><p id="kms_02_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_p57514295101230"><strong id="kms_02_0019__en-us_topic_0112992308_b842352706174353">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_0019__en-us_topic_0112992308_p50420322101230"><strong id="kms_02_0019__en-us_topic_0112992308_b842352706174350">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_0019__en-us_topic_0112992308_p28146304101230">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0019__en-us_topic_0112992308_row2638193101722"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0019__en-us_topic_0112992308_p4481944111821">random_data_length</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0019__en-us_topic_0112992308_p12354932111821">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0019__en-us_topic_0112992308_p27493178111821">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0019__en-us_topic_0112992308_p181143345379">Number of bits of a random number. The value is <strong id="kms_02_0019__en-us_topic_0112992308_b548313469244">512</strong>.</p>
</td>
</tr>
<tr id="kms_02_0019__en-us_topic_0112992308_row35142504101726"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.1 "><p id="kms_02_0019__en-us_topic_0112992308_p269135101746">sequence</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.3.2.2.5.1.2 "><p id="kms_02_0019__en-us_topic_0112992308_p20967256101746">No</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.3.2.2.5.1.3 "><p id="kms_02_0019__en-us_topic_0112992308_p21799971101746">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.2.5.1.4 "><p id="kms_02_0019__en-us_topic_0112992308_p32671918171823">36-byte serial number of a request message</p>
<p id="kms_02_0019__en-us_topic_0112992308_p20626198101746">Example: 919c82d4-8046-4722-9094-35c3c6524cff</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="kms_02_0019__en-us_topic_0112992308_sfadd53a5f4714e8f87811818d62d0296"><h4 class="sectiontitle">Responses</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0019__en-us_topic_0112992308_t98d238e10953421e84a073707024c329" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Response parameters</caption><thead align="left"><tr id="kms_02_0019__en-us_topic_0112992308_r144a2c52c5054c6d9243eb2ef3875a21"><th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.4.2.2.5.1.1"><p id="kms_02_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_a1851157c81e14d7f82db752a5737195a">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="17%" id="mcps1.3.4.2.2.5.1.3"><p id="kms_02_0019__en-us_topic_0112992308_a39360acf5daf4c01a1ebddeff5d68a1c">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.2.2.5.1.4"><p id="kms_02_0019__en-us_topic_0112992308_a0097000016b14857972b7929bcaaa038">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0019__en-us_topic_0112992308_rf212a916c502452a8e151eba2f118272"><td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.1 "><p id="kms_02_0019__en-us_topic_0112992308_p66286535111935">random_data</p>
</td>
<td class="cellrowborder" valign="top" width="16%" headers="mcps1.3.4.2.2.5.1.2 "><p id="kms_02_0019__en-us_topic_0112992308_p40522553111935">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="17%" headers="mcps1.3.4.2.2.5.1.3 "><p id="kms_02_0019__en-us_topic_0112992308_p500278111935">String</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.2.5.1.4 "><p id="kms_02_0019__en-us_topic_0112992308_p61101369111935">Random numbers are expressed in hexadecimal format. Two characters indicate one byte. Length of a random number must be consistent with the <span class="parmname" id="kms_02_0019__en-us_topic_0112992308_parmname671747902144312"><b>random_data_length</b></span> value entered by a user.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="kms_02_0019__en-us_topic_0112992308_section1683920202720"><h4 class="sectiontitle">Examples</h4><p id="kms_02_0019__en-us_topic_0112992308_p127191348102720">The following example describes how to create a random number with the length of <span class="parmvalue" id="kms_02_0019__en-us_topic_0112992308_parmvalue19739413241729"><b>512</b></span> bits.</p>
<ul id="kms_02_0019__en-us_topic_0112992308_ul197182082713"><li id="kms_02_0019__en-us_topic_0112992308_li696142022713">Example request<pre class="screen" id="kms_02_0019__en-us_topic_0112992308_screen159619204277">{
"random_data_length": "512"
}</pre>
</li><li id="kms_02_0019__en-us_topic_0112992308_li49702017279">Example response<pre class="screen" id="kms_02_0019__en-us_topic_0112992308_screen496120192715">{
"random_data": "5791C223E87124AB9FC29B5A8AC60BE4B98D168F47A58BB2A88833E40D6ED32D57E2AAB5410492EB25096873F9CE3D45E0D22F820A5AB4EEADC33A1A6AE780F1"
}</pre>
<p id="kms_02_0019__en-us_topic_0112992308_p169682020279">or</p>
<pre class="screen" id="kms_02_0019__en-us_topic_0112992308_screen17971120112714">{
"error": {
"error_code": "KMS.XXXX",
"error_msg": "XXX"
}
}</pre>
</li></ul>
</div>
<div class="section" id="kms_02_0019__en-us_topic_0112992308_section12126152083712"><h4 class="sectiontitle">Status Codes</h4><div class="p" id="kms_02_0019__en-us_topic_0112992308_en-us_topic_0112992294_en-us_topic_0079615001_p17772351"><a href="#kms_02_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_en-us_topic_0112992294_en-us_topic_0079615001_table20596071"></a><a name="en-us_topic_0112992308_en-us_topic_0112992294_en-us_topic_0079615001_table20596071"></a><table cellpadding="4" cellspacing="0" summary="" id="kms_02_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_en-us_topic_0112992294_p30689603203043">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="kms_02_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_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_0019__en-us_topic_0112992308_en-us_topic_0112992294_p1885682315512">Request processed successfully.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p id="kms_02_0019__en-us_topic_0112992308_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>