Guardtime KSI c SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
blocksigner.h File Reference
#include "ksi.h"

Go to the source code of this file.

Data Structures

struct  KSI_BlockSignerHandle_list_st
 

Macros

#define KSI_BlockSignerHandleList_append(lst, o)   KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o)))
 
#define KSI_BlockSignerHandleList_remove(lst, pos, o)   KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o)))
 
#define KSI_BlockSignerHandleList_indexOf(lst, o, i)   KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i)))
 
#define KSI_BlockSignerHandleList_insertAt(lst, pos, o)   KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o)))
 
#define KSI_BlockSignerHandleList_replaceAt(lst, pos, o)   KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o)))
 
#define KSI_BlockSignerHandleList_elementAt(lst, pos, o)   KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o)))
 
#define KSI_BlockSignerHandleList_length(lst)   (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0)
 
#define KSI_BlockSignerHandleList_sort(lst, cmp)   KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp)))
 
#define KSI_BlockSignerHandleList_foldl(lst, foldCtx, foldFn)   (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK)
 
#define KSI_BlockSignerHandleList_find(lst, o, f, i)   KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i)))
 
#define KSI_BlockSigner_add(signer, hsh)   KSI_BlockSigner_addLeaf((signer), (hsh), 0, NULL, NULL)
 

Typedefs

typedef struct KSI_BlockSigner_st KSI_BlockSigner
 
typedef struct
KSI_BlockSignerHandle_st 
KSI_BlockSignerHandle
 
typedef struct
KSI_BlockSignerHandle_list_st 
KSI_BlockSignerHandleList
 

Functions

int KSI_BlockSignerHandleList_new (KSI_BlockSignerHandleList **list)
 
void KSI_BlockSignerHandleList_free (KSI_BlockSignerHandleList *list)
 
int KSI_BlockSigner_new (KSI_CTX *ctx, KSI_HashAlgorithm algoId, KSI_DataHash *prevLeaf, KSI_OctetString *initVal, KSI_BlockSigner **signer)
 
void KSI_BlockSigner_free (KSI_BlockSigner *signer)
 
int KSI_BlockSigner_closeAndSign (KSI_BlockSigner *signer)
 
int KSI_BlockSigner_close (KSI_BlockSigner *signer, void *)
 
int KSI_BlockSigner_reset (KSI_BlockSigner *signer)
 
int KSI_BlockSigner_addLeaf (KSI_BlockSigner *signer, KSI_DataHash *hsh, int level, KSI_MetaData *metaData, KSI_BlockSignerHandle **handle)
 
int KSI_BlockSigner_getPrevLeaf (const KSI_BlockSigner *signer, KSI_DataHash **prevLeaf)
 
int KSI_BlockSignerHandle_getSignature (const KSI_BlockSignerHandle *handle, KSI_Signature **sig)
 
void KSI_BlockSignerHandle_free (KSI_BlockSignerHandle *handle)
 

Macro Definition Documentation

#define KSI_BlockSigner_add (   signer,
  hsh 
)    KSI_BlockSigner_addLeaf((signer), (hsh), 0, NULL, NULL)

Add a new leaf to the tree.

Parameters
[in]signerInstance of the KSI_BlockSigner.
[in]hshHash value of the leaf.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
#define KSI_BlockSignerHandleList_append (   lst,
 
)    KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o)))
#define KSI_BlockSignerHandleList_elementAt (   lst,
  pos,
 
)    KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o)))
#define KSI_BlockSignerHandleList_find (   lst,
  o,
  f,
 
)    KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i)))
#define KSI_BlockSignerHandleList_foldl (   lst,
  foldCtx,
  foldFn 
)    (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK)
#define KSI_BlockSignerHandleList_indexOf (   lst,
  o,
 
)    KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i)))
#define KSI_BlockSignerHandleList_insertAt (   lst,
  pos,
 
)    KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o)))
#define KSI_BlockSignerHandleList_length (   lst)    (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0)
#define KSI_BlockSignerHandleList_remove (   lst,
  pos,
 
)    KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o)))
#define KSI_BlockSignerHandleList_replaceAt (   lst,
  pos,
 
)    KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o)))
#define KSI_BlockSignerHandleList_sort (   lst,
  cmp 
)    KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp)))

Typedef Documentation

typedef struct KSI_BlockSigner_st KSI_BlockSigner
typedef struct KSI_BlockSignerHandle_st KSI_BlockSignerHandle

Function Documentation

int KSI_BlockSigner_addLeaf ( KSI_BlockSigner signer,
KSI_DataHash hsh,
int  level,
KSI_MetaData metaData,
KSI_BlockSignerHandle **  handle 
)

Lowlevel function for adding leafs to the aggregation tree.

Parameters
[in]signerInstance of the KSI_BlockSigner.
[in]hshHash value of the leaf node.
[in]levelLevel of the leaf node.
[in]metaDataA meta-data object to associate the input hash with, can be NULL.
[out]handleHandle for the current leaf; may be NULL.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
The function does not take ownership of hsh, metaData nor handle, it is the responsibility of the caller to free the objects.
See also
KSI_DataHash_free, KSI_MetaData_free, KSI_BlockSignerHandle_free.
int KSI_BlockSigner_close ( KSI_BlockSigner signer,
void *   
)
int KSI_BlockSigner_closeAndSign ( KSI_BlockSigner signer)

This function finalizes the computation of the tree but does not free the resources.

Parameters
[in]signerInstance of the KSI_BlockSigner.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
void KSI_BlockSigner_free ( KSI_BlockSigner signer)

Cleanup method for the KSI_BlockSigner.

Parameters
[in]signerInstance of the KSI_BlockSigner.
int KSI_BlockSigner_getPrevLeaf ( const KSI_BlockSigner signer,
KSI_DataHash **  prevLeaf 
)

Getter method for prevLeaf.

Parameters
[in]signerPointer to KSI_BlockSigner.
[out]prevLeafPointer to receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
Ownership of prevLeaf is passed to the caller who is responsible for freeing the object.
int KSI_BlockSigner_new ( KSI_CTX ctx,
KSI_HashAlgorithm  algoId,
KSI_DataHash prevLeaf,
KSI_OctetString initVal,
KSI_BlockSigner **  signer 
)

Create a new instance of KSI_BlockSigner.

Parameters
[in]ctxKSI context.
[in]algoIdAlgorithm to be used for the internal hash node computation.
[in]prevLeafFor linking two trees, the user may add the last leaf value (can be NULL)
[in]initValThe initial value for masking.
[out]signerPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
int KSI_BlockSigner_reset ( KSI_BlockSigner signer)

Resets the block signer to its initial state. This will invalidate all the KSI_BlockSignerHandle instances still remaining.

Parameters
[in]signerInstance of the KSI_BlockSigner.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
void KSI_BlockSignerHandle_free ( KSI_BlockSignerHandle handle)

Cleanup method for the handle.

Parameters
[in]handleInstance of the KSI_BlockSignerHandle
int KSI_BlockSignerHandle_getSignature ( const KSI_BlockSignerHandle handle,
KSI_Signature **  sig 
)

This function creates a new instance of a KSI signature and stores it in the output parameter.

Parameters
[in]handleHandle for the block signature.
[out]sigPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_BlockSigner_close, KSI_BlockSigner_free, KSI_BlockSigner_reset.
void KSI_BlockSignerHandleList_free ( KSI_BlockSignerHandleList list)
int KSI_BlockSignerHandleList_new ( KSI_BlockSignerHandleList **  list)