rsafill.c 747 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <auth.h>
  4. #include <mp.h>
  5. #include <libsec.h>
  6. #include "rsa2any.h"
  7. void
  8. usage(void)
  9. {
  10. fprint(2, "usage: auth/rsafill [file]\n");
  11. exits("usage");
  12. }
  13. void
  14. main(int argc, char **argv)
  15. {
  16. RSApriv *key;
  17. Attr *a;
  18. char *s;
  19. fmtinstall('A', _attrfmt);
  20. fmtinstall('B', mpfmt);
  21. quotefmtinstall();
  22. ARGBEGIN{
  23. default:
  24. usage();
  25. }ARGEND
  26. if(argc > 1)
  27. usage();
  28. if((key = getkey(argc, argv, 1, &a)) == nil)
  29. sysfatal("%r");
  30. s = smprint("key %A size=%d ek=%B !dk=%B n=%B !p=%B !q=%B !kp=%B !kq=%B !c2=%B\n",
  31. a,
  32. mpsignif(key->pub.n), key->pub.ek,
  33. key->dk, key->pub.n, key->p, key->q,
  34. key->kp, key->kq, key->c2);
  35. if(s == nil)
  36. sysfatal("smprint: %r");
  37. write(1, s, strlen(s));
  38. exits(nil);
  39. }