FmCreateHashObject
Synopsis
#include “fmciphobj.h”
HashObj * FmCreateHashObject(FMCO_HashObjIndex index);
Description
Returns the address of a hash object for digest operations.
Parameters
Option |
Description |
---|---|
index
|
The type of hash object requested. It can have the following values (defined in fmciphobj.h): >FMCO_IDX_MD2: Implementation of the MD-2 algorithm >FMCO_IDX_MD5: Implementation of the MD-5 algorithm >FMCO_IDX_RMD128: Implementation of the RIPEMD-128 algorithm >FMCO_IDX_RMD160: Implementation of the RIPEMD-160 algorithm >FMCO_IDX_SHA1: Implementation of the SHA-1 algorithm >FMCO_IDX_SHA256: Implementation of the SHA256 algorithm >FMCO_IDX_SHA384: Implementation of the SHA384 algorithm >FMCO_IDX_SHA512: Implementation of the SHA512 algorithm This list is correct at time of writing; the actual number of objects supported depends on the HSM firmware version. |
Operations supported
>Init
Data Block Size
Any
Return Value
The address of the hash object is returned. If the system doesn’t have enough memory to complete operation, NULL is returned.
Comments
The returned hash object should be freed by calling its Free() function (See Free).
NOTE It is the Operating System firmware that provides the HashObject – not the FM SDK. As new versions of OS firmware are developed and released more HashObjects may be added to the list of supported algorithms. Therefore a firmware upgrade may be required to obtain a particular Hash Algorithm.
Example
{
char buf[100];
char hash[100];
int lenOut;
HashObj *o = FmCreateHashObject(FMCO_IDX_SHA1);
If ( o == NULL )
Return error;
o->Init(o);
o->Update(o, data, len);
o->Final(o, hash, sizeof(hash), &lenOut);
o->Free(o);
}