equal
deleted
inserted
replaced
66 #if defined(WITH_GETRANDOM) |
66 #if defined(WITH_GETRANDOM) |
67 /* |
67 /* |
68 * This acts like a read from /dev/urandom with the exception that it |
68 * This acts like a read from /dev/urandom with the exception that it |
69 * *does* block if the entropy pool is not yet initialized. |
69 * *does* block if the entropy pool is not yet initialized. |
70 */ |
70 */ |
71 ret = getrandom(buf, len, 0); |
71 int left = len; |
|
72 char *b = buf; |
72 |
73 |
73 if(ret < 0) { |
74 do { |
74 lua_pushstring(L, strerror(errno)); |
75 ret = getrandom(b, left, 0); |
75 return lua_error(L); |
76 |
76 } |
77 if(ret < 0) { |
|
78 lua_pushstring(L, strerror(errno)); |
|
79 return lua_error(L); |
|
80 } |
|
81 |
|
82 b += ret; |
|
83 left -= ret; |
|
84 } while(left > 0); |
|
85 |
|
86 ret = len; |
77 |
87 |
78 #elif defined(WITH_ARC4RANDOM) |
88 #elif defined(WITH_ARC4RANDOM) |
79 arc4random_buf(buf, len); |
89 arc4random_buf(buf, len); |
80 ret = len; |
90 ret = len; |
81 #elif defined(WITH_OPENSSL) |
91 #elif defined(WITH_OPENSSL) |