2004-04-10 18:53:55 +00:00
|
|
|
.TH DSA 3
|
|
|
|
.SH NAME
|
2005-02-13 23:44:12 +00:00
|
|
|
asn1toDSApriv, dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm
|
2004-04-10 18:53:55 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <u.h>
|
|
|
|
.br
|
|
|
|
.B #include <libc.h>
|
|
|
|
.br
|
|
|
|
.B #include <mp.h>
|
|
|
|
.br
|
|
|
|
.B #include <libsec.h>
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSApriv* dsagen(DSApub *opub)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSAsig* dsasign(DSApriv *k, mpint *m)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
int dsaverify(DSApub *k, DSAsig *sig, mpint *m)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSApub* dsapuballoc(void)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
void dsapubfree(DSApub*)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSApriv* dsaprivalloc(void)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
void dsaprivfree(DSApriv*)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSAsig* dsasigalloc(void)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
void dsasigfree(DSAsig*)
|
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSApub* dsaprivtopub(DSApriv*)
|
2005-02-13 23:44:12 +00:00
|
|
|
.PP
|
|
|
|
.B
|
|
|
|
DSApriv* asn1toDSApriv(uchar *priv, int npriv)
|
2004-04-10 18:53:55 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.PP
|
|
|
|
DSA is the NIST approved digital signature algorithm. The owner of a key publishes
|
|
|
|
the public part of the key:
|
|
|
|
.EX
|
|
|
|
struct DSApub
|
|
|
|
{
|
|
|
|
mpint *p; // modulus
|
|
|
|
mpint *q; // group order, q divides p-1
|
|
|
|
mpint *alpha; // group generator
|
|
|
|
mpint *key; // alpha**secret mod p
|
|
|
|
};
|
|
|
|
.EE
|
|
|
|
This part can be used for verifying signatures (with
|
|
|
|
.IR dsaverify )
|
|
|
|
created by the owner.
|
|
|
|
The owner signs (with
|
|
|
|
.IR dsasign )
|
|
|
|
using his private key:
|
|
|
|
.EX
|
|
|
|
struct DSApriv
|
|
|
|
{
|
|
|
|
DSApub pub;
|
|
|
|
mpint *secret; // (decryption key)
|
|
|
|
};
|
|
|
|
.EE
|
|
|
|
.PP
|
|
|
|
Keys are generated using
|
|
|
|
.IR dsagen .
|
|
|
|
If
|
|
|
|
.IR dsagen 's
|
|
|
|
argument
|
|
|
|
.I opub
|
|
|
|
is
|
|
|
|
.BR nil ,
|
|
|
|
a key is created using a new
|
|
|
|
.B p
|
|
|
|
and
|
|
|
|
.B q
|
|
|
|
generated by
|
2005-01-03 06:40:20 +00:00
|
|
|
.IR DSAprimes
|
|
|
|
(see
|
2020-08-16 00:07:38 +00:00
|
|
|
.MR prime (3) ).
|
2004-04-10 18:53:55 +00:00
|
|
|
Otherwise,
|
|
|
|
.B p
|
|
|
|
and
|
|
|
|
.B q
|
|
|
|
are copied from the old key.
|
|
|
|
.PP
|
|
|
|
.I Dsaprivtopub
|
|
|
|
returns a newly allocated copy of the public key
|
|
|
|
corresponding to the private key.
|
|
|
|
.PP
|
|
|
|
The routines
|
|
|
|
.IR dsapuballoc ,
|
|
|
|
.IR dsapubfree ,
|
|
|
|
.IR dsaprivalloc ,
|
|
|
|
and
|
|
|
|
.I dsaprivfree
|
|
|
|
are provided to manage key storage.
|
|
|
|
.PP
|
|
|
|
.I Dsasign
|
|
|
|
signs message
|
|
|
|
.I m
|
|
|
|
using a private key
|
|
|
|
.I k
|
|
|
|
yielding a
|
|
|
|
.EX
|
|
|
|
struct DSAsig
|
|
|
|
{
|
|
|
|
mpint *r, *s;
|
|
|
|
};
|
|
|
|
.EE
|
|
|
|
.I Dsaverify
|
|
|
|
returns 0 if the signature is valid and \-1 if not.
|
|
|
|
.PP
|
|
|
|
The routines
|
|
|
|
.I dsasigalloc
|
|
|
|
and
|
|
|
|
.I dsasigfree
|
|
|
|
are provided to manage signature storage.
|
2005-02-13 23:44:12 +00:00
|
|
|
.PP
|
|
|
|
.I Asn1toDSApriv
|
|
|
|
converts an ASN1 formatted DSA private key into the corresponding
|
|
|
|
.B DSApriv
|
|
|
|
structure; see
|
2020-08-16 00:07:38 +00:00
|
|
|
.MR rsa (3)
|
2005-02-13 23:44:12 +00:00
|
|
|
for other ASN1 routines.
|
2004-04-10 18:53:55 +00:00
|
|
|
.SH SOURCE
|
2005-01-11 17:37:33 +00:00
|
|
|
.B \*9/src/libsec
|
2004-04-10 18:53:55 +00:00
|
|
|
.SH SEE ALSO
|
2020-08-16 00:07:38 +00:00
|
|
|
.MR mp (3) ,
|
|
|
|
.MR aes (3) ,
|
|
|
|
.MR blowfish (3) ,
|
|
|
|
.MR des (3) ,
|
|
|
|
.MR rc4 (3) ,
|
|
|
|
.MR rsa (3) ,
|
|
|
|
.MR sechash (3) ,
|
|
|
|
.MR prime (3) ,
|
|
|
|
.MR rand (3)
|