blob: d263d4b76985d9cd1b983a690080621162ff8e69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <u.h>
#include <libc.h>
#include <authsrv.h>
int
opasstokey(char *key, char *p)
{
uchar t[10];
int c, n;
n = strlen(p);
memset(t, ' ', sizeof t);
if(n < 5)
return 0;
if(n > 10)
n = 10;
strncpy((char*)t, p, n);
if(n >= 9){
c = p[8] & 0xf;
if(n == 10)
c += p[9] << 4;
for(n = 0; n < 8; n++)
if(c & (1 << n))
t[n] -= ' ';
}
for(n = 0; n < 7; n++)
key[n] = (t[n] >> n) + (t[n+1] << (8 - (n+1)));
return 1;
}
|