checkLicenseBufferWithCard static method

Uint8List checkLicenseBufferWithCard(
  1. Uint8List? licenseData
)

Checks the license using a buffer containing the license data and a card-based verification process. It outputs a challenge response for further verification.

param licenseData A buffer containing the license file data. return An array to hold the challenge response generated by the host. throws FaceException An error has occurred during Face Library execution.

Implementation

static Uint8List checkLicenseBufferWithCard(Uint8List? licenseData) {
  Pointer<UnsignedChar>? pLicenseData;
  if (licenseData != null) {
  	pLicenseData = calloc.allocate<UnsignedChar>(licenseData.length);
  	pLicenseData.cast<Uint8>().asTypedList(licenseData.length).setAll(0, licenseData);
  }
  Pointer<UnsignedChar> pChallengeR1 = calloc.allocate(16);
  Pointer<Int> pChallengeR1Size = calloc.allocate(1);
  pChallengeR1Size[0] = 16;
  try {
    var err = faceSDK.id3FaceLicense_CheckLicenseBufferWithCard(pLicenseData ?? nullptr, licenseData?.length ?? 0, pChallengeR1, pChallengeR1Size);
    if (err == FaceError.insufficientBuffer.value) {
      calloc.free(pChallengeR1);
      pChallengeR1 = calloc.allocate(pChallengeR1Size.value);
      err = faceSDK.id3FaceLicense_CheckLicenseBufferWithCard(pLicenseData ?? nullptr, licenseData?.length ?? 0, pChallengeR1, pChallengeR1Size);
    }
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vChallengeR1 = Uint8List.fromList(pChallengeR1.cast<Uint8>().asTypedList(pChallengeR1Size.value));
    return vChallengeR1;
  } finally {
    if (pLicenseData != null) {
      calloc.free(pLicenseData);
    }
    calloc.free(pChallengeR1);
    calloc.free(pChallengeR1Size);
  }
}