Verifies a Message Authentication Code (MAC).
You can use this operation to verify MAC for message data authentication such as . In this operation, you must use the same message data, secret encryption key and MAC algorithm that was used to generate MAC. You can use this operation to verify a DUPKT, CMAC, HMAC or EMV MAC by setting generation attributes and algorithm to the associated values.
For information about valid keys for this operation, see Understanding key attributes and Key types for specific data operations in the Amazon Web Services Payment Cryptography User Guide.
Cross-account use: This operation supports cross-account use when the key has a resource-based policy that grants access. For more information, see Resource-based policies.
Related operations:
Parameters:
-
key_identifier
(KeyArnOrKeyAliasType)
–
The keyARN of the encryption key that Amazon Web Services Payment Cryptography uses to verify MAC data.
-
message_data
(MessageDataType)
–
The data on for which MAC is under verification. This value must be hexBinary.
-
mac
(MacType)
–
-
verification_attributes
(MacAttributes)
–
The attributes and data values to use for MAC verification within Amazon Web Services Payment Cryptography.
-
mac_length
(Optional[IntegerRangeBetween4And32], default:
None
)
–
Raises:
Source code in docs_src/capo_payment_cryptography_data/_services/payment_cryptography_data.py
| def verify_mac(
self,
key_identifier: "capo_payment_cryptography_data.types.key_arn_or_key_alias_type.KeyArnOrKeyAliasType",
message_data: "capo_payment_cryptography_data.types.message_data_type.MessageDataType",
mac: "capo_payment_cryptography_data.types.mac_type.MacType",
verification_attributes: "capo_payment_cryptography_data.types.mac_attributes.MacAttributes",
*,
config_overrides: Optional[PaymentCryptographyDataClientConfig] = None,
mac_length: Optional[
"capo_payment_cryptography_data.types.integer_range_between4_and32.IntegerRangeBetween4And32"
] = None,
) -> "capo_payment_cryptography_data.types.verify_mac_output.VerifyMacOutput":
"""<p>Verifies a Message Authentication Code (MAC). </p> <p>You can use this operation to verify MAC for message data authentication such as . In this operation, you must use the same message data, secret encryption key and MAC algorithm that was used to generate MAC. You can use this operation to verify a DUPKT, CMAC, HMAC or EMV MAC by setting generation attributes and algorithm to the associated values. </p> <p>For information about valid keys for this operation, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/keys-validattributes.html">Understanding key attributes</a> and <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/crypto-ops-validkeys-ops.html">Key types for specific data operations</a> in the <i>Amazon Web Services Payment Cryptography User Guide</i>. </p> <p> <b>Cross-account use</b>: This operation supports cross-account use when the key has a resource-based policy that grants access. For more information, see <a href="https://docs.aws.amazon.com/payment-cryptography/latest/userguide/security_iam_resource-based-policies.html">Resource-based policies</a>.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>GenerateMac</a> </p> </li> </ul>
Args:
key_identifier: <p>The <code>keyARN</code> of the encryption key that Amazon Web Services Payment Cryptography uses to verify MAC data.</p>
message_data: <p>The data on for which MAC is under verification. This value must be hexBinary.</p>
mac: <p>The MAC being verified.</p>
verification_attributes: <p>The attributes and data values to use for MAC verification within Amazon Web Services Payment Cryptography.</p>
mac_length: <p>The length of the MAC.</p>
Raises:
capo_payment_cryptography_data.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
capo_payment_cryptography_data.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception, or failure.</p>
capo_payment_cryptography_data.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request was denied due to an invalid resource error.</p>
capo_payment_cryptography_data.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
capo_payment_cryptography_data.errors.validation_exception.ValidationException: <p>The request was denied due to an invalid request error.</p>
capo_payment_cryptography_data.errors.verification_failed_exception.VerificationFailedException: <p>This request failed verification.</p>
capo_payment_cryptography_data.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_payment_cryptography_data.types.verify_mac_input.VerifyMacInput]",
) -> OperationResponse[
"capo_payment_cryptography_data.types.verify_mac_output.VerifyMacOutput"
]:
import capo_payment_cryptography_data._operations.payment_cryptography_data_plane.verify_mac
output, http_response = (
capo_payment_cryptography_data._operations.payment_cryptography_data_plane.verify_mac.verify_mac(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_input(
input_: "capo_payment_cryptography_data.types.verify_mac_input.VerifyMacInput",
) -> dict[str, Any]:
import capo_payment_cryptography_data.types.verify_mac_input
return (
capo_payment_cryptography_data.types.verify_mac_input.redact_sensitive(
input_
)
)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("VerifyMac", redact_input=_redact_input)
)
input_: capo_payment_cryptography_data.types.verify_mac_input.VerifyMacInput = {
"key_identifier": key_identifier,
"message_data": message_data,
"mac": mac,
"verification_attributes": verification_attributes,
}
if mac_length is not None:
input_["mac_length"] = mac_length
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|