Remove the -K/-J options for setting keys.

The options were never really used and do not seem especially useful;
initialization with a seed file still works.

This also fixes a bug with the initialization of the siphash key.
This commit is contained in:
Johanna Amann 2016-07-13 16:40:47 -07:00
parent 313647ce0e
commit 499ed5b566
6 changed files with 19 additions and 26 deletions

View file

@ -190,8 +190,6 @@ void usage()
fprintf(stderr, " -G|--load-seeds <file> | load seeds from given file\n");
fprintf(stderr, " -H|--save-seeds <file> | save seeds to given file\n");
fprintf(stderr, " -I|--print-id <ID name> | print out given ID\n");
fprintf(stderr, " -J|--set-seed <seed> | set the random number seed\n");
fprintf(stderr, " -K|--md5-hashkey <hashkey> | set key for MD5-keyed hashing\n");
fprintf(stderr, " -N|--print-plugins | print available plugins and exit (-NN for verbose)\n");
fprintf(stderr, " -P|--prime-dns | prime DNS\n");
fprintf(stderr, " -Q|--time | print execution time summary to stderr\n");
@ -459,7 +457,6 @@ int main(int argc, char** argv)
char* debug_streams = 0;
int parse_only = false;
int bare_mode = false;
int seed = 0;
int dump_cfg = false;
int to_xml = 0;
int do_watchdog = 0;
@ -491,8 +488,6 @@ int main(int argc, char** argv)
{"force-dns", no_argument, 0, 'F'},
{"load-seeds", required_argument, 0, 'G'},
{"save-seeds", required_argument, 0, 'H'},
{"set-seed", required_argument, 0, 'J'},
{"md5-hashkey", required_argument, 0, 'K'},
{"print-plugins", no_argument, 0, 'N'},
{"prime-dns", no_argument, 0, 'P'},
{"time", no_argument, 0, 'Q'},
@ -546,7 +541,7 @@ int main(int argc, char** argv)
opterr = 0;
char opts[256];
safe_strncpy(opts, "B:e:f:G:H:I:i:J:K:n:p:R:r:s:T:t:U:w:x:X:z:CFNPQSWabdghv",
safe_strncpy(opts, "B:e:f:G:H:I:i:n:p:R:r:s:T:t:U:w:x:X:z:CFNPQSWabdghv",
sizeof(opts));
#ifdef USE_PERFTOOLS_DEBUG
@ -661,15 +656,6 @@ int main(int argc, char** argv)
id_name = optarg;
break;
case 'J':
seed = atoi(optarg);
break;
case 'K':
MD5((const u_char*) optarg, strlen(optarg), shared_hmac_md5_key);
hmac_key_set = true;
break;
case 'N':
++print_plugins;
break;
@ -760,7 +746,7 @@ int main(int argc, char** argv)
}
#endif
init_random_seed(seed, (seed_load_file && *seed_load_file ? seed_load_file : 0) , seed_save_file);
init_random_seed((seed_load_file && *seed_load_file ? seed_load_file : 0) , seed_save_file);
// DEBUG_MSG("HMAC key: %s\n", md5_digest_print(shared_hmac_md5_key));
init_hash_function();

View file

@ -791,13 +791,14 @@ void bro_srandom(unsigned int seed)
srandom(seed);
}
void init_random_seed(uint32 seed, const char* read_file, const char* write_file)
void init_random_seed(const char* read_file, const char* write_file)
{
static const int bufsiz = 20;
uint32 buf[bufsiz];
memset(buf, 0, sizeof(buf));
int pos = 0; // accumulates entropy
bool seeds_done = false;
uint32 seed = 0;
if ( read_file )
{
@ -870,7 +871,7 @@ void init_random_seed(uint32 seed, const char* read_file, const char* write_file
if ( ! siphash_key_set )
{
assert(sizeof(buf)-64 == 16);
memcpy(shared_siphash_key, buf+64, 16);
memcpy(shared_siphash_key, reinterpret_cast<const char*>(buf)+64, 16);
siphash_key_set = true;
}

View file

@ -195,8 +195,7 @@ extern void hmac_md5(size_t size, const unsigned char* bytes,
// over the "seed" argument. If write_file is given, the seeds are written
// to that file.
//
extern void init_random_seed(uint32 seed, const char* load_file,
const char* write_file);
extern void init_random_seed(const char* load_file, const char* write_file);
// Retrieves the initial seed computed after the very first call to
// init_random_seed(). Repeated calls to init_random_seed() will not affect

View file

@ -1,2 +1,3 @@
Ok error
171249.90868
171249.90868
Ok error

View file

@ -2,7 +2,8 @@
# Test the quality of HLL once by checking adding a large number of IP entries.
#
# @TEST-EXEC: bro %INPUT > out
# @TEST-EXEC: BRO_SEED_FILE="" bro %INPUT >> out
# @TEST-EXEC: BRO_SEED_FILE="" bro %INPUT > out2
# @TEST-EXEC: head -n1 out2 >> out
# @TEST-EXEC: btest-diff out
event bro_init()
@ -15,5 +16,10 @@ event bro_init()
hll_cardinality_add(cp, count_to_v4_addr(base+i));
}
if ( |hll_cardinality_estimate(cp) - 170000| > 10000 )
print "Big error";
else
print "Ok error";
print hll_cardinality_estimate(cp);
}

View file

@ -15,7 +15,7 @@
3912865238
3596260151
517973768
3606168384
119014752
1013039866
2458585167
1462428821
0
2278350848
32767