Files
doc-exports/docs/kms/api-ref/GenerateMac.html
qiaoli 18397ded73 kms_api_2025042703
Reviewed-by: Belejkanic, Lukas <lukas.belejkanic@t-systems.com>
Co-authored-by: qiaoli <qiaoli@huawei.com>
Co-committed-by: qiaoli <qiaoli@huawei.com>
2025-12-09 09:29:44 +00:00

185 lines
16 KiB
HTML

<a name="GenerateMac"></a><a name="GenerateMac"></a>
<h1 class="topictitle1">Generating a MAC</h1>
<div id="body8662426"><div class="section" id="GenerateMac__en-us_topic_0000002087645966_section142181543498"><h4 class="sectiontitle">Function</h4><p id="GenerateMac__en-us_topic_0000002087645966_p1421818424920">This API is used to generate a MAC.</p>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section621824104913"><h4 class="sectiontitle">Constraints</h4><p id="GenerateMac__p6296185020401">This API is supported only for keys whose <strong id="GenerateMac__b19841124521719">key_usage</strong> is <strong id="GenerateMac__b584174510173">GENERATE_VERIFY_MAC</strong>.</p>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section182181741492"><h4 class="sectiontitle">URI</h4><p id="GenerateMac__en-us_topic_0000002087645966_p1421819413495">POST /v1.0/{project_id}/kms/generate-mac</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="GenerateMac__en-us_topic_0000002087645966_table13219104134918" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter</caption><thead align="left"><tr id="GenerateMac__en-us_topic_0000002087645966_row9219243494"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.1"><p id="GenerateMac__en-us_topic_0000002087645966_p1821915474918">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.2"><p id="GenerateMac__en-us_topic_0000002087645966_p1921917464914">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.3"><p id="GenerateMac__en-us_topic_0000002087645966_p82191547499">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.3.3.2.5.1.4"><p id="GenerateMac__en-us_topic_0000002087645966_p921924104915">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="GenerateMac__en-us_topic_0000002087645966_row102191464917"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p82191046494">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p521910454916">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p122198415495">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.3.3.2.5.1.4 "><p id="GenerateMac__en-us_topic_0000002087645966_p172191044494">Project ID</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section1521916454917"><h4 class="sectiontitle">Request Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="GenerateMac__en-us_topic_0000002087645966_HeaderParameter" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request header parameters</caption><thead align="left"><tr id="GenerateMac__en-us_topic_0000002087645966_row172191841497"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.1"><p id="GenerateMac__en-us_topic_0000002087645966_p1921919414918">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.2"><p id="GenerateMac__en-us_topic_0000002087645966_p52207411494">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.3"><p id="GenerateMac__en-us_topic_0000002087645966_p122094164919">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.4.2.2.5.1.4"><p id="GenerateMac__en-us_topic_0000002087645966_p1922014420499">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="GenerateMac__en-us_topic_0000002087645966_row9219174154916"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p02204417496">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p13220446494">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p22209404918">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.2.2.5.1.4 "><p id="GenerateMac__en-us_topic_0000002087645966_p9220140494">User token.</p>
<p id="GenerateMac__en-us_topic_0000002087645966_p112203414490">It can be obtained by calling the IAM API used to obtain a user token. The value of <strong id="GenerateMac__b1498378832113652">X-Subject-Token</strong> in the response header is a token.</p>
</td>
</tr>
<tr id="GenerateMac__row10498145111318"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.1 "><p id="GenerateMac__p1279425073711">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="GenerateMac__p2794195010376">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.3 "><p id="GenerateMac__p9794195015373">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.2.2.5.1.4 "><p id="GenerateMac__p5617163694719">application/json</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="GenerateMac__en-us_topic_0000002087645966_request_GenerateMacRequestBody" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Request body parameters</caption><thead align="left"><tr id="GenerateMac__en-us_topic_0000002087645966_row17220204204918"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.1"><p id="GenerateMac__en-us_topic_0000002087645966_p52208424919">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.2"><p id="GenerateMac__en-us_topic_0000002087645966_p1622016410496">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.3"><p id="GenerateMac__en-us_topic_0000002087645966_p1322011420498">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.4.3.2.5.1.4"><p id="GenerateMac__en-us_topic_0000002087645966_p62207404918">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="GenerateMac__en-us_topic_0000002087645966_row9220443495"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p62201147493">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p15220642498">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p142201941499">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="GenerateMac__en-us_topic_0112992351_p13325105752814">ID of the key to be enabled. The value can be the key ID, alias (<strong id="GenerateMac__b181201539131818">key_alias</strong>), or URN.</p>
<ul id="GenerateMac__en-us_topic_0112992351_ul1703946133019"><li id="GenerateMac__en-us_topic_0112992351_li1170344663018">Key ID: A 36-byte string that matches the <strong id="GenerateMac__b7137134219182">^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$</strong> regular expression, for example, <strong id="GenerateMac__b550619446189">0d0466b0-e727-4d9c-b35d-f84bb474a37f</strong></li><li id="GenerateMac__en-us_topic_0112992351_li730017917319">Alias: An identifier of a key. The value starts with <span class="parmvalue" id="GenerateMac__parmvalue1736194917186"><b>alias/</b></span>, for example, <strong id="GenerateMac__b1891915001820">alias/4555</strong>.</li><li id="GenerateMac__en-us_topic_0112992351_li142001515173115">URN: Each alias automatically matches a unique URN, for example, <strong id="GenerateMac__b169156211033934">kms:eu-de-ring0:3ba44455500dd43127:alias:4555</strong>.</li></ul>
</td>
</tr>
<tr id="GenerateMac__en-us_topic_0000002087645966_row2220164204919"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p422012418491">mac_algorithm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p1022012417491">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p6220841498">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="GenerateMac__en-us_topic_0000002087645966_p18220445498">MAC algorithm. Possible values are as follows:</p>
<ul id="GenerateMac__en-us_topic_0000002087645966_ul102211645497"><li id="GenerateMac__en-us_topic_0000002087645966_li422116414910"><strong id="GenerateMac__b1167317130199">HMAC_SHA_256</strong></li><li id="GenerateMac__en-us_topic_0000002087645966_li7221124134916"><strong id="GenerateMac__b986551531915">HMAC_SHA_384</strong></li><li id="GenerateMac__en-us_topic_0000002087645966_li222116410496"><strong id="GenerateMac__b1132131791919">HMAC_SHA_512</strong></li></ul>
<div class="note" id="GenerateMac__note95451731406"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="GenerateMac__p185451315407">The value must be the algorithm used for creating the key.</p>
</div></div>
</td>
</tr>
<tr id="GenerateMac__en-us_topic_0000002087645966_row822084174916"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p12217414912">message</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p1022113464920">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p122124114918">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="GenerateMac__en-us_topic_0000002087645966_p1622119494916">Message to be processed. The original message can contain 1 to 4,096 characters. Convert the original message to the Base64 format before importing it.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section1922119464915"><h4 class="sectiontitle">Response Parameters</h4><p id="GenerateMac__en-us_topic_0000002087645966_p1221847492"><strong id="GenerateMac__en-us_topic_0000002087645966_b1422144114911">Status code: 200</strong></p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="GenerateMac__en-us_topic_0000002087645966_response_GenerateMacResponseBody" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Response body parameters</caption><thead align="left"><tr id="GenerateMac__en-us_topic_0000002087645966_row1022134164917"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.5.3.2.4.1.1"><p id="GenerateMac__en-us_topic_0000002087645966_p15221047495">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.5.3.2.4.1.2"><p id="GenerateMac__en-us_topic_0000002087645966_p1322114194915">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="60%" id="mcps1.3.5.3.2.4.1.3"><p id="GenerateMac__en-us_topic_0000002087645966_p12218424917">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="GenerateMac__en-us_topic_0000002087645966_row52218417497"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p122164114919">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p14221114204910">String</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p1622134154913">Key ID</p>
</td>
</tr>
<tr id="GenerateMac__en-us_topic_0000002087645966_row19221344492"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p22216484914">mac_algorithm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p722111424917">String</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p1222113419491">MAC algorithm</p>
</td>
</tr>
<tr id="GenerateMac__en-us_topic_0000002087645966_row722118454911"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p2022111410492">mac</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p5222134144917">String</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="GenerateMac__en-us_topic_0000002087645966_p152223454910">MAC</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section3222148493"><h4 class="sectiontitle">Example Request</h4><pre class="screen" id="GenerateMac__en-us_topic_0000002087645966_screen922212411496">{
"key_id" : "826314dd-1b5b-4037-b976-5f9b7a17df46",
"mac_algorithm" : "HMAC_SHA_256",
"message" : "ZmRzYQ=="
}</pre>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section72224434919"><h4 class="sectiontitle">Example Response</h4><p id="GenerateMac__en-us_topic_0000002087645966_p142226494914"><strong id="GenerateMac__en-us_topic_0000002087645966_b11222184144914">Status code: 200</strong></p>
<p id="GenerateMac__en-us_topic_0000002087645966_p222219413496">Request succeeded.</p>
<pre class="screen" id="GenerateMac__en-us_topic_0000002087645966_screen52221449499">{
"mac_algorithm" : "HMAC_SHA_256",
"key_id" : "826314dd-1b5b-4037-b976-5f9b7a17df46",
"mac" : "9d266415acf82985bb44daf4990604f1931384c88fd21ef32b202396755dcfd7"
}</pre>
</div>
<div class="section" id="GenerateMac__en-us_topic_0000002087645966_section93848410499"><h4 class="sectiontitle">Status Codes</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="GenerateMac__en-us_topic_0000002087645966_status_code" frame="border" border="1" rules="all"><thead align="left"><tr id="GenerateMac__en-us_topic_0000002087645966_row02277413490"><th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.8.2.1.3.1.1"><p id="GenerateMac__en-us_topic_0000002087645966_p10384447496">Status Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="85%" id="mcps1.3.8.2.1.3.1.2"><p id="GenerateMac__en-us_topic_0000002087645966_p2384542497">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="GenerateMac__en-us_topic_0000002087645966_row1422718414493"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.1.3.1.1 "><p id="GenerateMac__en-us_topic_0000002087645966_p1338415413493">200</p>
</td>
<td class="cellrowborder" valign="top" width="85%" headers="mcps1.3.8.2.1.3.1.2 "><p id="GenerateMac__en-us_topic_0000002087645966_p93849420498">Request succeeded.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="GenerateMac__en-us_topic_0133150654_en-us_topic_0112992294_p5626181018551">Exception status code. For details, see <a href="kms_02_0301.html">Status Codes</a>.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="topic_300000012.html">MAC</a></div>
</div>
</div>