139 lines · 2.0 KB · Text
RawDownload
.TH DSA 2.SH NAMEdsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.br.B #include <mp.h>.br.B #include <libsec.h>.PP.BDSApriv*	dsagen(DSApub *opub).PP.BDSAsig*	dsasign(DSApriv *k, mpint *m).PP.Bint		dsaverify(DSApub *k, DSAsig *sig, mpint *m).PP.BDSApub*	dsapuballoc(void).PP.Bvoid		dsapubfree(DSApub*).PP.BDSApriv*	dsaprivalloc(void).PP.Bvoid		dsaprivfree(DSApriv*).PP.BDSAsig*	dsasigalloc(void).PP.Bvoid		dsasigfree(DSAsig*).PP.BDSApub*	dsaprivtopub(DSApriv*).SH DESCRIPTION.PPDSA is the NIST approved digital signature algorithm.  The owner of a key publishesthe public part of the key:.IP.EXstruct DSApub{	mpint	*p;	// modulus	mpint	*q;	// group order, q divides p-1	mpint	*alpha;	// group generator	mpint	*key;	// alpha**secret mod p};.EE.LPThis part can be used for verifying signatures (with.IR dsaverify )created by the owner.The owner signs (with.IR dsasign )using his private key:.IP.EXstruct DSApriv{	DSApub	pub;	mpint	*secret; // (decryption key)};.EE.PPKeys are generated using.IR dsagen .If.IR dsagen 'sargument.I opubis.BR nil ,a key is created using a new.B pand.B qgenerated by.I DSAprimes(see.IR prime (2)).Otherwise,.B pand.B qare copied from the old key..PP.I Dsaprivtopubreturns a newly allocated copy of the public keycorresponding to the private key..PPThe routines.IR dsapuballoc ,.IR dsapubfree ,.IR dsaprivalloc ,and.I dsaprivfreeare provided to manage key storage..PP.I Dsasignsigns message.I musing a private key.I kyielding a.IP.EXstruct DSAsig{	mpint	*r, *s;};.EE.LP.I Dsaverifyreturns 0 if the signature is valid and \-1 if not..PPThe routines.I dsasigallocand.I dsasigfreeare provided to manage signature storage..SH SOURCE.B /sys/src/libsec.SH SEE ALSO.IR mp (2),.IR aes (2),.IR blowfish (2),.IR des (2),.IR rc4 (2),.IR rsa (2),.IR sechash (2),.IR prime (2),.IR rand (2)