1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- #include <u.h>
- #include <libc.h>
- #include <authsrv.h>
- int
- passtokey(char *key, char *p)
- {
- uint8_t buf[ANAMELEN], *t;
- int i, n;
- n = strlen(p);
- if(n >= ANAMELEN)
- n = ANAMELEN-1;
- memset(buf, ' ', 8);
- t = buf;
- strncpy((char*)t, p, n);
- t[n] = 0;
- memset(key, 0, DESKEYLEN);
- for(;;){
- for(i = 0; i < DESKEYLEN; i++)
- key[i] = (t[i] >> i) + (t[i+1] << (8 - (i+1)));
- if(n <= 8)
- return 1;
- n -= 8;
- t += 8;
- if(n < 8){
- t -= 8 - n;
- n = 8;
- }
- encrypt(key, t, 8);
- }
- }
|