dsa 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. .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
  82. .IR DSAprimes (2).
  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
  122. .B /sys/src/libsec
  123. .SH SEE ALSO
  124. .IR mp (2),
  125. .IR aes (2),
  126. .IR blowfish (2),
  127. .IR des (2),
  128. .IR rc4 (2),
  129. .IR rsa (2),
  130. .IR sechash (2),
  131. .IR prime (2),
  132. .IR rand (2)