libauthsrv: import better passtodeskey() function (from drawterm)

This commit is contained in:
cinap_lenrek 2023-01-06 21:16:21 +00:00
parent 6940bbc50b
commit 19c89f5212

View file

@ -9,14 +9,14 @@ passtodeskey(char key[DESKEYLEN], char *p)
uchar buf[PASSWDLEN], *t;
int i, n;
n = strlen(p);
if(n >= PASSWDLEN)
n = PASSWDLEN-1;
memset(buf, ' ', 8);
t = buf;
strncpy((char*)t, p, n);
t[n] = 0;
n = strlen(p);
if(n >= sizeof(buf))
n = sizeof(buf)-1;
memmove(buf, p, n);
buf[n] = 0;
memset(key, 0, DESKEYLEN);
t = buf;
for(;;){
for(i = 0; i < DESKEYLEN; i++)
key[i] = (t[i] >> i) + (t[i+1] << (8 - (i+1)));