Share via


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

後続の操作で使用するハッシュ アルゴリズムを選択するために、Windows 生体認証フレームワークによって呼び出されます。

構文

PIBIO_ENGINE_SET_HASH_ALGORITHM_FN PibioEngineSetHashAlgorithmFn;

HRESULT PibioEngineSetHashAlgorithmFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [in]      SIZE_T AlgorithmBufferSize,
  [in]      PUCHAR AlgorithmBuffer
)
{...}

パラメーター

[in, out] Pipeline

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

[in] AlgorithmBufferSize

AlgorithmBuffer パラメーターで指定されたバッファーのサイズ (バイト単位)。

[in] AlgorithmBuffer

選択するハッシュ アルゴリズムのオブジェクト識別子を含む NULL で終わる ANSI 文字列へのポインター。 EngineAdapterQueryHashAlgorithms 関数を呼び出して、サポートされているアルゴリズム オブジェクト識別子 (OID) の配列を取得します。

戻り値

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

リターン コード 説明
E_POINTER
必須のポインター パラメーターは NULL です
E_NOTIMPL
エンジン アダプターはテンプレート ハッシュをサポートしていません。
E_INVALIDARG
エンジン アダプターは、 AlgorithmBuffer パラメーターで指定されたハッシュ アルゴリズムをサポートしていません。

注釈

Windows 生体認証フレームワークは、この関数を呼び出して、ユニットがセンサー プールに追加されるたびに生体認証ユニットを構成します。

ハッシュ アルゴリズムはパイプラインごとに選択されるため、エンジン アダプターは選択したアルゴリズムをプライベート パイプライン コンテキストに格納する必要があります。

エンジン アダプターは、選択された最新のアルゴリズムを追跡し、次の関数の呼び出しを処理するときにこのアルゴリズムを使用する必要があります。

この関数によって選択されるアルゴリズムは、次に EngineAdapterSetHashAlgorithm が呼び出されるか、 EngineAdapterDetach メソッドが呼び出されるまで選択されたままになります。 特に、 EngineAdapterClearContext 関数の呼び出しは、選択したアルゴリズムに影響を与えるべきではありません。

SHA1 ハッシュ アルゴリズムのみが Windows 生体認証フレームワークで使用されます。 このアルゴリズムの OID 文字列値は "1.3.14.3.2.26" です。 詳細については、「 EngineAdapterQueryHashAlgorithms」を参照してください。

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

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterSetHashAlgorithm
//
// Purpose:
//      Selects a hash algorithm for use in subsequent operations.
//
// Parameters:
//      Pipeline            - Pointer to a WINBIO_PIPELINE structure associated 
//                            with the biometric unit performing the operation.   
//      AlgorithmBufferSize - Size, in bytes, of the buffer specified by the 
//                            AlgorithmBuffer parameter.
//      AlgorithmBuffer     - Pointer to a NULL-terminated ANSI string that 
//                            contains the object identifier of the hash algorithm
//                            to select.
//
static HRESULT
WINAPI
EngineAdapterSetHashAlgorithm(
    __inout PWINBIO_PIPELINE Pipeline,
    __in SIZE_T AlgorithmBufferSize,
    __in PUCHAR AlgorithmBuffer
    )
{
    ////////////////////////////////////////////////////////////////////////////
    // Return E_NOTIMPL here if your adapter does not support template hashing.
    ////////////////////////////////////////////////////////////////////////////

    HRESULT hr = S_OK;
    SIZE_T algorithmSize = (strlen(szOID_OIWSEC_sha1) + 1) * sizeof(CHAR);

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

    // Only the SHA1 hashing algorithm is supported.
    // Therefore, make certain that SHA1 is included in the algorithm
    // table.
    // The SHA1 object identifier, szOID_OIWSEC_sha1, is contained in the
    // Wincrypt.h header file.
    if (AlgorithmBufferSize != algorithmSize ||
        memcmp(AlgorithmBuffer, szOID_OIWSEC_sha1, algorithmSize) != 0)
    {
        hr = E_INVALIDARG;
        goto cleanup;
    }

    // Make any necessary changes to the adapter state to specify that
    // SHA1 hashing is enabled. If your adapter does not support template
    // hashing, return E_NOTIMPL.

cleanup:
    
    return hr;
}

要件

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

こちらもご覧ください

EngineAdapterQueryHashAlgorithms

プラグイン関数