scrypt.1 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. .\" Copyright 2009 Colin Percival
  2. .\" All rights reserved.
  3. .\"
  4. .\" Redistribution and use in source and binary forms, with or without
  5. .\" modification, are permitted provided that the following conditions
  6. .\" are met:
  7. .\" 1. Redistributions of source code must retain the above copyright
  8. .\" notice, this list of conditions and the following disclaimer.
  9. .\" 2. Redistributions in binary form must reproduce the above copyright
  10. .\" notice, this list of conditions and the following disclaimer in the
  11. .\" documentation and/or other materials provided with the distribution.
  12. .\"
  13. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  14. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  17. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. .\" SUCH DAMAGE.
  24. .Dd @DATE@
  25. .Dt SCRYPT 1
  26. .Os
  27. .Sh NAME
  28. .Nm scrypt
  29. .Nd encrypt and decrypt files
  30. .Sh SYNOPSIS
  31. .Nm
  32. .Brq Cm enc | Cm dec | Cm info
  33. .Op Fl f
  34. .Op Fl -logN Ar value
  35. .Op Fl M Ar maxmem
  36. .Op Fl m Ar maxmemfrac
  37. .Op Fl P
  38. .Op Fl p Ar value
  39. .Op Fl -passphrase Ar method:arg
  40. .Op Fl r Ar value
  41. .Op Fl t Ar maxtime
  42. .Op Fl v
  43. .Ar infile
  44. .Op Ar outfile
  45. .Nm
  46. .Fl -version
  47. .Sh DESCRIPTION
  48. .Nm Cm enc
  49. encrypts
  50. .Ar infile
  51. and writes the result to
  52. .Ar outfile
  53. if specified, or the standard output otherwise.
  54. The user will be prompted to enter a passphrase (twice) to
  55. be used to generate a derived encryption key.
  56. .Pp
  57. .Nm Cm dec
  58. decrypts
  59. .Ar infile
  60. and writes the result to
  61. .Ar outfile
  62. if specified, or the standard output otherwise.
  63. The user will be prompted to enter the passphrase used at
  64. encryption time to generate the derived encryption key.
  65. .Pp
  66. .Nm Cm info
  67. provides information about the encryption parameters used for
  68. .Ar infile .
  69. .Pp
  70. Unless otherwise specified via
  71. .Fl -passphrase ,
  72. .Nm
  73. reads passphrases from its controlling terminal, or failing that, from stdin.
  74. Prompts are only printed when
  75. .Nm
  76. is reading passphrases from some terminal.
  77. .Sh OPTIONS
  78. .Bl -tag -width "-m maxmemfrac"
  79. .It Fl f
  80. Force the operation to proceed even if it is anticipated to
  81. require an excessive amount of memory or CPU time.
  82. Do not print any warnings about exceeding any memory or CPU time limits.
  83. .It Fl -logN Ar value
  84. Set the work parameter N to
  85. .Pf 2^ Ar value .
  86. If
  87. .Fl -logN
  88. is set,
  89. .Fl r
  90. and
  91. .Fl p
  92. must also be set.
  93. If such explicit parameters are given, the resource limits set by
  94. .Fl M ,
  95. .Fl m ,
  96. and
  97. .Fl t
  98. are not enforced.
  99. .It Fl M Ar maxmem
  100. Use at most
  101. .Ar maxmem
  102. bytes of RAM to compute the derived encryption key.
  103. .It Fl m Ar maxmemfrac
  104. Use at most the fraction
  105. .Ar maxmemfrac
  106. of the available RAM to compute the derived encryption key.
  107. The maximum possible value for
  108. .Ar maxmemfrac
  109. is 0.5.
  110. .It Fl P
  111. Deprecated synonym for
  112. .Fl -passphrase Ar dev:stdin-once .
  113. .It Fl p Ar value
  114. Set the work parameter p to
  115. .Ar value .
  116. If
  117. .Fl p
  118. is set,
  119. .Fl -logN
  120. and
  121. .Fl r
  122. must also be set.
  123. If such explicit parameters are given, the resource limits set by
  124. .Fl M ,
  125. .Fl m ,
  126. and
  127. .Fl t
  128. are not enforced.
  129. .It Fl -passphrase Ar method:arg
  130. Read the passphrase using the specified method.
  131. .Bl -tag -width aa
  132. .It Ar dev:tty-stdin
  133. Attempt to read the passphrase from /dev/tty; if that fails, read it from stdin.
  134. This is the default behaviour.
  135. .It Ar dev:stdin-once
  136. Attempt to read the passphrase from stdin, and do so only once even when
  137. encrypting.
  138. This cannot be used if
  139. .Ar infile
  140. is also stdin (aka '-').
  141. .It Ar dev:tty-once
  142. Attempt to read the passphrase from /dev/tty, and do so only once
  143. even when encrypting.
  144. .It Ar env:VAR
  145. Read the passphrase from the environment variable specified by
  146. .Ar VAR .
  147. .Pp
  148. .Bf Em
  149. Storing a passphrase in an environment variable may be a security risk.
  150. .Ef
  151. Only use this option if you are certain that you know what you are doing.
  152. .It Ar file:FILENAME
  153. Read the passphrase from the file specified by
  154. .Ar FILENAME .
  155. .Pp
  156. .Bf Em
  157. Storing a passphrase in a file may be a security risk.
  158. .Ef
  159. Only use this option if you are certain that you know what you are doing.
  160. .El
  161. .It Fl r Ar value
  162. Set the work parameter r to
  163. .Ar value .
  164. If
  165. .Fl r
  166. is set,
  167. .Fl -logN
  168. and
  169. .Fl p
  170. must also be set.
  171. If such explicit parameters are given, the resource limits set by
  172. .Fl M ,
  173. .Fl m ,
  174. and
  175. .Fl t
  176. are not enforced.
  177. .It Fl t Ar maxtime
  178. Use at most
  179. .Ar maxtime
  180. seconds of CPU time to compute the derived encryption key.
  181. .It Fl v
  182. Print encryption parameters (N, r, p) and memory/cpu limits.
  183. .It Fl -version
  184. Print version of scrypt, and exit.
  185. .El
  186. .Pp
  187. In
  188. .Nm Cm enc ,
  189. the memory and CPU time limits are enforced by picking
  190. appropriate parameters to the
  191. .Nm
  192. key derivation function.
  193. In
  194. .Nm Cm dec ,
  195. the memory and CPU time limits are enforced by exiting with
  196. an error if decrypting the file would require too much memory
  197. or CPU time.
  198. .Sh EXIT STATUS
  199. The
  200. .Nm
  201. utility exits 0 on success, and >0 if an error occurs.
  202. .Pp
  203. Note that if the input encrypted file is corrupted,
  204. .Nm Cm dec
  205. may produce output prior to determining that the input
  206. was corrupt and exiting with a non-zero status; so
  207. users should direct the output to a safe location and
  208. check the exit status of
  209. .Nm
  210. before using the decrypted data.
  211. .Sh ALGORITHM PARAMETERS
  212. The scrypt algorithm has three tuneable work parameters: N, r, p.
  213. When decrypting, scrypt will always use the values specified by
  214. the encryption header.
  215. When encrypting, scrypt will choose appropriate values based on your system's
  216. speed and memory (influenced by
  217. .Fl M ,
  218. .Fl m ,
  219. and/or
  220. .Fl t ) ,
  221. unless you specify explicit parameters via
  222. .Fl -logN ,
  223. .Fl p ,
  224. .Fl r .
  225. .Sh SEE ALSO
  226. .Rs
  227. .%A "Colin Percival"
  228. .%T "Stronger Key Derivation via Sequential Memory-Hard Functions"
  229. .%R "BSDCan'09"
  230. .%D "May 2009"
  231. .Re
  232. .Rs
  233. .%A "Colin Percival"
  234. .%A "Simon Josefsson"
  235. .%T "The scrypt Password-Based Key Derivation Function"
  236. .%R "IETF RFC 7914"
  237. .%D "August 2016"
  238. .Re
  239. .Sh HISTORY
  240. The
  241. .Nm
  242. utility was written in May 2009 by Colin Percival as a
  243. demonstration of the
  244. .Nm
  245. key derivation function.
  246. The
  247. .Nm
  248. key derivation function was invented in March 2009 by Colin
  249. Percival in order to allow key files from the
  250. .Nm Tarsnap
  251. backup system to be passphrase protected.