plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

dsa.3 (2316B)


      1 .TH DSA 3
      2 .SH NAME
      3 asn1toDSApriv, dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm
      4 .SH SYNOPSIS
      5 .B #include <u.h>
      6 .br
      7 .B #include <libc.h>
      8 .br
      9 .B #include <mp.h>
     10 .br
     11 .B #include <libsec.h>
     12 .PP
     13 .B
     14 DSApriv*	dsagen(DSApub *opub)
     15 .PP
     16 .B
     17 DSAsig*	dsasign(DSApriv *k, mpint *m)
     18 .PP
     19 .B
     20 int		dsaverify(DSApub *k, DSAsig *sig, mpint *m)
     21 .PP
     22 .B
     23 DSApub*	dsapuballoc(void)
     24 .PP
     25 .B
     26 void		dsapubfree(DSApub*)
     27 .PP
     28 .B
     29 DSApriv*	dsaprivalloc(void)
     30 .PP
     31 .B
     32 void		dsaprivfree(DSApriv*)
     33 .PP
     34 .B
     35 DSAsig*	dsasigalloc(void)
     36 .PP
     37 .B
     38 void		dsasigfree(DSAsig*)
     39 .PP
     40 .B
     41 DSApub*	dsaprivtopub(DSApriv*)
     42 .PP
     43 .B
     44 DSApriv*	asn1toDSApriv(uchar *priv, int npriv)
     45 .SH DESCRIPTION
     46 .PP
     47 DSA is the NIST approved digital signature algorithm.  The owner of a key publishes
     48 the public part of the key:
     49 .EX
     50 	struct DSApub
     51 	{
     52 		mpint	*p;	// modulus
     53 		mpint	*q;	// group order, q divides p-1
     54 		mpint	*alpha;	// group generator
     55 		mpint	*key;	// alpha**secret mod p
     56 	};
     57 .EE
     58 This part can be used for verifying signatures (with
     59 .IR dsaverify )
     60 created by the owner.
     61 The owner signs (with
     62 .IR dsasign )
     63 using his private key:
     64 .EX
     65 	struct DSApriv
     66 	{
     67 		DSApub	pub;
     68 		mpint	*secret; // (decryption key)
     69 	};
     70 .EE
     71 .PP
     72 Keys are generated using
     73 .IR dsagen .
     74 If
     75 .IR dsagen 's
     76 argument
     77 .I opub
     78 is
     79 .BR nil ,
     80 a key is created using a new
     81 .B p
     82 and
     83 .B q
     84 generated by
     85 .IR DSAprimes
     86 (see
     87 .MR prime (3) ).
     88 Otherwise,
     89 .B p
     90 and
     91 .B q
     92 are copied from the old key.
     93 .PP
     94 .I Dsaprivtopub
     95 returns a newly allocated copy of the public key
     96 corresponding to the private key.
     97 .PP
     98 The routines
     99 .IR dsapuballoc ,
    100 .IR dsapubfree ,
    101 .IR dsaprivalloc ,
    102 and
    103 .I dsaprivfree
    104 are provided to manage key storage.
    105 .PP
    106 .I Dsasign
    107 signs message
    108 .I m
    109 using a private key
    110 .I k
    111 yielding a
    112 .EX
    113 	struct DSAsig
    114 	{
    115 		mpint	*r, *s;
    116 	};
    117 .EE
    118 .I Dsaverify
    119 returns 0 if the signature is valid and \-1 if not.
    120 .PP
    121 The routines
    122 .I dsasigalloc
    123 and
    124 .I dsasigfree
    125 are provided to manage signature storage.
    126 .PP
    127 .I Asn1toDSApriv
    128 converts an ASN1 formatted DSA private key into the corresponding
    129 .B DSApriv
    130 structure; see 
    131 .MR rsa (3)
    132 for other ASN1 routines.
    133 .SH SOURCE
    134 .B \*9/src/libsec
    135 .SH SEE ALSO
    136 .MR mp (3) ,
    137 .MR aes (3) ,
    138 .MR blowfish (3) ,
    139 .MR des (3) ,
    140 .MR rc4 (3) ,
    141 .MR rsa (3) ,
    142 .MR sechash (3) ,
    143 .MR prime (3) ,
    144 .MR rand (3)