DES_random_key.3ossl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "DES_RANDOM_KEY 3ossl"
  136. .TH DES_RANDOM_KEY 3ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked,
  143. DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key,
  144. DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt,
  145. DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt,
  146. DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt,
  147. DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt,
  148. DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt,
  149. DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys,
  150. DES_fcrypt, DES_crypt \- DES encryption
  151. .SH "SYNOPSIS"
  152. .IX Header "SYNOPSIS"
  153. .Vb 1
  154. \& #include <openssl/des.h>
  155. .Ve
  156. .PP
  157. The following functions have been deprecated since OpenSSL 3.0, and can be
  158. hidden entirely by defining \fB\s-1OPENSSL_API_COMPAT\s0\fR with a suitable version value,
  159. see \fBopenssl_user_macros\fR\|(7):
  160. .PP
  161. .Vb 1
  162. \& void DES_random_key(DES_cblock *ret);
  163. \&
  164. \& int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
  165. \& int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
  166. \& int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);
  167. \& void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);
  168. \&
  169. \& void DES_set_odd_parity(DES_cblock *key);
  170. \& int DES_is_weak_key(const_DES_cblock *key);
  171. \&
  172. \& void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
  173. \& DES_key_schedule *ks, int enc);
  174. \& void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output,
  175. \& DES_key_schedule *ks1, DES_key_schedule *ks2, int enc);
  176. \& void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
  177. \& DES_key_schedule *ks1, DES_key_schedule *ks2,
  178. \& DES_key_schedule *ks3, int enc);
  179. \&
  180. \& void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,
  181. \& long length, DES_key_schedule *schedule, DES_cblock *ivec,
  182. \& int enc);
  183. \& void DES_cfb_encrypt(const unsigned char *in, unsigned char *out,
  184. \& int numbits, long length, DES_key_schedule *schedule,
  185. \& DES_cblock *ivec, int enc);
  186. \& void DES_ofb_encrypt(const unsigned char *in, unsigned char *out,
  187. \& int numbits, long length, DES_key_schedule *schedule,
  188. \& DES_cblock *ivec);
  189. \& void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
  190. \& long length, DES_key_schedule *schedule, DES_cblock *ivec,
  191. \& int enc);
  192. \& void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
  193. \& long length, DES_key_schedule *schedule, DES_cblock *ivec,
  194. \& int *num, int enc);
  195. \& void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
  196. \& long length, DES_key_schedule *schedule, DES_cblock *ivec,
  197. \& int *num);
  198. \&
  199. \& void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,
  200. \& long length, DES_key_schedule *schedule, DES_cblock *ivec,
  201. \& const_DES_cblock *inw, const_DES_cblock *outw, int enc);
  202. \&
  203. \& void DES_ede2_cbc_encrypt(const unsigned char *input, unsigned char *output,
  204. \& long length, DES_key_schedule *ks1,
  205. \& DES_key_schedule *ks2, DES_cblock *ivec, int enc);
  206. \& void DES_ede2_cfb64_encrypt(const unsigned char *in, unsigned char *out,
  207. \& long length, DES_key_schedule *ks1,
  208. \& DES_key_schedule *ks2, DES_cblock *ivec,
  209. \& int *num, int enc);
  210. \& void DES_ede2_ofb64_encrypt(const unsigned char *in, unsigned char *out,
  211. \& long length, DES_key_schedule *ks1,
  212. \& DES_key_schedule *ks2, DES_cblock *ivec, int *num);
  213. \&
  214. \& void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
  215. \& long length, DES_key_schedule *ks1,
  216. \& DES_key_schedule *ks2, DES_key_schedule *ks3,
  217. \& DES_cblock *ivec, int enc);
  218. \& void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
  219. \& long length, DES_key_schedule *ks1,
  220. \& DES_key_schedule *ks2, DES_key_schedule *ks3,
  221. \& DES_cblock *ivec, int *num, int enc);
  222. \& void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,
  223. \& long length, DES_key_schedule *ks1,
  224. \& DES_key_schedule *ks2, DES_key_schedule *ks3,
  225. \& DES_cblock *ivec, int *num);
  226. \&
  227. \& DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,
  228. \& long length, DES_key_schedule *schedule,
  229. \& const_DES_cblock *ivec);
  230. \& DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
  231. \& long length, int out_count, DES_cblock *seed);
  232. \& void DES_string_to_key(const char *str, DES_cblock *key);
  233. \& void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);
  234. \&
  235. \& char *DES_fcrypt(const char *buf, const char *salt, char *ret);
  236. \& char *DES_crypt(const char *buf, const char *salt);
  237. .Ve
  238. .SH "DESCRIPTION"
  239. .IX Header "DESCRIPTION"
  240. All of the functions described on this page are deprecated. Applications should
  241. instead use \fBEVP_EncryptInit_ex\fR\|(3), \fBEVP_EncryptUpdate\fR\|(3) and
  242. \&\fBEVP_EncryptFinal_ex\fR\|(3) or the equivalently named decrypt functions.
  243. .PP
  244. This library contains a fast implementation of the \s-1DES\s0 encryption
  245. algorithm.
  246. .PP
  247. There are two phases to the use of \s-1DES\s0 encryption. The first is the
  248. generation of a \fIDES_key_schedule\fR from a key, the second is the
  249. actual encryption. A \s-1DES\s0 key is of type \fIDES_cblock\fR. This type
  250. consists of 8 bytes with odd parity. The least significant bit in
  251. each byte is the parity bit. The key schedule is an expanded form of
  252. the key; it is used to speed the encryption process.
  253. .PP
  254. \&\fBDES_random_key()\fR generates a random key. The random generator must be
  255. seeded when calling this function.
  256. If the automatic seeding or reseeding of the OpenSSL \s-1CSPRNG\s0 fails due to
  257. external circumstances (see \s-1\fBRAND\s0\fR\|(7)), the operation will fail.
  258. If the function fails, 0 is returned.
  259. .PP
  260. Before a \s-1DES\s0 key can be used, it must be converted into the
  261. architecture dependent \fIDES_key_schedule\fR via the
  262. \&\fBDES_set_key_checked()\fR or \fBDES_set_key_unchecked()\fR function.
  263. .PP
  264. \&\fBDES_set_key_checked()\fR will check that the key passed is of odd parity
  265. and is not a weak or semi-weak key. If the parity is wrong, then \-1
  266. is returned. If the key is a weak key, then \-2 is returned. If an
  267. error is returned, the key schedule is not generated.
  268. .PP
  269. \&\fBDES_set_key()\fR works like \fBDES_set_key_checked()\fR and remains for
  270. backward compatibility.
  271. .PP
  272. \&\fBDES_set_odd_parity()\fR sets the parity of the passed \fIkey\fR to odd.
  273. .PP
  274. \&\fBDES_is_weak_key()\fR returns 1 if the passed key is a weak key, 0 if it
  275. is ok.
  276. .PP
  277. The following routines mostly operate on an input and output stream of
  278. \&\fIDES_cblock\fRs.
  279. .PP
  280. \&\fBDES_ecb_encrypt()\fR is the basic \s-1DES\s0 encryption routine that encrypts or
  281. decrypts a single 8\-byte \fIDES_cblock\fR in \fIelectronic code book\fR
  282. (\s-1ECB\s0) mode. It always transforms the input data, pointed to by
  283. \&\fIinput\fR, into the output data, pointed to by the \fIoutput\fR argument.
  284. If the \fIencrypt\fR argument is nonzero (\s-1DES_ENCRYPT\s0), the \fIinput\fR
  285. (cleartext) is encrypted in to the \fIoutput\fR (ciphertext) using the
  286. key_schedule specified by the \fIschedule\fR argument, previously set via
  287. \&\fIDES_set_key\fR. If \fIencrypt\fR is zero (\s-1DES_DECRYPT\s0), the \fIinput\fR (now
  288. ciphertext) is decrypted into the \fIoutput\fR (now cleartext). Input
  289. and output may overlap. \fBDES_ecb_encrypt()\fR does not return a value.
  290. .PP
  291. \&\fBDES_ecb3_encrypt()\fR encrypts/decrypts the \fIinput\fR block by using
  292. three-key Triple-DES encryption in \s-1ECB\s0 mode. This involves encrypting
  293. the input with \fIks1\fR, decrypting with the key schedule \fIks2\fR, and
  294. then encrypting with \fIks3\fR. This routine greatly reduces the chances
  295. of brute force breaking of \s-1DES\s0 and has the advantage of if \fIks1\fR,
  296. \&\fIks2\fR and \fIks3\fR are the same, it is equivalent to just encryption
  297. using \s-1ECB\s0 mode and \fIks1\fR as the key.
  298. .PP
  299. The macro \fBDES_ecb2_encrypt()\fR is provided to perform two-key Triple-DES
  300. encryption by using \fIks1\fR for the final encryption.
  301. .PP
  302. \&\fBDES_ncbc_encrypt()\fR encrypts/decrypts using the \fIcipher-block-chaining\fR
  303. (\s-1CBC\s0) mode of \s-1DES.\s0 If the \fIencrypt\fR argument is nonzero, the
  304. routine cipher-block-chain encrypts the cleartext data pointed to by
  305. the \fIinput\fR argument into the ciphertext pointed to by the \fIoutput\fR
  306. argument, using the key schedule provided by the \fIschedule\fR argument,
  307. and initialization vector provided by the \fIivec\fR argument. If the
  308. \&\fIlength\fR argument is not an integral multiple of eight bytes, the
  309. last block is copied to a temporary area and zero filled. The output
  310. is always an integral multiple of eight bytes.
  311. .PP
  312. \&\fBDES_xcbc_encrypt()\fR is \s-1RSA\s0's \s-1DESX\s0 mode of \s-1DES.\s0 It uses \fIinw\fR and
  313. \&\fIoutw\fR to 'whiten' the encryption. \fIinw\fR and \fIoutw\fR are secret
  314. (unlike the iv) and are as such, part of the key. So the key is sort
  315. of 24 bytes. This is much better than \s-1CBC DES.\s0
  316. .PP
  317. \&\fBDES_ede3_cbc_encrypt()\fR implements outer triple \s-1CBC DES\s0 encryption with
  318. three keys. This means that each \s-1DES\s0 operation inside the \s-1CBC\s0 mode is
  319. \&\f(CW\*(C`C=E(ks3,D(ks2,E(ks1,M)))\*(C'\fR. This mode is used by \s-1SSL.\s0
  320. .PP
  321. The \fBDES_ede2_cbc_encrypt()\fR macro implements two-key Triple-DES by
  322. reusing \fIks1\fR for the final encryption. \f(CW\*(C`C=E(ks1,D(ks2,E(ks1,M)))\*(C'\fR.
  323. This form of Triple-DES is used by the \s-1RSAREF\s0 library.
  324. .PP
  325. \&\fBDES_pcbc_encrypt()\fR encrypts/decrypts using the propagating cipher block
  326. chaining mode used by Kerberos v4. Its parameters are the same as
  327. \&\fBDES_ncbc_encrypt()\fR.
  328. .PP
  329. \&\fBDES_cfb_encrypt()\fR encrypts/decrypts using cipher feedback mode. This
  330. method takes an array of characters as input and outputs an array of
  331. characters. It does not require any padding to 8 character groups.
  332. Note: the \fIivec\fR variable is changed and the new changed value needs to
  333. be passed to the next call to this function. Since this function runs
  334. a complete \s-1DES ECB\s0 encryption per \fInumbits\fR, this function is only
  335. suggested for use when sending a small number of characters.
  336. .PP
  337. \&\fBDES_cfb64_encrypt()\fR
  338. implements \s-1CFB\s0 mode of \s-1DES\s0 with 64\-bit feedback. Why is this
  339. useful you ask? Because this routine will allow you to encrypt an
  340. arbitrary number of bytes, without 8 byte padding. Each call to this
  341. routine will encrypt the input bytes to output and then update ivec
  342. and num. num contains 'how far' we are though ivec. If this does
  343. not make much sense, read more about \s-1CFB\s0 mode of \s-1DES.\s0
  344. .PP
  345. \&\fBDES_ede3_cfb64_encrypt()\fR and \fBDES_ede2_cfb64_encrypt()\fR is the same as
  346. \&\fBDES_cfb64_encrypt()\fR except that Triple-DES is used.
  347. .PP
  348. \&\fBDES_ofb_encrypt()\fR encrypts using output feedback mode. This method
  349. takes an array of characters as input and outputs an array of
  350. characters. It does not require any padding to 8 character groups.
  351. Note: the \fIivec\fR variable is changed and the new changed value needs to
  352. be passed to the next call to this function. Since this function runs
  353. a complete \s-1DES ECB\s0 encryption per \fInumbits\fR, this function is only
  354. suggested for use when sending a small number of characters.
  355. .PP
  356. \&\fBDES_ofb64_encrypt()\fR is the same as \fBDES_cfb64_encrypt()\fR using Output
  357. Feed Back mode.
  358. .PP
  359. \&\fBDES_ede3_ofb64_encrypt()\fR and \fBDES_ede2_ofb64_encrypt()\fR is the same as
  360. \&\fBDES_ofb64_encrypt()\fR, using Triple-DES.
  361. .PP
  362. The following functions are included in the \s-1DES\s0 library for
  363. compatibility with the \s-1MIT\s0 Kerberos library.
  364. .PP
  365. \&\fBDES_cbc_cksum()\fR produces an 8 byte checksum based on the input stream
  366. (via \s-1CBC\s0 encryption). The last 4 bytes of the checksum are returned
  367. and the complete 8 bytes are placed in \fIoutput\fR. This function is
  368. used by Kerberos v4. Other applications should use
  369. \&\fBEVP_DigestInit\fR\|(3) etc. instead.
  370. .PP
  371. \&\fBDES_quad_cksum()\fR is a Kerberos v4 function. It returns a 4 byte
  372. checksum from the input bytes. The algorithm can be iterated over the
  373. input, depending on \fIout_count\fR, 1, 2, 3 or 4 times. If \fIoutput\fR is
  374. non-NULL, the 8 bytes generated by each pass are written into
  375. \&\fIoutput\fR.
  376. .PP
  377. The following are DES-based transformations:
  378. .PP
  379. \&\fBDES_fcrypt()\fR is a fast version of the Unix \fBcrypt\fR\|(3) function. This
  380. version takes only a small amount of space relative to other fast
  381. \&\fBcrypt()\fR implementations. This is different to the normal \fBcrypt()\fR in
  382. that the third parameter is the buffer that the return value is
  383. written into. It needs to be at least 14 bytes long. This function
  384. is thread safe, unlike the normal \fBcrypt()\fR.
  385. .PP
  386. \&\fBDES_crypt()\fR is a faster replacement for the normal system \fBcrypt()\fR.
  387. This function calls \fBDES_fcrypt()\fR with a static array passed as the
  388. third parameter. This mostly emulates the normal non-thread-safe semantics
  389. of \fBcrypt\fR\|(3).
  390. The \fBsalt\fR must be two \s-1ASCII\s0 characters.
  391. .PP
  392. The values returned by \fBDES_fcrypt()\fR and \fBDES_crypt()\fR are terminated by \s-1NUL\s0
  393. character.
  394. .PP
  395. \&\fBDES_enc_write()\fR writes \fIlen\fR bytes to file descriptor \fIfd\fR from
  396. buffer \fIbuf\fR. The data is encrypted via \fIpcbc_encrypt\fR (default)
  397. using \fIsched\fR for the key and \fIiv\fR as a starting vector. The actual
  398. data send down \fIfd\fR consists of 4 bytes (in network byte order)
  399. containing the length of the following encrypted data. The encrypted
  400. data then follows, padded with random data out to a multiple of 8
  401. bytes.
  402. .SH "BUGS"
  403. .IX Header "BUGS"
  404. \&\fBDES_cbc_encrypt()\fR does not modify \fBivec\fR; use \fBDES_ncbc_encrypt()\fR
  405. instead.
  406. .PP
  407. \&\fBDES_cfb_encrypt()\fR and \fBDES_ofb_encrypt()\fR operates on input of 8 bits.
  408. What this means is that if you set numbits to 12, and length to 2, the
  409. first 12 bits will come from the 1st input byte and the low half of
  410. the second input byte. The second 12 bits will have the low 8 bits
  411. taken from the 3rd input byte and the top 4 bits taken from the 4th
  412. input byte. The same holds for output. This function has been
  413. implemented this way because most people will be using a multiple of 8
  414. and because once you get into pulling bytes input bytes apart things
  415. get ugly!
  416. .PP
  417. \&\fBDES_string_to_key()\fR is available for backward compatibility with the
  418. \&\s-1MIT\s0 library. New applications should use a cryptographic hash function.
  419. The same applies for \fBDES_string_to_2key()\fR.
  420. .SH "NOTES"
  421. .IX Header "NOTES"
  422. The \fBdes\fR library was written to be source code compatible with
  423. the \s-1MIT\s0 Kerberos library.
  424. .PP
  425. Applications should use the higher level functions
  426. \&\fBEVP_EncryptInit\fR\|(3) etc. instead of calling these
  427. functions directly.
  428. .PP
  429. Single-key \s-1DES\s0 is insecure due to its short key size. \s-1ECB\s0 mode is
  430. not suitable for most applications; see \fBdes_modes\fR\|(7).
  431. .SH "RETURN VALUES"
  432. .IX Header "RETURN VALUES"
  433. \&\fBDES_set_key()\fR, \fBDES_key_sched()\fR, and \fBDES_set_key_checked()\fR
  434. return 0 on success or negative values on error.
  435. .PP
  436. \&\fBDES_is_weak_key()\fR returns 1 if the passed key is a weak key, 0 if it
  437. is ok.
  438. .PP
  439. \&\fBDES_cbc_cksum()\fR and \fBDES_quad_cksum()\fR return 4\-byte integer representing the
  440. last 4 bytes of the checksum of the input.
  441. .PP
  442. \&\fBDES_fcrypt()\fR returns a pointer to the caller-provided buffer and \fBDES_crypt()\fR \-
  443. to a static buffer on success; otherwise they return \s-1NULL.\s0
  444. .SH "SEE ALSO"
  445. .IX Header "SEE ALSO"
  446. \&\fBdes_modes\fR\|(7),
  447. \&\fBEVP_EncryptInit\fR\|(3)
  448. .SH "HISTORY"
  449. .IX Header "HISTORY"
  450. All of these functions were deprecated in OpenSSL 3.0.
  451. .PP
  452. The requirement that the \fBsalt\fR parameter to \fBDES_crypt()\fR and \fBDES_fcrypt()\fR
  453. be two \s-1ASCII\s0 characters was first enforced in
  454. OpenSSL 1.1.0. Previous versions tried to use the letter uppercase \fBA\fR
  455. if both character were not present, and could crash when given non-ASCII
  456. on some platforms.
  457. .SH "COPYRIGHT"
  458. .IX Header "COPYRIGHT"
  459. Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved.
  460. .PP
  461. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  462. this file except in compliance with the License. You can obtain a copy
  463. in the file \s-1LICENSE\s0 in the source distribution or at
  464. <https://www.openssl.org/source/license.html>.