diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/auth/lib/keyfmt.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/auth/lib/keyfmt.c')
-rwxr-xr-x | sys/src/cmd/auth/lib/keyfmt.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/src/cmd/auth/lib/keyfmt.c b/sys/src/cmd/auth/lib/keyfmt.c new file mode 100755 index 000000000..86c2378a3 --- /dev/null +++ b/sys/src/cmd/auth/lib/keyfmt.c @@ -0,0 +1,29 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> +#include "authcmdlib.h" + +/* + * print a key in des standard form + */ +int +keyfmt(Fmt *f) +{ + uchar key[8]; + char buf[32]; + uchar *k; + int i; + + k = va_arg(f->args, uchar*); + key[0] = 0; + for(i = 0; i < 7; i++){ + key[i] |= k[i] >> i; + key[i] &= ~1; + key[i+1] = k[i] << (7 - i); + } + key[7] &= ~1; + sprint(buf, "%.3uo %.3uo %.3uo %.3uo %.3uo %.3uo %.3uo %.3uo", + key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]); + fmtstrcpy(f, buf); + return 0; +} |