PIBIO_ENGINE_VERIFY_FEATURE_SET_FN回调函数 (winbio_adapter.h)

由 Windows 生物识别框架调用,将当前功能集中的模板与数据库中的特定模板进行比较。 如果模板是等效的,引擎适配器必须将 Match 参数指向的布尔值设置为 TRUE,在 PayloadBlob 参数中返回匹配的模板,并在 HashValue 参数中返回模板的哈希。

Syntax

PIBIO_ENGINE_VERIFY_FEATURE_SET_FN PibioEngineVerifyFeatureSetFn;

HRESULT PibioEngineVerifyFeatureSetFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [in]      PWINBIO_IDENTITY Identity,
  [in]      WINBIO_BIOMETRIC_SUBTYPE SubFactor,
  [out]     PBOOLEAN Match,
  [out]     PUCHAR *PayloadBlob,
  [out]     PSIZE_T PayloadBlobSize,
  [out]     PUCHAR *HashValue,
  [out]     PSIZE_T HashSize,
  [out]     PWINBIO_REJECT_DETAIL RejectDetail
)
{...}

参数

[in, out] Pipeline

指向与执行作的生物识别单元关联的 WINBIO_PIPELINE 结构的指针。

[in] Identity

指向包含应与从数据库恢复的模板匹配的 GUID 或 SID 的 WINBIO_IDENTITY 结构的指针。

[in] SubFactor

个WINBIO_BIOMETRIC_SUBTYPE 值,该值应与从数据库恢复的模板的值匹配。 有关更多详细信息,请参阅“备注”部分。

[out] Match

指向布尔值的指针,该值指定 IdentitySubFactor 参数是否与从数据库恢复的模板匹配。 TRUE 指定这些值匹配。

[out] PayloadBlob

接收指向使用模板保存的有效负载数据的指针的变量的地址。 如果没有有效负载数据,请将此值设置为 NULL

[out] PayloadBlobSize

指向接收 PayloadBlob 参数中指定的缓冲区大小(以字节为单位)的值的指针。 如果没有使用模板存储的有效负载数据,请将此值设置为零。

[out] HashValue

接收指向模板哈希的指针的变量的地址。 如果引擎适配器不支持哈希生成,请将此值设置为 NULL

[out] HashSize

指向包含 HashValue 参数所指定的哈希大小(以字节为单位)的值的指针。 如果引擎适配器不支持哈希生成,请将此值设置为零。

[out] RejectDetail

指向在捕获失败阻止引擎执行匹配作时接收其他信息的 WINBIO_REJECT_DETAIL 值的指针。 如果最新捕获成功,请将此参数设置为零。 为指纹捕获定义了以下值

  • WINBIO_FP_TOO_HIGH
  • WINBIO_FP_TOO_LOW
  • WINBIO_FP_TOO_LEFT
  • WINBIO_FP_TOO_RIGHT
  • WINBIO_FP_TOO_FAST
  • WINBIO_FP_TOO_SLOW
  • WINBIO_FP_POOR_QUALITY
  • WINBIO_FP_TOO_SKEWED
  • WINBIO_FP_TOO_SHORT
  • WINBIO_FP_MERGE_FAILURE

返回值

如果函数成功,它将返回S_OK。 如果函数失败,则它必须返回以下 HRESULT 值之一来指示错误。

返回代码 Description
E_POINTER
必需指针参数为 NULL
E_INVALIDARG
SubFactor 参数中指定的值不正确。
WINBIO_E_BAD_CAPTURE
功能集不符合用于验证作的引擎适配器的内部要求。 有关失败的详细信息由 RejectDetail 参数指定。
WINBIO_E_NO_MATCH
管道中的功能集与存储在数据库中的功能匹配,但它与 标识SubFactor 参数中传递的值的组合不对应。

注解

SubFactor 参数指定与生物识别模板关联的子因素。 Windows 生物识别框架仅支持指纹捕获,并且可以使用以下常量来表示子类型信息。

  • WINBIO_ANSI_381_POS_RH_THUMB
  • WINBIO_ANSI_381_POS_RH_INDEX_FINGER
  • WINBIO_ANSI_381_POS_RH_MIDDLE_FINGER
  • WINBIO_ANSI_381_POS_RH_RING_FINGER
  • WINBIO_ANSI_381_POS_RH_LITTLE_FINGER
  • WINBIO_ANSI_381_POS_LH_THUMB
  • WINBIO_ANSI_381_POS_LH_INDEX_FINGER
  • WINBIO_ANSI_381_POS_LH_MIDDLE_FINGER
  • WINBIO_ANSI_381_POS_LH_RING_FINGER
  • WINBIO_ANSI_381_POS_LH_LITTLE_FINGER
  • WINBIO_SUBTYPE_ANY
重要说明  

不要尝试验证为 SubFactor 参数提供的值。 Windows 生物识别服务将验证提供的值,然后再将其传递给你的实现。 如果值 是WINBIO_SUBTYPE_NO_INFORMATIONWINBIO_SUBTYPE_ANY,则验证适当的位置。

 
用于生成模板哈希的算法是此管道上最近调用对 EngineAdapterSetHashAlgorithm 函数选择的算法。

此函数返回的哈希值(如果有)是在数据库中找到的注册模板的哈希,而不是附加到管道的匹配模板。

EngineAdapterIdentifyFeatureSet 函数成功返回后,PayloadBlobHashValue 缓冲区由引擎适配器拥有和管理。 引擎适配器必须使缓冲区地址对此管道有效,直到下一次调用 EngineAdapterClearContext

例子

