summaryrefslogtreecommitdiff
path: root/appl/cmd
diff options
context:
space:
mode:
authorCharles Forsyth <charles.forsyth@gmail.com>2013-06-05 12:18:49 +0000
committerCharles Forsyth <charles.forsyth@gmail.com>2013-06-05 12:18:49 +0000
commitada3bbabd7950eaa1c6581a4a3a2dcafc4c42f1b (patch)
tree984c943cfd346ff95b856ec1f39627fc835a8b6f /appl/cmd
parent06155dbb53eb0585800b239acd6e45b946c6e0cf (diff)
use Crypt not Keyring
Diffstat (limited to 'appl/cmd')
-rw-r--r--appl/cmd/auth/dsagen.b14
-rw-r--r--appl/cmd/auth/rsagen.b44
2 files changed, 32 insertions, 26 deletions
diff --git a/appl/cmd/auth/dsagen.b b/appl/cmd/auth/dsagen.b
index 3e24df2f..51b50a12 100644
--- a/appl/cmd/auth/dsagen.b
+++ b/appl/cmd/auth/dsagen.b
@@ -5,9 +5,12 @@ include "sys.m";
include "draw.m";
-include "keyring.m";
- kr: Keyring;
- IPint, DSAsk, DSApk, DSAsig: import kr;
+include "ipints.m";
+ ipints: IPints;
+ IPint: import ipints;
+
+include "crypt.m";
+ crypt: Crypt;
include "arg.m";
@@ -19,7 +22,8 @@ Dsagen: module
init(nil: ref Draw->Context, args: list of string)
{
sys = load Sys Sys->PATH;
- kr = load Keyring Keyring->PATH;
+ ipints = load IPints IPints->PATH;
+ crypt = load Crypt Crypt->PATH;
arg := load Arg Arg->PATH;
arg->init(args);
@@ -37,7 +41,7 @@ init(nil: ref Draw->Context, args: list of string)
arg->usage();
arg = nil;
- sk := DSAsk.gen(nil);
+ sk := crypt->dsagen(nil);
if(tag != nil)
tag = " "+tag;
s := add("p", sk.pk.p);
diff --git a/appl/cmd/auth/rsagen.b b/appl/cmd/auth/rsagen.b
index a1a4477c..48fcba6d 100644
--- a/appl/cmd/auth/rsagen.b
+++ b/appl/cmd/auth/rsagen.b
@@ -5,8 +5,12 @@ include "sys.m";
include "draw.m";
-include "keyring.m";
- kr: Keyring;
+include "ipints.m";
+ ipints: IPints;
+ IPint: import ipints;
+
+include "crypt.m";
+ crypt: Crypt;
include "arg.m";
@@ -18,7 +22,8 @@ Rsagen: module
init(nil: ref Draw->Context, args: list of string)
{
sys = load Sys Sys->PATH;
- kr = load Keyring Keyring->PATH;
+ ipints = load IPints IPints->PATH;
+ crypt = load Crypt Crypt->PATH;
arg := load Arg Arg->PATH;
arg->init(args);
@@ -43,34 +48,31 @@ init(nil: ref Draw->Context, args: list of string)
arg->usage();
arg = nil;
- sk := kr->genSK("rsa", "", nbits);
+ sk := crypt->rsagen(nbits, 6, 0);
if(sk == nil)
error("unable to generate key");
- s := kr->sktoattr(sk);
- # need to fix the attr interface so the following isn't needed:
- s = skip(s, "alg");
- s = skip(s, "owner");
if(tag != nil)
tag = " "+tag;
- a := sys->aprint("key proto=rsa%s size=%d %s\n", tag, nbits, s);
+ s := add("ek", sk.pk.ek);
+ s += add("n", sk.pk.n);
+ s += add("!dk", sk.dk);
+ s += add("!p", sk.p);
+ s += add("!q", sk.q);
+ s += add("!kp", sk.kp);
+ s += add("!kq", sk.kq);
+ s += add("!c2", sk.c2);
+ a := sys->aprint("key proto=rsa%s size=%d%s\n", tag, sk.pk.n.bits(), s);
if(sys->write(sys->fildes(1), a, len a) != len a)
error(sys->sprint("error writing key: %r"));
}
-skip(s: string, attr: string): string
-{
- for(i := 0; i < len s && s[i] != ' '; i++)
- {}
- if(i >= len s)
- return s;
- (nf, fld) := sys->tokenize(s[0:i], "=");
- if(nf == 2 && hd fld == attr)
- s = s[i+1:];
- return s;
-}
-
error(s: string)
{
sys->fprint(sys->fildes(2), "rsagen: %s\n", s);
raise "fail:error";
}
+
+add(name: string, b: ref IPint): string
+{
+ return " "+name+"="+b.iptostr(16);
+}