summaryrefslogtreecommitdiff
path: root/common/attrs.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-20 09:33:04 +0100
committerStef Walter <stefw@gnome.org>2013-03-20 10:54:00 +0100
commitf45942a4fc3e1c5219e9b5201b82203337ee7280 (patch)
treef83313676d1c8de9dbc48d161e16c13264bc8049 /common/attrs.c
parent1dc227b4fce16fcc721276925492f4ba4db00b4f (diff)
hash: Add the murmur2 hash and start using it
Add implementation of the murmur2 hash function, and start using it for our dictionaries. Our implementation is incremental like our other hash functions. Also remove p11_oid_hash() which wasn't being used. In addition fix several tests whose success was based on the way that the dictionary hashed. This was a hidden testing bug.
Diffstat (limited to 'common/attrs.c')
-rw-r--r--common/attrs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/common/attrs.c b/common/attrs.c
index 5539789..cce1aaf 100644
--- a/common/attrs.c
+++ b/common/attrs.c
@@ -40,12 +40,14 @@
#include "compat.h"
#include "constants.h"
#include "debug.h"
+#include "hash.h"
#include "pkcs11.h"
#include "pkcs11x.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -481,11 +483,12 @@ unsigned int
p11_attr_hash (const void *data)
{
const CK_ATTRIBUTE *attr = data;
- unsigned int hash = (unsigned int)attr->type;
- const char *p, *end;
+ uint32_t hash;
- for (p = attr->pValue, end = p + attr->ulValueLen ; p != NULL && p != end; p++)
- hash = (hash << 5) - hash + *p;
+ p11_hash_murmur2 (&hash,
+ &attr->type, sizeof (attr->type),
+ attr->pValue, (size_t)attr->ulValueLen,
+ NULL);
return hash;
}