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

195 lines
16 KiB
HTML

<a name="VerifyMac"></a><a name="VerifyMac"></a>
<h1 class="topictitle1">Verifying a MAC</h1>
<div id="body8662426"><div class="section" id="VerifyMac__en-us_topic_0000002123085433_section8229174104913"><h4 class="sectiontitle">Function</h4><p id="VerifyMac__en-us_topic_0000002123085433_p7229114144919">This API is used to verify a MAC.</p>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section8229174194913"><h4 class="sectiontitle">Constraints</h4><p id="VerifyMac__p185351640144118">This API is supported only for keys whose <strong id="VerifyMac__b129202429611376">key_usage</strong> is <strong id="VerifyMac__b54264855711376">GENERATE_VERIFY_MAC</strong>.</p>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section322917418493"><h4 class="sectiontitle">URI</h4><p id="VerifyMac__en-us_topic_0000002123085433_p122910454918">POST /v1.0/{project_id}/kms/verify-mac</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="VerifyMac__en-us_topic_0000002123085433_table102301843495" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter</caption><thead align="left"><tr id="VerifyMac__en-us_topic_0000002123085433_row322919424913"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.1"><p id="VerifyMac__en-us_topic_0000002123085433_p823010410491">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.2"><p id="VerifyMac__en-us_topic_0000002123085433_p5230164194917">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.3.3.2.5.1.3"><p id="VerifyMac__en-us_topic_0000002123085433_p12307454918">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.3.3.2.5.1.4"><p id="VerifyMac__en-us_topic_0000002123085433_p132301146497">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="VerifyMac__en-us_topic_0000002123085433_row622918420492"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p623015418492">project_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p1923018474912">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.3.3.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p92301043494">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.3.3.2.5.1.4 "><p id="VerifyMac__en-us_topic_0000002123085433_p1723014413492">Project ID</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section112302418492"><h4 class="sectiontitle">Request Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="VerifyMac__en-us_topic_0000002123085433_HeaderParameter" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Request header parameters</caption><thead align="left"><tr id="VerifyMac__en-us_topic_0000002123085433_row1023044194918"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.1"><p id="VerifyMac__en-us_topic_0000002123085433_p132301745491">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.2"><p id="VerifyMac__en-us_topic_0000002123085433_p192301241495">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.2.5.1.3"><p id="VerifyMac__en-us_topic_0000002123085433_p1923018474910">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.4.2.2.5.1.4"><p id="VerifyMac__en-us_topic_0000002123085433_p1023019420497">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="VerifyMac__en-us_topic_0000002123085433_row192301241496"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p023094204914">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p323017418496">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p223024114910">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.2.2.5.1.4 "><p id="VerifyMac__en-us_topic_0000002123085433_p92301144497">User token.</p>
<p id="VerifyMac__en-us_topic_0000002123085433_p172309413494">It can be obtained by calling the IAM API used to obtain a user token. The value of <strong id="VerifyMac__b95451969031813">X-Subject-Token</strong> in the response header is a token.</p>
</td>
</tr>
<tr id="VerifyMac__row149907171414"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.1 "><p id="VerifyMac__p1279425073711">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.2 "><p id="VerifyMac__p2794195010376">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.2.5.1.3 "><p id="VerifyMac__p9794195015373">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.2.2.5.1.4 "><p id="VerifyMac__p5617163694719">application/json</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="VerifyMac__en-us_topic_0000002123085433_request_VerifyMacRequestBody" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Request body parameters</caption><thead align="left"><tr id="VerifyMac__en-us_topic_0000002123085433_row122313454915"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.1"><p id="VerifyMac__en-us_topic_0000002123085433_p172311413492">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.2"><p id="VerifyMac__en-us_topic_0000002123085433_p19231114194914">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.3.2.5.1.3"><p id="VerifyMac__en-us_topic_0000002123085433_p1231134104915">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="40%" id="mcps1.3.4.3.2.5.1.4"><p id="VerifyMac__en-us_topic_0000002123085433_p123184204911">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="VerifyMac__en-us_topic_0000002123085433_row192316418491"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p92315404912">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p623115420491">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p12311744491">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="VerifyMac__en-us_topic_0112992351_p13325105752814">ID of the key to be enabled. The value can be the key ID, alias (<strong id="VerifyMac__b15224139217">key_alias</strong>), or URN.</p>
<ul id="VerifyMac__en-us_topic_0112992351_ul1703946133019"><li id="VerifyMac__en-us_topic_0112992351_li1170344663018">Key ID: A 36-byte string that matches the <strong id="VerifyMac__b13116532115">^[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="VerifyMac__b560010618210">0d0466b0-e727-4d9c-b35d-f84bb474a37f</strong></li><li id="VerifyMac__en-us_topic_0112992351_li730017917319">Alias: An identifier of a key. The value starts with <span class="parmvalue" id="VerifyMac__parmvalue174973913214"><b>alias/</b></span>, for example, <strong id="VerifyMac__b47943105211">alias/4555</strong>.</li><li id="VerifyMac__en-us_topic_0112992351_li142001515173115">URN: Each alias automatically matches a unique URN, for example, <strong id="VerifyMac__b29630670733935">kms:eu-de-ring0:3ba44455500dd43127:alias:4555</strong>.</li></ul>
</td>
</tr>
<tr id="VerifyMac__en-us_topic_0000002123085433_row7231134114915"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p423124184918">mac_algorithm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p16231134164920">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p923119434919">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="VerifyMac__en-us_topic_0000002123085433_p023112415492">MAC algorithm. Possible values are as follows:</p>
<ul id="VerifyMac__en-us_topic_0000002123085433_ul102315414915"><li id="VerifyMac__en-us_topic_0000002123085433_li02318494912"><strong id="VerifyMac__b80597546431922">HMAC_SHA_256</strong></li><li id="VerifyMac__en-us_topic_0000002123085433_li62311343495"><strong id="VerifyMac__b148205510231927">HMAC_SHA_384</strong></li><li id="VerifyMac__en-us_topic_0000002123085433_li15231194184911"><strong id="VerifyMac__b120426142931932">HMAC_SHA_512</strong></li></ul>
<div class="note" id="VerifyMac__note95451731406"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="VerifyMac__p185451315407">The value must be the algorithm used for creating the key.</p>
</div></div>
</td>
</tr>
<tr id="VerifyMac__en-us_topic_0000002123085433_row72311243491"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p723115415498">message</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p52319413497">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p52322045497">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="VerifyMac__en-us_topic_0000002123085433_p16232114164911">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>
<tr id="VerifyMac__en-us_topic_0000002123085433_row112313413495"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p1523294174915">mac</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p12327434913">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.3.2.5.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p1723211416495">String</p>
</td>
<td class="cellrowborder" valign="top" width="40%" headers="mcps1.3.4.3.2.5.1.4 "><p id="VerifyMac__en-us_topic_0000002123085433_p1723224124913">MAC to be verified</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section42328417490"><h4 class="sectiontitle">Response Parameters</h4><p id="VerifyMac__en-us_topic_0000002123085433_p1123218416493"><strong id="VerifyMac__en-us_topic_0000002123085433_b5232114144914">Status code: 200</strong></p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="VerifyMac__en-us_topic_0000002123085433_response_VerifyMacResponseBody" frame="border" border="1" rules="all"><caption><b>Table 4 </b>Response body parameters</caption><thead align="left"><tr id="VerifyMac__en-us_topic_0000002123085433_row132321941496"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.5.3.2.4.1.1"><p id="VerifyMac__en-us_topic_0000002123085433_p1523254194917">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.5.3.2.4.1.2"><p id="VerifyMac__en-us_topic_0000002123085433_p72321743496">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="60%" id="mcps1.3.5.3.2.4.1.3"><p id="VerifyMac__en-us_topic_0000002123085433_p523254154914">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="VerifyMac__en-us_topic_0000002123085433_row223294134913"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p4232204144913">key_id</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p1623218411492">String</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p323214424911">Key ID</p>
</td>
</tr>
<tr id="VerifyMac__en-us_topic_0000002123085433_row19232184154917"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p9232104174917">mac_algorithm</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p1623234184917">String</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p1323214413490">MAC algorithm</p>
</td>
</tr>
<tr id="VerifyMac__en-us_topic_0000002123085433_row1423213414913"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p14232114124911">mac_valid</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.5.3.2.4.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p22322420498">Boolean</p>
</td>
<td class="cellrowborder" valign="top" width="60%" headers="mcps1.3.5.3.2.4.1.3 "><p id="VerifyMac__en-us_topic_0000002123085433_p1232649492">MAC verification result</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section1323244154911"><h4 class="sectiontitle">Example Request</h4><pre class="screen" id="VerifyMac__en-us_topic_0000002123085433_screen823314184910">{
"key_id" : "826314dd-1b5b-4037-b976-5f9b7a17df46",
"mac_algorithm" : "HMAC_SHA_256",
"message" : "ZmRzYQ==",
"mac" : "8549f9f5ef335184e23e6d477776f0fd338d02c59e48e52e8d81d158e2fc9262"
}</pre>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section122335424919"><h4 class="sectiontitle">Example Response</h4><p id="VerifyMac__en-us_topic_0000002123085433_p4233649491"><strong id="VerifyMac__en-us_topic_0000002123085433_b4233164154920">Status code: 200</strong></p>
<p id="VerifyMac__en-us_topic_0000002123085433_p152330414914">Request succeeded.</p>
<pre class="screen" id="VerifyMac__en-us_topic_0000002123085433_screen1723310412492">{
"mac_algorithm" : "HMAC_SHA_256",
"key_id" : "826314dd-1b5b-4037-b976-5f9b7a17df46",
"mac_valid" : true
}</pre>
</div>
<div class="section" id="VerifyMac__en-us_topic_0000002123085433_section338564184916"><h4 class="sectiontitle">Status Codes</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="VerifyMac__en-us_topic_0000002123085433_status_code" frame="border" border="1" rules="all"><thead align="left"><tr id="VerifyMac__en-us_topic_0000002123085433_row1623916412494"><th align="left" class="cellrowborder" valign="top" width="15%" id="mcps1.3.8.2.1.3.1.1"><p id="VerifyMac__en-us_topic_0000002123085433_p338554104918">Status Code</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="85%" id="mcps1.3.8.2.1.3.1.2"><p id="VerifyMac__en-us_topic_0000002123085433_p83851546497">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="VerifyMac__en-us_topic_0000002123085433_row72391416495"><td class="cellrowborder" valign="top" width="15%" headers="mcps1.3.8.2.1.3.1.1 "><p id="VerifyMac__en-us_topic_0000002123085433_p9385745493">200</p>
</td>
<td class="cellrowborder" valign="top" width="85%" headers="mcps1.3.8.2.1.3.1.2 "><p id="VerifyMac__en-us_topic_0000002123085433_p03851848496">Request succeeded.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p id="VerifyMac__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>