mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-17 14:46:13 +03:00
Improve random number generator
This commit is contained in:
parent
0ed1a1b8b4
commit
517abc595b
@ -125,15 +125,21 @@ char *normalize_path(modsec_rec *msr, char *input) {
|
||||
*/
|
||||
unsigned char *getkey(apr_pool_t *mp) {
|
||||
unsigned short int length = 12;
|
||||
struct glinear data;
|
||||
uint64_t seed;
|
||||
char output[13];
|
||||
char *key = NULL;
|
||||
|
||||
output[length] = '\0';
|
||||
|
||||
srand((unsigned int) time(0));
|
||||
seed = data.seed;
|
||||
srand(data.seed);
|
||||
while(length--) {
|
||||
seed *= data.mul;
|
||||
seed += data.add;
|
||||
data.seed = seed % data.mod;
|
||||
output[length] = (rand() % 94 + 33);
|
||||
srand(rand());
|
||||
srand(data.seed + rand() + time(0));
|
||||
}
|
||||
|
||||
key = apr_psprintf(mp,"%s",output);
|
||||
|
@ -27,6 +27,13 @@
|
||||
#define INT32_MAX (2147483647)
|
||||
#endif
|
||||
|
||||
struct glinear {
|
||||
uint32_t seed;
|
||||
uint32_t mod;
|
||||
uint32_t mul;
|
||||
uint32_t add;
|
||||
};
|
||||
|
||||
char DSOLOCAL *hmac(modsec_rec *msr,const unsigned char *key, int key_len,
|
||||
char *msg, int msglen);
|
||||
unsigned char DSOLOCAL *do_hash_link(modsec_rec *msr, char *link,
|
||||
|
Loading…
x
Reference in New Issue
Block a user