plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

rsa2pub.c (652B)


      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 
      8 void
      9 usage(void)
     10 {
     11 	fprint(2, "usage: auth/rsa2pub [file]\n");
     12 	exits("usage");
     13 }
     14 
     15 void
     16 main(int argc, char **argv)
     17 {
     18 	RSApriv *key;
     19 	Attr *a;
     20 	char *s;
     21 
     22 	fmtinstall('A', _attrfmt);
     23 	fmtinstall('B', mpfmt);
     24 	quotefmtinstall();
     25 
     26 	ARGBEGIN{
     27 	default:
     28 		usage();
     29 	}ARGEND
     30 
     31 	if(argc > 1)
     32 		usage();
     33 
     34 	if((key = getkey(argc, argv, 0, &a)) == nil)
     35 		sysfatal("%r");
     36 
     37 	s = smprint("key %A size=%d ek=%lB n=%lB\n",
     38 		a,
     39 		mpsignif(key->pub.n), key->pub.ek, key->pub.n);
     40 	if(s == nil)
     41 		sysfatal("smprint: %r");
     42 	write(1, s, strlen(s));
     43 	exits(nil);
     44 }