keyfmt.c 508 B

1234567891011121314151617181920212223242526272829
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "authcmdlib.h"
  5. /*
  6. * print a key in des standard form
  7. */
  8. int
  9. keyfmt(Fmt *f)
  10. {
  11. uchar key[8];
  12. char buf[32];
  13. uchar *k;
  14. int i;
  15. k = va_arg(f->args, uchar*);
  16. key[0] = 0;
  17. for(i = 0; i < 7; i++){
  18. key[i] |= k[i] >> i;
  19. key[i] &= ~1;
  20. key[i+1] = k[i] << (7 - i);
  21. }
  22. key[7] &= ~1;
  23. sprint(buf, "%.3uo %.3uo %.3uo %.3uo %.3uo %.3uo %.3uo %.3uo",
  24. key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
  25. fmtstrcpy(f, buf);
  26. return 0;
  27. }