bool allocated_hash; /* TRUE if the hash was allocated */
unsigned char *key;
- uint32 key_len;
+ SilcUInt32 key_len;
unsigned char inner_pad[64];
unsigned char outer_pad[64];
};
static void silc_hmac_init_internal(SilcHmac hmac, unsigned char *key,
- uint32 key_len)
+ SilcUInt32 key_len)
{
SilcHash hash = hmac->hash;
unsigned char hvalue[20];
SILC_LOG_DEBUG(("Registering new HMAC `%s'", hmac->name));
+ /* Check for existing */
+ if (silc_hmac_list) {
+ SilcHmacObject *entry;
+ silc_dlist_start(silc_hmac_list);
+ while ((entry = silc_dlist_get(silc_hmac_list)) != SILC_LIST_END) {
+ if (!strcmp(entry->name, hmac->name))
+ return FALSE;
+ }
+ }
+
new = silc_calloc(1, sizeof(*new));
new->name = strdup(hmac->name);
new->len = hmac->len;
/* Returns the length of the MAC that the HMAC will produce. */
-uint32 silc_hmac_len(SilcHmac hmac)
+SilcUInt32 silc_hmac_len(SilcHmac hmac)
{
return hmac->hmac->len;
}
/* Sets the HMAC key used in the HMAC creation */
void silc_hmac_set_key(SilcHmac hmac, const unsigned char *key,
- uint32 key_len)
+ SilcUInt32 key_len)
{
if (hmac->key) {
memset(hmac->key, 0, hmac->key_len);
uses the internal key set with silc_hmac_set_key. */
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)
{
SILC_LOG_DEBUG(("Making HMAC for message"));
key. The key is sent as argument to the function. */
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)
{
SILC_LOG_DEBUG(("Making HMAC for message"));
routine allows these dangerous truncations. */
void silc_hmac_make_truncated(SilcHmac hmac, unsigned char *data,
- uint32 data_len,
- uint32 truncated_len,
+ SilcUInt32 data_len,
+ SilcUInt32 truncated_len,
unsigned char *return_hash)
{
unsigned char hvalue[20];
/* Same as above but with specific key */
void silc_hmac_init_with_key(SilcHmac hmac, const unsigned char *key,
- uint32 key_len)
+ SilcUInt32 key_len)
{
SilcHash hash = hmac->hash;
/* Add data to be used in the MAC computation. */
void silc_hmac_update(SilcHmac hmac, const unsigned char *data,
- uint32 data_len)
+ SilcUInt32 data_len)
{
SilcHash hash = hmac->hash;
hash->hash->update(hmac->hash_context, (unsigned char *)data, data_len);
/* Compute the final MAC. */
void silc_hmac_final(SilcHmac hmac, unsigned char *return_hash,
- uint32 *return_len)
+ SilcUInt32 *return_len)
{
SilcHash hash = hmac->hash;
unsigned char mac[20];