Guardtime KSI c SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Typedefs | Functions
Base Types

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
 

Functions

void KSI_Integer_free (KSI_Integer *o)
 
char * KSI_Integer_toDateString (const KSI_Integer *o, char *buf, size_t buf_len)
 
KSI_uint64_t KSI_Integer_getUInt64 (const KSI_Integer *o)
 
int KSI_Integer_new (KSI_CTX *ctx, KSI_uint64_t value, KSI_Integer **o)
 
int KSI_Integer_equals (const KSI_Integer *a, const KSI_Integer *b)
 
int KSI_Integer_compare (const KSI_Integer *a, const KSI_Integer *b)
 
int KSI_Integer_equalsUInt (const KSI_Integer *o, KSI_uint64_t i)
 
KSI_IntegerKSI_Integer_ref (KSI_Integer *o)
 
int KSI_Integer_fromTlv (KSI_TLV *tlv, KSI_Integer **o)
 
int KSI_Integer_toTlv (KSI_CTX *ctx, const KSI_Integer *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv)
 
void KSI_OctetString_free (KSI_OctetString *t)
 
int KSI_OctetString_new (KSI_CTX *ctx, const unsigned char *data, size_t data_len, KSI_OctetString **t)
 
int KSI_OctetString_extract (const KSI_OctetString *t, const unsigned char **data, size_t *data_len)
 
int KSI_OctetString_equals (const KSI_OctetString *left, const KSI_OctetString *right)
 
KSI_OctetStringKSI_OctetString_ref (KSI_OctetString *o)
 
int KSI_OctetString_fromTlv (KSI_TLV *tlv, KSI_OctetString **o)
 
int KSI_OctetString_toTlv (KSI_CTX *ctx, const KSI_OctetString *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv)
 
char * KSI_OctetString_toString (const KSI_OctetString *id, char separator, char *buf, size_t buf_len)
 
void KSI_Utf8String_free (KSI_Utf8String *t)
 
int KSI_Utf8String_new (KSI_CTX *ctx, const char *str, size_t len, KSI_Utf8String **t)
 
size_t KSI_Utf8String_size (const KSI_Utf8String *t)
 
const char * KSI_Utf8String_cstr (const KSI_Utf8String *o)
 
KSI_Utf8StringKSI_Utf8String_ref (KSI_Utf8String *o)
 
int KSI_Utf8String_fromTlv (KSI_TLV *tlv, KSI_Utf8String **o)
 
int KSI_Utf8String_toTlv (KSI_CTX *ctx, const KSI_Utf8String *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv)
 
int KSI_Utf8StringNZ_fromTlv (KSI_TLV *tlv, KSI_Utf8String **o)
 
int KSI_Utf8StringNZ_toTlv (KSI_CTX *ctx, const KSI_Utf8String *o, unsigned tag, int isNonCritical, int isForward, KSI_TLV **tlv)
 
int KSI_OctetString_LegacyId_getUtf8String (const KSI_OctetString *id, KSI_Utf8String **str)
 

Detailed Description

Macro Definition Documentation

#define KSI_DEFINE_GET_CTX (   type)    KSI_CTX *type##_getCtx(const type *o);
#define KSI_uint64_t   uint64_t

Typedef Documentation

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.

See also
KSI_CTX_new, KSI_CTX_free.
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.

See also
KSI_Integer_new, KSI_Integer_free.
typedef int(* KSI_LoggerCallback)(void *logCtx, int level, const char *message)

Logger callback function pointer type.

