/* ************************************************************************ ** ** Copyright (c) 2010 by ** Core|Vision B.V. ** Cereslaan 10b ** 5384 VT Heesch ** The Netherlands ** ** All Rights Reserved ** ************************************************************************ */ /* ************************************************************************ ** ** Project name: Dual Inventive: Utility Library ** Filename: cp3000-sign.h ** Author: Jack Weeland ** Date: January 27, 2010 ** File version: 1.00 of January 27, 2010 ** ************************************************************************ */ /* ************************************************************************ ** ** CP3000 digital signatures ** ************************************************************************ */ #ifndef __CP3000_SIGN_H #define __CP3000_SIGN_H #include /* ** Definitions - digital signature */ // length (in bits) of the signature #define DIGITAL_SIGNATURE_BITS 160 /* ** Definitions - data types */ // Context for a digital signature typedef struct CP3000_SIGNATURE *cp3000_signature_t; /* ** Exported functions - Digitial signatures and message digest */ // Calculate digital signature (three steps) // Three steps: init, add data component(s) and calculate signature (with clean-up). // Step 3 returns the size of the signature in bytes cp3000_signature_t cp3000_sign_init(cp3000_key_t private_key); int cp3000_sign_add(cp3000_signature_t, const char *s); int cp3000_sign_done(cp3000_signature_t, unsigned char *signature, size_t sig_sz); // Verify a digital signature // Three steps: init, add data component(s) and verify signature (with clean-up). // Step 3 returns 0 on success and -1 on error (i.e. signature not okay) cp3000_signature_t cp3000_verify_init(cp3000_key_t public_key); int cp3000_verify_add(cp3000_signature_t, const char *s); int cp3000_verify_done(cp3000_signature_t, const unsigned char *signature, size_t sig_sz); // Calculate message digest (three steps) // Three steps: init, add data component(s) and calculate the digest (with clean-up). // Step 3 returns the size of the signature in bytes cp3000_signature_t cp3000_digest_init(); int cp3000_digest_add(cp3000_signature_t, const char *s); int cp3000_digest_done(cp3000_signature_t, unsigned char *signature, size_t sig_sz); #endif /* __CP3000_SIGN_H */