KMSClient.generate_mac
rboto-kms==0.4.0 · Service index · Types
Model summary (excerpt): Generates a hash-based message authentication code (HMAC) for a message using an HMAC KMS key and a MAC algorithm that the key supports. HMAC KMS keys and the HMAC algorithms that KMS uses conform to industry standards defined in RFC 2104 . You can use value that GenerateMac returns in the VerifyMac operation to demonstrate that the original message has not changed. Also, because a secret key...
Install and imports
from rboto import KMSClient
from collections.abc import Sequence
from rboto_kms.types import (
GenerateMacOutput,
MacAlgorithmSpec,
)
Signature
async def generate_mac(
*,
message: bytes,
key_id: str,
mac_algorithm: MacAlgorithmSpec,
grant_tokens: Sequence[str] | None = None,
dry_run: bool | None = None,
) -> GenerateMacOutput: ...
Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.
Arguments
| Argument | Required | Model notes (excerpt) |
|---|---|---|
message |
Yes | The message to be hashed. Specify a message of up to 4,096 bytes. GenerateMac and VerifyMac do not provide special handling for message digests. If you generate an HMAC for a hash digest of a message, you must verify the HMAC of the same hash digest. |
key_id |
Yes | The HMAC KMS key to use in the operation. The MAC algorithm computes the HMAC for the message and the key as described in RFC 2104 . To identify an HMAC KMS key, use the DescribeKey operation and see the KeySpec field in the response. |
mac_algorithm |
Yes | The MAC algorithm used in the operation. The algorithm must be compatible with the HMAC KMS key that you specify. To find the MAC algorithms that your HMAC KMS key supports, use the DescribeKey operation and see the MacAlgorithms field in the DescribeKey response. |
grant_tokens |
No | A list of grant tokens. Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency . For more information, see Grant token and Using a grant token in the Key Management Service Developer Guide . |
dry_run |
No | Checks if your request will succeed. DryRun is an optional parameter. To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide . |
Output
GenerateMacOutput.
Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.
| Field | Type | Presence | References |
|---|---|---|---|
mac |
bytes | None |
Always present | — |
mac_algorithm |
MacAlgorithmSpecOutput | None |
Always present | MacAlgorithmSpecOutput |
key_id |
str | None |
Always present | — |
| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.
Related types
GenerateMacOutput, MacAlgorithmSpec
Follow these links for nested inputs and outputs; recursive types link back to the same type page.
Pagination and streaming
No generated paginator for this operation.
No output stream.
Errors
Import from rboto_kms.exceptions:
DisabledError, DryRunOperationError, InvalidGrantTokenError, InvalidKeyUsageError, KMSInternalError, KMSInvalidStateError, KeyUnavailableError, NotFoundError.
Other service failures use the service base error; credential, transport and timeout failures use shared errors.