Parameters
[in]logCtxLogger context.
[in]levelLog level information.
[in]messagePointer to the logged message.
Returns
Implementation must return status code (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.

An utf-8 string which must have at least one printable character.

Function Documentation

int KSI_Integer_compare ( const KSI_Integer a,
const KSI_Integer b 
)

Function to compare the values of two KSI_Integer objects.

Parameters
[in]aLeft operand.
[in]bRight operand.
Returns
Returns 0 if the values are equal, -1 if b is greater and 1 otherwise.
Note
NULL values are treated as they where KSI_Integer objects with value 0.
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.

Parameters
[in]aLeft operand.
[in]bRight operand.
Returns
0 if the values differ, otherwise returns value greater than 0.
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.

Parameters
[in]oPointer to KSI_Integer.
[in]iNative unsigned value
Returns
Returns 0 if the values differ, otherwise value greater than 0.
Note
If a == NULL, the result is always not true.
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.

Parameters
[in]oPointer to be freed
See also
KSI_Integer_new, KSI_Integer_ref
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.

Parameters
[in]tlvPointer to KSI_TLV.
[out]oPointer to receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_Integer_fromTlv
KSI_uint64_t KSI_Integer_getUInt64 ( const KSI_Integer o)

Returns the native 64-bit value of the KSI_Integer.

Parameters
[in]oPointer to KSI_Integer.
Returns
The native 64-bit value.
int KSI_Integer_new ( KSI_CTX ctx,
KSI_uint64_t  value,
KSI_Integer **  o 
)

Constructor to create a new KSI_Integer.

Parameters
[in]ctxKSI context.
[in]valueValue of the new KSI_Integer.
[out]oPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
KSI_Integer* KSI_Integer_ref ( KSI_Integer o)
  • Increases the inner reference count of that object. *
    Parameters
    [in]oPointer to KSI_Integer *
    Returns
    Returns the input pointer on success or NULL on error. *
    See also
    KSI_Integer_free
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.

Parameters
[in]oPointer to KSI_Integer.
[in]bufPointer to buffer.
[in]buf_lenLength of the buffer.
Returns
On success returns buf and NULL if an error occurred.
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.

Parameters
[in]ctxKSI context.
[in]oPointer to KSI_Integer
[in]tagTag value of the KSI_TLV
[in]isNonCriticalFlag is-non-critical.
[in]isForwardFlag is-forward.
[out]tlvPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_Integer_fromTlv, KSI_TLV_free
int KSI_OctetString_equals ( const KSI_OctetString left,
const KSI_OctetString right 
)

Function to check for the equality of two octet strings.

Parameters
[in]leftLeft operand.
[in]rightRight operand.
Returns
Returns 0 if the octet strings are not equal.
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.

Parameters
[in]tObject 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.

Parameters
[in]tlvPointer to KSI_TLV.
[out]oPointer to receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_OctetString_fromTlv
int KSI_OctetString_LegacyId_getUtf8String ( const KSI_OctetString id,
KSI_Utf8String **  str 
)

Creates a KSI_Utf8String object initialized with signer id.

Parameters
[in]idLegacy ID.
[out]strPointer to the receiving pointer.
Returns
On success returns KSI_OK, otherwise a status code is returned (see KSI_StatusCode).
See also
KSI_Utf8String_free, KSI_Utf8String_cstr
int KSI_OctetString_new ( KSI_CTX ctx,
const unsigned char *  data,
size_t  data_len,
KSI_OctetString **  t 
)

Constructor.

Parameters
[in]ctxKSI context.
[in]dataPointer to the data.
[in]data_lenLength of the data.
[out]tPointer to the receiving pointer.
KSI_OctetString* KSI_OctetString_ref ( KSI_OctetString o)
  • Increases the inner reference count of that object. *
    Parameters
    [in]oPointer to KSI_OctetString *
    Returns
    Returns the input pointer on success or NULL on error. *
    See also
    KSI_OctetString_free
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.

Parameters
[in]ctxKSI context.
[in]oPointer to KSI_OctetString
[in]tagTag value of the KSI_TLV
[in]isNonCriticalFlag is-non-critical.
[in]isForwardFlag is-forward.
[out]tlvPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_OctetString_fromTlv, KSI_TLV_free
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.

Parameters
[in]oPointer to the string object.
Returns
Pointer to the null terminated c string.
void KSI_Utf8String_free ( KSI_Utf8String t)

Cleanup method for the KSI_Utf8String object.

Parameters
[in]tPointer 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.

Parameters
[in]tlvPointer to KSI_TLV.
[out]oPointer to receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_Utf8String_fromTlv
int KSI_Utf8String_new ( KSI_CTX ctx,
const char *  str,
size_t  len,
KSI_Utf8String **  t 
)

Creates a new KSI_Utf8String object.

Parameters
[in]ctxKSI context.
[in]strString value.
[in]lenLength of the string.
[out]tPointer to the receiving pointer.
Returns
On success returns KSI_OK, otherwise a status code is returned (see KSI_StatusCode).
See also
KSI_Utf8String_free, KSI_Utf8String_cstr
KSI_Utf8String* KSI_Utf8String_ref ( KSI_Utf8String o)
  • Increases the inner reference count of that object. *
    Parameters
    [in]oPointer to KSI_Utf8String *
    Returns
    Returns the input pointer on success or NULL on error. *
    See also
    KSI_Utf8String_free
size_t KSI_Utf8String_size ( const KSI_Utf8String t)

Returns the actual size of the string in bytes.

Parameters
[in]tKSI utf8 string object.
Returns
Returns the actual size of the string in bytes or 0 if the object is NULL.
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.

Parameters
[in]ctxKSI context.
[in]oPointer to KSI_Utf8String
[in]tagTag value of the KSI_TLV
[in]isNonCriticalFlag is-non-critical.
[in]isForwardFlag is-forward.
[out]tlvPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_Utf8String_fromTlv, KSI_TLV_free
int KSI_Utf8StringNZ_fromTlv ( KSI_TLV tlv,
KSI_Utf8String **  o 
)

Functions as KSI_Utf8String_fromTlv, but adds constraint to the content not being empty.

Parameters
[in]tlvPointer to KSI_TLV.
[out]oPointer to receiving pointer.
Returns
status code (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.

Parameters
[in]ctxKSI context.
[in]oString to be encoded as TLV.
[in]tagTag of the TLV.
[in]isNonCriticalIs-non-critical flag.
[in]isForwardIs-forward flag.
[out]tlvPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).