Use a constant salt so that entering a site and master password
will always yield the same result.
This commit is contained in:
parent
162bda494e
commit
f40668e4ef
1 changed files with 9 additions and 33 deletions
|
@ -144,43 +144,19 @@ checkparams(uint32_t maxmem, uint32_t megaops,
|
||||||
static int
|
static int
|
||||||
getsalt(uint8_t salt[32])
|
getsalt(uint8_t salt[32])
|
||||||
{
|
{
|
||||||
int fd;
|
uint8_t randomdata[32] = {
|
||||||
ssize_t lenread;
|
0x67, 0x18, 0x53, 0x16 , 0xdc, 0x1e, 0x95, 0xd2,
|
||||||
uint8_t * buf = salt;
|
0x78, 0x49, 0xc3, 0x99, 0xe6, 0x6f, 0x07, 0xc1,
|
||||||
size_t buflen = 32;
|
0xa7, 0x0d, 0x02, 0x07, 0x0f, 0x24, 0xbb, 0xfa,
|
||||||
|
0xf5, 0xb5, 0x42, 0x72, 0x94, 0x9b, 0x35, 0xa6
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Open /dev/urandom. */
|
for (i = 0; i < 32; i++)
|
||||||
if ((fd = open("/dev/urandom", O_RDONLY)) == -1)
|
salt[i] = randomdata[i];
|
||||||
goto err0;
|
|
||||||
|
|
||||||
/* Read bytes until we have filled the buffer. */
|
|
||||||
while (buflen > 0) {
|
|
||||||
if ((lenread = read(fd, buf, buflen)) == -1)
|
|
||||||
goto err1;
|
|
||||||
|
|
||||||
/* The random device should never EOF. */
|
|
||||||
if (lenread == 0)
|
|
||||||
goto err1;
|
|
||||||
|
|
||||||
/* We're partly done. */
|
|
||||||
buf += lenread;
|
|
||||||
buflen -= lenread;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close the device. */
|
|
||||||
while (close(fd) == -1) {
|
|
||||||
if (errno != EINTR)
|
|
||||||
goto err0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success! */
|
/* Success! */
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
err1:
|
|
||||||
close(fd);
|
|
||||||
err0:
|
|
||||||
/* Failure! */
|
|
||||||
return (4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Reference in a new issue