Guardtime KSI c SDK
|
Typedefs | |
typedef int(* | KSI_Config_Callback )(KSI_CTX *ctx, KSI_Config *conf) |
typedef enum KSI_Option_en | KSI_Option |
#define KSI_CERT_COMMON_NAME "2.5.4.3" |
#define KSI_CERT_COUNTRY "2.5.4.6" |
#define KSI_CERT_EMAIL "1.2.840.113549.1.9.1" |
#define KSI_CERT_ORGANIZATION "2.5.4.10" |
#define KSI_CTX_FLAG_AGGR_PDU_VER KSI_OPT_AGGR_PDU_VER |
Deprecated. Defined for backwards compatibility. See KSI_Option and KSI_CTX_setOption for replacement.
#define KSI_CTX_FLAG_EXT_PDU_VER KSI_OPT_EXT_PDU_VER |
#define KSI_CTX_HA_MAX_SUBSERVICES 3 |
#define KSI_CTX_PUBFILE_CACHE_DEFAULT_TTL (8 * 60 * 60) |
#define KSI_CTX_setAggregatorHmacAlgorithm | ( | ctx, | |
alg_id | |||
) | KSI_CTX_setOption(ctx, KSI_OPT_AGGR_HMAC_ALGORITHM, (void*)(alg_id)) |
#define KSI_CTX_setExtenderHmacAlgorithm | ( | ctx, | |
alg_id | |||
) | KSI_CTX_setOption(ctx, KSI_OPT_EXT_HMAC_ALGORITHM, (void*)(alg_id)) |
#define KSI_CTX_setFlag | ( | ctx, | |
flag, | |||
param | |||
) | KSI_CTX_setOption((ctx), (flag), (param)) |
#define KSI_CtxFlag KSI_Option_en |
#define KSI_extendSignature | ( | ctx, | |
sig, | |||
extended | |||
) | KSI_extendSignatureWithPolicy(ctx, sig, KSI_VERIFICATION_POLICY_INTERNAL, NULL, extended) |
#define KSI_sendExtendRequest | ( | ctx, | |
request, | |||
handle | |||
) | KSI_sendExtenderRequest(ctx, request, handle) |
#define KSI_sendSignRequest | ( | ctx, | |
request, | |||
handle | |||
) | KSI_sendAggregatorRequest(ctx, request, handle) |
typedef int(* KSI_Config_Callback)(KSI_CTX *ctx, KSI_Config *conf) |
Service configuration receive callback.
[in] | ctx | KSI context object. |
[in] | conf | Pointer to the configuration. |
typedef enum KSI_Option_en KSI_Option |
enum KSI_Option_en |
Enumerator | |||
---|---|---|---|
KSI_OPT_AGGR_PDU_VER |
PDU version for KSI aggregation messages.
| ||
KSI_OPT_EXT_PDU_VER |
PDU version for KSI extending messages.
| ||
KSI_OPT_AGGR_HMAC_ALGORITHM |
Aggregator HMAC algorithm.
| ||
KSI_OPT_EXT_HMAC_ALGORITHM |
Extender HMAC algorithm.
| ||
KSI_OPT_DATAHASH_CACHE_SIZE |
The size of the dynamic recycle pool for KSI_DataHash objects.
| ||
KSI_OPT_AGGR_CONF_RECEIVED_CALLBACK |
Aggregator configuration received callback.
| ||
KSI_OPT_EXT_CONF_RECEIVED_CALLBACK |
Extender configuration received callback.
| ||
KSI_OPT_PUBFILE_CACHE_TTL_SECONDS |
Publications file cache timeout. After the timeout expires a call to the KSI_receivePublicationsFile will trigger a new publications file download.
| ||
KSI_OPT_HA_SAFEGUARD |
High availability service maximum number of subservices.
| ||
__KSI_NUMBER_OF_OPTIONS |
enum KSI_PDUver_en |
enum KSI_StatusCode |
KSI function returnvalues.
void* KSI_calloc | ( | size_t | num, |
size_t | size | ||
) |
Allocates num
times of size
bytes of memory.
[in] | num | Number of blocks to allocate. |
[in] | size | Size of a single block. |
NULL
if an error occurred. int KSI_createSignature | ( | KSI_CTX * | ctx, |
KSI_DataHash * | dataHash, | ||
KSI_Signature ** | sig | ||
) |
Create a KSI signature from a given data hash.
[in] | ctx | KSI context. |
[in] | dataHash | Data hash object from the document to be signed. |
[out] | sig | Pointer to the receiving pointer to the KSI signature object. |
void KSI_CTX_free | ( | KSI_CTX * | ctx | ) |
Destructor for KSI context object KSI_CTX.
[in] | ctx | KSI ctx. |
int KSI_CTX_getLastFailedSignature | ( | KSI_CTX * | ctx, |
KSI_Signature ** | lastFailedSignature | ||
) |
Getter method for lastFailedSignature
.
[in] | ctx | Pointer to KSI_CTX. |
[out] | lastFailedSignature | Pointer to receiving pointer. |
lastFailedSignature
is passed to the caller who is responsible for freeing the object.int KSI_CTX_getPKITruststore | ( | KSI_CTX * | ctx, |
KSI_PKITruststore ** | pki | ||
) |
Getter function for the PKI truststore object.
[in] | ctx | KSI context. |
[out] | pki | Pointer to the receiving PKI trust store pointer. |
int KSI_CTX_getPublicationCertEmail | ( | KSI_CTX * | ctx, |
const char ** | address | ||
) |
Getter function for the e-mail address used to verify the publications file PKI signature.
[in] | ctx | KSI context. |
[out] | address | Pointer to the receiving pointer. |
int KSI_CTX_getPublicationsFile | ( | KSI_CTX * | ctx, |
KSI_PublicationsFile ** | var | ||
) |
Getter function for the publications file.
[in] | ctx | KSI context. |
[out] | var | Pointer to the receiving pointer to publications file. |
int KSI_CTX_new | ( | KSI_CTX ** | ctx | ) |
Constructor for the central KSI object KSI_CTX. For thread safety, this object may not be shared between threads. Also, this object may be freed only if there are no other objects created using this object - this applies recursively to other objects created by the user.
[in] | ctx | Pointer to the receiving pointer. |
int KSI_CTX_registerGlobals | ( | KSI_CTX * | ctx, |
int(*)(void) | initFn, | ||
void(*)(void) | cleanupFn | ||
) |
This function is used to call global init functions and to register the appropriate global cleanup method. The init function will be called only once per KSI context and the cleanup method will be called when KSI_CTX_free is called on the context object. The global init and cleanup functions must keep track how many times they are called (if multiple calls cause issues) and allow multiple calls.
[in] | ctx | KSI context. |
[in] | initFn | Global initiation function. |
[in] | cleanupFn | Global cleanup function. |
int KSI_CTX_setAggregator | ( | KSI_CTX * | ctx, |
const char * | uri, | ||
const char * | loginId, | ||
const char * | key | ||
) |
Configuration method for the aggregator.
[in] | ctx | KSI context. |
[in] | uri | Aggregation service URI. |
[in] | loginId | The login id for the service. |
[in] | key | Key for the loginId. |
int KSI_CTX_setConnectionTimeoutSeconds | ( | KSI_CTX * | ctx, |
int | timeout | ||
) |
Setter for connection timeout.
[in] | ctx | KSI context. |
[in] | timeout | Connection timeout in seconds. |
int KSI_CTX_setDefaultPubFileCertConstraints | ( | KSI_CTX * | ctx, |
const KSI_CertConstraint * | arr | ||
) |
This method specifies the default constraints for verifying the publications file PKI certificate. The input consists of an array of OID and expected value pairs terminated by a pair of two NULLs. Except in the last terminating NULL pair, the expected value may not be NULL - this will make the function to return KSI_INVALID_ARGUMENT.
[in] | ctx | KSI context. |
[in] | arr | Array of OID and value pairs, terminated by a pair of NULLs. |
int KSI_CTX_setExtender | ( | KSI_CTX * | ctx, |
const char * | uri, | ||
const char * | loginId, | ||
const char * | key | ||
) |
Configuration method for the extender.
[in] | ctx | KSI context. |
[in] | uri | Extending service URI. |
[in] | loginId | The login id for the service. |
[in] | key | Key for the loginId. |
int KSI_CTX_setLoggerCallback | ( | KSI_CTX * | ctx, |
KSI_LoggerCallback | cb, | ||
void * | logCtx | ||
) |
This function sets the callback for logging for the context. For logging to streams KSI_LOG_StreamLogger can be used.
[in] | ctx | KSI context. |
[in] | cb | Logger callback function. |
[in] | logCtx | Pointer to logger context, may be NULL . |
int KSI_CTX_setLogLevel | ( | KSI_CTX * | ctx, |
int | level | ||
) |
Setter for the internal log level.
[in] | ctx | KSI context. |
[in] | level | Log level. |
int KSI_CTX_setNetworkProvider | ( | KSI_CTX * | ctx, |
KSI_NetworkClient * | net | ||
) |
Setter for the network provider.
[in] | ctx | KSI context,. |
[in] | net | Network provider. |
int KSI_CTX_setOption | ( | KSI_CTX * | ctx, |
KSI_Option | opt, | ||
void * | param | ||
) |
Configuration method for the KSI option.
[in] | ctx | KSI context. |
[in] | opt | KSI option. |
[in] | param | Value for specified KSI option. |
param
is dependent on the KSI option. int KSI_CTX_setPKITruststore | ( | KSI_CTX * | ctx, |
KSI_PKITruststore * | pki | ||
) |
Setter for the PKI truststore.
[in] | ctx | KSI context. |
[in] | pki | PKI trust store. |
int KSI_CTX_setPublicationCertEmail | ( | KSI_CTX * | ctx, |
const char * | |||
) |
int KSI_CTX_setPublicationsFile | ( | KSI_CTX * | ctx, |
KSI_PublicationsFile * | var | ||
) |
Setter function for the publications file.
[in] | ctx | KSI context. |
[in] | var | Publications file. |
int KSI_CTX_setPublicationUrl | ( | KSI_CTX * | ctx, |
const char * | uri | ||
) |
Setter for publications file url.
[in] | ctx | KSI_context. |
[in] | uri | URL to the publications file. |
int KSI_CTX_setRequestHeaderCallback | ( | KSI_CTX * | ctx, |
KSI_RequestHeaderCallback | cb | ||
) |
This function sets the callback which is executed on every requests header KSI_Header prior to serializing and submitting the request. The callback should be used when additional data (i.e session id and message id) should be added to the header.
[in] | ctx | KSI context. |
[in] | cb | Request header callback function. |
int KSI_CTX_setTransferTimeoutSeconds | ( | KSI_CTX * | ctx, |
int | timeout | ||
) |
Setter for transfer timeout.
[in] | ctx | KSI context. |
[in] | timeout | Transfer timeout in seconds. |
int KSI_ERR_getBaseErrorMessage | ( | KSI_CTX * | ctx, |
char * | buf, | ||
size_t | len, | ||
int * | error, | ||
int * | ext | ||
) |
Get base error message and optional internal and external error code. If there are no errors, buf
will contain string returned by KSI_getErrorString(KSI_OK), error
will be equal to KSI_OK
and ext
will be equal to 0.
[in] | ctx | KSI context object. |
[out] | buf | Buffer for storing error message. |
[in] | len | The length of the buffer. |
[out] | error | Pointer to buffer for base error code. Can be NULL. |
[out] | ext | Pointer to buffer for external component error code. Can be NULL. |
int KSI_ERR_statusDump | ( | KSI_CTX * | ctx, |
FILE * | f | ||
) |
Dump error stack trace to stream.
[in] | ctx | KSI context object. |
[in] | f | Output stream. |
char* KSI_ERR_toString | ( | KSI_CTX * | ctx, |
char * | buf, | ||
size_t | buf_len | ||
) |
Get error stack trace NUL terminated c string representation.
[in] | ctx | KSI context object. |
[in] | buf | Pointer to receiving buffer. |
[in] | buf_len | Size of buf. |
int KSI_extendSignatureWithPolicy | ( | KSI_CTX * | ctx, |
const KSI_Signature * | sig, | ||
const KSI_Policy * | policy, | ||
KSI_VerificationContext * | context, | ||
KSI_Signature ** | extended | ||
) |
Extend the signature to the earliest available publication. Verify the extended signature with the provided policy and context.
[in] | ctx | KSI context. |
[in] | sig | Signature to be extended. |
[in] | policy | Verification policy. |
[in] | context | Verification context. |
[out] | extended | Pointer to the receiving pointer to the extended signature. |
void KSI_free | ( | void * | ptr | ) |
Free memory allocated by KSI_malloc or KSI_calloc.
[in] | ptr | Pointer to the memory to be freed. |
const char* KSI_getErrorString | ( | int | statusCode | ) |
Function to convert a KSI_StatusCode value to a human readable string value.
[in] | statusCode | KSI_StatusCode value. |
const char* KSI_getVersion | ( | void | ) |
This function returns a pointer to a constant string describing the version number of the package.
void* KSI_malloc | ( | size_t | size | ) |
Allocates size
bytes of memory.
[in] | size | Size of allocated block. |
NULL
if an error occurred. int KSI_receiveAggregatorConfig | ( | KSI_CTX * | ctx, |
KSI_Config ** | config | ||
) |
Get aggregator service configuration.
[in] | ctx | KSI context. |
[out] | config | Pointer to the receiving pointer. |
int KSI_receiveExtenderConfig | ( | KSI_CTX * | ctx, |
KSI_Config ** | config | ||
) |
Get extender service configuration.
[in] | ctx | KSI context. |
[out] | config | Pointer to the receiving pointer. |
int KSI_receivePublicationsFile | ( | KSI_CTX * | ctx, |
KSI_PublicationsFile ** | pubFile | ||
) |
Accessor method for the publications file. It will download the publications file from the uri specified by the KSI context.
[in] | ctx | KSI context. |
[out] | pubFile | Pointer to the receiving pointer. |
int KSI_sendAggregatorRequest | ( | KSI_CTX * | ctx, |
KSI_AggregationReq * | request, | ||
KSI_RequestHandle ** | handle | ||
) |
Send a binary request to aggregator using the specified KSI context.
[in] | ctx | KSI context object. |
[in] | request | Request object. |
[out] | handle | Pointer to the receiving pointer of the network handle. |
int KSI_sendExtenderRequest | ( | KSI_CTX * | ctx, |
KSI_ExtendReq * | request, | ||
KSI_RequestHandle ** | handle | ||
) |
Send a binary request to extender using the specified KSI context.
[in] | ctx | KSI context object. |
[in] | request | Request object. |
[out] | handle | Pointer to the receiving pointer of the network handle. |
int KSI_sendPublicationRequest | ( | KSI_CTX * | ctx, |
const unsigned char * | request, | ||
size_t | request_length, | ||
KSI_RequestHandle ** | handle | ||
) |
Send a binary request to download publications file using the specified KSI context.
[in] | ctx | KSI context object. |
[in] | request | Pointer to the binary request. |
[in] | request_length | Length of the binary request. |
[out] | handle | Pointer to the receiving pointer of the network handle. |
int KSI_verifyDataHash | ( | KSI_CTX * | ctx, |
KSI_Signature * | sig, | ||
const KSI_DataHash * | hsh | ||
) |
Use the KSI context to verify the signature and the datahash.
[in] | ctx | KSI context. |
[in] | sig | KSI signature. |
[in] | hsh | Document data hash. |
int KSI_verifyPublicationsFile | ( | KSI_CTX * | ctx, |
const KSI_PublicationsFile * | pubFile | ||
) |
Verify the PKI signature of the publications file using the context.
[in] | ctx | KSI context. |
[in] | pubFile | Publications file. |
int KSI_verifySignature | ( | KSI_CTX * | ctx, |
KSI_Signature * | sig | ||
) |
Use the KSI context to verify the signature.
[in] | ctx | KSI context. |
[in] | sig | KSI signature. |