PIBIO_ENGINE_SET_HASH_ALGORITHM_FN función de devolución de llamada (winbio_adapter.h)

Llamado por Windows Biometric Framework para seleccionar un algoritmo hash para su uso en las operaciones posteriores.

Sintaxis

PIBIO_ENGINE_SET_HASH_ALGORITHM_FN PibioEngineSetHashAlgorithmFn;

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

Parámetros

[in, out] Pipeline

Puntero a una estructura de WINBIO_PIPELINE asociada a la unidad biométrica que realiza la operación.

[in] AlgorithmBufferSize

Tamaño, en bytes, del búfer especificado por el parámetro AlgorithmBuffer .

[in] AlgorithmBuffer

Puntero a una cadena ANSI terminada en NULL que contiene el identificador de objeto del algoritmo hash que se va a seleccionar. Llame a la función EngineAdapterQueryHashAlgorithms para recuperar una matriz de los identificadores de objeto de algoritmo admitidos (OID).

Valor devuelto

Si la función se ejecuta correctamente, devuelve S_OK. Si se produce un error en la función, debe devolver uno de los siguientes valores HRESULT para indicar el error.

Código devuelto Descripción
E_POINTER
Un parámetro de puntero obligatorio es NULL.
E_NOTIMPL
El adaptador del motor no admite el hash de plantillas.
E_INVALIDARG
El adaptador del motor no admite el algoritmo hash especificado por el parámetro AlgorithmBuffer .

Comentarios

Windows Biometric Framework llama a esta función para configurar una unidad biométrica cada vez que la unidad se agrega a un grupo de sensores.

Dado que se selecciona un algoritmo hash por canalización, el adaptador del motor debe almacenar el algoritmo seleccionado en un contexto de canalización privada.

El adaptador del motor debe realizar un seguimiento del algoritmo más reciente seleccionado y usar este algoritmo al procesar llamadas a las siguientes funciones:

El algoritmo elegido por esta función debe permanecer seleccionado hasta la próxima vez que se llame a EngineAdapterSetHashAlgorithm o hasta que se llame al método EngineAdapterDetach . En concreto, las llamadas a la función EngineAdapterClearContext no deben afectar al algoritmo seleccionado.

Solo el marco biométrico de Windows usa el algoritmo hash SHA1. El valor de cadena OID para este algoritmo es "1.3.14.3.2.26". Para obtener más información, vea EngineAdapterQueryHashAlgorithms.

Ejemplos

El siguiente pseudocódigo muestra una posible implementación de esta función. El ejemplo no se compila. Debes adaptarlo para que se adapte a tu propósito.

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

Requisitos

Requisito Value
Cliente mínimo compatible Windows 7 [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows Server 2008 R2 [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado winbio_adapter.h (incluya Winbio_adapter.h)

Consulte también

EngineAdapterQueryHashAlgorithms

Funciones de complemento