Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <mp.h>
4
#include <libsec.h>
5
 
6
void
7
usage(void)
8
{
9
	fprint(2, "usage: auth/dsagen [-t 'attr=value attr=value ...']\n");
10
	exits("usage");
11
}
12
 
13
void
14
main(int argc, char **argv)
15
{
16
	char *s, *tag;
17
	DSApriv *key;
18
 
19
	tag = nil;
20
	fmtinstall('B', mpfmt);
21
 
22
	ARGBEGIN{
23
	case 't':
24
		tag = EARGF(usage());
25
		break;
26
	default:
27
		usage();
28
	}ARGEND
29
 
30
	if(argc != 0)
31
		usage();
32
 
33
	key = dsagen(nil);
34
 
35
	s = smprint("key proto=dsa %s%sp=%B q=%B alpha=%B key=%B !secret=%B\n",
36
		tag ? tag : "", tag ? " " : "",
37
		key->pub.p, key->pub.q, key->pub.alpha, key->pub.key,
38
		key->secret);
39
	if(s == nil)
40
		sysfatal("smprint: %r");
41
 
42
	if(write(1, s, strlen(s)) != strlen(s))
43
		sysfatal("write: %r");
44
 
45
	exits(nil);
46
}