/*
- silchash.h
+ silchash.h
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1999 - 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
/****s* silccrypt/SilcHashAPI/SilcHash
*
* NAME
- *
+ *
* typedef struct SilcHashStruct *SilcHash;
*
* DESCRIPTION
/****s* silccrypt/SilcHashAPI/SilcHashObject
*
* NAME
- *
+ *
* typedef struct { ... } SilcHashObject;
*
* DESCRIPTION
***/
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);
/* Default HASH function in the SILC protocol */
#define SILC_DEFAULT_HASH "sha1"
+#define SILC_HASH_MAXLEN 64
/* Macros */
#define SILC_HASH_SIM_CONTEXT_LEN "context_len"
/* Macros that can be used to declare SILC Hash API functions. */
-#define SILC_HASH_API_INIT(hash) \
+#define SILC_HASH_API_INIT(hash) \
void silc_##hash##_init(void *context)
#define SILC_HASH_API_UPDATE(hash) \
void silc_##hash##_update(void *context, const unsigned char *data, \
SilcUInt32 len)
-#define SILC_HASH_API_FINAL(hash) \
+#define SILC_HASH_API_FINAL(hash) \
void silc_##hash##_final(void *context, unsigned char *digest)
#define SILC_HASH_API_TRANSFORM(hash) \
void silc_##hash##_transform(SilcUInt32 *state, const unsigned char *buffer)
-#define SILC_HASH_API_CONTEXT_LEN(hash) \
+#define SILC_HASH_API_CONTEXT_LEN(hash) \
SilcUInt32 silc_##hash##_context_len()
/* Prototypes */
*
* SYNOPSIS
*
- * bool silc_hash_register(const SilcHashObject *hash);
+ * SilcBool silc_hash_register(const SilcHashObject *hash);
*
* DESCRIPTION
*
* that are builtin the sources. Returns FALSE on error.
*
***/
-bool silc_hash_register(const SilcHashObject *hash);
+SilcBool silc_hash_register(const SilcHashObject *hash);
/****f* silccrypt/SilcHashAPI/silc_hash_unregister
*
* SYNOPSIS
*
- * bool silc_hash_unregister(SilcHashObject *hash);
+ * SilcBool silc_hash_unregister(SilcHashObject *hash);
*
* DESCRIPTION
*
* FALSE on error.
*
***/
-bool silc_hash_unregister(SilcHashObject *hash);
+SilcBool silc_hash_unregister(SilcHashObject *hash);
/****f* silccrypt/SilcHashAPI/silc_hash_register_default
*
* SYNOPSIS
*
- * bool silc_hash_register_default(void);
+ * SilcBool silc_hash_register_default(void);
*
* DESCRIPTION
*
* which case this function should not be used).
*
***/
-bool silc_hash_register_default(void);
+SilcBool silc_hash_register_default(void);
+
+/****f* silccrypt/SilcHashAPI/silc_hash_unregister_all
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_hash_unregister_all(void);
+ *
+ * DESCRIPTION
+ *
+ * Unregisters all registered hash functions.
+ *
+ ***/
+SilcBool silc_hash_unregister_all(void);
/****f* silccrypt/SilcHashAPI/silc_hash_alloc
*
* SYNOPSIS
*
- * bool silc_hash_alloc(const unsigned char *name, SilcHash *new_hash);
+ * SilcBool silc_hash_alloc(const unsigned char *name, SilcHash *new_hash);
*
* DESCRIPTION
*
* returns FALSE if such hash function does not exist.
*
***/
-bool silc_hash_alloc(const unsigned char *name, SilcHash *new_hash);
+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
*
- * bool silc_hash_is_supported(const unsigned char *name);
+ * SilcBool silc_hash_is_supported(const unsigned char *name);
*
* DESCRIPTION
*
* Returns TRUE if the hash function indicated by the `name' exists.
*
***/
-bool silc_hash_is_supported(const unsigned char *name);
+SilcBool silc_hash_is_supported(const unsigned char *name);
/****f* silccrypt/SilcHashAPI/silc_hash_get_supported
*
***/
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
* 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.
*
*
* DESCRIPTION
*
- * Utility function which can be used to create a textual bableprint
+ * Utility function which can be used to create a textual babbleprint
* out of the data indicated by `data' of length of `data_len' bytes.
* If `hash' is NULL then SHA1 hash function is used automatically.
* The caller must free the returned string.