Overview
| Comment: | switch from syscall to getrandom | 
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive | 
| Timelines: | family | ancestors | descendants | both | trunk | 
| Files: | files | file ages | folders | 
| SHA3-256: | 6b3b3fa87f45e77ca4ac432e1be5e5f3 | 
| User & Date: | lexi on 2019-07-19 11:47:45 | 
| Other Links: | manifest | tags | 
Context
| 2019-07-19 | ||
| 11:50 | fix static assert check-in: da3eccdcfa user: lexi tags: trunk | |
| 11:47 | switch from syscall to getrandom check-in: 6b3b3fa87f user: lexi tags: trunk | |
| 11:34 | add mkpw check-in: 42ea2c7296 user: lexi tags: trunk | |
Changes
Modified mkpw.c from [a0f03f1e22] to [2857320b30].
| 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
 | 
 *  → mkpw is unlikely to be portable to non-POSIX
 *    systems, but should run fine on Linux as well
 *    as BSDs with getrandom() support.
 */
#include <unistd.h>
#include <sys/random.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#define sz(a) ( sizeof (a) / sizeof (a) [0] )
#define say(x) (write(2, (x), sizeof (x)))
#ifdef _CLIPBOARD
................................................................................
	char buf[len+1];
	/* *buf = 0; */
	unsigned char noise[len];
	for (size_t i = 0; i<q; ++i) {
		unsigned char* cur = noise;
		getrandom(noise, len, 0);
		for(char* ptr = buf; ptr < buf + len; ++ptr, ++cur) {
			*ptr = tbl[*cur % chars]; /* such a waste of entropy… :( */
		}
		buf[len] = '\n';
		write(1, buf, len + 1);
 | 
>
 
>
|
 | 
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 | * → mkpw is unlikely to be portable to non-POSIX * systems, but should run fine on Linux as well * as BSDs with getrandom() support. */ #include <unistd.h> #include <sys/random.h> #include <sys/syscall.h> #include <stddef.h> #include <stdint.h> #include <string.h> #define sz(a) ( sizeof (a) / sizeof (a) [0] ) #define say(x) (write(2, (x), sizeof (x))) #ifdef _CLIPBOARD ................................................................................ char buf[len+1]; /* *buf = 0; */ unsigned char noise[len]; for (size_t i = 0; i<q; ++i) { unsigned char* cur = noise; syscall(SYS_getrandom, noise, len, 0); /* getrandom(noise, len, 0); // android doesnt like it */ for(char* ptr = buf; ptr < buf + len; ++ptr, ++cur) { *ptr = tbl[*cur % chars]; /* such a waste of entropy… :( */ } buf[len] = '\n'; write(1, buf, len + 1); |