Guardtime KSI c SDK
Typedefs | Functions
Util

Typedefs

typedef struct KSI_HmacHasher_st KSI_HmacHasher
 

Functions

int KSI_base32Decode (const char *base32, unsigned char **data, size_t *data_len)
 
int KSI_base32Encode (const unsigned char *data, size_t data_len, size_t group_len, char **encoded)
 
unsigned long KSI_crc32 (const void *data, size_t length, unsigned long ival)
 
int KSI_HMAC_create (KSI_CTX *ctx, KSI_HashAlgorithm algo_id, const char *key, const unsigned char *data, size_t data_len, KSI_DataHash **hmac)
 
int KSI_HmacHasher_open (KSI_CTX *ctx, KSI_HashAlgorithm algo_id, const char *key, KSI_HmacHasher **hasher)
 
int KSI_HmacHasher_reset (KSI_HmacHasher *hasher)
 
int KSI_HmacHasher_add (KSI_HmacHasher *hasher, const void *data, size_t data_length)
 
int KSI_HmacHasher_close (KSI_HmacHasher *hasher, KSI_DataHash **hmac)
 
void KSI_HmacHasher_free (KSI_HmacHasher *hasher)
 

Detailed Description

Typedef Documentation

typedef struct KSI_HmacHasher_st KSI_HmacHasher

This structure is used for calculating the HMAC hash values.

See also
KSI_DataHash, KSI_HmacHasher_open, KSI_HmacHasher_reset, KSI_HmacHasher_close, KSI_HmacHasher_free

Function Documentation

int KSI_base32Decode ( const char *  base32,
unsigned char **  data,
size_t *  data_len 
)

Decodes given base32 encoded data.

Parameters
[in]base32Pointer to the base32 encoded source string.
[out]dataPointer to the receiving pointer.
[out]data_lenPointer to the raw value length variable.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
The caller is responsible for freeing the output memory data.
int KSI_base32Encode ( const unsigned char *  data,
size_t  data_len,
size_t  group_len,
char **  encoded 
)

Encodes given binary data to base32.

Parameters
[in]dataPointer to the input data.
[in]data_lenLength of the input data.
[in]group_lenLength of a group (the groups are separated with '-')
[out]encodedPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
The caller is responsible for freeing the output memory encoded.
unsigned long KSI_crc32 ( const void *  data,
size_t  length,
unsigned long  ival 
)

Calculates CRC32 checksum.

Parameters
[in]dataPointer to the data.
[in]lengthLength of the data.
[in]ivalInitial value. Pass 0 for the first or single call to this function and pass result from the previous call for the next part of the data.
Returns
CRC32 of the data.
int KSI_HMAC_create ( KSI_CTX ctx,
KSI_HashAlgorithm  algo_id,
const char *  key,
const unsigned char *  data,
size_t  data_len,
KSI_DataHash **  hmac 
)

Creates a KSI_DataHash representing the HMAC value calculated by the key and data using alg as the hash algorithm.

Parameters
[in]ctxKSI context.
[in]algo_idHash algorithm ID see KSI_Hash
[in]keyKey value for the HMAC.
[in]dataPointer to the data to be HMAC'ed.
[in]data_lenLength of the data.
[out]hmacPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_DataHash_free
int KSI_HmacHasher_add ( KSI_HmacHasher hasher,
const void *  data,
size_t  data_length 
)

Adds data to an open HMAC computation.

Parameters
[in]hasherHasher object.
[in]dataPointer to the data to be hashed.
[in]data_lengthLength of the hashed data.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_HmacHasher_open, KSI_HmacHasher_close
int KSI_HmacHasher_close ( KSI_HmacHasher hasher,
KSI_DataHash **  hmac 
)

Finalizes an HMAC computation.

Parameters
[in]hasherHasher object.
[out]hmacPointer that will receive pointer to the hash object.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_HmacHasher_open, KSI_HmacHasher_add, KSI_HmacHasher_free
void KSI_HmacHasher_free ( KSI_HmacHasher hasher)

Frees the hasher object.

Parameters
[in]hasherHasher object.
See also
KSI_HmacHasher_open
int KSI_HmacHasher_open ( KSI_CTX ctx,
KSI_HashAlgorithm  algo_id,
const char *  key,
KSI_HmacHasher **  hasher 
)

Starts an HMAC computation.

Parameters
[in]ctxKSI context.
[in]algo_idIdentifier of the hash algorithm. See KSI_HashAlgorithm_en for possible values.
[in]keyKey value for the HMAC.
[out]hasherPointer that will receive pointer to the hasher object.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_HmacHasher_add, KSI_HmacHasher_close
int KSI_HmacHasher_reset ( KSI_HmacHasher hasher)

Resets the state of the HMAC computation.

Parameters
[in]hasherThe hasher.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_HmacHasher_open, KSI_HmacHasher_close