Guardtime KSI c SDK
|
Macros | |
#define | KSI_uint64_t uint64_t |
#define | KSI_DEFINE_GET_CTX(type) KSI_CTX *type##_getCtx(const type *o); |
Typedefs | |
typedef int(* | KSI_LoggerCallback) (void *logCtx, int level, const char *message) |
typedef struct KSI_CTX_st | KSI_CTX |
typedef struct KSI_TLV_st | KSI_TLV |
typedef struct KSI_ERR_st | KSI_ERR |
typedef struct KSI_Integer_st | KSI_Integer |
typedef struct KSI_OctetString_st | KSI_OctetString |
typedef struct KSI_Utf8String_st | KSI_Utf8String |
typedef KSI_Utf8String | KSI_Utf8StringNZ |
#define KSI_DEFINE_GET_CTX | ( | type | ) | KSI_CTX *type##_getCtx(const type *o); |
#define KSI_uint64_t uint64_t |
typedef struct KSI_CTX_st KSI_CTX |
This is the central object of the SDK - the context. Instances of the context may not be shared between threads. There are no limits how many instances one thread can have, but objects created using this context should not be mixed with each other.
typedef struct KSI_ERR_st KSI_ERR |
Type for easy error handling with stacktrace and error messages.
typedef struct KSI_Integer_st KSI_Integer |
Immutable object representing a 64-bit integer.
typedef int(* KSI_LoggerCallback) (void *logCtx, int level, const char *message) |
Logger callback function pointer type.
[in] | logCtx | Logger context. |
[in] | level | Log level information. |
[in] | message | Pointer to the logged message. |
KSI_OK
, when operation succeeded, otherwise an error code). typedef struct KSI_OctetString_st KSI_OctetString |
Octet string type for storing binary data.
typedef struct KSI_TLV_st KSI_TLV |
This type represents a plain Type Length Value (TLV) object.
typedef struct KSI_Utf8String_st KSI_Utf8String |
Utf-8 string type.
typedef KSI_Utf8String KSI_Utf8StringNZ |
An utf-8 string which must have at least one printable character.
int KSI_Integer_compare | ( | const KSI_Integer * | a, |
const KSI_Integer * | b | ||
) |
Function to compare the values of two KSI_Integer objects.
[in] | a | Left operand. |
[in] | b | Right operand. |
int KSI_Integer_equals | ( | const KSI_Integer * | a, |
const KSI_Integer * | b | ||
) |
Function to determine equality of the values of the two KSI_Integer objects.
[in] | a | Left operand. |
[in] | b | Right operand. |
int KSI_Integer_equalsUInt | ( | const KSI_Integer * | o, |
KSI_uint64_t | i | ||
) |
Function to compare the equality of a KSI_Integer with a native unsigned value.
[in] | o | Pointer to KSI_Integer. |
[in] | i | Native unsigned value |
void KSI_Integer_free | ( | KSI_Integer * | o | ) |
Method to free or dereference a KSI_Integer object. The object is not freed if the object is still referenced from somewhere.
[in] | o | Pointer to be freed |
int KSI_Integer_fromTlv | ( | KSI_TLV * | tlv, |
KSI_Integer ** | o | ||
) |
Function to convert a plain KSI_TLV to a KSI_Integer . 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). KSI_uint64_t KSI_Integer_getUInt64 | ( | const KSI_Integer * | o | ) |
Returns the native 64-bit value of the KSI_Integer.
[in] | o | Pointer to KSI_Integer. |
int KSI_Integer_new | ( | KSI_CTX * | ctx, |
KSI_uint64_t | value, | ||
KSI_Integer ** | o | ||
) |
Constructor to create a new KSI_Integer.
[in] | ctx | KSI context. |
[in] | value | Value of the new KSI_Integer. |
[out] | o | Pointer to the receiving pointer. |
KSI_OK
, when operation succeeded, otherwise an error code). KSI_Integer* KSI_Integer_ref | ( | KSI_Integer * | o | ) |
[in] | o | Pointer to KSI_Integer * |
NULL
on error. * char* KSI_Integer_toDateString | ( | const KSI_Integer * | o, |
char * | buf, | ||
size_t | buf_len | ||
) |
This method converts the KSI_Integer value as UTC time and converts its value to a string with the following format: "%Y-%m-%d %H:%M:%S UTC". The result is written to buffer. If the buffer is too short, the remainder is discarded. It is guaranteed to set a terminating '\0' to the end of the result.
[in] | o | Pointer to KSI_Integer. |
[in] | buf | Pointer to buffer. |
[in] | buf_len | Length of the buffer. |
int KSI_Integer_toTlv | ( | KSI_CTX * | ctx, |
const KSI_Integer * | o, | ||
unsigned | tag, | ||
int | isNonCritical, | ||
int | isForward, | ||
KSI_TLV ** | tlv | ||
) |
Function to convert a KSI_Integer to a plain KSI_TLV object.
[in] | ctx | KSI context. |
[in] | o | Pointer to KSI_Integer |
[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_OctetString_equals | ( | const KSI_OctetString * | left, |
const KSI_OctetString * | right | ||
) |
Function to check for the equality of two octet strings.
[in] | left | Left operand. |
[in] | right | Right operand. |
int KSI_OctetString_extract | ( | const KSI_OctetString * | t, |
const unsigned char ** | data, | ||
size_t * | data_len | ||
) |
void KSI_OctetString_free | ( | KSI_OctetString * | t | ) |
Free the object.
[in] | t | Object to be freed. |
int KSI_OctetString_fromTlv | ( | KSI_TLV * | tlv, |
KSI_OctetString ** | o | ||
) |
Function to convert a plain KSI_TLV to a KSI_OctetString . 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_OctetString_LegacyId_getUtf8String | ( | const KSI_OctetString * | id, |
KSI_Utf8String ** | str | ||
) |
Creates a KSI_Utf8String object initialized with signer id.
[in] | id | Legacy ID. |
[out] | str | Pointer to the receiving pointer. |
int KSI_OctetString_new | ( | KSI_CTX * | ctx, |
const unsigned char * | data, | ||
size_t | data_len, | ||
KSI_OctetString ** | t | ||
) |
Constructor.
[in] | ctx | KSI context. |
[in] | data | Pointer to the data. |
[in] | data_len | Length of the data. |
[out] | t | Pointer to the receiving pointer. |
KSI_OctetString* KSI_OctetString_ref | ( | KSI_OctetString * | o | ) |
[in] | o | Pointer to KSI_OctetString * |
NULL
on error. * char* KSI_OctetString_toString | ( | const KSI_OctetString * | id, |
char | separator, | ||
char * | buf, | ||
size_t | buf_len | ||
) |
int KSI_OctetString_toTlv | ( | KSI_CTX * | ctx, |
const KSI_OctetString * | o, | ||
unsigned | tag, | ||
int | isNonCritical, | ||
int | isForward, | ||
KSI_TLV ** | tlv | ||
) |
Function to convert a KSI_OctetString to a plain KSI_TLV object.
[in] | ctx | KSI context. |
[in] | o | Pointer to KSI_OctetString |
[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). const char* KSI_Utf8String_cstr | ( | const KSI_Utf8String * | o | ) |
Returns a constant pointer to a buffer containing the null terminated c string or NULL if the object is NULL.
[in] | o | Pointer to the string object. |
void KSI_Utf8String_free | ( | KSI_Utf8String * | t | ) |
Cleanup method for the KSI_Utf8String object.
[in] | t | Pointer to the object to be freed. |
int KSI_Utf8String_fromTlv | ( | KSI_TLV * | tlv, |
KSI_Utf8String ** | o | ||
) |
Function to convert a plain KSI_TLV to a KSI_Utf8String . 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_Utf8String_new | ( | KSI_CTX * | ctx, |
const char * | str, | ||
size_t | len, | ||
KSI_Utf8String ** | t | ||
) |
Creates a new KSI_Utf8String object.
[in] | ctx | KSI context. |
[in] | str | String value. |
[in] | len | Length of the string. |
[out] | t | Pointer to the receiving pointer. |
KSI_Utf8String* KSI_Utf8String_ref | ( | KSI_Utf8String * | o | ) |
[in] | o | Pointer to KSI_Utf8String * |
NULL
on error. * size_t KSI_Utf8String_size | ( | const KSI_Utf8String * | t | ) |
Returns the actual size of the string in bytes.
[in] | t | KSI utf8 string object. |
int KSI_Utf8String_toTlv | ( | KSI_CTX * | ctx, |
const KSI_Utf8String * | o, | ||
unsigned | tag, | ||
int | isNonCritical, | ||
int | isForward, | ||
KSI_TLV ** | tlv | ||
) |
Function to convert a KSI_Utf8String to a plain KSI_TLV object.
[in] | ctx | KSI context. |
[in] | o | Pointer to KSI_Utf8String |
[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_Utf8StringNZ_fromTlv | ( | KSI_TLV * | tlv, |
KSI_Utf8String ** | o | ||
) |
Functions as KSI_Utf8String_fromTlv, but adds constraint to the content not being empty.
[in] | tlv | Pointer to KSI_TLV. |
[out] | o | Pointer to receiving pointer. |
KSI_OK
, when operation succeeded, otherwise an error code). int KSI_Utf8StringNZ_toTlv | ( | KSI_CTX * | ctx, |
const KSI_Utf8String * | o, | ||
unsigned | tag, | ||
int | isNonCritical, | ||
int | isForward, | ||
KSI_TLV ** | tlv | ||
) |
Functions as KSI_Utf8String_toTlv, but adds constraint to the content not being empty.
[in] | ctx | KSI context. |
[in] | o | String to be encoded as TLV. |
[in] | tag | Tag of the TLV. |
[in] | isNonCritical | Is-non-critical flag. |
[in] | isForward | Is-forward flag. |
[out] | tlv | Pointer to the receiving pointer. |
KSI_OK
, when operation succeeded, otherwise an error code).