shithub: riscv

Download patch

ref: a200ecd3a65539ed3320e076b3679afe84f6a79e
parent: 91a701747cb295a2b0339a332fb9a2f9e97b23c8
author: cinap_lenrek <[email protected]>
date: Sat Jan 6 03:32:51 EST 2018

remove asn12dsa, dsa2pub, dsa2ssh and dsagen

was mostly usefull for old ssh.

--- a/sys/src/cmd/auth/asn12dsa.c
+++ /dev/null
@@ -1,69 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <bio.h>
-#include <mp.h>
-#include <libsec.h>
-
-void
-usage(void)
-{
-	fprint(2, "auth/asn12dsa [-t tag] [file]\n");
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	char *s;
-	uchar *buf;
-	int fd;
-	long n, tot;
-	char *tag;
-	DSApriv *key;
-
-	fmtinstall('B', mpfmt);
-
-	tag = nil;
-	ARGBEGIN{
-	case 't':
-		tag = EARGF(usage());
-		break;
-	default:
-		usage();
-	}ARGEND
-
-	if(argc != 0 && argc != 1)
-		usage();
-
-	fd = 0;
-	if(argc == 1){
-		if((fd = open(*argv, OREAD)) < 0)
-			sysfatal("open %s: %r", *argv);
-	}
-
-	buf = nil;
-	tot = 0;
-	for(;;){
-		buf = realloc(buf, tot+8192);
-		if(buf == nil)
-			sysfatal("realloc: %r");
-		if((n = read(fd, buf+tot, 8192)) < 0)
-			sysfatal("read: %r");
-		if(n == 0)
-			break;
-		tot += n;
-	}
-
-	key = asn1toDSApriv(buf, tot);
-	if(key == nil)
-		sysfatal("couldn't parse asn1 key");
-
-	s = smprint("key proto=dsa %s%sp=%B q=%B alpha=%B key=%B !secret=%B\n",
-		tag ? tag : "", tag ? " " : "",
-		key->pub.p, key->pub.q, key->pub.alpha, key->pub.key,
-		key->secret);
-	if(s == nil)
-		sysfatal("smprint: %r");
-	write(1, s, strlen(s));
-	exits(0);
-}
--- a/sys/src/cmd/auth/dsa2pub.c
+++ /dev/null
@@ -1,44 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <auth.h>
-#include <mp.h>
-#include <libsec.h>
-#include "rsa2any.h"
-
-void
-usage(void)
-{
-	fprint(2, "usage: auth/dsa2pub [file]\n");
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	DSApriv *key;
-	Attr *a;
-	char *s;
-
-	fmtinstall('A', _attrfmt);
-	fmtinstall('B', mpfmt);
-	quotefmtinstall();
-
-	ARGBEGIN{
-	default:
-		usage();
-	}ARGEND
-
-	if(argc > 1)
-		usage();
-
-	if((key = getdsakey(argc, argv, 0, &a)) == nil)
-		sysfatal("%r");
-
-	s = smprint("key %A p=%B q=%B alpha=%B key=%B\n",
-		a, 
-		key->pub.p, key->pub.q, key->pub.alpha, key->pub.key);
-	if(s == nil)
-		sysfatal("smprint: %r");
-	write(1, s, strlen(s));
-	exits(nil);
-}
--- a/sys/src/cmd/auth/dsa2ssh.c
+++ /dev/null
@@ -1,48 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <auth.h>
-#include <mp.h>
-#include <libsec.h>
-#include "rsa2any.h"
-
-void
-usage(void)
-{
-	fprint(2, "usage: auth/dsa2ssh [-c comment] [file]\n");
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	DSApriv *k;
-	char *comment;
-	uchar buf[8192], *p;
-	
-	fmtinstall('B', mpfmt);
-	fmtinstall('[', encodefmt);
-	comment = "";
-	ARGBEGIN{
-	case 'c':
-		comment = EARGF(usage());
-		break;
-	default:
-		usage();
-	}ARGEND
-
-	if(argc > 1)
-		usage();
-
-	if((k = getdsakey(argc, argv, 0, nil)) == nil)
-		sysfatal("%r");
-
-	p = buf;
-	p = put4(p, 7);
-	p = putn(p, "ssh-dss", 7);
-	p = putmp2(p, k->pub.p);
-	p = putmp2(p, k->pub.q);
-	p = putmp2(p, k->pub.alpha);
-	p = putmp2(p, k->pub.key);
-	print("ssh-dss %.*[ %s\n", (int)(p - buf), buf, comment);
-	exits(nil);
-}
--- a/sys/src/cmd/auth/dsagen.c
+++ /dev/null
@@ -1,46 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <mp.h>
-#include <libsec.h>
-
-void
-usage(void)
-{
-	fprint(2, "usage: auth/dsagen [-t 'attr=value attr=value ...']\n");
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	char *s, *tag;
-	DSApriv *key;
-
-	tag = nil;
-	fmtinstall('B', mpfmt);
-
-	ARGBEGIN{
-	case 't':
-		tag = EARGF(usage());
-		break;
-	default:
-		usage();
-	}ARGEND
-
-	if(argc != 0)
-		usage();
-
-	key = dsagen(nil);
-
-	s = smprint("key proto=dsa %s%sp=%B q=%B alpha=%B key=%B !secret=%B\n",
-		tag ? tag : "", tag ? " " : "",
-		key->pub.p, key->pub.q, key->pub.alpha, key->pub.key,
-		key->secret);
-	if(s == nil)
-		sysfatal("smprint: %r");
-
-	if(write(1, s, strlen(s)) != strlen(s))
-		sysfatal("write: %r");
-	
-	exits(nil);
-}
--- a/sys/src/cmd/auth/mkfile
+++ b/sys/src/cmd/auth/mkfile
@@ -6,7 +6,6 @@
 	as\
 	asaudit\
 	asn1dump\
