X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilccrypt%2Fsilchmac.h;h=66d82349b2279091c6fa1484d67619539a3c62c4;hp=a94d2b167d84a3f660270dd1565acba8e13e6a1c;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hpb=1e4e7d57f414a337e084df4072a2690f0c9b71c6 diff --git a/lib/silccrypt/silchmac.h b/lib/silccrypt/silchmac.h index a94d2b16..66d82349 100644 --- a/lib/silccrypt/silchmac.h +++ b/lib/silccrypt/silchmac.h @@ -1,10 +1,10 @@ /* - silchmac.h + silchmac.h Author: Pekka Riikonen - Copyright (C) 1999 - 2001 Pekka Riikonen + Copyright (C) 1999 - 2006 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,13 +20,13 @@ #ifndef SILCHMAC_H #define SILCHMAC_H -/****h* silccrypt/SilcHMACAPI +/****h* silccrypt/SILC HMAC Interface * * DESCRIPTION * * This is the interface for HMAC, or the keyed hash values, that are * used for packet and message authentication. These routines uses - * already implemented hash functions from the SilcHashAPI. These + * already implemented hash functions from the SilcHashAPI. These * routines were created according to RFC 2104. * ***/ @@ -34,7 +34,7 @@ /****s* silccrypt/SilcHMACAPI/SilcHmac * * NAME - * + * * typedef struct SilcHmacStruct *SilcHmac; * * DESCRIPTION @@ -50,7 +50,7 @@ typedef struct SilcHmacStruct *SilcHmac; /****s* silccrypt/SilcHMACAPI/SilcHmacObject * * NAME - * + * * typedef struct { ... } SilcHmacObject; * * DESCRIPTION @@ -65,7 +65,7 @@ typedef struct SilcHmacStruct *SilcHmac; ***/ typedef struct { char *name; - uint32 len; + SilcUInt32 len; } SilcHmacObject; /* Marks for all hmacs. This can be used in silc_hmac_unregister @@ -73,7 +73,7 @@ typedef struct { #define SILC_ALL_HMACS ((SilcHmacObject *)1) /* Default hmacs for silc_hmac_register_default(). */ -extern SilcHmacObject silc_default_hmacs[]; +extern DLLAPI const SilcHmacObject silc_default_hmacs[]; /* Default HMAC in the SILC protocol */ #define SILC_DEFAULT_HMAC "hmac-sha1-96" @@ -84,7 +84,7 @@ extern SilcHmacObject silc_default_hmacs[]; * * SYNOPSIS * - * bool silc_hmac_register(SilcHmacObject *hmac); + * SilcBool silc_hmac_register(const SilcHmacObject *hmac); * * DESCRIPTION * @@ -97,13 +97,13 @@ extern SilcHmacObject silc_default_hmacs[]; * that are builtin the sources. Returns FALSE on error. * ***/ -bool silc_hmac_register(SilcHmacObject *hmac); +SilcBool silc_hmac_register(const SilcHmacObject *hmac); /****f* silccrypt/SilcHMACAPI/silc_hmac_unregister * * SYNOPSIS * - * bool silc_hmac_unregister(SilcHmacObject *hmac); + * SilcBool silc_hmac_unregister(SilcHmacObject *hmac); * * DESCRIPTION * @@ -112,13 +112,13 @@ bool silc_hmac_register(SilcHmacObject *hmac); * error. * ***/ -bool silc_hmac_unregister(SilcHmacObject *hmac); +SilcBool silc_hmac_unregister(SilcHmacObject *hmac); /****f* silccrypt/SilcHMACAPI/silc_hmac_register_default * * SYNOPSIS * - * bool silc_hmac_register_default(void); + * SilcBool silc_hmac_register_default(void); * * DESCRIPTION * @@ -131,13 +131,27 @@ bool silc_hmac_unregister(SilcHmacObject *hmac); * used). * ***/ -bool silc_hmac_register_default(void); +SilcBool silc_hmac_register_default(void); + +/****f* silccrypt/SilcHMACAPI/silc_hmac_unregister_all + * + * SYNOPSIS + * + * SilcBool silc_hmac_unregister_all(void); + * + * DESCRIPTION + * + * Unregisters all registered HMACs. + * + ***/ +SilcBool silc_hmac_unregister_all(void); /****f* silccrypt/SilcHMACAPI/silc_hmac_alloc * * SYNOPSIS * - * bool silc_hmac_alloc(char *name, SilcHash hash, SilcHmac *new_hmac); + * SilcBool silc_hmac_alloc(const char *name, SilcHash hash, + * SilcHmac *new_hmac); * * DESCRIPTION * @@ -148,7 +162,7 @@ bool silc_hmac_register_default(void); * FALSE if such HMAC does not exist. * ***/ -bool silc_hmac_alloc(char *name, SilcHash hash, SilcHmac *new_hmac); +SilcBool silc_hmac_alloc(const char *name, SilcHash hash, SilcHmac *new_hmac); /****f* silccrypt/SilcHMACAPI/silc_hmac_free * @@ -168,14 +182,14 @@ void silc_hmac_free(SilcHmac hmac); * * SYNOPSIS * - * bool silc_hmac_is_supported(const char *name); + * SilcBool silc_hmac_is_supported(const char *name); * * DESCRIPTION * * Returns TRUE if the HMAC indicated by the `name' exists. * ***/ -bool silc_hmac_is_supported(const char *name); +SilcBool silc_hmac_is_supported(const char *name); /****f* silccrypt/SilcHMACAPI/silc_hmac_get_supported * @@ -197,14 +211,14 @@ char *silc_hmac_get_supported(void); * * SYNOPSIS * - * uint32 silc_hmac_len(SilcHmac hmac); + * SilcUInt32 silc_hmac_len(SilcHmac hmac); * * DESCRIPTION * * Returns the length of the MAC that the HMAC will produce. * ***/ -uint32 silc_hmac_len(SilcHmac hmac); +SilcUInt32 silc_hmac_len(SilcHmac hmac); /****f* silccrypt/SilcHMACAPI/silc_hmac_get_hash * @@ -238,7 +252,7 @@ const char *silc_hmac_get_name(SilcHmac hmac); * SYNOPSIS * * void silc_hmac_set_key(SilcHmac hmac, const unsigned char *key, - * uint32 key_len); + * SilcUInt32 key_len); * * DESCRIPTION * @@ -250,38 +264,53 @@ const char *silc_hmac_get_name(SilcHmac hmac); * ***/ void silc_hmac_set_key(SilcHmac hmac, const unsigned char *key, - uint32 key_len); + SilcUInt32 key_len); + +/****f* silccrypt/SilcHMACAPI/silc_hmac_get_key + * + * SYNOPSIS + * + * const unsigned char * + * silc_hmac_get_key(SilcHmac hmac, SilcUInt32 *key_len); + * + * DESCRIPTION + * + * Returns the key data from the `hmac' set with silc_hamc_set_key. + * The caller must not free the returned pointer. + * + ***/ +const unsigned char *silc_hmac_get_key(SilcHmac hmac, SilcUInt32 *key_len); /****f* silccrypt/SilcHMACAPI/silc_hmac_make * * SYNOPSIS * * void silc_hmac_make(SilcHmac hmac, unsigned char *data, - * uint32 data_len, unsigned char *return_hash, - * uint32 *return_len); + * SilcUInt32 data_len, unsigned char *return_hash, + * SilcUInt32 *return_len); * * DESCRIPTION * * Computes a MAC from a data buffer indicated by the `data' of the - * length of `data_len'. The returned MAC is copied into the + * length of `data_len'. The returned MAC is copied into the * `return_hash' pointer which must be at least the size of the * value silc_hmac_len returns. The returned length is still * returned to `return_len'. * ***/ void silc_hmac_make(SilcHmac hmac, unsigned char *data, - uint32 data_len, unsigned char *return_hash, - uint32 *return_len); + SilcUInt32 data_len, unsigned char *return_hash, + SilcUInt32 *return_len); /****f* silccrypt/SilcHMACAPI/silc_hmac_make_with_key * * SYNOPSIS * * void silc_hmac_make_with_key(SilcHmac hmac, unsigned char *data, - * uint32 data_len, - * unsigned char *key, uint32 key_len, + * SilcUInt32 data_len, + * unsigned char *key, SilcUInt32 key_len, * unsigned char *return_hash, - * uint32 *return_len); + * SilcUInt32 *return_len); * * DESCRIPTION * @@ -291,19 +320,19 @@ void silc_hmac_make(SilcHmac hmac, unsigned char *data, * ***/ void silc_hmac_make_with_key(SilcHmac hmac, unsigned char *data, - uint32 data_len, - unsigned char *key, uint32 key_len, + SilcUInt32 data_len, + unsigned char *key, SilcUInt32 key_len, unsigned char *return_hash, - uint32 *return_len); + SilcUInt32 *return_len); /****f* silccrypt/SilcHMACAPI/silc_hmac_make_truncated * * SYNOPSIS * - * void silc_hmac_make_truncated(SilcHmac hmac, - * unsigned char *data, - * uint32 data_len, - * uint32 truncated_len, + * void silc_hmac_make_truncated(SilcHmac hmac, + * unsigned char *data, + * SilcUInt32 data_len, + * SilcUInt32 truncated_len, * unsigned char *return_hash); * * DESCRIPTION @@ -321,10 +350,10 @@ void silc_hmac_make_with_key(SilcHmac hmac, unsigned char *data, * truncations. * ***/ -void silc_hmac_make_truncated(SilcHmac hmac, - unsigned char *data, - uint32 data_len, - uint32 truncated_len, +void silc_hmac_make_truncated(SilcHmac hmac, + unsigned char *data, + SilcUInt32 data_len, + SilcUInt32 truncated_len, unsigned char *return_hash); /****f* silccrypt/SilcHMACAPI/silc_hmac_init @@ -341,7 +370,7 @@ void silc_hmac_make_truncated(SilcHmac hmac, * put them into a buffer and compute the MAC from the buffer by * calling the silc_hmac_make, or you can use the silc_hmac_init, * silc_hmac_update and silc_hmac_final to do the MAC. This function - * prepares the allocated HMAC context for this kind of MAC + * prepares the allocated HMAC context for this kind of MAC * computation. The caller must have been called the function * silc_hmac_set_key before calling this function. To add the * data to be used in the MAC computation call the silc_hmac_update @@ -355,7 +384,7 @@ void silc_hmac_init(SilcHmac hmac); * SYNOPSIS * * void silc_hmac_init_with_key(SilcHmac hmac, const unsigned char *key, - * uint32 key_len); + * SilcUInt32 key_len); * * DESCRIPTION * @@ -364,14 +393,14 @@ void silc_hmac_init(SilcHmac hmac); * ***/ void silc_hmac_init_with_key(SilcHmac hmac, const unsigned char *key, - uint32 key_len); + SilcUInt32 key_len); /****f* silccrypt/SilcHMACAPI/silc_hmac_update * * SYNOPSIS * * void silc_hmac_update(SilcHmac hmac, const unsigned char *data, - * uint32 data_len); + * SilcUInt32 data_len); * * DESCRIPTION * @@ -384,7 +413,7 @@ void silc_hmac_init_with_key(SilcHmac hmac, const unsigned char *key, * EXAMPLE * * unsigned char mac[20]; - * uint32 mac_len; + * SilcUInt32 mac_len; * * silc_hmac_init(hmac); * silc_hmac_update(hmac, data, data_len); @@ -393,19 +422,19 @@ void silc_hmac_init_with_key(SilcHmac hmac, const unsigned char *key, * ***/ void silc_hmac_update(SilcHmac hmac, const unsigned char *data, - uint32 data_len); + SilcUInt32 data_len); -/****f* silccrypt/SilcHMACAPI/silc_hmac_init +/****f* silccrypt/SilcHMACAPI/silc_hmac_final * * SYNOPSIS * * void silc_hmac_final(SilcHmac hmac, unsigned char *return_hash, - * uint32 *return_len); + * SilcUInt32 *return_len); * * DESCRIPTION * * This function is used to produce the final MAC from the data - * that has been added to the HMAC context by calling the + * that has been added to the HMAC context by calling the * silc_hmac_update function. The MAC is copied in to the * `return_hash' pointer which must be at least the size that * the silc_hmac_len returns. The length of the MAC is still @@ -413,9 +442,6 @@ void silc_hmac_update(SilcHmac hmac, const unsigned char *data, * ***/ void silc_hmac_final(SilcHmac hmac, unsigned char *return_hash, - uint32 *return_len); - -void silc_hmac_set_b(SilcHmac hmac); -bool silc_hmac_get_b(SilcHmac hmac); + SilcUInt32 *return_len); #endif