Guardtime KSI c SDK
Macros | Functions
signature_helper.h File Reference
#include "types.h"

Go to the source code of this file.

Macros

#define KSI_Signature_fromFile(ctx, fileName, sig)   KSI_Signature_fromFileWithPolicy(ctx, fileName, KSI_VERIFICATION_POLICY_INTERNAL, NULL, sig)
 
#define KSI_Signature_sign(ctx, hsh, signature)   KSI_Signature_signWithPolicy(ctx, hsh, KSI_VERIFICATION_POLICY_INTERNAL, NULL, signature)
 

Functions

int KSI_Signature_getHashAlgorithm (const KSI_Signature *sig, KSI_HashAlgorithm *algo_id)
 
int KSI_Signature_createDataHasher (const KSI_Signature *sig, KSI_DataHasher **hsr)
 
int KSI_Signature_verifyWithPolicy (KSI_Signature *sig, const KSI_DataHash *docHsh, KSI_uint64_t rootLevel, const KSI_Policy *policy, KSI_VerificationContext *verificationContext)
 
int KSI_Signature_verifyDocument (KSI_Signature *sig, KSI_CTX *ctx, const void *doc, size_t doc_len)
 
int KSI_Signature_fromFileWithPolicy (KSI_CTX *ctx, const char *fileName, const KSI_Policy *policy, KSI_VerificationContext *context, KSI_Signature **sig)
 
int KSI_Signature_signWithPolicy (KSI_CTX *ctx, KSI_DataHash *hsh, const KSI_Policy *policy, KSI_VerificationContext *context, KSI_Signature **signature)
 
int KSI_Signature_create (KSI_CTX *ctx, KSI_DataHash *hsh, KSI_Signature **signature)
 
int KSI_Signature_createAggregated (KSI_CTX *ctx, KSI_DataHash *rootHash, uint64_t rootLevel, KSI_Signature **signature)
 

Macro Definition Documentation

#define KSI_Signature_fromFile (   ctx,
  fileName,
  sig 
)    KSI_Signature_fromFileWithPolicy(ctx, fileName, KSI_VERIFICATION_POLICY_INTERNAL, NULL, sig)
#define KSI_Signature_sign (   ctx,
  hsh,
  signature 
)    KSI_Signature_signWithPolicy(ctx, hsh, KSI_VERIFICATION_POLICY_INTERNAL, NULL, signature)

Function Documentation

int KSI_Signature_create ( KSI_CTX ctx,
KSI_DataHash hsh,
KSI_Signature **  signature 
)
int KSI_Signature_createAggregated ( KSI_CTX ctx,
KSI_DataHash rootHash,
uint64_t  rootLevel,
KSI_Signature **  signature 
)
int KSI_Signature_createDataHasher ( const KSI_Signature sig,
KSI_DataHasher **  hsr 
)

This method creates a data hasher object to be used on the signed data.

Parameters
[in]sigKSI signature.
[out]hsrData hasher.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_DataHasher_free, KSI_DataHasher_close, KSI_DataHasher_open, KSI_Signature_getHashAlgorithm.
int KSI_Signature_fromFileWithPolicy ( KSI_CTX ctx,
const char *  fileName,
const KSI_Policy policy,
KSI_VerificationContext context,
KSI_Signature **  sig 
)

A convenience function for reading a signature from a file. The signature is verified with the provided policy and context.

Parameters
[in]ctxKSI context.
[in]fileNameName of the signature file.
[in]policyVerification policy.
[in]contextVerification context.
[out]sigPointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
It must be noted that access to metadata, supported by some file systems, is limited by the use of function fopen. Alternate Data Streams (WIndows NTFS) and Resource Forks (OS X HFS) may or may not be supported, depending on the C standard library used in the application.
int KSI_Signature_getHashAlgorithm ( const KSI_Signature sig,
KSI_HashAlgorithm algo_id 
)

Access method for the hash algorithm used to hash the signed document.

Parameters
[in]sigKSI signature.
[out]algo_idPointer to the receiving hash id variable.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
See also
KSI_DataHasher_open, KSI_DataHash_create, KSI_DataHasher_close, KSI_Signature_createDataHasher.
int KSI_Signature_signWithPolicy ( KSI_CTX ctx,
KSI_DataHash hsh,
const KSI_Policy policy,
KSI_VerificationContext context,
KSI_Signature **  signature 
)

This function signs the given data hash hsh. This function requires a access to a working aggregator and fails if it is not accessible. The signature is verified with the provided policy and context.

Parameters
[in]ctxKSI context.
[in]hshDocument hash.
[in]policyVerification policy.
[in]contextVerification context.
[out]signaturePointer to the receiving pointer.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
For signing hash values, the use of KSI_createSignature is strongly recomended.
See also
KSI_createSignature, KSI_Signature_free
int KSI_Signature_verifyDocument ( KSI_Signature sig,
KSI_CTX ctx,
const void *  doc,
size_t  doc_len 
)

Verifies that the document matches the signature.

Parameters
[in]sigKSI signature.
[in]ctxKSI context.
[in]docPointer to document.
[in]doc_lenDocument length.
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
int KSI_Signature_verifyWithPolicy ( KSI_Signature sig,
const KSI_DataHash docHsh,
KSI_uint64_t  rootLevel,
const KSI_Policy policy,
KSI_VerificationContext verificationContext 
)

Verifies the signature based on the given verification policy.

Parameters
[in]sigKSI signature.
[in]docHshDocument hash. Can be ommited.
[in]rootLevelThe level of the input hash (usually 0).
[in]policyVerification policy. Can be ommited.
verificationContext
Returns
status code (KSI_OK, when operation succeeded, otherwise an error code).
Note
In case the docHsh is ommited, only the signature is verified.