Generate a hash-based message authentication code (HMAC) for a message using HMAC KMS key and key-supported MAC algorithms
The following table lists only the interface-specific request parameters and some common parameters. See common parameters for more information.
const columns = [ { width: '20%', title: 'Parameter', dataIndex: 'Name', className: 'openapi-doc-parameter-table-name' }, { width: 130, title: 'Type', dataIndex: 'DataType', className: 'openapi-doc-parameter-table-type' }, { width: 90, title: 'Required', dataIndex: 'IsRequired', className: 'openapi-doc-parameter-table-required' }, { width: '20%', title: 'Example Value', dataIndex: 'Example', className: 'openapi-doc-parameter-table-example' }, { title: 'Description', dataIndex: 'Description', className: 'openapi-doc-parameter-table-description' }, ]; const data = [ { rowKey: '->Action', Name: 'Action', DataType: 'String', IsRequired: 'yes', Example: <RenderMd content={"GenerateMac"} />, Description: <RenderMd content={"The action to perform, value: GenerateMac."} />, children: [ ] }, { rowKey: '->Version', Name: 'Version', DataType: 'String', IsRequired: 'Yes', Example: <RenderMd content={"2021-02-18"} />, Description: <RenderMd content={"API version, value: 2021-02-18."} />, children: [ ] }, { rowKey: '->KeyringName', Name: 'KeyringName', DataType: 'String', IsRequired: 'No', Example: <RenderMd content={"keyringName"} />, Description: <RenderMd content={"Keyring name, length 2 - 31 characters. Valid characters: [a-zA-Z0-9-_]"} />, children: [ ] }, { rowKey: '->KeyName', Name: 'KeyName', DataType: 'String', IsRequired: 'No', Example: <RenderMd content={"keyName"} />, Description: <RenderMd content={"Primary key name, length between 2 and 31 characters. Allowed characters: [a-zA-Z0-9-_]"} />, children: [ ] }, { rowKey: '->KeyID', Name: 'KeyID', DataType: 'String', IsRequired: 'No', Example: <RenderMd content={"0324d9b3-c5d9-4b6f-94e7-884010a16fee"} />, Description: <RenderMd content={"Primary key ID, choose one: \nKeyringName and KeyName\nKeyID"} />, children: [ ] }, { rowKey: '->Message', Name: 'Message', DataType: 'String', IsRequired: 'Yes' Example: <RenderMd content={"testMessage"} />, Description: <RenderMd content={"Signature message.\nWhen MessageType is RAW: if raw signature data is specified, the hash algorithm in Algorithm will generate a digest from the raw message before signing; valid length: [1, 4096]\nWhen MessageType is DIGEST: the maximum length is 32 bytes"} /> children: [ ] }, { rowKey: '->MacAlgorithm', Name: 'MacAlgorithm', DataType: 'String', IsRequired: 'yes', Example: <RenderMd content={"HMAC_SHA_256"} />, Description: <RenderMd content={"MacAlgorithm algorithm, supports only HMAC_SM3|HMAC_SHA_256"} />, children: [ ] }, ]; return (<Table rowKey="rowKey" className="openapi-doc-parameter-table" columns={columns} data={data} border={ { cell: true, wrapper: true } } scroll={ { x: "auto" } } pagination={false} />);
The following table lists only the unique response parameters for this interface. For more information, see response structure.
const columns = [ { width: '25%', title: 'Parameter', dataIndex: 'Name', className: 'openapi-doc-parameter-table-name', }, { width: 130, title: 'Type', dataIndex: 'DataType', className: 'openapi-doc-parameter-table-type' }, { width: '25%', title: 'Example value', dataIndex: 'Example', className: 'openapi-doc-parameter-table-example' }, { title: 'Description', dataIndex: 'Description', className: 'openapi-doc-parameter-table-description' }, ]; const data = [ { rowKey: "->KeyID", Name: "KeyID", DataType: "String", Example: <RenderMd content={"41cb6fdba8ef249312e4ce66f7d6b5b68e565ef84d6333793b5934d6779e847c"} />, Description: <RenderMd content={"unique identifier of the master key in UUID format"} /> children: [ ] }, { rowKey: "->Mac", Name: "Mac", DataType: "String", Example: <RenderMd content={"0324d9b3-c5d9-4b6f-94e7-884010a16fee"} />, Description: <RenderMd content={"message authentication code"} />, children: [ ] }, ]; return (<Table rowKey="rowKey" className="openapi-doc-parameter-table" columns={columns} data={data} border={ { cell: true, wrapper: true } } scroll={ { x: "auto" } } pagination={false} />);
POST /?Action=GenerateMac&Version=2021-02-18 HTTP/1.1 Host: kms.cn-beijing.volcengineapi.com Content-Type: application/json; charset=UTF-8 X-Date: 20240708T151941Z X-Content-Sha256: 287e874e******d653b44d21e Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20240708/cn-beijing/kms/request, SignedHeaders=host;x-content-sha256;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f { "Message": "5Lq65LmL5Yid5oCn5pys5ZaE5oCn55u46L+R5Lmg55u46L+c", "MacAlgorithm": "HMAC_SHA_256", "KeyringName": "fd65f1d1-9b0c-4254-897f-1965b2", "KeyName": "bbbb" }
{ "ResponseMetadata": { "RequestId": "02172956002604000000000000000000000ffff0a7ab9adc81d5f", "Action": "GenerateMac", "Version": "2021-02-18", "Service": "kms", "Region": "cn-beijing" }, "Result": { "KeyID": "1096b6a5-3bb5-430a-8c5b-65ae1ca73346", "Mac": "49NIoYbYAkVv8tT6hoAY+jJ0gZCRQujiv7wc0S763ao=" } }
The table below lists error codes related to this interface and business logic. Refer to the Common Error Codes documentation for public error codes.
Status Code | Error Code | Description |
|---|---|---|
400 | MissingParameter | |
400 | InvalidParameter | |
400 | InvalidKeyStatus | |
400 | InvalidKeyUsage | |
403 | AccessDenied | |
403 | Reject.Throttling.CMK | |
404 | Not Found | |
500 | UndefinedError |