xref: /inferno-os/module/oldauth.m (revision 25b96b1d6a760df53b31e14ed1ae5f3c36e87bf5)
1*25b96b1dSforsythOldauth: module
2*25b96b1dSforsyth{
3*25b96b1dSforsyth	PATH:	con "/dis/lib/oldauth.dis";
4*25b96b1dSforsyth
5*25b96b1dSforsyth	init:	fn();
6*25b96b1dSforsyth
7*25b96b1dSforsyth	# Inferno certificate
8*25b96b1dSforsyth	Certificate: adt
9*25b96b1dSforsyth	{
10*25b96b1dSforsyth		sa:	string;	# signature algorithm
11*25b96b1dSforsyth		ha:	string;		# hash algorithm
12*25b96b1dSforsyth		signer:	string;	# name of signer
13*25b96b1dSforsyth		exp:	int;		# expiration date
14*25b96b1dSforsyth		sig:	ref Crypt->PKsig;
15*25b96b1dSforsyth	};
16*25b96b1dSforsyth
17*25b96b1dSforsyth	# authentication info
18*25b96b1dSforsyth	Authinfo: adt
19*25b96b1dSforsyth	{
20*25b96b1dSforsyth		mysk:	ref Crypt->SK;			# my private key
21*25b96b1dSforsyth		mypk:	ref Crypt->PK;			# my public key
22*25b96b1dSforsyth		owner:	string;	# owner of mypk for certificate
23*25b96b1dSforsyth		cert:	ref Certificate;	# signature of my public key
24*25b96b1dSforsyth		spk:	ref Crypt->PK;			# signers public key
25*25b96b1dSforsyth		alpha:	ref IPints->IPint;		# diffie helman parameters
26*25b96b1dSforsyth		p:	ref IPints->IPint;
27*25b96b1dSforsyth	};
28*25b96b1dSforsyth
29*25b96b1dSforsyth	# auth io
30*25b96b1dSforsyth	readauthinfo: fn(filename: string): ref Authinfo;
31*25b96b1dSforsyth	writeauthinfo: fn(filename: string, info: ref Authinfo): int;
32*25b96b1dSforsyth
33*25b96b1dSforsyth	# convert types to text in a canonical form
34*25b96b1dSforsyth	certtostr: fn (c: ref Certificate): string;
35*25b96b1dSforsyth	pktostr: fn (pk: ref Crypt->PK, owner: string): string;
36*25b96b1dSforsyth	sktostr: fn (sk: ref Crypt->SK, owner: string): string;
37*25b96b1dSforsyth
38*25b96b1dSforsyth	# parse text into types
39*25b96b1dSforsyth	strtocert: fn (s: string): ref Certificate;
40*25b96b1dSforsyth	strtopk: fn (s: string): (ref Crypt->PK, string);
41*25b96b1dSforsyth	strtosk: fn (s: string): (ref Crypt->SK, string);
42*25b96b1dSforsyth
43*25b96b1dSforsyth	# create and verify Certificates
44*25b96b1dSforsyth	sign: fn (sk: ref Crypt->SK, signer: string, exp: int, state: ref Crypt->DigestState, ha: string):
45*25b96b1dSforsyth		ref Certificate;
46*25b96b1dSforsyth	verify: fn (pk: ref Crypt->PK, cert: ref Certificate, state: ref Crypt->DigestState):
47*25b96b1dSforsyth		int;
48*25b96b1dSforsyth};
49