-	asn12dsa\
 	asn12rsa\
 	authsrv\
 	changeuser\
@@ -13,9 +12,6 @@
 	convkeys\
 	cron\
 	debug\
-	dsa2pub\
-	dsa2ssh\
-	dsagen\
 	guard.srv\
 	httpauth\
 	keyfs\
@@ -109,7 +105,6 @@
 	rm -f *.[$OS] *.[$OS].a [$OS].* y.tab.? y.debug y.output $TARG *.acid
 
 $O.%:	$LIB
-$O.dsa2ssh $O.dsafill $O.dsa2x509 $O.dsa2pub $O.dsa2csr: rsa2any.$O
 $O.rsa2asn1 $O.rsa2ssh $O.rsafill $O.rsa2x509 $O.rsa2pub $O.rsa2csr: rsa2any.$O
 $O.authsrv $O.guard.srv: secureidcheck.$O
 
--- a/sys/src/cmd/auth/rsa2any.c
+++ b/sys/src/cmd/auth/rsa2any.c
@@ -158,103 +158,6 @@
 	return key;
 }
 
-DSApriv*
-getdsakey(int argc, char **argv, int needprivate, Attr **pa)
-{
-	char *file, *s, *p;
-	DSApriv *key;
-	Biobuf *b;
-	Attr *a;
-
-	if(argc == 0)
-		file = "#d/0";
-	else
-		file = argv[0];
-
-	key = mallocz(sizeof(RSApriv), 1);
-	if(key == nil)
-		return nil;
-
-	if((b = Bopen(file, OREAD)) == nil){
-		werrstr("open %s: %r", file);
-		return nil;
-	}
-	s = Brdstr(b, '\n', 1);
-	if(s == nil){
-		werrstr("read %s: %r", file);
-		return nil;
-	}
-	if(strncmp(s, "key ", 4) != 0){
-		werrstr("bad key format");
-		return nil;
-	}
-
-	a = _parseattr(s+4);
-	if(a == nil){
-		werrstr("empty key");
-		return nil;
-	}
-	if((p = _strfindattr(a, "proto")) == nil){
-		werrstr("no proto");
-		return nil;
-	}
-	if(strcmp(p, "dsa") != 0){
-		werrstr("proto not dsa");
-		return nil;
-	}
-	if((p = _strfindattr(a, "p")) == nil){
-		werrstr("no p");
-		return nil;
-	}
-	if((key->pub.p = strtomp(p, &p, 16, nil)) == nil || *p != 0){
-		werrstr("bad p");
-		return nil;
-	}
-	if((p = _strfindattr(a, "q")) == nil){
-		werrstr("no q");
-		return nil;
-	}
-	if((key->pub.q = strtomp(p, &p, 16, nil)) == nil || *p != 0){
-		werrstr("bad q");
-		return nil;
-	}
-	if((p = _strfindattr(a, "alpha")) == nil){
-		werrstr("no alpha");
-		return nil;
-	}
-	if((key->pub.alpha = strtomp(p, &p, 16, nil)) == nil || *p != 0){
-		werrstr("bad alpha");
-		return nil;
-	}
-	if((p = _strfindattr(a, "key")) == nil){
-		werrstr("no key=");
-		return nil;
-	}
-	if((key->pub.key = strtomp(p, &p, 16, nil)) == nil || *p != 0){
-		werrstr("bad key=");
-		return nil;
-	}
-	if(!needprivate)
-		goto call;
-	if((p = _strfindattr(a, "!secret")) == nil){
-		werrstr("no !secret");
-		return nil;
-	}
-	if((key->secret = strtomp(p, &p, 16, nil)) == nil || *p != 0){
-		werrstr("bad !secret");
-		return nil;
-	}
-call:
-	a = _delattr(a, "p");
-	a = _delattr(a, "q");
-	a = _delattr(a, "alpha");
-	a = _delattr(a, "key");
-	a = _delattr(a, "!secret");
-	if(pa)
-		*pa = a;
-	return key;
-}
-
 uchar*
 put4(uchar *p, uint n)
 {
--- a/sys/src/cmd/auth/rsa2any.h
+++ b/sys/src/cmd/auth/rsa2any.h
@@ -1,4 +1,3 @@
-DSApriv*getdsakey(int argc, char **argv, int needprivate, Attr **pa);
 RSApriv*getrsakey(int argc, char **argv, int needprivate, Attr **pa);
 uchar*	put4(uchar *p, uint n);
 uchar*	putmp2(uchar *p, mpint *b);