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 值,以指出錯誤。

傳回碼 Description
E_POINTER
強制指標參數為 NULL
E_NOTIMPL
引擎配接器不支援範本哈希。
E_INVALIDARG
引擎配接器不支援 AlgorithmBuffer 參數所指定的哈希演算法。

備註

Windows 生物特徵辨識架構會呼叫此函式,以在每次將單元新增至感測器集區時設定生物特徵辨識單位。

因為會根據每個管線選取哈希演算法,所以引擎配接器必須將選取的演算法儲存在私人管線內容中。

引擎配接器必須追蹤選取的最新演算法,並在處理對下列函式的呼叫時使用此演算法:

此函式所選擇的演演算法必須保持選取狀態,直到下次呼叫 EngineAdapterSetHashAlgorithm ,或直到呼叫 EngineAdapterDetach 方法為止。 特別是, 對 EngineAdapterClearContext 函式的呼叫不應影響選取的演算法。

Windows 生物特徵辨識架構只會使用 SHA1 哈希演算法。 此演算法的 OID 字串值是 “1.3.14.3.2.26”。 如需詳細資訊,請參閱 EngineAdapterQueryHashAlgorithms

範例

下列虛擬程式代碼顯示此函式的一個可能實作。 此範例不會編譯。 您必須調整它以符合您的用途。

//////////////////////////////////////////////////////////////////////////////////////////
//
// 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

外掛程式函式