PIBIO_ENGINE_GET_ENROLLMENT_HASH_FN コールバック関数 (winbio_adapter.h)

パイプライン内の完成した登録テンプレートのハッシュを取得するために、Windows 生体認証フレームワークによって呼び出されます。

構文

PIBIO_ENGINE_GET_ENROLLMENT_HASH_FN PibioEngineGetEnrollmentHashFn;

HRESULT PibioEngineGetEnrollmentHashFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PUCHAR *HashValue,
  [out]     PSIZE_T HashSize
)
{...}

パラメーター

[in, out] Pipeline

操作を実行する生体認証ユニットに関連付けられている WINBIO_PIPELINE 構造体へのポインター。

[out] HashValue

テンプレートのハッシュを含むバイト配列へのポインターを受け取る変数のアドレス。

[out] HashSize

HashValue パラメーターによって指されるハッシュのサイズをバイト単位で受け取る変数へのポインター。

戻り値

関数が成功した場合は、S_OK を返します。 関数が失敗した場合は、次のいずれかの HRESULT 値を返してエラーを示す必要があります。

リターン コード 説明
E_POINTER
必須のポインター パラメーターは NULL です
E_NOTIMPL
エンジン アダプターでは、テンプレート ハッシュの生成はサポートされていません。
WINBIO_E_INVALID_DEVICE_STATE
パイプラインには、完成した登録テンプレートが含まれていません。

解説

この関数によってハッシュされるテンプレートは、 EngineAdapterCommitEnrollment が呼び出されたときにデータベースに格納される完成した登録テンプレートである必要があります。 中間キャプチャされたサンプルの 1 つをハッシュすることはできません。

テンプレート ハッシュの生成に使用されるアルゴリズムは、このパイプラインで EngineAdapterSetHashAlgorithm への最新の呼び出しによって選択されたアルゴリズムです。

ハッシュを含むメモリは、 EngineAdapterGetEnrollmentHash 関数が正常に返された後、エンジン アダプターによって所有および管理されます。 エンジン アダプターは、フレームワークが次のいずれかの関数を呼び出すまで、バッファー アドレスを有効なままにする必要があります。

エンジン アダプターは、パイプラインごとに個別のハッシュ バッファーを保持する必要もあります。

次の擬似コードは、この関数の 1 つの可能な実装を示しています。 この例はコンパイルされません。 目的に合わせて調整する必要があります。

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterGetEnrollmentHash
//
// Purpose:
//      Retrieves the hash of the completed enrollment template in the pipeline.
//
// Parameters:
//      Pipeline        - Pointer to a WINBIO_PIPELINE structure associated 
//                        with the biometric unit performing the operation
//      HashValue       - Contains the hash of the template
//      HashSize        - Size, in bytes, of the hash pointed to by the 
//                        HashValue parameter
//
static HRESULT
WINAPI
EngineAdapterGetEnrollmentHash(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PUCHAR *HashValue,
    __out PSIZE_T HashSize
    )
{
    ////////////////////////////////////////////////////////////////////////////
    // Return E_NOTIMPL here if your adapter does not support template hashing.
    ////////////////////////////////////////////////////////////////////////////

    HRESULT hr = S_OK;

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

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

    // Return if an enrollment is not in progress. This example assumes that 
    // an enrollment object is part of your engine context structure.
    if (context->Enrollment.InProgress != TRUE)
    {
        hr = WINBIO_E_INVALID_DEVICE_STATE;
        goto cleanup;
    }

    // Initialize the hash.
    *HashValue = NULL;
    *HashSize = 0;

    // If your engine adapter supports template hashing, call a custom function
    // (_AdapterGenerateHashForTemplate) to calculate the hash of the new
    // enrollment template. The hash value should be saved in the adapter
    // context.
    hr = _AdapterGenerateHashForTemplate(
                context,
                context->Enrollment.Template, 
                context->Enrollment.TemplateSize,
                context->HashBuffer,
                &context->HashSize
                );
    if (FAILED(hr))
    {
        goto cleanup;
    }

    // Return the hash to the caller.
    *HashValue = context->HashBuffer;
    *HashSize = context->HashSize;

cleanup:

    return hr;
}

要件

   
サポートされている最小のクライアント Windows 7 [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows Server 2008 R2 [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー winbio_adapter.h (Winbio_adapter.h を含む)

関連項目

プラグイン関数