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

Lo llama Windows Biometric Framework para recuperar una matriz de identificadores de objeto (OID) que representan los algoritmos hash admitidos por el adaptador del motor.

Sintaxis

PIBIO_ENGINE_QUERY_HASH_ALGORITHMS_FN PibioEngineQueryHashAlgorithmsFn;

HRESULT PibioEngineQueryHashAlgorithmsFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PSIZE_T AlgorithmCount,
  [out]     PSIZE_T AlgorithmBufferSize,
  [out]     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.

[out] AlgorithmCount

Puntero a un valor que recibe el número de cadenas OID de algoritmo en el búfer especificado por el parámetro AlgorithmBuffer .

[out] AlgorithmBufferSize

Puntero a un valor que contiene el tamaño, en bytes, del búfer especificado por el parámetro AlgorithmBuffer . El tamaño incluye los dos valores NULL que finalizan el búfer.

[out] AlgorithmBuffer

Dirección de una variable que recibe un puntero a un búfer que contiene cadenas ANSI empaquetadas terminadas en NULL. Cada cadena representa un OID para un algoritmo hash. La cadena final del búfer debe terminar con dos valores NULL sucesivos.

Valor devuelto

Si la función se realiza 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 la generación de hash de plantillas.

Comentarios

El marco biométrico de Windows usa solo el algoritmo hash SHA1. Por lo tanto, este OID debe incluirse en el búfer. Otras cadenas de OID son opcionales y se pueden incluir para futuras versiones de Windows. En Wincrypt.h, incluido con el Windows SDK, el símbolo del algoritmo SHA1 es szOID_OIWSEC_sha1 y el valor de cadena asociado es "1.3.14.3.2.26". Este valor de cadena debe estar en el búfer. Consulte Wincrypt.h para ver otros valores de OID.

En el ejemplo siguiente se muestra cómo crear un búfer de OID. El algoritmo SHA1 ("1.3.14.3.2.26") se incluye primero, aunque el orden de inclusión no es importante. También se incluye otro algoritmo, szOID_OIWSEC_shaRSA con un valor de "1.3.14.3.2.15". Tenga en cuenta que un único valor NULL identifica el final de cada cadena de OID y que un valor NULL adicional después del final de la última cadena identifica el final del búfer.

char OidBuffer[] = 
{
    '1','.','3','.','1','4','.','3','.','2','.','2','6','\0',
    '1','.','3','.','1','4','.','3','.','2','.','1','5','\0','\0'
};

Si esta función se realiza correctamente, devuelva la dirección del inicio de este búfer en el argumento AlgorithmBuffer . El adaptador del motor posee el búfer. Dado que Windows Biometric Framework lee el búfer, la dirección debe permanecer válida siempre y cuando el adaptador del motor esté conectado a la unidad biométrica.

Normalmente, se compila la tabla de cadenas de OID en el adaptador del motor como un bloque de datos estático.

Ejemplos

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

//////////////////////////////////////////////////////////////////////////////////////////
//
// EngineAdapterQueryHashAlgorithms
// 
//      Retrieves an array of object identifiers (OIDs) that represent the 
//      hash algorithms supported by the engine adapter.
//
// Parameters:
//      Pipeline            - Pointer to a WINBIO_PIPELINE structure associated 
//                            with the biometric unit performing the operation.
//      AlgorithmCount      - Pointer to a value that receives the number of 
//                            algorithm OID strings specified by the 
//                            AlgorithmBuffer parameter.
//      AlgorithmBufferSize - Pointer to a value that contains the size, 
//                            in bytes, of the buffer specified by the 
//                            AlgorithmBuffer parameter.
//      AlgorithmBuffer     - Address of a variable that receives a pointer to 
//                            a buffer that contains packed, NULL-terminated ANSI 
//                            strings. Each string represents an OID for a hash 
//                            algorithm. The final string in the buffer must be 
//                            terminated by two successive NULL values.
//
// Note:
//      The following algorithm table contains the SHA1 OID. Only 
//      the SHA1 hash algorithm is supported by the Windows Biometric Framework.
//      The algorithm table must be defined in global scope for the engine adapter.
//

static char g_HashAlgorithmOidTable[] = 
{
    '1','.','3','.','1','4','.','3','.','2','.','2','6','\0','\0'
};

static HRESULT
WINAPI
EngineAdapterQueryHashAlgorithms(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PSIZE_T AlgorithmCount,
    __out PSIZE_T AlgorithmBufferSize,
    __out PUCHAR *AlgorithmBuffer
    )
{
    ////////////////////////////////////////////////////////////////////////////
    // 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(AlgorithmCount) ||
        !ARGUMENT_PRESENT(AlgorithmBufferSize) ||
        !ARGUMENT_PRESENT(AlgorithmBuffer))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Pass the address and size of the static algorithm table and the number
    // of algorithms to the caller. If your adapter does not support template
    // hashing, return E_NOTIMPL.
    *AlgorithmCount = 1;
    *AlgorithmBufferSize = sizeof(g_HashAlgorithmOidTable);
    *AlgorithmBuffer = g_HashAlgorithmOidTable;

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

EngineAdapterSetHashAlgorithm

Funciones de complemento