ePass1000 C/C++ API Reference Manual Version 2.0

# epas_HashToken

The epas_HashToken function performs a message hash on the currently opened file.

    EPAS_STATUS EPAS_API
    epas_HashToken(
        EPAS_HANDLE hContextHandle,        // [in]
        unsigned long ulFlags,             // [in]
        unsigned long ulRefData,           // [in]
        unsigned char* pucBuffer,          // [in]
        unsigned long ulBufferSize,        // [in]
        unsigned char* pucResponse,        // [out]
        unsigned long ulRespSize,          // [in]
        unsigned long* pulReturnedBytes    // [out]
    );

#### Requirement

epas_CreateContext, epas_OpenDevice, epas_OpenFile

#### Parameters

hContextHandle
  [in] Handle to device context.
ulFlags
  [in] This parameter defines the type of hash to perform as follows:

  Flag | Meaning
  --- | ---
  EPAS_HASH_MD5_HMAC | This flag performs the following on the currently opened file: 1. Initialize the MD5 hash state with the token. 2. If length of input buffer is less than 64 bytes, perform MD5 final padding. 3. Update MD5 hash state with pucBuffer. 4. Return the hash state in the pucResponse buffer. Note: MD5 HMAC requires two files. The first file is the currently opened file, The second file ID is defined in ulRefData.

ulRefData
  [in] This parameter defines the file ID of the second key file. The first key file must be the currently opened file.
pucBuffer
  [in] Point to a buffer that contain challenge input for the hash operation, and not exceed 55 bytes.
ulBufferSize
  [in] Defines the number of bytes in the pucBuffer, and not exceed 55 bytes.
pucResponse
  [out] Point to a buffer that receives result of the hash operation .
ulRespSize
  [in] Defines the size of the pucResponse buffer.
pulReturnedBytes
  [out] Pointer to an unsigned long integer that receives the number of bytes the digest returned.

#### Remarks

The size of the challenge input which pointed by pucBuffer cannot exceed 55 bytes.

#### Return Values

If the function succeeds, FT_SUCCESS returned.

If appropriate file access has not granted or no opened file, FT_ACCESS_DENIED returned.

For a list of all return codes, see Status Return Values.

#### See Also

epas_GenRandom, epas_MD5_HMAC