Blob
1 .TH DSA 32 .SH NAME3 asn1toDSApriv, dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm4 .SH SYNOPSIS5 .B #include <u.h>6 .br7 .B #include <libc.h>8 .br9 .B #include <mp.h>10 .br11 .B #include <libsec.h>12 .PP13 .B14 DSApriv* dsagen(DSApub *opub)15 .PP16 .B17 DSAsig* dsasign(DSApriv *k, mpint *m)18 .PP19 .B20 int dsaverify(DSApub *k, DSAsig *sig, mpint *m)21 .PP22 .B23 DSApub* dsapuballoc(void)24 .PP25 .B26 void dsapubfree(DSApub*)27 .PP28 .B29 DSApriv* dsaprivalloc(void)30 .PP31 .B32 void dsaprivfree(DSApriv*)33 .PP34 .B35 DSAsig* dsasigalloc(void)36 .PP37 .B38 void dsasigfree(DSAsig*)39 .PP40 .B41 DSApub* dsaprivtopub(DSApriv*)42 .PP43 .B44 DSApriv* asn1toDSApriv(uchar *priv, int npriv)45 .SH DESCRIPTION46 .PP47 DSA is the NIST approved digital signature algorithm. The owner of a key publishes48 the public part of the key:49 .EX50 struct DSApub51 {52 mpint *p; // modulus53 mpint *q; // group order, q divides p-154 mpint *alpha; // group generator55 mpint *key; // alpha**secret mod p56 };57 .EE58 This part can be used for verifying signatures (with59 .IR dsaverify )60 created by the owner.61 The owner signs (with62 .IR dsasign )63 using his private key:64 .EX65 struct DSApriv66 {67 DSApub pub;68 mpint *secret; // (decryption key)69 };70 .EE71 .PP72 Keys are generated using73 .IR dsagen .74 If75 .IR dsagen 's76 argument77 .I opub78 is79 .BR nil ,80 a key is created using a new81 .B p82 and83 .B q84 generated by85 .IR DSAprimes86 (see87 .IR prime (3)).88 Otherwise,89 .B p90 and91 .B q92 are copied from the old key.93 .PP94 .I Dsaprivtopub95 returns a newly allocated copy of the public key96 corresponding to the private key.97 .PP98 The routines99 .IR dsapuballoc ,100 .IR dsapubfree ,101 .IR dsaprivalloc ,102 and103 .I dsaprivfree104 are provided to manage key storage.105 .PP106 .I Dsasign107 signs message108 .I m109 using a private key110 .I k111 yielding a112 .EX113 struct DSAsig114 {115 mpint *r, *s;116 };117 .EE118 .I Dsaverify119 returns 0 if the signature is valid and \-1 if not.120 .PP121 The routines122 .I dsasigalloc123 and124 .I dsasigfree125 are provided to manage signature storage.126 .PP127 .I Asn1toDSApriv128 converts an ASN1 formatted DSA private key into the corresponding129 .B DSApriv130 structure; see131 .IR rsa (3)132 for other ASN1 routines.133 .SH SOURCE134 .B \*9/src/libsec135 .SH SEE ALSO136 .IR mp (3),137 .IR aes (3),138 .IR blowfish (3),139 .IR des (3),140 .IR rc4 (3),141 .IR rsa (3),142 .IR sechash (3),143 .IR prime (3),144 .IR rand (3)