View a markdown version of this page

Genera un pin casuale e il PVV associato, quindi verifica il valore - AWS Crittografia dei pagamenti

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Genera un pin casuale e il PVV associato, quindi verifica il valore

Crea la/e chiave/i

Per generare un pin casuale e il PVV, sono necessarie due chiavi, una PIN Verification Key (PVK) per generare il PVV e una PIN Encryption Key per crittografare il pin. Il pin stesso viene generato casualmente in modo sicuro all'interno del servizio e non è correlato crittograficamente a nessuna delle due chiavi.

Il PGK deve essere una chiave dell'algoritmo TDES_2KEY basato sull'algoritmo PVV stesso. Un PEK può essere TDES_2KEY, TDES_3KEY o AES_128. In questo caso, poiché il PEK è destinato all'uso interno del sistema, AES_128 sarebbe una buona scelta. Se un PEK viene utilizzato per l'interscambio con altri sistemi (ad esempio reti di carte, acquirer, ATM) o viene spostato nell'ambito di una migrazione, TDES_2KEY potrebbe essere la scelta più appropriata per motivi di compatibilità.

Crea il PEK

$ aws payment-cryptography create-key \ --exportable --key-attributes KeyAlgorithm=AES_128,KeyUsage=TR31_P0_PIN_ENCRYPTION_KEY,\ KeyClass=SYMMETRIC_KEY,\ KeyModesOfUse='{Encrypt=true,Decrypt=true,Wrap=true,Unwrap=true}' --tags='[{"Key":"CARD_BIN","Value":"12345678"}]'

La risposta riprende i parametri della richiesta, incluso un ARN per le chiamate successive e un Key Check Value (KCV).

{ "Key": { "KeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt", "KeyAttributes": { "KeyUsage": "TR31_P0_PIN_ENCRYPTION_KEY", "KeyClass": "SYMMETRIC_KEY", "KeyAlgorithm": "AES_128", "KeyModesOfUse": { "Encrypt": false, "Decrypt": false, "Wrap": false, "Unwrap": false, "Generate": true, "Sign": false, "Verify": true, "DeriveKey": false, "NoRestrictions": false } }, "KeyCheckValue": "7CC9E2", "KeyCheckValueAlgorithm": "CMAC", "Enabled": true, "Exportable": true, "KeyState": "CREATE_COMPLETE", "KeyOrigin": "AWS_PAYMENT_CRYPTOGRAPHY", "CreateTimestamp": "2023-06-05T06:41:46.648000-07:00", "UsageStartTimestamp": "2023-06-05T06:41:46.626000-07:00" } }

Prendi nota di KeyArn ciò che rappresenta la chiave, ad esempio arn:aws:payment-cryptography:us-east- 2:111122223333:. key/ivi5ksfsuplneuyt Ne avrai bisogno nel passaggio successivo.

Crea il PVK

$ aws payment-cryptography create-key --exportable --key-attributes KeyAlgorithm=TDES_2KEY,KeyUsage=TR31_V2_VISA_PIN_VERIFICATION_KEY,KeyClass=SYMMETRIC_KEY,KeyModesOfUse='{Generate=true,Verify=true}' --tags='[{"Key":"CARD_BIN","Value":"12345678"}]'

La risposta riprende i parametri della richiesta, incluso un ARN per le chiamate successive e un Key Check Value (KCV).

{ "Key": { "KeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ov6icy4ryas4zcza", "KeyAttributes": { "KeyUsage": "TR31_V2_VISA_PIN_VERIFICATION_KEY", "KeyClass": "SYMMETRIC_KEY", "KeyAlgorithm": "TDES_2KEY", "KeyModesOfUse": { "Encrypt": false, "Decrypt": false, "Wrap": false, "Unwrap": false, "Generate": true, "Sign": false, "Verify": true, "DeriveKey": false, "NoRestrictions": false } }, "KeyCheckValue": "51A200", "KeyCheckValueAlgorithm": "ANSI_X9_24", "Enabled": true, "Exportable": true, "KeyState": "CREATE_COMPLETE", "KeyOrigin": "AWS_PAYMENT_CRYPTOGRAPHY", "CreateTimestamp": "2023-06-05T06:41:46.648000-07:00", "UsageStartTimestamp": "2023-06-05T06:41:46.626000-07:00" } }

Prendi nota di KeyArn ciò che rappresenta la chiave, ad esempio arn:aws:payment-cryptography:us-east- 2:111122223333:. key/ov6icy4ryas4zcza Ne avrai bisogno nel passaggio successivo.

Genera un PIN casuale, genera PVV e restituisci il PIN crittografato e il PVV

Esempio

In questo esempio, genereremo un nuovo pin (casuale) a 4 cifre in cui le uscite saranno crittografate PIN block (PinData.PinBlock) e (pin). PVV Data.VerificationValue Gli input chiave sono PAN il formato Pin Verification Key (noto anche come chiave di generazione del pin), Pin Encryption Key e il formato PIN Block.

Questo comando richiede che la chiave sia di tipoTR31_V2_VISA_PIN_VERIFICATION_KEY.

$ aws payment-cryptography-data generate-pin-data --generation-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2 --encryption-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt --primary-account-number 171234567890123 --pin-block-format ISO_FORMAT_0 --generation-attributes VisaPin={PinVerificationKeyIndex=1}
{ "GenerationKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2", "GenerationKeyCheckValue": "7F2363", "EncryptionKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt", "EncryptionKeyCheckValue": "7CC9E2", "EncryptedPinBlock": "AC17DC148BDA645E", "PinData": { "VerificationValue": "5507" } }

Convalida il PIN crittografato utilizzando il metodo PVV

Esempio

In questo esempio, convalideremo un PIN per un determinato PAN. Il PIN viene in genere fornito dal titolare della carta o dall'utente durante il momento della transazione per la convalida e viene confrontato con il valore in archivio (l'input del titolare della carta viene fornito come valore crittografato dal terminale o da un altro provider upstream). Per convalidare questo input, verranno forniti anche i seguenti valori in fase di esecuzione: il pin crittografato, la chiave utilizzata per crittografare il pin di input (spesso indicato come IWK) PAN e il valore da verificare (a PVV oPIN offset).

Se AWS Payment Cryptography è in grado di convalidare il PIN, viene restituito un. http/200 Se il PIN non viene convalidato, restituirà un. http/400

$ aws payment-cryptography-data verify-pin-data --verification-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2 --encryption-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt --primary-account-number 171234567890123 --pin-block-format ISO_FORMAT_0 --verification-attributes VisaPin="{PinVerificationKeyIndex=1,VerificationValue=5507}" --encrypted-pin-block AC17DC148BDA645E
{ "VerificationKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2", "VerificationKeyCheckValue": "7F2363", "EncryptionKeyArn": "arn:aws:payment-cryptography:us-east-2:111122223333:key/ivi5ksfsuplneuyt", "EncryptionKeyCheckValue": "7CC9E2", }