8 #define between(x,min,max) (((min-1-x) & (x-max-1))>>8)
15 c = between(o, 0, 25) & ('A'+o);
16 c |= between(o, 26, 51) & ('a'+(o-26));
17 c |= between(o, 52, 61) & ('0'+(o-52));
18 c |= between(o, 62, 62) & ('-');
19 c |= between(o, 63, 63) & ('_');
24 encurl64(void *in, int n)
30 if((out = malloc(lim)) == nil)
31 sysfatal("malloc: %r");
32 enc64x(out, lim, in, n, encurl64chr);
33 if((p = strchr(out, '=')) != nil)
41 fprint(2, "usage: auth/rsa2pub [file]\n");
46 main(int argc, char **argv)
48 uchar nbuf[8192], ebuf[512];
53 fmtinstall('[', encodefmt);
64 if((k = getrsakey(argc, argv, 0, nil)) == nil)
67 nlen = (mpsignif(k->pub.n)+7)/8;
68 if(nlen >= sizeof(nbuf))
69 sysfatal("key too big");
70 mptobe(k->pub.n, nbuf, nlen, nil);
71 nstr = encurl64(nbuf, nlen);
73 elen = (mpsignif(k->pub.ek)+7)/8;
74 if(elen >= sizeof(ebuf))
75 sysfatal("key too big");
76 mptobe(k->pub.ek, ebuf, elen, nil);
77 estr = encurl64(ebuf, elen);