dsa2ssh.c (774B)
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/dsa2ssh [-c comment] [file]\n"); 12 exits("usage"); 13 } 14 15 void 16 main(int argc, char **argv) 17 { 18 DSApriv *k; 19 char *comment; 20 uchar buf[8192], *p; 21 22 fmtinstall('B', mpfmt); 23 fmtinstall('[', encodefmt); 24 comment = ""; 25 ARGBEGIN{ 26 case 'c': 27 comment = EARGF(usage()); 28 break; 29 default: 30 usage(); 31 }ARGEND 32 33 if(argc > 1) 34 usage(); 35 36 if((k = getdsakey(argc, argv, 0, nil)) == nil) 37 sysfatal("%r"); 38 39 p = buf; 40 p = put4(p, 7); 41 p = putn(p, "ssh-dss", 7); 42 p = putmp2(p, k->pub.p); 43 p = putmp2(p, k->pub.q); 44 p = putmp2(p, k->pub.alpha); 45 p = putmp2(p, k->pub.key); 46 print("ssh-dss %.*[ %s\n", p-buf, buf, comment); 47 exits(nil); 48 }