Guardtime KSI c SDK
Loading...
Searching...
No Matches
ksi.h
Go to the documentation of this file.
1/*
2 * Copyright 2013-2015 Guardtime, Inc.
3 *
4 * This file is part of the Guardtime client SDK.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License").
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
13 * express or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 * "Guardtime" and "KSI" are trademarks or registered trademarks of
16 * Guardtime, Inc., and no license to trademarks is granted; Guardtime
17 * reserves and retains all trademark rights.
18 */
19
20#ifndef _KSI_BASE_H_
21#define _KSI_BASE_H_
22
23#include <stdio.h>
24#include <stdint.h>
25
26#include "version.h"
27#include "types.h"
28#include "hash.h"
29#include "publicationsfile.h"
30#include "log.h"
31#include "signature.h"
32#include "verification.h"
33#include "policy.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
43
48/* RETURN CODES WHICH ARE NOT ERRORS */
49 KSI_OK = 0,
50
71
72/* SYNTAX ERRORS */
124 /*
125 * The hash algorithm has been marked as deprecated at given time.
126 */
128 /*
129 * The hash algorithm has been marked as obsolete at given time.
130 */
132/* SYSTEM ERRORS */
187
192
197
202
207
212
217
222
223 /* Generic service errors. */
224
253
254 /* Aggregator errors. */
255
277
282
283 /* Extender status codes. */
284
305
310
315
320
321 /* Async status codes. */
322
327
332
333
338};
339
344 KSI_ENUM_DEPRECATED(KSI_PDU_VERSION_1, Only PDU v2 is supported.) = 1,
346};
347
348#define KSI_CTX_PUBFILE_CACHE_DEFAULT_TTL (8 * 60 * 60)
349
350#define KSI_CTX_HA_MAX_SUBSERVICES 3
351
358typedef int (*KSI_Config_Callback)(KSI_CTX *ctx, KSI_Config *conf);
359
426
432const char *KSI_getVersion(void);
433
443const char *KSI_getErrorString(int statusCode);
444
457
466
481int KSI_CTX_registerGlobals(KSI_CTX *ctx, int (*initFn)(void), void (*cleanupFn)(void));
482
491int KSI_ERR_statusDump(KSI_CTX *ctx, FILE *f);
492
501char *KSI_ERR_toString(KSI_CTX *ctx, char *buf, size_t buf_len);
502
515int KSI_ERR_getBaseErrorMessage(KSI_CTX *ctx, char *buf, size_t len, int *error, int *ext);
516
524void *KSI_malloc(size_t size);
525
534void *KSI_calloc(size_t num, size_t size);
535
540void KSI_free(void *ptr);
541
551
552#define KSI_sendSignRequest(ctx, request, handle) KSI_sendAggregatorRequest(ctx, request, handle)
553
563
564#define KSI_sendExtendRequest(ctx, request, handle) KSI_sendExtenderRequest(ctx, request, handle)
565
575int KSI_sendPublicationRequest(KSI_CTX *ctx, const unsigned char *request, size_t request_length, KSI_RequestHandle **handle);
576
594
603
611
619
628
648
662
663#define KSI_extendSignature(ctx, sig, extended) KSI_extendSignatureWithPolicy(ctx, sig, KSI_VERIFICATION_POLICY_INTERNAL, NULL, extended)
664
673int KSI_CTX_setLogLevel(KSI_CTX *ctx, int level);
674
687
697
705int KSI_CTX_setPublicationUrl(KSI_CTX *ctx, const char *uri);
706
715int KSI_CTX_setExtender(KSI_CTX *ctx, const char *uri, const char *loginId, const char *key);
716
725int KSI_CTX_setAggregator(KSI_CTX *ctx, const char *uri, const char *loginId, const char *key);
726
736int KSI_CTX_setOption(KSI_CTX *ctx, KSI_Option opt, void *param);
737
738#define KSI_CTX_setAggregatorHmacAlgorithm(ctx, alg_id) KSI_CTX_setOption(ctx, KSI_OPT_AGGR_HMAC_ALGORITHM, (void*)(alg_id))
739#define KSI_CTX_setExtenderHmacAlgorithm(ctx, alg_id) KSI_CTX_setOption(ctx, KSI_OPT_EXT_HMAC_ALGORITHM, (void*)(alg_id))
740
745#define KSI_CTX_FLAG_AGGR_PDU_VER KSI_OPT_AGGR_PDU_VER
746#define KSI_CTX_FLAG_EXT_PDU_VER KSI_OPT_EXT_PDU_VER
747#define KSI_CtxFlag KSI_Option_en
748#define KSI_CTX_setFlag(ctx, flag, param) KSI_CTX_setOption((ctx), (flag), (param))
749
757
765
773
781
789
791
792#define KSI_CERT_EMAIL "1.2.840.113549.1.9.1"
793#define KSI_CERT_COMMON_NAME "2.5.4.3"
794#define KSI_CERT_COUNTRY "2.5.4.6"
795#define KSI_CERT_ORGANIZATION "2.5.4.10"
796
817
825
833
842int KSI_CTX_getPublicationCertEmail(KSI_CTX *ctx, const char **address);
843
852
856#ifdef __cplusplus
857}
858#endif
859
860#endif
#define KSI_FN_DEPRECATED(decl, comment)
Definition common.h:50
struct KSI_CTX_st KSI_CTX
Definition types_base.h:78
int(* KSI_LoggerCallback)(void *logCtx, int level, const char *message)
Definition types_base.h:69
enum KSI_Option_en KSI_Option
int KSI_sendExtenderRequest(KSI_CTX *ctx, KSI_ExtendReq *request, KSI_RequestHandle **handle)
int KSI_receivePublicationsFile(KSI_CTX *ctx, KSI_PublicationsFile **pubFile)
char * KSI_ERR_toString(KSI_CTX *ctx, char *buf, size_t buf_len)
int KSI_receiveAggregatorConfig(KSI_CTX *ctx, KSI_Config **config)
int KSI_CTX_setPublicationUrl(KSI_CTX *ctx, const char *uri)
int KSI_CTX_setAggregator(KSI_CTX *ctx, const char *uri, const char *loginId, const char *key)
int KSI_CTX_setExtender(KSI_CTX *ctx, const char *uri, const char *loginId, const char *key)
int KSI_sendPublicationRequest(KSI_CTX *ctx, const unsigned char *request, size_t request_length, KSI_RequestHandle **handle)
int KSI_CTX_setTransferTimeoutSeconds(KSI_CTX *ctx, int timeout)
KSI_PDUver_en
Definition ksi.h:343
void KSI_free(void *ptr)
int KSI_CTX_setPKITruststore(KSI_CTX *ctx, KSI_PKITruststore *pki)
int KSI_ERR_statusDump(KSI_CTX *ctx, FILE *f)
void KSI_CTX_free(KSI_CTX *ctx)
const char * KSI_getErrorString(int statusCode)
int KSI_extendSignatureWithPolicy(KSI_CTX *ctx, const KSI_Signature *sig, const KSI_Policy *policy, KSI_VerificationContext *context, KSI_Signature **extended)
int KSI_CTX_setLogLevel(KSI_CTX *ctx, int level)
int KSI_CTX_getPublicationsFile(KSI_CTX *ctx, KSI_PublicationsFile **var)
int KSI_verifySignature(KSI_CTX *ctx, KSI_Signature *sig)
const char * KSI_getVersion(void)
int KSI_verifyPublicationsFile(KSI_CTX *ctx, const KSI_PublicationsFile *pubFile)
void * KSI_malloc(size_t size)
int KSI_CTX_setLoggerCallback(KSI_CTX *ctx, KSI_LoggerCallback cb, void *logCtx)
int KSI_CTX_new(KSI_CTX **ctx)
int KSI_CTX_setOption(KSI_CTX *ctx, KSI_Option opt, void *param)
int KSI_CTX_getLastFailedSignature(KSI_CTX *ctx, KSI_Signature **lastFailedSignature)
KSI_Option_en
Definition ksi.h:360
int KSI_receiveExtenderConfig(KSI_CTX *ctx, KSI_Config **config)
int KSI_CTX_getPKITruststore(KSI_CTX *ctx, KSI_PKITruststore **pki)
#define KSI_CERT_EMAIL
Definition ksi.h:792
KSI_StatusCode
Definition ksi.h:47
int KSI_sendAggregatorRequest(KSI_CTX *ctx, KSI_AggregationReq *request, KSI_RequestHandle **handle)
int KSI_verifyDataHash(KSI_CTX *ctx, KSI_Signature *sig, const KSI_DataHash *hsh)
int KSI_CTX_setNetworkProvider(KSI_CTX *ctx, KSI_NetworkClient *net)
int KSI_CTX_setDefaultPubFileCertConstraints(KSI_CTX *ctx, const KSI_CertConstraint *arr)
void * KSI_calloc(size_t num, size_t size)
int KSI_CTX_setPublicationsFile(KSI_CTX *ctx, KSI_PublicationsFile *var)
int KSI_createSignature(KSI_CTX *ctx, KSI_DataHash *dataHash, KSI_Signature **sig)
int KSI_ERR_getBaseErrorMessage(KSI_CTX *ctx, char *buf, size_t len, int *error, int *ext)
int KSI_CTX_getPublicationCertEmail(KSI_CTX *ctx, const char **address)
int KSI_CTX_setRequestHeaderCallback(KSI_CTX *ctx, KSI_RequestHeaderCallback cb)
int KSI_CTX_registerGlobals(KSI_CTX *ctx, int(*initFn)(void), void(*cleanupFn)(void))
int KSI_CTX_setPublicationCertEmail(KSI_CTX *ctx, const char *email)
int(* KSI_Config_Callback)(KSI_CTX *ctx, KSI_Config *conf)
Definition ksi.h:358
int KSI_CTX_setConnectionTimeoutSeconds(KSI_CTX *ctx, int timeout)
@ KSI_ENUM_DEPRECATED
Definition ksi.h:344
@ KSI_PDU_VERSION_2
Definition ksi.h:345
@ KSI_OPT_EXT_PDU_VER
Definition ksi.h:372
@ __KSI_NUMBER_OF_OPTIONS
Definition ksi.h:424
@ KSI_OPT_AGGR_PDU_VER
Definition ksi.h:366
@ KSI_OPT_EXT_CONF_RECEIVED_CALLBACK
Definition ksi.h:404
@ KSI_OPT_AGGR_HMAC_ALGORITHM
Definition ksi.h:378
@ KSI_OPT_DATAHASH_CACHE_SIZE
Definition ksi.h:389
@ KSI_OPT_PUBFILE_CACHE_TTL_SECONDS
Definition ksi.h:413
@ KSI_OPT_EXT_HMAC_ALGORITHM
Definition ksi.h:383
@ KSI_OPT_HA_SAFEGUARD
Definition ksi.h:422
@ KSI_OPT_AGGR_CONF_RECEIVED_CALLBACK
Definition ksi.h:397
@ KSI_INVALID_PUBLICATION
Definition ksi.h:176
@ KSI_SERVICE_AGGR_TOO_MANY_REQUESTS
Definition ksi.h:268
@ KSI_NETWORK_SEND_TIMEOUT
Definition ksi.h:152
@ KSI_EXTEND_NO_SUITABLE_PUBLICATION
Definition ksi.h:168
@ KSI_SERVICE_AGGR_REQUEST_TOO_LARGE
Definition ksi.h:259
@ KSI_SERVICE_AGGR_PDU_V1_RESPONSE_TO_PDU_V2_REQUEST
Definition ksi.h:281
@ KSI_ASYNC_CONNECTION_CLOSED
Definition ksi.h:326
@ KSI_HTTP_ERROR
Definition ksi.h:160
@ KSI_SERVICE_AUTHENTICATION_FAILURE
Definition ksi.h:232
@ KSI_SERVICE_AGGR_REQUEST_OVER_QUOTA
Definition ksi.h:264
@ KSI_SERVICE_EXTENDER_REQUEST_TIME_TOO_NEW
Definition ksi.h:304
@ KSI_ASYNC_NOT_FINISHED
Definition ksi.h:103
@ KSI_PUBLICATIONS_FILE_NOT_CONFIGURED
Definition ksi.h:62
@ KSI_NETWORK_RECIEVE_TIMEOUT
Definition ksi.h:156
@ KSI_PUBLICATIONS_FILE_NOT_SIGNED_WITH_PKI
Definition ksi.h:180
@ KSI_OK
Definition ksi.h:49
@ KSI_INVALID_PKI_SIGNATURE
Definition ksi.h:111
@ KSI_INCOMPATIBLE_HASH_CHAIN
Definition ksi.h:216
@ KSI_SERVICE_EXTENDER_DATABASE_CORRUPT
Definition ksi.h:296
@ KSI_SERVICE_INVALID_PAYLOAD
Definition ksi.h:236
@ KSI_SERVICE_EXTENDER_PDU_V1_RESPONSE_TO_PDU_V2_REQUEST
Definition ksi.h:319
@ KSI_SERVICE_EXTENDER_REQUEST_TIME_IN_FUTURE
Definition ksi.h:309
@ KSI_OUT_OF_MEMORY
Definition ksi.h:136
@ KSI_NETWORK_CONNECTION_TIMEOUT
Definition ksi.h:148
@ KSI_REQUEST_PENDING
Definition ksi.h:196
@ KSI_SERVICE_EXTENDER_INVALID_TIME_RANGE
Definition ksi.h:288
@ KSI_UNAVAILABLE_HASH_ALGORITHM
Definition ksi.h:91
@ KSI_UNSUPPORTED_PDU_VERSION
Definition ksi.h:211
@ KSI_INVALID_SIGNATURE
Definition ksi.h:107
@ KSI_INVALID_STATE
Definition ksi.h:119
@ KSI_INVALID_ARGUMENT
Definition ksi.h:77
@ KSI_SERVICE_EXTENDER_PDU_V2_RESPONSE_TO_PDU_V1_REQUEST
Definition ksi.h:314
@ KSI_EXTEND_WRONG_CAL_CHAIN
Definition ksi.h:164
@ KSI_TLV_PAYLOAD_TYPE_MISMATCH
Definition ksi.h:99
@ KSI_UNKNOWN_HASH_ALGORITHM_ID
Definition ksi.h:123
@ KSI_INVALID_VERIFICATION_INPUT
Definition ksi.h:70
@ KSI_BUFFER_OVERFLOW
Definition ksi.h:95
@ KSI_PUBFILE_VERIFICATION_NOT_CONFIGURED
Definition ksi.h:66
@ KSI_AGGREGATOR_NOT_CONFIGURED
Definition ksi.h:54
@ KSI_SERVICE_EXTENDER_DATABASE_MISSING
Definition ksi.h:292
@ KSI_ASYNC_REQUEST_CACHE_FULL
Definition ksi.h:331
@ KSI_HMAC_ALGORITHM_MISMATCH
Definition ksi.h:206
@ KSI_SERVICE_INTERNAL_ERROR
Definition ksi.h:240
@ KSI_HASH_ALGORITHM_OBSOLETE
Definition ksi.h:131
@ KSI_REQUEST_ID_MISMATCH
Definition ksi.h:201
@ KSI_INVALID_FORMAT
Definition ksi.h:82
@ KSI_UNTRUSTED_HASH_ALGORITHM
Definition ksi.h:87
@ KSI_CRYPTO_FAILURE
Definition ksi.h:186
@ KSI_SERVICE_UPSTREAM_ERROR
Definition ksi.h:244
@ KSI_SERVICE_UNKNOWN_ERROR
Definition ksi.h:252
@ KSI_SERVICE_EXTENDER_REQUEST_TIME_TOO_OLD
Definition ksi.h:300
@ KSI_VERIFICATION_FAILURE
Definition ksi.h:172
@ KSI_SERVICE_AGGR_PDU_V2_RESPONSE_TO_PDU_V1_REQUEST
Definition ksi.h:276
@ KSI_HMAC_MISMATCH
Definition ksi.h:191
@ KSI_SERVICE_INVALID_REQUEST
Definition ksi.h:228
@ KSI_NETWORK_ERROR
Definition ksi.h:144
@ KSI_IO_ERROR
Definition ksi.h:140
@ KSI_SERVICE_AGGR_INPUT_TOO_LONG
Definition ksi.h:272
@ KSI_NETWORK_PROVIDER_DISABLED
Definition ksi.h:221
@ KSI_UNKNOWN_ERROR
Definition ksi.h:337
@ KSI_SERVICE_UPSTREAM_TIMEOUT
Definition ksi.h:248
@ KSI_EXTENDER_NOT_CONFIGURED
Definition ksi.h:58
@ KSI_HASH_ALGORITHM_DEPRECATED
Definition ksi.h:127
@ KSI_PKI_CERTIFICATE_NOT_TRUSTED
Definition ksi.h:115
struct KSI_DataHash_st KSI_DataHash
Definition hash.h:52
struct KSI_ExtendReq_st KSI_ExtendReq
Definition types.h:54
struct KSI_VerificationContext_st KSI_VerificationContext
Definition types.h:73
struct KSI_NetHandle_st KSI_RequestHandle
Definition types.h:115
struct KSI_AggregationReq_st KSI_AggregationReq
Definition types.h:51
struct KSI_NetworkClient_st KSI_NetworkClient
Definition types.h:121
struct KSI_PKITruststore_st KSI_PKITruststore
Definition types.h:103
struct KSI_Config_st KSI_Config
Definition types.h:50
int(* KSI_RequestHeaderCallback)(KSI_Header *hdr)
Definition types.h:83
struct KSI_Signature_st KSI_Signature
Definition types.h:67
struct KSI_CertConstraint_st KSI_CertConstraint
Definition types.h:64
struct KSI_Policy_st KSI_Policy
Definition types.h:70
struct KSI_PublicationsFile_st KSI_PublicationsFile
Definition publicationsfile.h:45
const KSI_Policy * KSI_VERIFICATION_POLICY_EMPTY