/* Given a pointer to some noise, and a desired length, open up the * random_seed_file and get between 16 bytes and the desired length from * said file, putting the entropy in the noise pointer */ void get_entropy_from_seedfile(uint8_t *noise,int len) { char *filename = 0; int zap = 0; int seed = -1; if(key_s[DWM_S_random_seed_file] == 0) { filename = "/dev/urandom"; /* Default filename */ } else { filename = (char *)dw_to_cstr(key_s[DWM_S_random_seed_file]); zap = 1; } seed = open(filename, O_RDONLY); if(seed == -1) { dw_log_3strings("Fatal error opening random seed file ", filename,"",1); exit(1); } if(read(seed,(void *)noise,len) < 16) { dw_log_3strings("Unable to get 128 bits of entropy; file ", filename, " must be\n at least 16 bytes (128 bits) long",1); exit(1); } if(zap == 1) { free(filename); filename = 0; } close(seed); }
/* Read mararc parameters and set global variables based on those * parameters */ void process_mararc(char *name) { if(dwm_parse_mararc(name) != 1) { dw_log_3strings("Fatal error parsing file ",name,"",1); exit(1); } /* The following sanity check triggers a warning; disabled */ /*if(key_s == 0 || key_d == 0) { dw_fatal("error getting mararc parameters"); }*/ }
/* Read mararc parameters and set global variables based on those * parameters; disable cache reading if cache file is more recent */ void process_mararc(char *name) { if(dwm_parse_mararc(name) != 1) { dw_log_3strings("Fatal error parsing file ",name,"",1); exit(1); } /* The following sanity check triggers a warning; disabled */ /*if(key_s == 0 || key_d == 0) { dw_fatal("error getting mararc parameters"); }*/ /* If the dwood3rc is newer than the cache file, do not read the * cache */ if(stat(name,&mararc_st) != 0) { dw_log_string("Can not stat rc file; not reading cache",0); do_read_cache = 0; } }