

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 驗證 PIN 資料
<a name="verify-pin-data"></a>

驗證 PIN 資料函數用於驗證 PIN 是否正確。這通常涉及比較先前存放的接腳值與持卡人在 POI 中輸入的接腳值。這些函數會比較兩個值，而不會公開任一來源的基礎值。

## 使用 PVV 方法驗證加密的 PIN
<a name="verify-pin-data.pvv-example"></a>

**Example**  
在此範例中，我們將驗證指定 PAN 的 PIN。PIN 通常由持卡人或使用者在驗證的交易時間提供，並與檔案上的值進行比較 （持卡人的輸入會以終端機或其他上游提供者的加密值提供）。為了驗證此輸入，也會在執行時間提供下列值：用來加密輸入接腳的金鑰 （通常為 `IWK`)，`PAN`以及要驗證的值 ( `PVV`或 `PIN offset`)。  
如果 AWS 付款密碼編譯能夠驗證 PIN，則會傳回 http/200。如果未驗證 PIN 碼，則會傳回 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",
    
        }
```

## 使用 PVV 方法驗證加密的 PIN 碼 - 錯誤 PIN 碼錯誤
<a name="verify-pin-data.pvv-example.badpin"></a>

**Example**  
在此範例中，我們將嘗試驗證指定 PAN 的 PIN，但由於 PIN 不正確而失敗。  
使用 SDKs時，這會顯示為 {"Message"："Pin 區塊驗證失敗。"，"Reason"："INVALID\_PIN"}  

```
$ 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=9999}" --encrypted-pin-block AC17DC148BDA645E 
```

```
        An error occurred (VerificationFailedException) when calling the VerifyPinData operation: Pin block verification failed. 
```

## 使用 PVV 方法驗證加密的 PIN 碼 - 錯誤輸入錯誤
<a name="verify-pin-data.pvv-example.badkey"></a>

**Example**  
在此範例中，我們將嘗試驗證指定 PAN 的 PIN，但由於輸入錯誤而失敗，而傳入的資料不是有效的 PIN。常見原因是：使用 1/錯誤金鑰 2/輸入參數，例如平移或接腳區塊格式不正確 3/接腳區塊損毀。  

```
$ aws payment-cryptography-data verify-pin-data --verification-key-identifier arn:aws:payment-cryptography:us-east-2:111122223333:key/37y2tsl45p5zjbh2 --encryption-key-identifier  --primary-account-number 171234567890123 --pin-block-format ISO_FORMAT_0  --verification-attributes VisaPin="{PinVerificationKeyIndex=1,VerificationValue=9999}" --encrypted-pin-block AC17DC148BDA645E 
```

```
        An error occurred (ValidationException) when calling the VerifyPinData operation: Pin block provided is invalid. Please check your input to ensure all field values are correct.
```