dsa 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. .TH DSA 2
  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. .IP
  47. .EX
  48. struct DSApub
  49. {
  50. mpint *p; // modulus
  51. mpint *q; // group order, q divides p-1
  52. mpint *alpha; // group generator
  53. mpint *key; // alpha**secret mod p
  54. };
  55. .EE
  56. .LP
  57. This part can be used for verifying signatures (with
  58. .IR dsaverify )
  59. created by the owner.
  60. The owner signs (with
  61. .IR dsasign )
  62. using his private key:
  63. .IP
  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. .I DSAprimes
  86. (see
  87. .IR prime (2)).
  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. .IP
  113. .EX
  114. struct DSAsig
  115. {
  116. mpint *r, *s;
  117. };
  118. .EE
  119. .LP
  120. .I Dsaverify
  121. returns 0 if the signature is valid and \-1 if not.
  122. .PP
  123. The routines
  124. .I dsasigalloc
  125. and
  126. .I dsasigfree
  127. are provided to manage signature storage.
  128. .SH SOURCE
  129. .B /sys/src/libsec
  130. .SH SEE ALSO
  131. .IR mp (2),
  132. .IR aes (2),
  133. .IR blowfish (2),
  134. .IR des (2),
  135. .IR rc4 (2),
  136. .IR rsa (2),
  137. .IR sechash (2),
  138. .IR prime (2),
  139. .IR rand (2),
  140. .IR dsa (8)