home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Networking / nmap-5.00-setup.exe / nselib / openssl.luadoc < prev    next >
Text File  |  2009-07-06  |  6KB  |  178 lines

  1. --- OpenSSL bindings.
  2. --
  3. -- This module is a wrapper for OpenSSL functions that provide encryption and
  4. -- decryption, hashing, and multiprecision integers.
  5. --
  6. -- The <code>openssl</code> module may not always be available. It depends on
  7. -- whether OpenSSL support was enabled at compile time. Scripts using the
  8. -- module should be made to fail gracefully using code like the following:
  9. -- <code>
  10. -- if not pcall(require, "openssl") then
  11. --   action = function(host, port)
  12. --     stdnse.print_debug(2, "Skipping \"%s\" because OpenSSL is missing.", id)
  13. --   end
  14. -- end
  15. -- action = action or function(host, port)
  16. --   ...
  17. -- end
  18. -- </code>
  19. -- @author Sven Klemm <sven@c3d2.de>
  20. -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
  21.  
  22. module "openssl"
  23.  
  24. --- Returns the size of <code>bignum</code> in bits.
  25. -- @param bignum bignum to operate on.
  26. -- @return Size of <code>bignum</code>.
  27. function bignum_num_bits(bignum)
  28.  
  29. --- Returns the size of <code>bignum</code> in bytes.
  30. -- @param bignum bignum to operate on.
  31. -- @return Size of <code>bignum</code>.
  32. function bignum_num_bytes(bignum)
  33.  
  34. --- Sets the bit at <code>position</code> in <code>bignum</code>.
  35. -- @param bignum bignum to operate on.
  36. -- @param position Bit position.
  37. function bignum_set_bit(bignum, position)
  38.  
  39. --- Clears the bit at <code>position</code> in <code>bignum</code>.
  40. -- @param bignum bignum to operate on.
  41. -- @param position Bit position.
  42. function bignum_clear_bit(bignum, position)
  43.  
  44. --- Gets the state of the bit at <code>position</code> in <code>bignum</code>.
  45. -- @param bignum bignum to operate on.
  46. -- @param position Bit position.
  47. -- @return True if the selected bit is set, false otherwise. 
  48. function bignum_is_bit_set(bignum, position)
  49.  
  50. --- Converts a binary-encoded string into a bignum.
  51. -- @param string Binary string.
  52. -- @return bignum.
  53. function bignum_bin2bn(string)
  54.  
  55. --- Converts a decimal-encoded string into a bignum.
  56. -- @param string Decimal string.
  57. -- @return bignum.
  58. function bignum_dec2bn(string)
  59.  
  60. --- Converts a hex-encoded string into a bignum.
  61. -- @param string Hex string.
  62. -- @return bignum.
  63. function bignum_hex2bn(string)
  64.  
  65. --- Converts <code>bignum</code> into a binary-encoded string.
  66. -- @param bignum bignum to operate on.
  67. -- @return Binary string.
  68. function bignum_bn2bin(bignum)
  69.  
  70. --- Converts <code>bignum</code> into a decimal-encoded string.
  71. -- @param bignum bignum to operate on.
  72. -- @return Decimal string.
  73. function bignum_bn2dec(bignum)
  74.  
  75. --- Converts <code>bignum</code> into a hex-encoded string.
  76. -- @param bignum bignum to operate on.
  77. -- @return Hex string.
  78. function bignum_bn2hex(bignum)
  79.  
  80. --- Returns a random bignum.
  81. -- @param bits Size of the returned bignum in bits.
  82. -- @return Random bignum.
  83. function bignum_rand(bits)
  84.  
  85. --- Returns a pseudorandom bignum.
  86. -- @param bits Size of the returned bignum in bits.
  87. -- @return Pseudoandom bignum.
  88. function bignum_pseudo_rand(bits)
  89.  
  90. --- Returns the bignum which is the result of <code>a</code>^<code>p</code> mod
  91. -- <code>m</code>.
  92. -- @param a Base.
  93. -- @param p Exponent.
  94. -- @param m Modulus.
  95. -- @return bignum.
  96. function bignum_mod_exp(a, p, m)
  97.  
  98. --- Returns a string containing random data.
  99. -- @param bytes Length of the returned string in bytes.
  100. -- @return Random string.
  101. function rand_bytes(bytes)
  102.  
  103. --- Returns a string containing pseudorandom data.
  104. -- @param bytes Length of the returned string in bytes.
  105. -- @return Pseudorandom string.
  106. function rand_pseudo_bytes(bytes)
  107.  
  108. --- Returns the MD2 digest of a string.
  109. -- @param message String to digest.
  110. -- @return MD2 digest.
  111. function md2(message)
  112.  
  113. --- Returns the MD4 digest of a string.
  114. -- @param message String to digest.
  115. -- @return MD4 digest.
  116. function md4(message)
  117.  
  118. --- Returns the MD5 digest of a string.
  119. -- @param message String to digest.
  120. -- @return MD5 digest.
  121. function md5(message)
  122.  
  123. --- Returns the SHA-1 digest of a string.
  124. -- @param message String to digest.
  125. -- @return SHA-1 digest.
  126. function sha1(message)
  127.  
  128. --- Returns the RIPEMD-160 digest of a string.
  129. -- @param message String to digest.
  130. -- @return RIPEMD-160 digest.
  131. function ripemd160(message)
  132.  
  133. --- Returns the digest of a string using a named algorithm.
  134. -- @param algorithm Any of the strings returned by
  135. -- <code>openssl.supported_digests</code>.
  136. -- @param message String to digest.
  137. function digest(algorithm, message)
  138.  
  139. --- Returns the message authentication code of a string using a named algorithm.
  140. -- @param algorithm Any of the strings returned by
  141. -- <code>openssl.supported_digests</code>.
  142. -- @param key Key.
  143. -- @param message String.
  144. function hmac(algorithm, key, message)
  145.  
  146. --- Encrypt data with a given algorithm, key, and initialization vector.
  147. -- @param algorithm Any of the strings returned by
  148. -- <code>openssl.supported_ciphers</code>.
  149. -- @param key Key.
  150. -- @param iv Initialization vector.
  151. -- @param data Data to encrypt.
  152. -- @param padding If true, then a partial final block will be padded and
  153. -- encrypted (default false).
  154. function encrypt(algorithm, key, iv, data, padding)
  155.  
  156. --- Decrypt data with a given algorithm, key, and initialization vector.
  157. -- @param algorithm Any of the strings returned by
  158. -- <code>openssl.supported_ciphers</code>.
  159. -- @param key Key.
  160. -- @param iv Initialization vector.
  161. -- @param data Data to decrypt.
  162. -- @param padding If true, then the final block must be padded correctly
  163. -- (default false).
  164. function decrypt(algorithm, key, iv, data, padding)
  165.  
  166. --- Returns a table with the names of the supported cipher algorithms.
  167. -- @return Array containing cipher names as strings.
  168. function supported_ciphers()
  169.  
  170. --- Returns a table with the names of the supported digest algorithms.
  171. -- @return Array containing digest names as strings.
  172. function supported_digests()
  173.  
  174. --- Converts a 56-bit DES key into a 64-bit key with the correct parity.
  175. -- @param data A 7-byte string.
  176. -- @return An 8-byte string.
  177. function DES_string_to_key(data)
  178.