aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/auth/rsagen.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-13 18:04:20 +0000
committerrsc <devnull@localhost>2005-02-13 18:04:20 +0000
commit57fcfc2a0b8ecd266ce130dab9a29b7ceb558d64 (patch)
tree2d7dc505e9bda2e49efdc13ed459d7e2fad5f579 /src/cmd/auth/rsagen.c
parentce94dbe662155bd60d6839b5e8c82ad708667bcd (diff)
downloadplan9port-57fcfc2a0b8ecd266ce130dab9a29b7ceb558d64.tar.gz
plan9port-57fcfc2a0b8ecd266ce130dab9a29b7ceb558d64.tar.bz2
plan9port-57fcfc2a0b8ecd266ce130dab9a29b7ceb558d64.zip
add others
Diffstat (limited to 'src/cmd/auth/rsagen.c')
-rw-r--r--src/cmd/auth/rsagen.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/cmd/auth/rsagen.c b/src/cmd/auth/rsagen.c
new file mode 100644
index 00000000..d05f562e
--- /dev/null
+++ b/src/cmd/auth/rsagen.c
@@ -0,0 +1,60 @@
+#include <u.h>
+#include <libc.h>
+#include <mp.h>
+#include <libsec.h>
+
+void
+usage(void)
+{
+ fprint(2, "usage: auth/rsagen [-b bits] [-t 'attr=value attr=value ...']\n");
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ char *s;
+ int bits;
+ char *tag;
+ RSApriv *key;
+
+ bits = 1024;
+ tag = nil;
+ key = nil;
+ fmtinstall('B', mpfmt);
+
+ ARGBEGIN{
+ case 'b':
+ bits = atoi(EARGF(usage()));
+ if(bits == 0)
+ usage();
+ break;
+ case 't':
+ tag = EARGF(usage());
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ if(argc != 0)
+ usage();
+
+ do{
+ if(key)
+ rsaprivfree(key);
+ key = rsagen(bits, 6, 0);
+ }while(mpsignif(key->pub.n) != bits);
+
+ s = smprint("key proto=rsa %s%ssize=%d ek=%B !dk=%B n=%B !p=%B !q=%B !kp=%B !kq=%B !c2=%B\n",
+ tag ? tag : "", tag ? " " : "",
+ mpsignif(key->pub.n), key->pub.ek,
+ key->dk, key->pub.n, key->p, key->q,
+ key->kp, key->kq, key->c2);
+ if(s == nil)
+ sysfatal("smprint: %r");
+
+ if(write(1, s, strlen(s)) != strlen(s))
+ sysfatal("write: %r");
+
+ exits(nil);
+}