Ejemplo n.º 1
0
static PLHashNumber
nss_certificate_hash (
  const void *key
)
{
    unsigned int i;
    PLHashNumber h;
    NSSCertificate *c = (NSSCertificate *)key;
    h = 0;
    for (i=0; i<c->issuer.size; i++)
	h = PR_ROTATE_LEFT32(h, 4) ^ ((unsigned char *)c->issuer.data)[i];
    for (i=0; i<c->serial.size; i++)
	h = PR_ROTATE_LEFT32(h, 4) ^ ((unsigned char *)c->serial.data)[i];
    return h;
}
Ejemplo n.º 2
0
// Hash string ignore case, based on PL_HashString
static PLDHashNumber
StringHash(PLDHashTable *table, const void *key)
{
    PLDHashNumber h = 0;
    for (const char *s = reinterpret_cast<const char*>(key); *s; ++s)
        h = PR_ROTATE_LEFT32(h, 4) ^ nsCRT::ToLower(*s);
    return h;
}
Ejemplo n.º 3
0
PL_HashString(const void *key)
{
    PLHashNumber h;
    const PRUint8 *s;

    h = 0;
    for (s = (const PRUint8*)key; *s; s++)
        h = PR_ROTATE_LEFT32(h, 4) ^ *s;
    return h;
}
Ejemplo n.º 4
0
/*
 * caseInsensitiveHashKey is just like PL_DHashStringKey except it
 * uses (*s & ~0x20) instead of simply *s.  This means that "aFOO" and
 * "afoo" and "aFoo" will all hash to the same thing.  It also means
 * that some strings that aren't case-insensensitively equal will hash
 * to the same value, but it's just a hash function so it doesn't
 * matter.
 */
static PLDHashNumber
caseInsensitiveStringHashKey(PLDHashTable *table, const void *key)
{
    PLDHashNumber h = 0;
    const NameTableKey* tableKey = static_cast<const NameTableKey*>(key);
    if (tableKey->mIsUnichar) {
        for (const PRUnichar* s = tableKey->mKeyStr.m2b->get();
             *s != '\0';
             s++)
            h = PR_ROTATE_LEFT32(h, 4) ^ (*s & ~0x20);
    } else {
        for (const unsigned char* s =
                 reinterpret_cast<const unsigned char*>
                                 (tableKey->mKeyStr.m1b->get());
             *s != '\0';
             s++)
            h = PR_ROTATE_LEFT32(h, 4) ^ (*s & ~0x20);
    }
    return h;
}
Ejemplo n.º 5
0
    static PLDHashNumber
    HashKey(PLDHashTable *table, const void *key)
    {
        const BlobImpl::Data *data =
            static_cast<const BlobImpl::Data *>(key);

        const PRUint8 *p = data->mBytes, *limit = p + data->mLength;
        PLDHashNumber h = 0;
        for ( ; p < limit; ++p)
            h = PR_ROTATE_LEFT32(h, 4) ^ *p;
        return h;
    }
Ejemplo n.º 6
0
static PLHashNumber
nss_item_hash
(
  const void *key
)
{
  unsigned int i;
  PLHashNumber h;
  NSSItem *it = (NSSItem *)key;
  h = 0;
  for (i=0; i<it->size; i++)
    h = PR_ROTATE_LEFT32(h, 4) ^ ((unsigned char *)it->data)[i];
  return h;
}