/* The initiator checks the CHAP response replied by target against its own calculation of the expected hash value. */
EFI_STATUS IScsiCHAPAuthTarget(IN ISCSI_CHAP_AUTH_DATA *AuthData, IN UINT8 *TargetResponse)
/* The initiator checks the CHAP response replied by target against its own calculation of the expected hash value. */
EFI_STATUS IScsiCHAPAuthTarget(IN ISCSI_CHAP_AUTH_DATA *AuthData, IN UINT8 *TargetResponse)
{
  EFI_STATUS  Status;
  UINT32      SecretSize;
  UINT8       VerifyRsp[ISCSI_CHAP_MAX_DIGEST_SIZE];
  INTN        Mismatch;
  Status = EFI_SUCCESS;
  SecretSize = (UINT32)AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
  ASSERT (AuthData->Hash != NULL);
  Status = IScsiCHAPCalculateResponse (
             AuthData->OutIdentifier,
             AuthData->AuthConfig->ReverseCHAPSecret,
             SecretSize,
             AuthData->OutChallenge,
             AuthData->Hash->DigestSize,
             AuthData->Hash,
             VerifyRsp
             );
  Mismatch = CompareMem (
               VerifyRsp,
               TargetResponse,
               AuthData->Hash->DigestSize
               );
  if (Mismatch != 0) {
    Status = EFI_SECURITY_VIOLATION;
  }
  return Status;
}