mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Improve random number generator
This commit is contained in:
parent
f72ba4d36f
commit
4ef3cc8eba
@ -128,20 +128,20 @@ unsigned long prng() {
|
||||
unsigned short seed_num;
|
||||
unsigned long seed;
|
||||
|
||||
seed_num = seed & 16BITS_MASK;
|
||||
num = seed & 31BITS_MASK;
|
||||
seed_num = seed & N16BITS_MASK;
|
||||
num = seed & N31BITS_MASK;
|
||||
|
||||
p = num_matrix1;
|
||||
|
||||
for(n = 18; n-- ; ) {
|
||||
num = 30903*seed_num + (num>>16);
|
||||
*p++ = seed_num = num & 16BITS_MASK;
|
||||
*p++ = seed_num = num & N16BITS_MASK;
|
||||
if (n == 9)
|
||||
p = num_matrix2;
|
||||
}
|
||||
|
||||
num_matrix1[0] &= 15BITS_MASK;
|
||||
num_matrix2[0] &= 15BITS_MASK;
|
||||
num_matrix1[0] &= N15BITS_MASK;
|
||||
num_matrix2[0] &= N15BITS_MASK;
|
||||
memcpy((char*)num_matrix1+2,(char*)num_matrix1+1,8*sizeof(short));
|
||||
memcpy((char*)num_matrix2+2,(char*)num_matrix2+1,8*sizeof(short));
|
||||
|
||||
@ -158,10 +158,10 @@ unsigned long prng() {
|
||||
5555 * num_matrix2[6] + 6666 * num_matrix2[7] +
|
||||
7777 * num_matrix2[8] + 9272 * num_matrix2[9];
|
||||
|
||||
num_matrix1[0] = num1/16BITS_MASK;
|
||||
num_matrix2[0] = num2/16BITS_MASK;
|
||||
num_matrix1[1] = 16BITS_MASK&num1;
|
||||
num_matrix2[1] = 16BITS_MASK&num2;
|
||||
num_matrix1[0] = num1/N16BITS_MASK;
|
||||
num_matrix2[0] = num2/N16BITS_MASK;
|
||||
num_matrix1[1] = N16BITS_MASK&num1;
|
||||
num_matrix2[1] = N16BITS_MASK&num2;
|
||||
|
||||
seed = (((long)num_matrix1[1])<<16)+(long)num_matrix2[1];
|
||||
|
||||
|
@ -34,10 +34,10 @@ struct glinear {
|
||||
uint32_t add;
|
||||
};
|
||||
|
||||
#define 16BITS_MASK 65536L
|
||||
#define 16BITS_MASK 0xFFFF
|
||||
#define 15BITS_MASK 0x7FFF
|
||||
#define 31BITS_MASK 0x7FFFFFFF
|
||||
#define N16BITS_MASK 65536L
|
||||
#define N16BITS_MASK 0xFFFF
|
||||
#define N15BITS_MASK 0x7FFF
|
||||
#define N31BITS_MASK 0x7FFFFFFF
|
||||
|
||||
char DSOLOCAL *hmac(modsec_rec *msr,const unsigned char *key, int key_len,
|
||||
char *msg, int msglen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user