Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[silc.git] / lib / silccrypt / silchash.h
index d7317f0c0b067013fb66993dff59f48c9913dfc7..dee139efdc6fa760b757c6db38ec4884a069ad3d 100644 (file)
@@ -1,10 +1,10 @@
 /*
 
-  silchash.h 
+  silchash.h
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2002 Pekka Riikonen
+  Copyright (C) 1997 - 2007 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
@@ -34,7 +34,7 @@
 /****s* silccrypt/SilcHashAPI/SilcHash
  *
  * NAME
- * 
+ *
  *    typedef struct SilcHashStruct *SilcHash;
  *
  * DESCRIPTION
@@ -50,7 +50,7 @@ typedef struct SilcHashStruct *SilcHash;
 /****s* silccrypt/SilcHashAPI/SilcHashObject
  *
  * NAME
- * 
+ *
  *    typedef struct { ... } SilcHashObject;
  *
  * DESCRIPTION
@@ -65,8 +65,9 @@ typedef struct SilcHashStruct *SilcHash;
  ***/
 typedef struct {
   char *name;
-  SilcUInt32 hash_len;
-  SilcUInt32 block_len;
+  char *oid;
+  SilcUInt16 hash_len;
+  SilcUInt16 block_len;
 
   void (*init)(void *);
   void (*update)(void *, const unsigned char *, SilcUInt32);
@@ -197,6 +198,21 @@ SilcBool silc_hash_unregister_all(void);
  ***/
 SilcBool silc_hash_alloc(const unsigned char *name, SilcHash *new_hash);
 
+/****f* silccrypt/SilcHashAPI/silc_hash_alloc_by_oid
+ *
+ * SYNOPSIS
+ *
+ *    SilcBool silc_hash_alloc_by_oid(const char *oid, SilcHash *new_hash);
+ *
+ * DESCRIPTION
+ *
+ *    Same as silc_hash_alloc but allocates the hash algorithm by the
+ *    hash algorithm OID string indicated by `oid'. Returns FALSE if such
+ *    hash function does not exist.
+ *
+ ***/
+SilcBool silc_hash_alloc_by_oid(const char *oid, SilcHash *new_hash);
+
 /****f* silccrypt/SilcHashAPI/silc_hash_free
  *
  * SYNOPSIS
@@ -278,6 +294,20 @@ SilcUInt32 silc_hash_block_len(SilcHash hash);
  ***/
 const char *silc_hash_get_name(SilcHash hash);
 
+/****f* silccrypt/SilcHashAPI/silc_hash_get_oid
+ *
+ * SYNOPSIS
+ *
+ *    const char *silc_hash_get_name(SilcHash hash);
+ *
+ * DESCRIPTION
+ *
+ *    Returns the hash OID string.  Returns NULL if the hash doesn't have
+ *    OID string.  Use strlen() to get the OID string length.
+ *
+ ***/
+const char *silc_hash_get_oid(SilcHash hash);
+
 /****f* silccrypt/SilcHashAPI/silc_hash_make
  *
  * SYNOPSIS
@@ -310,7 +340,7 @@ void silc_hash_make(SilcHash hash, const unsigned char *data,
  *    put them into a buffer and compute the digest from the buffer by
  *    calling the silc_hash_make, or you can use the silc_hash_init,
  *    silc_hash_update and silc_hash_final to do the digest.  This function
- *    prepares the allocated hash function context for this kind of digest 
+ *    prepares the allocated hash function context for this kind of digest
  *    computation.  To add the data to be used in the digest computation
  *    call the silc_hash_update function.
  *