summaryrefslogtreecommitdiffstats
path: root/security/nss/lib/ssl/sslbloom.c
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-28 07:38:20 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-28 07:38:20 +0200
commit6b2bba06b433fb75979ab6daf7bbe8bc76c53875 (patch)
tree75803b4683889e6e0d2a3faef30415db3ff7b3ba /security/nss/lib/ssl/sslbloom.c
parent72def35cd0cf3649b6d7ab72b66117df3e1c33fc (diff)
parentc75dae3ed21bfa5a8ae46cd83d18329af5bea05a (diff)
downloadUXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.gz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.lz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.xz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into pm_url_1
Diffstat (limited to 'security/nss/lib/ssl/sslbloom.c')
-rw-r--r--security/nss/lib/ssl/sslbloom.c94
1 files changed, 0 insertions, 94 deletions
diff --git a/security/nss/lib/ssl/sslbloom.c b/security/nss/lib/ssl/sslbloom.c
deleted file mode 100644
index 3d5f9d1f1..000000000
--- a/security/nss/lib/ssl/sslbloom.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * A bloom filter.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "sslbloom.h"
-#include "prnetdb.h"
-#include "secport.h"
-
-static inline unsigned int
-sslBloom_Size(unsigned int bits)
-{
- return (bits >= 3) ? (1 << (bits - 3)) : 1;
-}
-
-SECStatus
-sslBloom_Init(sslBloomFilter *filter, unsigned int k, unsigned int bits)
-{
- PORT_Assert(filter);
- PORT_Assert(bits > 0);
- PORT_Assert(bits <= sizeof(PRUint32) * 8);
- PORT_Assert(k > 0);
-
- filter->filter = PORT_ZNewArray(PRUint8, sslBloom_Size(bits));
- if (!filter->filter) {
- return SECFailure; /* Error code already set. */
- }
-
- filter->k = k;
- filter->bits = bits;
- return SECSuccess;
-}
-
-void
-sslBloom_Zero(sslBloomFilter *filter)
-{
- PORT_Memset(filter->filter, 0, sslBloom_Size(filter->bits));
-}
-
-void
-sslBloom_Fill(sslBloomFilter *filter)
-{
- PORT_Memset(filter->filter, 0xff, sslBloom_Size(filter->bits));
-}
-
-static PRBool
-sslBloom_AddOrCheck(sslBloomFilter *filter, const PRUint8 *hashes, PRBool add)
-{
- unsigned int iteration;
- unsigned int bitIndex;
- PRUint32 tmp = 0;
- PRUint8 mask;
- unsigned int bytes = (filter->bits + 7) / 8;
- unsigned int shift = (bytes * 8) - filter->bits;
- PRBool found = PR_TRUE;
-
- PORT_Assert(bytes <= sizeof(unsigned int));
-
- for (iteration = 0; iteration < filter->k; ++iteration) {
- PORT_Memcpy(((PRUint8 *)&tmp) + (sizeof(tmp) - bytes),
- hashes, bytes);
- hashes += bytes;
- bitIndex = PR_ntohl(tmp) >> shift;
-
- mask = 1 << (bitIndex % 8);
- found = found && filter->filter[bitIndex / 8] & mask;
- if (add) {
- filter->filter[bitIndex / 8] |= mask;
- }
- }
- return found;
-}
-
-PRBool
-sslBloom_Add(sslBloomFilter *filter, const PRUint8 *hashes)
-{
- return sslBloom_AddOrCheck(filter, hashes, PR_TRUE);
-}
-
-PRBool
-sslBloom_Check(sslBloomFilter *filter, const PRUint8 *hashes)
-{
- return sslBloom_AddOrCheck(filter, hashes, PR_FALSE);
-}
-
-void
-sslBloom_Destroy(sslBloomFilter *filter)
-{
- PORT_Free(filter->filter);
- PORT_Memset(filter, 0, sizeof(*filter));
-}