以下伪代码显示了此函数的一个可能实现。 该示例未编译。 你必须适应你的目的。

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterVerifyFeatureSet
//
// Purpose:
//      Compares the template in the current feature set with a specific 
//      template in the database.
//      
// Parameters:
//      Pipeline        - Pointer to a WINBIO_PIPELINE structure associated 
//                        with the biometric unit performing the operation
//      Identity        - GUID or SID that is expected to match that of the 
//                        template recovered from the database
//      SubFactor       - A WINBIO_BIOMETRIC_SUBTYPE value that is expected 
//                        to match that of the template recovered from the 
//                        database
//      Match           - A Boolean value that specifies whether the Identity 
//                        and SubFactor parameters match those of the template
//                        recovered from the database
//      PayloadBlob     - Payload data saved with the template
//      PayloadBlobSize - Size, in bytes, of the buffer specified in the 
//                        PayloadBlob parameter
//      HashValue       - Hash of the template
//      HashSize        - Size, in bytes, of the hash specified by the 
//                        HashValue parameter
//      RejectDetail    - Receives additional information if a capture failure 
//                        prevents the engine from performing a matching operation
// 
static HRESULT
WINAPI
EngineAdapterVerifyFeatureSet(
    __inout PWINBIO_PIPELINE Pipeline,
    __in PWINBIO_IDENTITY Identity,
    __in WINBIO_BIOMETRIC_SUBTYPE SubFactor,
    __out PBOOLEAN Match,
    __out PUCHAR *PayloadBlob,
    __out PSIZE_T PayloadBlobSize,
    __out PUCHAR *HashValue,
    __out PSIZE_T HashSize,
    __out PWINBIO_REJECT_DETAIL RejectDetail
    )
{
    HRESULT hr = S_OK;
    WINBIO_STORAGE_RECORD thisRecord;
    BOOLEAN match = FALSE;
    WINBIO_REJECT_DETAIL rejectDetail = 0;

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(Identity) ||
        !ARGUMENT_PRESENT(Match) ||
        !ARGUMENT_PRESENT(PayloadBlob) ||
        !ARGUMENT_PRESENT(PayloadBlobSize) ||
        !ARGUMENT_PRESENT(HashValue) ||
        !ARGUMENT_PRESENT(HashSize) ||
        !ARGUMENT_PRESENT(RejectDetail))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline.
    PWINBIO_ENGINE_CONTEXT context = 
           (PWINBIO_ENGINE_CONTEXT)Pipeline->EngineContext;

    // Initialize the return values.
    *Match              = FALSE;
    *PayloadBlob        = NULL;
    *PayloadBlobSize    = 0;
    *HashValue          = NULL;
    *HashSize           = 0;
    *RejectDetail       = 0;

    // The biometric unit cannot perform verification or identification
    // operations while it is performing an enrollment sequence.
    if (context->Enrollment.InProgress == TRUE)
    {
        hr = WINBIO_E_ENROLLMENT_IN_PROGRESS;
        goto cleanup;
    }

    // Query the storage adapter to determine whether the Identity and 
    // SubFactor combination specified on input are in the database. If
    // they are not, there can be no match. WbioStorageQueryBySubject
    // is a wrapper function defined in the Winbio_adapter.h header file.
    hr = WbioStorageQueryBySubject( Pipeline, Identity, SubFactor);
    if (FAILED(hr))
    {
        if (hr == WINBIO_E_DATABASE_NO_RESULTS)
        {
            hr = WINBIO_E_NO_MATCH;
        }
        goto cleanup;
    }

    // Position the cursor on the first record in the database. 
    // WbioStorageFirstRecord is a wrapper function defined in the 
    // Winbio_adapter.h header file.
    hr = WbioStorageFirstRecord( Pipeline );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Retrieve the current template record for the Identity and SubFactor 
    // combination specified on input. 
    hr = WbioStorageGetCurrentRecord( Pipeline, &thisRecord );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Call a custom function (_AdapterCompareTemplateToCurrentFeatureSet)
    // to compare the feature set attached to the pipeline with the template 
    // retrieved from the database.
    // If the template and feature set do not match, return WINBIO_E_NO_MATCH
    // and set the Match parameter to FALSE.
    // If your custom function cannot process the feature set, return 
    // WINBIO_E_BAD_CAPTURE and set extended error information in the 
    // RejectDetail parameter.
    hr = _AdapterCompareTemplateToCurrentFeatureSet( 
                context, 
                context->FeatureSet,
                context->FeatureSetSize,
                thisRecord.TemplateBlob, 
                thisRecord.TemplateBlobSize,
                &match,
                RejectDetail 
                );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // If there is a match and if your engine adapter supports template
    // hashing, call a custom function (_AdapterGenerateHashForTemplate)
    // to calculate the hash. Save the hash value in the context area of
    // the engine adapter.
    // Skip this step if your adapter does not support template hashing.
    hr = _AdapterGenerateHashForTemplate(
                context,
                thisRecord.TemplateBlob, 
                thisRecord.TemplateBlobSize,
                context->HashBuffer,
                &context->HashSize
                );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Set the return values.
    *Match              = TRUE;
    *PayloadBlob        = thisRecord.PayloadBlob;
    *PayloadBlobSize    = thisRecord.PayloadBlobSize;
    *HashValue          = &context->HashBuffer;
    *HashSize           = context->HashSize;

cleanup:

    if (hr == WINBIO_E_DATABASE_NO_RESULTS)
    {
        hr = WINBIO_E_NO_MATCH;
    }

    return hr;
}

要求

Requirement 价值
最低支持的客户端 Windows 7 [仅限桌面应用]
支持的最低服务器 Windows Server 2008 R2 [仅限桌面应用]
目标平台 Windows操作系统
Header winbio_adapter.h (包括 Winbio_adapter.h)

另请参阅

EngineAdapterIdentifyFeatureSet

插件函数