Added SILC Server library.
[silc.git] / lib / silccrypt / silchmac.c
index 9647aa5ee6a4b23bae1b56864845e5e52aef45dd..6b3abed3dc6376663c76592ccf48b813dccea4a0 100644 (file)
@@ -18,7 +18,7 @@
 */
 /* $Id$ */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 /* HMAC context */
 struct SilcHmacStruct {
@@ -39,11 +39,11 @@ SilcDList silc_hmac_list = NULL;
 /* Default hmacs for silc_hmac_register_default(). */
 const SilcHmacObject silc_default_hmacs[] =
 {
-  { "hmac-sha1-96", 12 },
   { "hmac-sha256-96", 12 },
+  { "hmac-sha1-96", 12 },
   { "hmac-md5-96", 12 },
-  { "hmac-sha1", 20 },
   { "hmac-sha256", 32 },
+  { "hmac-sha1", 20 },
   { "hmac-md5", 16 },
 
   { NULL, 0 }
@@ -54,7 +54,7 @@ static void silc_hmac_init_internal(SilcHmac hmac, unsigned char *key,
 {
   SilcHash hash = hmac->hash;
   SilcUInt32 block_len;
-  unsigned char hvalue[20];
+  unsigned char hvalue[SILC_HASH_MAXLEN];
   int i;
 
   memset(hmac->inner_pad, 0, sizeof(hmac->inner_pad));
@@ -84,7 +84,7 @@ static void silc_hmac_init_internal(SilcHmac hmac, unsigned char *key,
 /* Registers a new HMAC into the SILC. This function is used at the
    initialization of the SILC. */
 
-bool silc_hmac_register(const SilcHmacObject *hmac)
+SilcBool silc_hmac_register(const SilcHmacObject *hmac)
 {
 #ifndef SILC_EPOC
   SilcHmacObject *new;
@@ -116,7 +116,7 @@ bool silc_hmac_register(const SilcHmacObject *hmac)
 
 /* Unregister a HMAC from the SILC. */
 
-bool silc_hmac_unregister(SilcHmacObject *hmac)
+SilcBool silc_hmac_unregister(SilcHmacObject *hmac)
 {
 #ifndef SILC_EPOC
   SilcHmacObject *entry;
@@ -150,7 +150,7 @@ bool silc_hmac_unregister(SilcHmacObject *hmac)
    The application may use this to register the default hmacs if
    specific hmacs in any specific order is not wanted. */
 
-bool silc_hmac_register_default(void)
+SilcBool silc_hmac_register_default(void)
 {
 #ifndef SILC_EPOC
   int i;
@@ -162,7 +162,7 @@ bool silc_hmac_register_default(void)
   return TRUE;
 }
 
-bool silc_hmac_unregister_all(void)
+SilcBool silc_hmac_unregister_all(void)
 {
 #ifndef SILC_EPOC
   SilcHmacObject *entry;
@@ -185,7 +185,7 @@ bool silc_hmac_unregister_all(void)
    of the HMAC.  If it is NULL then the hash function is allocated and
    the name of the hash algorithm is derived from the `name'. */
 
-bool silc_hmac_alloc(const char *name, SilcHash hash, SilcHmac *new_hmac)
+SilcBool silc_hmac_alloc(const char *name, SilcHash hash, SilcHmac *new_hmac)
 {
   SILC_LOG_DEBUG(("Allocating new HMAC"));
 
@@ -283,7 +283,7 @@ const char *silc_hmac_get_name(SilcHmac hmac)
 
 /* Returns TRUE if HMAC `name' is supported. */
 
-bool silc_hmac_is_supported(const char *name)
+SilcBool silc_hmac_is_supported(const char *name)
 {
 #ifndef SILC_EPOC
   SilcHmacObject *entry;
@@ -405,7 +405,7 @@ void silc_hmac_make_truncated(SilcHmac hmac, unsigned char *data,
                              SilcUInt32 truncated_len,
                              unsigned char *return_hash)
 {
-  unsigned char hvalue[20];
+  unsigned char hvalue[SILC_HASH_MAXLEN];
 
   SILC_LOG_DEBUG(("Making HMAC for message"));
 
@@ -449,7 +449,7 @@ void silc_hmac_final(SilcHmac hmac, unsigned char *return_hash,
                     SilcUInt32 *return_len)
 {
   SilcHash hash = hmac->hash;
-  unsigned char mac[20];
+  unsigned char mac[SILC_HASH_MAXLEN];
 
   silc_hash_final(hash, mac);
   silc_hash_init(hash);