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 DSAprimes (3).83 Otherwise,84 .B p85 and86 .B q87 are copied from the old key.88 .PP89 .I Dsaprivtopub90 returns a newly allocated copy of the public key91 corresponding to the private key.92 .PP93 The routines94 .IR dsapuballoc ,95 .IR dsapubfree ,96 .IR dsaprivalloc ,97 and98 .I dsaprivfree99 are provided to manage key storage.100 .PP101 .I Dsasign102 signs message103 .I m104 using a private key105 .I k106 yielding a107 .EX108 struct DSAsig109 {110 mpint *r, *s;111 };112 .EE113 .I Dsaverify114 returns 0 if the signature is valid and \-1 if not.115 .PP116 The routines117 .I dsasigalloc118 and119 .I dsasigfree120 are provided to manage signature storage.121 .SH SOURCE122 .B /usr/local/plan9/src/libsec123 .SH SEE ALSO124 .IR mp (3),125 .IR aes (3),126 .IR blowfish (3),127 .IR des (3),128 .IR rc4 (3),129 .IR rsa (3),130 .IR sechash (3),131 .IR prime (3),132 .IR rand (3)