tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

sslbloom.h (1266B)


      1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /*
      3 * A bloom filter.
      4 *
      5 * This Source Code Form is subject to the terms of the Mozilla Public
      6 * License, v. 2.0. If a copy of the MPL was not distributed with this
      7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      8 
      9 #ifndef __sslbloom_h_
     10 #define __sslbloom_h_
     11 
     12 #include "prtypes.h"
     13 #include "seccomon.h"
     14 
     15 typedef struct sslBloomFilterStr {
     16    unsigned int k;    /* The number of hashes. */
     17    unsigned int bits; /* The number of bits in each hash: bits = log2(m) */
     18    PRUint8 *filter;   /* The filter itself. */
     19 } sslBloomFilter;
     20 
     21 SECStatus sslBloom_Init(sslBloomFilter *filter, unsigned int k, unsigned int bits);
     22 void sslBloom_Zero(sslBloomFilter *filter);
     23 void sslBloom_Fill(sslBloomFilter *filter);
     24 /* Add the given hashes to the filter.  It's the caller's responsibility to
     25 * ensure that there is at least |ceil(k*bits/8)| bytes of data available in
     26 * |hashes|. Returns PR_TRUE if the entry was already present or it was likely
     27 * to be present. */
     28 PRBool sslBloom_Add(sslBloomFilter *filter, const PRUint8 *hashes);
     29 PRBool sslBloom_Check(sslBloomFilter *filter, const PRUint8 *hashes);
     30 void sslBloom_Destroy(sslBloomFilter *filter);
     31 
     32 #endif /* __sslbloom_h_ */