|
Guardtime KSI c SDK
|
Data Structures | |
| struct | KSI_DataHash_list_st |
Macros | |
| #define | KSI_MAX_IMPRINT_LEN 65 /* Algorithm ID (1 byte) + longest digest. */ |
| #define | KSI_DataHashList_append(lst, o) KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o))) |
| #define | KSI_DataHashList_remove(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o))) |
| #define | KSI_DataHashList_indexOf(lst, o, i) KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i))) |
| #define | KSI_DataHashList_insertAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o))) |
| #define | KSI_DataHashList_replaceAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o))) |
| #define | KSI_DataHashList_elementAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o))) |
| #define | KSI_DataHashList_length(lst) (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0) |
| #define | KSI_DataHashList_sort(lst, cmp) KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp))) |
| #define | KSI_DataHashList_foldl(lst, foldCtx, foldFn) (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK) |
| #define | KSI_DataHashList_find(lst, o, f, i) KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i))) |
Typedefs | |
| typedef struct KSI_DataHasher_st | KSI_DataHasher |
| typedef struct KSI_DataHash_st | KSI_DataHash |
| typedef enum KSI_HashAlgorithm_en | KSI_HashAlgorithm |
| typedef struct KSI_DataHash_list_st | KSI_DataHashList |
Enumerations | |
| enum | KSI_HashAlgorithm_en { __KSI_HASHALG_DO_NOT_USE = -1 , KSI_HASHALG_SHA1 = 0x00 , KSI_HASHALG_SHA2_256 = 0x01 , KSI_HASHALG_RIPEMD160 = 0x02 , KSI_HASHALG_SHA2_384 = 0x04 , KSI_HASHALG_SHA2_512 = 0x05 , KSI_HASHALG_SHA3_224 = 0x07 , KSI_HASHALG_SHA3_256 = 0x08 , KSI_HASHALG_SHA3_384 = 0x09 , KSI_HASHALG_SHA3_512 = 0x0a , KSI_HASHALG_SM3 = 0x0b , KSI_NUMBER_OF_KNOWN_HASHALGS , KSI_HASHALG_INVALID_VALUE = 0x100 } |
Variables | |
| const int | KSI_HASHALG_INVALID |
| const int | KSI_HASHALG_SHA3_244 |
This module consists of two main objects:
| #define KSI_DataHashList_append | ( | lst, | |
| o | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o))) |
| #define KSI_DataHashList_elementAt | ( | lst, | |
| pos, | |||
| o | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o))) |
| #define KSI_DataHashList_find | ( | lst, | |
| o, | |||
| f, | |||
| i | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i))) |
| #define KSI_DataHashList_foldl | ( | lst, | |
| foldCtx, | |||
| foldFn | |||
| ) | (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK) |
| #define KSI_DataHashList_indexOf | ( | lst, | |
| o, | |||
| i | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i))) |
| #define KSI_DataHashList_insertAt | ( | lst, | |
| pos, | |||
| o | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o))) |
| #define KSI_DataHashList_length | ( | lst | ) | (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0) |
| #define KSI_DataHashList_remove | ( | lst, | |
| pos, | |||
| o | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o))) |
| #define KSI_DataHashList_replaceAt | ( | lst, | |
| pos, | |||
| o | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o))) |
| #define KSI_DataHashList_sort | ( | lst, | |
| cmp | |||
| ) | KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp))) |
| #define KSI_MAX_IMPRINT_LEN 65 /* Algorithm ID (1 byte) + longest digest. */ |
The maximum length of an imprint.
| typedef struct KSI_DataHash_st KSI_DataHash |
This structure represents hashed data.
| typedef struct KSI_DataHasher_st KSI_DataHasher |
This structure is used for calculating the hash values.
| typedef struct KSI_DataHash_list_st KSI_DataHashList |
| typedef enum KSI_HashAlgorithm_en KSI_HashAlgorithm |
The Guardtime representation of hash algorithms, necessary to calculate instances of KSI_DataHasher and KSI_DataHash.
| enum KSI_HashAlgorithm_en |
The Guardtime representation of hash algorithms, necessary to calculate instances of KSI_DataHasher and KSI_DataHash.
| int KSI_checkHashAlgorithmAt | ( | KSI_HashAlgorithm | algo_id, |
| time_t | used_at | ||
| ) |
This function will check the status of the hash algorithm at a given time.
| [in] | algo_id | Hash algorithm id. |
| [in] | used_at | UTC time when the algorithm was/is used. |
used_at, or used_at, and | int KSI_DataHash_clone | ( | KSI_DataHash * | from, |
| KSI_DataHash ** | to | ||
| ) |
Creates a clone of the data hash.
| [in] | from | Data hash to be cloned. |
| [out] | to | Pointer to the receiving pointer to the cloned object. |
| int KSI_DataHash_create | ( | KSI_CTX * | ctx, |
| const void * | data, | ||
| size_t | data_length, | ||
| KSI_HashAlgorithm | algo_id, | ||
| KSI_DataHash ** | hash | ||
| ) |
Calculates the data hash object from the input data.
| [in] | ctx | KSI context. |
| [in] | data | Pointer to the input data. |
| [in] | data_length | Length of the imput data. |
| [in] | algo_id | Hash algorithm id. |
| [out] | hash | Pointer to the pointer receiving the data hash object. |
| int KSI_DataHash_createZero | ( | KSI_CTX * | ctx, |
| KSI_HashAlgorithm | algo_id, | ||
| KSI_DataHash ** | hsh | ||
| ) |
Creates a hash value where all the bits in the digest are set to zero.
| [in] | ctx | KSI context. |
| [in] | algo_id | The hash algorithm id. |
| [out] | hsh | Pointer to the receiving pointer. |
| int KSI_DataHash_equals | ( | const KSI_DataHash * | left, |
| const KSI_DataHash * | right | ||
| ) |
Returns 1 if the two given data hash objects are both not NULL and the hash values equal to each other.
| [in] | left | One data hash object. |
| [in] | right | An other data hash object. |
NULL or are not equal, otherwise non-zero value is returned. | int KSI_DataHash_extract | ( | const KSI_DataHash * | hash, |
| KSI_HashAlgorithm * | algo_id, | ||
| const unsigned char ** | digest, | ||
| size_t * | digest_length | ||
| ) |
Extracts the hashing algorithm, digest and its length from the KSI_DataHash. If any of the output pointers is NULL, it is ignored. The digest is a pointer to an internal field of the KSI_DataHash thus extracting the digest does not make a copy of the buffer. This means the digest pointer is valid until KSI_DataHash_free is called on the object.
| [in] | hash | Data hash object. |
| [out] | algo_id | Algorithm used to compute the hash. |
| [out] | digest | Binary digest value. |
| [out] | digest_length | Length of the digest value. |
NULL the value will be ignored. | void KSI_DataHash_free | ( | KSI_DataHash * | hash | ) |
Frees the data hash object..
| [in] | hash | KSI_DataHash object that is to be freed. |
| int KSI_DataHash_fromDigest | ( | KSI_CTX * | ctx, |
| KSI_HashAlgorithm | algo_id, | ||
| const unsigned char * | digest, | ||
| size_t | digest_length, | ||
| KSI_DataHash ** | hash | ||
| ) |
Constructor for KSI_DataHash object from existing hash value.
| [in] | ctx | KSI context. |
| [in] | algo_id | Algorithm used to compute the digest value. |
| [in] | digest | Binary digest value. |
| [in] | digest_length | Length of the binary digest value. |
| [in] | hash | Pointer that will receive pointer to the hash object. |
| int KSI_DataHash_fromImprint | ( | KSI_CTX * | ctx, |
| const unsigned char * | imprint, | ||
| size_t | imprint_length, | ||
| KSI_DataHash ** | hash | ||
| ) |
Constructor for KSI_DataHash object from existing imprint.
| [in] | ctx | KSI context. |
| [in] | imprint | Pointer to the imprint. |
| [in] | imprint_length | Length of the imprint. |
| [out] | hash | Pointer that will receive pointer to the data hash objet. |
| int KSI_DataHash_fromTlv | ( | KSI_TLV * | tlv, |
| KSI_DataHash ** | o | ||
| ) |
Function to convert a plain KSI_TLV to a KSI_DataHash . The TLV meta data (i.e. tag, length and flags) are not preserved.
| [in] | tlv | Pointer to KSI_TLV. |
| [out] | o | Pointer to receiving pointer. |
KSI_OK, when operation succeeded, otherwise an error code). | int KSI_DataHash_getHashAlg | ( | const KSI_DataHash * | hash, |
| KSI_HashAlgorithm * | algo_id | ||
| ) |
Accessor method for extracting the hash algorithm from the KSI_DataHash.
| hash | Data hash object. |
| algo_id | Pointer to the receiving pointer. |
| int KSI_DataHash_getImprint | ( | const KSI_DataHash * | hash, |
| const unsigned char ** | imprint, | ||
| size_t * | imprint_length | ||
| ) |
Encodes the data hash object as an imprint.
| [in] | hash | Data hash object. |
| [out] | imprint | Pointer that will receive pointer to the imprint. |
| [out] | imprint_length | Pointer that will receive the length of the imprint. |
| KSI_DataHash* KSI_DataHash_ref | ( | KSI_DataHash * | o | ) |
| [in] | o | Pointer to KSI_DataHash * |
NULL on error. * | char* KSI_DataHash_toString | ( | const KSI_DataHash * | hsh, |
| char * | buf, | ||
| size_t | buf_len | ||
| ) |
Creates a string representation of the datahash.
| [in] | hsh | Input hash object. |
| [in,out] | buf | Pointer to the receiving buffer. |
| [in] | buf_len | Length of the receiving buffer. |
| int KSI_DataHash_toTlv | ( | KSI_CTX * | ctx, |
| const KSI_DataHash * | o, | ||
| unsigned | tag, | ||
| int | isNonCritical, | ||
| int | isForward, | ||
| KSI_TLV ** | tlv | ||
| ) |
Function to convert a KSI_DataHash to a plain KSI_TLV object.
| [in] | ctx | KSI context. |
| [in] | o | Pointer to KSI_DataHash [in] tag Tag value of the KSI_TLV |
| [in] | isNonCritical | Flag is-non-critical. |
| [in] | isForward | Flag is-forward. |
| [out] | tlv | Pointer to the receiving pointer. |
KSI_OK, when operation succeeded, otherwise an error code). | int KSI_DataHasher_add | ( | KSI_DataHasher * | hasher, |
| const void * | data, | ||
| size_t | data_length | ||
| ) |
Adds data to an open hash computation.
| [in] | hasher | Hasher object. |
| [in] | data | Pointer to the data to be hashed. |
| [in] | data_length | Length of the hashed data. |
| int KSI_DataHasher_addImprint | ( | KSI_DataHasher * | hasher, |
| const KSI_DataHash * | hsh | ||
| ) |
Adds the imprint value to the hash computation.
| [in] | hasher | Hasher object. |
| [in] | hsh | Datahash object. |
| int KSI_DataHasher_addOctetString | ( | KSI_DataHasher * | hasher, |
| const KSI_OctetString * | data | ||
| ) |
Adds the value of the octet string to the hash computation.
| [in] | hasher | Hasher object. |
| [in] | data | Octet string object. |
| int KSI_DataHasher_close | ( | KSI_DataHasher * | hasher, |
| KSI_DataHash ** | hash | ||
| ) |
Finalizes a hash computation.
| [in] | hasher | Hasher object. |
| [out] | hash | Pointer that will receive pointer to the hash object. |
| void KSI_DataHasher_free | ( | KSI_DataHasher * | hasher | ) |
| int KSI_DataHasher_open | ( | KSI_CTX * | ctx, |
| KSI_HashAlgorithm | algo_id, | ||
| KSI_DataHasher ** | hasher | ||
| ) |
Starts a hash computation.
| [in] | ctx | KSI context. |
| [in] | algo_id | Identifier of the hash algorithm. See KSI_HashAlgorithm_en for possible values. |
| [out] | hasher | Pointer that will receive pointer to the hasher object. |
| int KSI_DataHasher_reset | ( | KSI_DataHasher * | hasher | ) |
Resets the state of the hash computation.
| [in] | hasher | The hasher. |
| void KSI_DataHashList_free | ( | KSI_DataHashList * | list | ) |
| int KSI_DataHashList_new | ( | KSI_DataHashList ** | list | ) |
| KSI_HashAlgorithm KSI_getHashAlgorithmByName | ( | const char * | name | ) |
Returns the hash algorithm specified by the case insensitive string parameter name. If the algorithm name is not recognized the value of invalid algorithm is returned. To verify the correctness of the returned value KSI_isHashAlgorithmSupported or KSI_isHashAlgorithmTrusted function must be used. The valid inputs are "default" for the configured default hash algorithm or one of the following: "sha-1", "sha1", "sha-256", "sha2-256", "sha-2", "sha2", "sha256", "ripemd-160", "ripemd160", "sha-384", "sha384", "sha2-384", "sha-512", "sha512", "sha2-512", "sha3-224", "sha3-256", "sha3-384", "sha3-512", "sm-3", "sm3".
| [in] | name | Name of the hash function. |
| const char* KSI_getHashAlgorithmName | ( | KSI_HashAlgorithm | algo_id | ) |
Returns a pointer to constant string containing the name of the hash algorithm. Returns NULL if the algorithm is unknown.
| [in] | algo_id | The hash algorithm id. |
| unsigned int KSI_getHashLength | ( | KSI_HashAlgorithm | algo_id | ) |
Returns the hash length in bytes for the given hash algorithm id or -1 if the hash algorithm is not recognized or supported.
| [in] | algo_id | Hash algorithm id |
| unsigned int KSI_HashAlgorithm_getBlockSize | ( | KSI_HashAlgorithm | algo_id | ) |
Returns the size of the data block the underlying hash algorithm operates upon in bytes.
| [in] | algo_id | Hash algorithm id. |
| time_t KSI_HashAlgorithm_getDeprecatedFrom | ( | KSI_HashAlgorithm | algo_id | ) |
The time the function has been marked as deprecated.
| [in] | algo_id | Hash algorithm id. |
| time_t KSI_HashAlgorithm_getObsoleteFrom | ( | KSI_HashAlgorithm | algo_id | ) |
The time the function has been marked as obsolete.
| [in] | algo_id | Hash algorithm id. |
| int KSI_isHashAlgorithmSupported | ( | KSI_HashAlgorithm | algo_id | ) |
Is the given hash algorithm hash_id supported, meaning the hash value can be calculated using the API.
| [in] | algo_id | Hash algorithm id. |
| int KSI_isHashAlgorithmTrusted | ( | KSI_HashAlgorithm | algo_id | ) |
This function is used to check if the given hash algorithm is trusted. If the algorithm has been marked as deprecated or obsolete, it will return 0 or otherwise 1 is returned.
| [in] | algo_id | Hash algorithm id. |
|
extern |
|
extern |