Blob
1 .TH DSA 32 .SH NAME3 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 .SH DESCRIPTION43 .PP44 DSA is the NIST approved digital signature algorithm. The owner of a key publishes45 the public part of the key:46 .EX47 struct DSApub48 {49 mpint *p; // modulus50 mpint *q; // group order, q divides p-151 mpint *alpha; // group generator52 mpint *key; // alpha**secret mod p53 };54 .EE55 This part can be used for verifying signatures (with56 .IR dsaverify )57 created by the owner.58 The owner signs (with59 .IR dsasign )60 using his private key:61 .EX62 struct DSApriv63 {64 DSApub pub;65 mpint *secret; // (decryption key)66 };67 .EE68 .PP69 Keys are generated using70 .IR dsagen .71 If72 .IR dsagen 's73 argument74 .I opub75 is76 .BR nil ,77 a key is created using a new78 .B p79 and80 .B q81 generated by82 .IR DSAprimes83 (see84 .IR prime (3)).85 Otherwise,86 .B p87 and88 .B q89 are copied from the old key.90 .PP91 .I Dsaprivtopub92 returns a newly allocated copy of the public key93 corresponding to the private key.94 .PP95 The routines96 .IR dsapuballoc ,97 .IR dsapubfree ,98 .IR dsaprivalloc ,99 and100 .I dsaprivfree101 are provided to manage key storage.102 .PP103 .I Dsasign104 signs message105 .I m106 using a private key107 .I k108 yielding a109 .EX110 struct DSAsig111 {112 mpint *r, *s;113 };114 .EE115 .I Dsaverify116 returns 0 if the signature is valid and \-1 if not.117 .PP118 The routines119 .I dsasigalloc120 and121 .I dsasigfree122 are provided to manage signature storage.123 .SH SOURCE124 .B \*9/src/libsec125 .SH SEE ALSO126 .IR mp (3),127 .IR aes (3),128 .IR blowfish (3),129 .IR des (3),130 .IR rc4 (3),131 .IR rsa (3),132 .IR sechash (3),133 .IR prime (3),134 .IR rand (3)