]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/auth/rsa2ssh.c
show line numbers in dtracy type errors
[plan9front.git] / sys / src / cmd / auth / rsa2ssh.c
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/rsa2ssh [-c comment] [file]\n");
12         exits("usage");
13 }
14
15 void
16 main(int argc, char **argv)
17 {
18         RSApriv *k;
19         char *comment;
20         uchar buf[8192], *p;
21
22         fmtinstall('B', mpfmt);
23         fmtinstall('[', encodefmt);
24
25         comment = "";
26
27         ARGBEGIN{
28         case 'c':
29                 comment = EARGF(usage());
30                 break;
31         case '2':       /* backwards compatibility */
32                 break;
33         default:
34                 usage();
35         }ARGEND
36
37         if(argc > 1)
38                 usage();
39
40         if((k = getrsakey(argc, argv, 0, nil)) == nil)
41                 sysfatal("%r");
42
43         p = buf;
44         p = put4(p, 7);
45         p = putn(p, "ssh-rsa", 7);
46         p = putmp2(p, k->pub.ek);
47         p = putmp2(p, k->pub.n);
48
49         print("ssh-rsa %.*[ %s\n", (int)(p-buf), buf, comment);
50
51         exits(nil);
52 }