rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 1 | .TH DSA 3 |
| 2 | .SH NAME |
| 3 | 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 | .SH DESCRIPTION |
| 43 | .PP |
| 44 | DSA is the NIST approved digital signature algorithm. The owner of a key publishes |
| 45 | the public part of the key: |
| 46 | .EX |
| 47 | struct DSApub |
| 48 | { |
| 49 | mpint *p; // modulus |
| 50 | mpint *q; // group order, q divides p-1 |
| 51 | mpint *alpha; // group generator |
| 52 | mpint *key; // alpha**secret mod p |
| 53 | }; |
| 54 | .EE |
| 55 | This part can be used for verifying signatures (with |
| 56 | .IR dsaverify ) |
| 57 | created by the owner. |
| 58 | The owner signs (with |
| 59 | .IR dsasign ) |
| 60 | using his private key: |
| 61 | .EX |
| 62 | struct DSApriv |
| 63 | { |
| 64 | DSApub pub; |
| 65 | mpint *secret; // (decryption key) |
| 66 | }; |
| 67 | .EE |
| 68 | .PP |
| 69 | Keys are generated using |
| 70 | .IR dsagen . |
| 71 | If |
| 72 | .IR dsagen 's |
| 73 | argument |
| 74 | .I opub |
| 75 | is |
| 76 | .BR nil , |
| 77 | a key is created using a new |
| 78 | .B p |
| 79 | and |
| 80 | .B q |
| 81 | generated by |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 82 | .IR DSAprimes (3). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 83 | Otherwise, |
| 84 | .B p |
| 85 | and |
| 86 | .B q |
| 87 | are copied from the old key. |
| 88 | .PP |
| 89 | .I Dsaprivtopub |
| 90 | returns a newly allocated copy of the public key |
| 91 | corresponding to the private key. |
| 92 | .PP |
| 93 | The routines |
| 94 | .IR dsapuballoc , |
| 95 | .IR dsapubfree , |
| 96 | .IR dsaprivalloc , |
| 97 | and |
| 98 | .I dsaprivfree |
| 99 | are provided to manage key storage. |
| 100 | .PP |
| 101 | .I Dsasign |
| 102 | signs message |
| 103 | .I m |
| 104 | using a private key |
| 105 | .I k |
| 106 | yielding a |
| 107 | .EX |
| 108 | struct DSAsig |
| 109 | { |
| 110 | mpint *r, *s; |
| 111 | }; |
| 112 | .EE |
| 113 | .I Dsaverify |
| 114 | returns 0 if the signature is valid and \-1 if not. |
| 115 | .PP |
| 116 | The routines |
| 117 | .I dsasigalloc |
| 118 | and |
| 119 | .I dsasigfree |
| 120 | are provided to manage signature storage. |
| 121 | .SH SOURCE |
rsc | b5fdffe | 2004-04-19 19:22:56 +0000 | [diff] [blame] | 122 | .B /usr/local/plan9/src/libsec |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 123 | .SH SEE ALSO |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 124 | .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) |