mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 01:23:48 +08:00
PPP, magic, enables building without PPP_MD5_RANDM support
The only API difference with and without the PPP_MD5_RANDM support is the availability of the random_bytes() function. Added a random_bytes() function on top of magic() when PPP_MD5_RANDM support is not enabled, thus allowing builds for both cases. PPP_MD5_RANDM is still enabled by default (it was mandatory) if a protocol using encryption is enabled, such as CHAP, EAP, or L2TP auth support.
This commit is contained in:
@@ -209,7 +209,7 @@ static u32_t magic_randomseed = 0; /* Seed used for random number generatio
|
||||
* operational. Thus we call it again on the first random
|
||||
* event.
|
||||
*/
|
||||
void magic_init() {
|
||||
void magic_init(void) {
|
||||
magic_randomseed += sys_jiffies();
|
||||
|
||||
/* Initialize the Borland random number generator. */
|
||||
@@ -249,10 +249,24 @@ void magic_randomize(void) {
|
||||
* operator or network events in which case it will be pseudo random
|
||||
* seeded by the real time clock.
|
||||
*/
|
||||
u32_t magic() {
|
||||
u32_t magic(void) {
|
||||
return ((((u32_t)rand() << 16) + rand()) + magic_randomseed);
|
||||
}
|
||||
|
||||
/*
|
||||
* random_bytes - Fill a buffer with random bytes.
|
||||
*/
|
||||
void random_bytes(unsigned char *buf, u32_t buf_len) {
|
||||
u32_t new_rand, n;
|
||||
|
||||
while (buf_len > 0) {
|
||||
new_rand = magic();
|
||||
n = LWIP_MIN(buf_len, sizeof(new_rand));
|
||||
MEMCPY(buf, &new_rand, n);
|
||||
buf += n;
|
||||
buf_len -= n;
|
||||
}
|
||||
}
|
||||
#endif /* PPP_MD5_RANDM */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user