Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Una firma MAC è un'uscita crittografica utilizzata per verificare l'integrità e l'autenticità dei dati. Un algoritmo di firma MAC consente di eseguire due operazioni distinte:
Un'operazione di firma che utilizza una chiave di firma per produrre una firma MAC sui dati non elaborati.
Un'operazione di verifica in cui l'autenticità del messaggio può essere convalidata in base alla chiave di firma e al tag MAC da verificare.
Una firma MAC ha due scopi principali:
Verificare l'integrità dei dati firmati.
Verifica l'autenticità del messaggio.
Sebbene lo scopo delle firme MAC sia simile a quello delle firme digitali,
le firme MAC si basano sulla crittografia simmetrica. I tag MAC vengono generati e verificati utilizzando la stessa chiave segreta. Per utilizzare le firme MAC, sia il mittente sia il destinatario di un messaggio devono avere la stessa chiave.
Esempio di caso d'uso per una firma MAC
Gli algoritmi MAC come il codice di autenticazione messaggio con hash basato su chiave (HMAC) sono un eccellente meccanismo di controllo dell'integrità dei dati di trasferimento dei file grazie alla loro efficienza. Le funzioni hash possono prendere un messaggio di lunghezza arbitraria e trasformarlo in un digest di lunghezza fissa, massimizzando così l'utilizzo della larghezza di banda.
Flusso di lavoro di firma MAC
Di seguito è descritto il flusso per la creazione e la convalida di una firma. I due partecipanti a questo flusso di lavoro sono il firmatario dei dati e il destinatario dei dati.
Il firmatario e il destinatario concordano sull'utilizzo di una chiave MAC specifica e condivisa.
Entrambi possono utilizzare questa chiave per creare o verificare le firme MAC.
Il firmatario esegue un'operazione di firma sui dati per calcolare un tag MAC.
Il firmatario fornisce i dati e il tag MAC al destinatario dei dati.
Il destinatario utilizza la chiave MAC condivisa per verificare la firma MAC. Se la verifica non va a buon fine, significa che i dati sono stati alterati.
Algoritmi di firma
Cloud Key Management Service supporta solo gli algoritmi HMAC (Keyed-Hash Message Authentication Code) per la firma MAC. Gli algoritmi HMAC utilizzano funzioni di hash crittografica, come SHA-2 o SHA-3, per calcolare il tag MAC. La sicurezza della funzione HMAC dipende dalla sicurezza della funzione di hashing, dalle dimensioni dell'output dell'hash e dalle dimensioni della chiave. Per ulteriori informazioni sugli algoritmi di firma HMAC, consulta Algoritmi di firma HMAC.
Limitazioni
Quando utilizzi Cloud KMS per le firme MAC, la dimensione massima del file è 16 KiB per le chiavi Cloud HSM e 64 KiB per tutte le altre chiavi.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-02 UTC."],[],[],null,["# MAC signatures\n\nA *MAC signature* is a cryptographic output used to verify the integrity and\nauthenticity of data. A MAC signature algorithm lets you perform two distinct\noperations:\n\n- A signing operation, which uses a signing key to produce a MAC signature\n over raw data.\n\n- A verification operation, where the authenticity of the message can be\n validated given the signing key and the MAC tag to be verified.\n\nThere are two main purposes of a MAC signature:\n\n- Verify the integrity of the signed data.\n- Verify the authenticity of the message.\n\nWhile the purpose of MAC signatures is similar to that of digital signatures,\nMAC signatures rely on symmetric cryptography. MAC tags are generated and\nverified using the same secret key. The sender and the receiver of\na message must both have the same key to use MAC signatures.\n| **Note:** Since the sender and the receiver have the same cryptographic material, you can't use MAC tags to prove which of the two signed the file. If you need to be able to verify that the message was signed by the sender, use [digital signatures based on asymmetric keys](/kms/docs/digital-signatures) instead.\n\nExample use case for a MAC signature\n------------------------------------\n\nMAC algorithms like keyed-hash message authentication code (HMAC) are an\nexcellent file transfer data integrity-checking mechanism because of their\nefficiency. Hash functions can take a message of arbitrary length and transform\nit into a fixed-length digest, thus maximizing bandwidth usage.\n\nMAC signing workflow\n--------------------\n\nThe following describes the flow for creating and validating a signature. The\ntwo participants in this workflow consist of the signer of data, and the data\nrecipient.\n\n1. The signer and the recipient agree on using a specific, shared MAC key.\n\n Both can use this key to create or verify MAC signatures.\n2. The signer performs a sign operation over the data to compute a MAC tag.\n\n3. The signer provides the data and the MAC tag to the data recipient.\n\n4. The recipient uses the shared MAC key to verify the MAC signature. If\n verification is unsuccessful, then the data has been altered.\n\nSigning algorithms\n------------------\n\nCloud Key Management Service only supports keyed-hash message authentication code (HMAC)\nalgorithms for MAC signing. HMAC algorithms use cryptographic hash functions,\nsuch as SHA-2 or SHA-3, to compute the MAC tag. The strength of the HMAC\nfunction depends on the strength of the hash function, the size of the hash\noutput, and the size of the key. For more information about HMAC signing\nalgorithms, see [HMAC signing\nalgorithms](/kms/docs/algorithms#mac_signing_algorithms).\n\nLimitations\n-----------\n\nWhen using Cloud KMS for MAC signatures, the maximum file size is 16 KiB for Cloud HSM keys and 64 KiB for all other keys.\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn about [HMAC signing algorithms](/kms/docs/algorithms#hmac_signing_algorithms).\n- [Create a key](/kms/docs/creating-keys) with the [`MAC`](/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose.ENUM_VALUES.MAC) key purpose and an [HMAC signing algorithm](/kms/docs/algorithms#hmac_signing_algorithms).\n- [Create a MAC signature](/kms/docs/create-validate-mac-signatures#create_mac_signature) using an existing `MAC` key with a message.\n- [Verify a MAC signature](/kms/docs/create-validate-mac-signatures#verify_mac_signature) using an existing `MAC` key with a message and its signature."]]