Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.] */
  56. #include <openssl/des.h>
  57. #include <stdlib.h>
  58. #include "internal.h"
  59. static const uint32_t des_skb[8][64] = {
  60. {/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
  61. 0x00000000L, 0x00000010L, 0x20000000L, 0x20000010L, 0x00010000L,
  62. 0x00010010L, 0x20010000L, 0x20010010L, 0x00000800L, 0x00000810L,
  63. 0x20000800L, 0x20000810L, 0x00010800L, 0x00010810L, 0x20010800L,
  64. 0x20010810L, 0x00000020L, 0x00000030L, 0x20000020L, 0x20000030L,
  65. 0x00010020L, 0x00010030L, 0x20010020L, 0x20010030L, 0x00000820L,
  66. 0x00000830L, 0x20000820L, 0x20000830L, 0x00010820L, 0x00010830L,
  67. 0x20010820L, 0x20010830L, 0x00080000L, 0x00080010L, 0x20080000L,
  68. 0x20080010L, 0x00090000L, 0x00090010L, 0x20090000L, 0x20090010L,
  69. 0x00080800L, 0x00080810L, 0x20080800L, 0x20080810L, 0x00090800L,
  70. 0x00090810L, 0x20090800L, 0x20090810L, 0x00080020L, 0x00080030L,
  71. 0x20080020L, 0x20080030L, 0x00090020L, 0x00090030L, 0x20090020L,
  72. 0x20090030L, 0x00080820L, 0x00080830L, 0x20080820L, 0x20080830L,
  73. 0x00090820L, 0x00090830L, 0x20090820L, 0x20090830L, },
  74. {/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
  75. 0x00000000L, 0x02000000L, 0x00002000L, 0x02002000L, 0x00200000L,
  76. 0x02200000L, 0x00202000L, 0x02202000L, 0x00000004L, 0x02000004L,
  77. 0x00002004L, 0x02002004L, 0x00200004L, 0x02200004L, 0x00202004L,
  78. 0x02202004L, 0x00000400L, 0x02000400L, 0x00002400L, 0x02002400L,
  79. 0x00200400L, 0x02200400L, 0x00202400L, 0x02202400L, 0x00000404L,
  80. 0x02000404L, 0x00002404L, 0x02002404L, 0x00200404L, 0x02200404L,
  81. 0x00202404L, 0x02202404L, 0x10000000L, 0x12000000L, 0x10002000L,
  82. 0x12002000L, 0x10200000L, 0x12200000L, 0x10202000L, 0x12202000L,
  83. 0x10000004L, 0x12000004L, 0x10002004L, 0x12002004L, 0x10200004L,
  84. 0x12200004L, 0x10202004L, 0x12202004L, 0x10000400L, 0x12000400L,
  85. 0x10002400L, 0x12002400L, 0x10200400L, 0x12200400L, 0x10202400L,
  86. 0x12202400L, 0x10000404L, 0x12000404L, 0x10002404L, 0x12002404L,
  87. 0x10200404L, 0x12200404L, 0x10202404L, 0x12202404L, },
  88. {/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
  89. 0x00000000L, 0x00000001L, 0x00040000L, 0x00040001L, 0x01000000L,
  90. 0x01000001L, 0x01040000L, 0x01040001L, 0x00000002L, 0x00000003L,
  91. 0x00040002L, 0x00040003L, 0x01000002L, 0x01000003L, 0x01040002L,
  92. 0x01040003L, 0x00000200L, 0x00000201L, 0x00040200L, 0x00040201L,
  93. 0x01000200L, 0x01000201L, 0x01040200L, 0x01040201L, 0x00000202L,
  94. 0x00000203L, 0x00040202L, 0x00040203L, 0x01000202L, 0x01000203L,
  95. 0x01040202L, 0x01040203L, 0x08000000L, 0x08000001L, 0x08040000L,
  96. 0x08040001L, 0x09000000L, 0x09000001L, 0x09040000L, 0x09040001L,
  97. 0x08000002L, 0x08000003L, 0x08040002L, 0x08040003L, 0x09000002L,
  98. 0x09000003L, 0x09040002L, 0x09040003L, 0x08000200L, 0x08000201L,
  99. 0x08040200L, 0x08040201L, 0x09000200L, 0x09000201L, 0x09040200L,
  100. 0x09040201L, 0x08000202L, 0x08000203L, 0x08040202L, 0x08040203L,
  101. 0x09000202L, 0x09000203L, 0x09040202L, 0x09040203L, },
  102. {/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
  103. 0x00000000L, 0x00100000L, 0x00000100L, 0x00100100L, 0x00000008L,
  104. 0x00100008L, 0x00000108L, 0x00100108L, 0x00001000L, 0x00101000L,
  105. 0x00001100L, 0x00101100L, 0x00001008L, 0x00101008L, 0x00001108L,
  106. 0x00101108L, 0x04000000L, 0x04100000L, 0x04000100L, 0x04100100L,
  107. 0x04000008L, 0x04100008L, 0x04000108L, 0x04100108L, 0x04001000L,
  108. 0x04101000L, 0x04001100L, 0x04101100L, 0x04001008L, 0x04101008L,
  109. 0x04001108L, 0x04101108L, 0x00020000L, 0x00120000L, 0x00020100L,
  110. 0x00120100L, 0x00020008L, 0x00120008L, 0x00020108L, 0x00120108L,
  111. 0x00021000L, 0x00121000L, 0x00021100L, 0x00121100L, 0x00021008L,
  112. 0x00121008L, 0x00021108L, 0x00121108L, 0x04020000L, 0x04120000L,
  113. 0x04020100L, 0x04120100L, 0x04020008L, 0x04120008L, 0x04020108L,
  114. 0x04120108L, 0x04021000L, 0x04121000L, 0x04021100L, 0x04121100L,
  115. 0x04021008L, 0x04121008L, 0x04021108L, 0x04121108L, },
  116. {/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
  117. 0x00000000L, 0x10000000L, 0x00010000L, 0x10010000L, 0x00000004L,
  118. 0x10000004L, 0x00010004L, 0x10010004L, 0x20000000L, 0x30000000L,
  119. 0x20010000L, 0x30010000L, 0x20000004L, 0x30000004L, 0x20010004L,
  120. 0x30010004L, 0x00100000L, 0x10100000L, 0x00110000L, 0x10110000L,
  121. 0x00100004L, 0x10100004L, 0x00110004L, 0x10110004L, 0x20100000L,
  122. 0x30100000L, 0x20110000L, 0x30110000L, 0x20100004L, 0x30100004L,
  123. 0x20110004L, 0x30110004L, 0x00001000L, 0x10001000L, 0x00011000L,
  124. 0x10011000L, 0x00001004L, 0x10001004L, 0x00011004L, 0x10011004L,
  125. 0x20001000L, 0x30001000L, 0x20011000L, 0x30011000L, 0x20001004L,
  126. 0x30001004L, 0x20011004L, 0x30011004L, 0x00101000L, 0x10101000L,
  127. 0x00111000L, 0x10111000L, 0x00101004L, 0x10101004L, 0x00111004L,
  128. 0x10111004L, 0x20101000L, 0x30101000L, 0x20111000L, 0x30111000L,
  129. 0x20101004L, 0x30101004L, 0x20111004L, 0x30111004L, },
  130. {/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
  131. 0x00000000L, 0x08000000L, 0x00000008L, 0x08000008L, 0x00000400L,
  132. 0x08000400L, 0x00000408L, 0x08000408L, 0x00020000L, 0x08020000L,
  133. 0x00020008L, 0x08020008L, 0x00020400L, 0x08020400L, 0x00020408L,
  134. 0x08020408L, 0x00000001L, 0x08000001L, 0x00000009L, 0x08000009L,
  135. 0x00000401L, 0x08000401L, 0x00000409L, 0x08000409L, 0x00020001L,
  136. 0x08020001L, 0x00020009L, 0x08020009L, 0x00020401L, 0x08020401L,
  137. 0x00020409L, 0x08020409L, 0x02000000L, 0x0A000000L, 0x02000008L,
  138. 0x0A000008L, 0x02000400L, 0x0A000400L, 0x02000408L, 0x0A000408L,
  139. 0x02020000L, 0x0A020000L, 0x02020008L, 0x0A020008L, 0x02020400L,
  140. 0x0A020400L, 0x02020408L, 0x0A020408L, 0x02000001L, 0x0A000001L,
  141. 0x02000009L, 0x0A000009L, 0x02000401L, 0x0A000401L, 0x02000409L,
  142. 0x0A000409L, 0x02020001L, 0x0A020001L, 0x02020009L, 0x0A020009L,
  143. 0x02020401L, 0x0A020401L, 0x02020409L, 0x0A020409L, },
  144. {/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
  145. 0x00000000L, 0x00000100L, 0x00080000L, 0x00080100L, 0x01000000L,
  146. 0x01000100L, 0x01080000L, 0x01080100L, 0x00000010L, 0x00000110L,
  147. 0x00080010L, 0x00080110L, 0x01000010L, 0x01000110L, 0x01080010L,
  148. 0x01080110L, 0x00200000L, 0x00200100L, 0x00280000L, 0x00280100L,
  149. 0x01200000L, 0x01200100L, 0x01280000L, 0x01280100L, 0x00200010L,
  150. 0x00200110L, 0x00280010L, 0x00280110L, 0x01200010L, 0x01200110L,
  151. 0x01280010L, 0x01280110L, 0x00000200L, 0x00000300L, 0x00080200L,
  152. 0x00080300L, 0x01000200L, 0x01000300L, 0x01080200L, 0x01080300L,
  153. 0x00000210L, 0x00000310L, 0x00080210L, 0x00080310L, 0x01000210L,
  154. 0x01000310L, 0x01080210L, 0x01080310L, 0x00200200L, 0x00200300L,
  155. 0x00280200L, 0x00280300L, 0x01200200L, 0x01200300L, 0x01280200L,
  156. 0x01280300L, 0x00200210L, 0x00200310L, 0x00280210L, 0x00280310L,
  157. 0x01200210L, 0x01200310L, 0x01280210L, 0x01280310L, },
  158. {/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
  159. 0x00000000L, 0x04000000L, 0x00040000L, 0x04040000L, 0x00000002L,
  160. 0x04000002L, 0x00040002L, 0x04040002L, 0x00002000L, 0x04002000L,
  161. 0x00042000L, 0x04042000L, 0x00002002L, 0x04002002L, 0x00042002L,
  162. 0x04042002L, 0x00000020L, 0x04000020L, 0x00040020L, 0x04040020L,
  163. 0x00000022L, 0x04000022L, 0x00040022L, 0x04040022L, 0x00002020L,
  164. 0x04002020L, 0x00042020L, 0x04042020L, 0x00002022L, 0x04002022L,
  165. 0x00042022L, 0x04042022L, 0x00000800L, 0x04000800L, 0x00040800L,
  166. 0x04040800L, 0x00000802L, 0x04000802L, 0x00040802L, 0x04040802L,
  167. 0x00002800L, 0x04002800L, 0x00042800L, 0x04042800L, 0x00002802L,
  168. 0x04002802L, 0x00042802L, 0x04042802L, 0x00000820L, 0x04000820L,
  169. 0x00040820L, 0x04040820L, 0x00000822L, 0x04000822L, 0x00040822L,
  170. 0x04040822L, 0x00002820L, 0x04002820L, 0x00042820L, 0x04042820L,
  171. 0x00002822L, 0x04002822L, 0x00042822L, 0x04042822L, }};
  172. static const uint32_t DES_SPtrans[8][64] = {
  173. {/* nibble 0 */
  174. 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, 0x02000000L,
  175. 0x00080802L, 0x00080002L, 0x02000002L, 0x00080802L, 0x02080800L,
  176. 0x02080000L, 0x00000802L, 0x02000802L, 0x02000000L, 0x00000000L,
  177. 0x00080002L, 0x00080000L, 0x00000002L, 0x02000800L, 0x00080800L,
  178. 0x02080802L, 0x02080000L, 0x00000802L, 0x02000800L, 0x00000002L,
  179. 0x00000800L, 0x00080800L, 0x02080002L, 0x00000800L, 0x02000802L,
  180. 0x02080002L, 0x00000000L, 0x00000000L, 0x02080802L, 0x02000800L,
  181. 0x00080002L, 0x02080800L, 0x00080000L, 0x00000802L, 0x02000800L,
  182. 0x02080002L, 0x00000800L, 0x00080800L, 0x02000002L, 0x00080802L,
  183. 0x00000002L, 0x02000002L, 0x02080000L, 0x02080802L, 0x00080800L,
  184. 0x02080000L, 0x02000802L, 0x02000000L, 0x00000802L, 0x00080002L,
  185. 0x00000000L, 0x00080000L, 0x02000000L, 0x02000802L, 0x02080800L,
  186. 0x00000002L, 0x02080002L, 0x00000800L, 0x00080802L, },
  187. {/* nibble 1 */
  188. 0x40108010L, 0x00000000L, 0x00108000L, 0x40100000L, 0x40000010L,
  189. 0x00008010L, 0x40008000L, 0x00108000L, 0x00008000L, 0x40100010L,
  190. 0x00000010L, 0x40008000L, 0x00100010L, 0x40108000L, 0x40100000L,
  191. 0x00000010L, 0x00100000L, 0x40008010L, 0x40100010L, 0x00008000L,
  192. 0x00108010L, 0x40000000L, 0x00000000L, 0x00100010L, 0x40008010L,
  193. 0x00108010L, 0x40108000L, 0x40000010L, 0x40000000L, 0x00100000L,
  194. 0x00008010L, 0x40108010L, 0x00100010L, 0x40108000L, 0x40008000L,
  195. 0x00108010L, 0x40108010L, 0x00100010L, 0x40000010L, 0x00000000L,
  196. 0x40000000L, 0x00008010L, 0x00100000L, 0x40100010L, 0x00008000L,
  197. 0x40000000L, 0x00108010L, 0x40008010L, 0x40108000L, 0x00008000L,
  198. 0x00000000L, 0x40000010L, 0x00000010L, 0x40108010L, 0x00108000L,
  199. 0x40100000L, 0x40100010L, 0x00100000L, 0x00008010L, 0x40008000L,
  200. 0x40008010L, 0x00000010L, 0x40100000L, 0x00108000L, },
  201. {/* nibble 2 */
  202. 0x04000001L, 0x04040100L, 0x00000100L, 0x04000101L, 0x00040001L,
  203. 0x04000000L, 0x04000101L, 0x00040100L, 0x04000100L, 0x00040000L,
  204. 0x04040000L, 0x00000001L, 0x04040101L, 0x00000101L, 0x00000001L,
  205. 0x04040001L, 0x00000000L, 0x00040001L, 0x04040100L, 0x00000100L,
  206. 0x00000101L, 0x04040101L, 0x00040000L, 0x04000001L, 0x04040001L,
  207. 0x04000100L, 0x00040101L, 0x04040000L, 0x00040100L, 0x00000000L,
  208. 0x04000000L, 0x00040101L, 0x04040100L, 0x00000100L, 0x00000001L,
  209. 0x00040000L, 0x00000101L, 0x00040001L, 0x04040000L, 0x04000101L,
  210. 0x00000000L, 0x04040100L, 0x00040100L, 0x04040001L, 0x00040001L,
  211. 0x04000000L, 0x04040101L, 0x00000001L, 0x00040101L, 0x04000001L,
  212. 0x04000000L, 0x04040101L, 0x00040000L, 0x04000100L, 0x04000101L,
  213. 0x00040100L, 0x04000100L, 0x00000000L, 0x04040001L, 0x00000101L,
  214. 0x04000001L, 0x00040101L, 0x00000100L, 0x04040000L, },
  215. {/* nibble 3 */
  216. 0x00401008L, 0x10001000L, 0x00000008L, 0x10401008L, 0x00000000L,
  217. 0x10400000L, 0x10001008L, 0x00400008L, 0x10401000L, 0x10000008L,
  218. 0x10000000L, 0x00001008L, 0x10000008L, 0x00401008L, 0x00400000L,
  219. 0x10000000L, 0x10400008L, 0x00401000L, 0x00001000L, 0x00000008L,
  220. 0x00401000L, 0x10001008L, 0x10400000L, 0x00001000L, 0x00001008L,
  221. 0x00000000L, 0x00400008L, 0x10401000L, 0x10001000L, 0x10400008L,
  222. 0x10401008L, 0x00400000L, 0x10400008L, 0x00001008L, 0x00400000L,
  223. 0x10000008L, 0x00401000L, 0x10001000L, 0x00000008L, 0x10400000L,
  224. 0x10001008L, 0x00000000L, 0x00001000L, 0x00400008L, 0x00000000L,
  225. 0x10400008L, 0x10401000L, 0x00001000L, 0x10000000L, 0x10401008L,
  226. 0x00401008L, 0x00400000L, 0x10401008L, 0x00000008L, 0x10001000L,
  227. 0x00401008L, 0x00400008L, 0x00401000L, 0x10400000L, 0x10001008L,
  228. 0x00001008L, 0x10000000L, 0x10000008L, 0x10401000L, },
  229. {/* nibble 4 */
  230. 0x08000000L, 0x00010000L, 0x00000400L, 0x08010420L, 0x08010020L,
  231. 0x08000400L, 0x00010420L, 0x08010000L, 0x00010000L, 0x00000020L,
  232. 0x08000020L, 0x00010400L, 0x08000420L, 0x08010020L, 0x08010400L,
  233. 0x00000000L, 0x00010400L, 0x08000000L, 0x00010020L, 0x00000420L,
  234. 0x08000400L, 0x00010420L, 0x00000000L, 0x08000020L, 0x00000020L,
  235. 0x08000420L, 0x08010420L, 0x00010020L, 0x08010000L, 0x00000400L,
  236. 0x00000420L, 0x08010400L, 0x08010400L, 0x08000420L, 0x00010020L,
  237. 0x08010000L, 0x00010000L, 0x00000020L, 0x08000020L, 0x08000400L,
  238. 0x08000000L, 0x00010400L, 0x08010420L, 0x00000000L, 0x00010420L,
  239. 0x08000000L, 0x00000400L, 0x00010020L, 0x08000420L, 0x00000400L,
  240. 0x00000000L, 0x08010420L, 0x08010020L, 0x08010400L, 0x00000420L,
  241. 0x00010000L, 0x00010400L, 0x08010020L, 0x08000400L, 0x00000420L,
  242. 0x00000020L, 0x00010420L, 0x08010000L, 0x08000020L, },
  243. {/* nibble 5 */
  244. 0x80000040L, 0x00200040L, 0x00000000L, 0x80202000L, 0x00200040L,
  245. 0x00002000L, 0x80002040L, 0x00200000L, 0x00002040L, 0x80202040L,
  246. 0x00202000L, 0x80000000L, 0x80002000L, 0x80000040L, 0x80200000L,
  247. 0x00202040L, 0x00200000L, 0x80002040L, 0x80200040L, 0x00000000L,
  248. 0x00002000L, 0x00000040L, 0x80202000L, 0x80200040L, 0x80202040L,
  249. 0x80200000L, 0x80000000L, 0x00002040L, 0x00000040L, 0x00202000L,
  250. 0x00202040L, 0x80002000L, 0x00002040L, 0x80000000L, 0x80002000L,
  251. 0x00202040L, 0x80202000L, 0x00200040L, 0x00000000L, 0x80002000L,
  252. 0x80000000L, 0x00002000L, 0x80200040L, 0x00200000L, 0x00200040L,
  253. 0x80202040L, 0x00202000L, 0x00000040L, 0x80202040L, 0x00202000L,
  254. 0x00200000L, 0x80002040L, 0x80000040L, 0x80200000L, 0x00202040L,
  255. 0x00000000L, 0x00002000L, 0x80000040L, 0x80002040L, 0x80202000L,
  256. 0x80200000L, 0x00002040L, 0x00000040L, 0x80200040L, },
  257. {/* nibble 6 */
  258. 0x00004000L, 0x00000200L, 0x01000200L, 0x01000004L, 0x01004204L,
  259. 0x00004004L, 0x00004200L, 0x00000000L, 0x01000000L, 0x01000204L,
  260. 0x00000204L, 0x01004000L, 0x00000004L, 0x01004200L, 0x01004000L,
  261. 0x00000204L, 0x01000204L, 0x00004000L, 0x00004004L, 0x01004204L,
  262. 0x00000000L, 0x01000200L, 0x01000004L, 0x00004200L, 0x01004004L,
  263. 0x00004204L, 0x01004200L, 0x00000004L, 0x00004204L, 0x01004004L,
  264. 0x00000200L, 0x01000000L, 0x00004204L, 0x01004000L, 0x01004004L,
  265. 0x00000204L, 0x00004000L, 0x00000200L, 0x01000000L, 0x01004004L,
  266. 0x01000204L, 0x00004204L, 0x00004200L, 0x00000000L, 0x00000200L,
  267. 0x01000004L, 0x00000004L, 0x01000200L, 0x00000000L, 0x01000204L,
  268. 0x01000200L, 0x00004200L, 0x00000204L, 0x00004000L, 0x01004204L,
  269. 0x01000000L, 0x01004200L, 0x00000004L, 0x00004004L, 0x01004204L,
  270. 0x01000004L, 0x01004200L, 0x01004000L, 0x00004004L, },
  271. {/* nibble 7 */
  272. 0x20800080L, 0x20820000L, 0x00020080L, 0x00000000L, 0x20020000L,
  273. 0x00800080L, 0x20800000L, 0x20820080L, 0x00000080L, 0x20000000L,
  274. 0x00820000L, 0x00020080L, 0x00820080L, 0x20020080L, 0x20000080L,
  275. 0x20800000L, 0x00020000L, 0x00820080L, 0x00800080L, 0x20020000L,
  276. 0x20820080L, 0x20000080L, 0x00000000L, 0x00820000L, 0x20000000L,
  277. 0x00800000L, 0x20020080L, 0x20800080L, 0x00800000L, 0x00020000L,
  278. 0x20820000L, 0x00000080L, 0x00800000L, 0x00020000L, 0x20000080L,
  279. 0x20820080L, 0x00020080L, 0x20000000L, 0x00000000L, 0x00820000L,
  280. 0x20800080L, 0x20020080L, 0x20020000L, 0x00800080L, 0x20820000L,
  281. 0x00000080L, 0x00800080L, 0x20020000L, 0x20820080L, 0x00800000L,
  282. 0x20800000L, 0x20000080L, 0x00820000L, 0x00020080L, 0x20020080L,
  283. 0x20800000L, 0x00000080L, 0x20820000L, 0x00820080L, 0x00000000L,
  284. 0x20000000L, 0x20800080L, 0x00020000L, 0x00820080L, }};
  285. #define HPERM_OP(a, t, n, m) \
  286. ((t) = ((((a) << (16 - (n))) ^ (a)) & (m)), \
  287. (a) = (a) ^ (t) ^ (t >> (16 - (n))))
  288. void DES_set_key(const DES_cblock *key, DES_key_schedule *schedule) {
  289. static const int shifts2[16] = {0, 0, 1, 1, 1, 1, 1, 1,
  290. 0, 1, 1, 1, 1, 1, 1, 0};
  291. uint32_t c, d, t, s, t2;
  292. const uint8_t *in;
  293. int i;
  294. in = key->bytes;
  295. c2l(in, c);
  296. c2l(in, d);
  297. /* do PC1 in 47 simple operations :-)
  298. * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
  299. * for the inspiration. :-) */
  300. PERM_OP(d, c, t, 4, 0x0f0f0f0fL);
  301. HPERM_OP(c, t, -2, 0xcccc0000L);
  302. HPERM_OP(d, t, -2, 0xcccc0000L);
  303. PERM_OP(d, c, t, 1, 0x55555555L);
  304. PERM_OP(c, d, t, 8, 0x00ff00ffL);
  305. PERM_OP(d, c, t, 1, 0x55555555L);
  306. d = (((d & 0x000000ffL) << 16L) | (d & 0x0000ff00L) |
  307. ((d & 0x00ff0000L) >> 16L) | ((c & 0xf0000000L) >> 4L));
  308. c &= 0x0fffffffL;
  309. for (i = 0; i < ITERATIONS; i++) {
  310. if (shifts2[i]) {
  311. c = ((c >> 2L) | (c << 26L));
  312. d = ((d >> 2L) | (d << 26L));
  313. } else {
  314. c = ((c >> 1L) | (c << 27L));
  315. d = ((d >> 1L) | (d << 27L));
  316. }
  317. c &= 0x0fffffffL;
  318. d &= 0x0fffffffL;
  319. /* could be a few less shifts but I am to lazy at this
  320. * point in time to investigate */
  321. s = des_skb[0][(c) & 0x3f] |
  322. des_skb[1][((c >> 6L) & 0x03) | ((c >> 7L) & 0x3c)] |
  323. des_skb[2][((c >> 13L) & 0x0f) | ((c >> 14L) & 0x30)] |
  324. des_skb[3][((c >> 20L) & 0x01) | ((c >> 21L) & 0x06) |
  325. ((c >> 22L) & 0x38)];
  326. t = des_skb[4][(d) & 0x3f] |
  327. des_skb[5][((d >> 7L) & 0x03) | ((d >> 8L) & 0x3c)] |
  328. des_skb[6][(d >> 15L) & 0x3f] |
  329. des_skb[7][((d >> 21L) & 0x0f) | ((d >> 22L) & 0x30)];
  330. /* table contained 0213 4657 */
  331. t2 = ((t << 16L) | (s & 0x0000ffffL)) & 0xffffffffL;
  332. schedule->subkeys[i][0] = ROTATE(t2, 30) & 0xffffffffL;
  333. t2 = ((s >> 16L) | (t & 0xffff0000L));
  334. schedule->subkeys[i][1] = ROTATE(t2, 26) & 0xffffffffL;
  335. }
  336. }
  337. static const uint8_t kOddParity[256] = {
  338. 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14,
  339. 14, 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28,
  340. 31, 31, 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44,
  341. 44, 47, 47, 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59,
  342. 61, 61, 62, 62, 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74,
  343. 74, 76, 76, 79, 79, 81, 81, 82, 82, 84, 84, 87, 87, 88, 88,
  344. 91, 91, 93, 93, 94, 94, 97, 97, 98, 98, 100, 100, 103, 103, 104,
  345. 104, 107, 107, 109, 109, 110, 110, 112, 112, 115, 115, 117, 117, 118, 118,
  346. 121, 121, 122, 122, 124, 124, 127, 127, 128, 128, 131, 131, 133, 133, 134,
  347. 134, 137, 137, 138, 138, 140, 140, 143, 143, 145, 145, 146, 146, 148, 148,
  348. 151, 151, 152, 152, 155, 155, 157, 157, 158, 158, 161, 161, 162, 162, 164,
  349. 164, 167, 167, 168, 168, 171, 171, 173, 173, 174, 174, 176, 176, 179, 179,
  350. 181, 181, 182, 182, 185, 185, 186, 186, 188, 188, 191, 191, 193, 193, 194,
  351. 194, 196, 196, 199, 199, 200, 200, 203, 203, 205, 205, 206, 206, 208, 208,
  352. 211, 211, 213, 213, 214, 214, 217, 217, 218, 218, 220, 220, 223, 223, 224,
  353. 224, 227, 227, 229, 229, 230, 230, 233, 233, 234, 234, 236, 236, 239, 239,
  354. 241, 241, 242, 242, 244, 244, 247, 247, 248, 248, 251, 251, 253, 253, 254,
  355. 254
  356. };
  357. void DES_set_odd_parity(DES_cblock *key) {
  358. unsigned i;
  359. for (i = 0; i < DES_KEY_SZ; i++) {
  360. key->bytes[i] = kOddParity[key->bytes[i]];
  361. }
  362. }
  363. static void DES_encrypt1(uint32_t *data, const DES_key_schedule *ks, int enc) {
  364. uint32_t l, r, t, u;
  365. r = data[0];
  366. l = data[1];
  367. IP(r, l);
  368. /* Things have been modified so that the initial rotate is done outside
  369. * the loop. This required the DES_SPtrans values in sp.h to be
  370. * rotated 1 bit to the right. One perl script later and things have a
  371. * 5% speed up on a sparc2. Thanks to Richard Outerbridge
  372. * <71755.204@CompuServe.COM> for pointing this out. */
  373. /* clear the top bits on machines with 8byte longs */
  374. /* shift left by 2 */
  375. r = ROTATE(r, 29) & 0xffffffffL;
  376. l = ROTATE(l, 29) & 0xffffffffL;
  377. /* I don't know if it is worth the effort of loop unrolling the
  378. * inner loop */
  379. if (enc) {
  380. D_ENCRYPT(ks, l, r, 0);
  381. D_ENCRYPT(ks, r, l, 1);
  382. D_ENCRYPT(ks, l, r, 2);
  383. D_ENCRYPT(ks, r, l, 3);
  384. D_ENCRYPT(ks, l, r, 4);
  385. D_ENCRYPT(ks, r, l, 5);
  386. D_ENCRYPT(ks, l, r, 6);
  387. D_ENCRYPT(ks, r, l, 7);
  388. D_ENCRYPT(ks, l, r, 8);
  389. D_ENCRYPT(ks, r, l, 9);
  390. D_ENCRYPT(ks, l, r, 10);
  391. D_ENCRYPT(ks, r, l, 11);
  392. D_ENCRYPT(ks, l, r, 12);
  393. D_ENCRYPT(ks, r, l, 13);
  394. D_ENCRYPT(ks, l, r, 14);
  395. D_ENCRYPT(ks, r, l, 15);
  396. } else {
  397. D_ENCRYPT(ks, l, r, 15);
  398. D_ENCRYPT(ks, r, l, 14);
  399. D_ENCRYPT(ks, l, r, 13);
  400. D_ENCRYPT(ks, r, l, 12);
  401. D_ENCRYPT(ks, l, r, 11);
  402. D_ENCRYPT(ks, r, l, 10);
  403. D_ENCRYPT(ks, l, r, 9);
  404. D_ENCRYPT(ks, r, l, 8);
  405. D_ENCRYPT(ks, l, r, 7);
  406. D_ENCRYPT(ks, r, l, 6);
  407. D_ENCRYPT(ks, l, r, 5);
  408. D_ENCRYPT(ks, r, l, 4);
  409. D_ENCRYPT(ks, l, r, 3);
  410. D_ENCRYPT(ks, r, l, 2);
  411. D_ENCRYPT(ks, l, r, 1);
  412. D_ENCRYPT(ks, r, l, 0);
  413. }
  414. /* rotate and clear the top bits on machines with 8byte longs */
  415. l = ROTATE(l, 3) & 0xffffffffL;
  416. r = ROTATE(r, 3) & 0xffffffffL;
  417. FP(r, l);
  418. data[0] = l;
  419. data[1] = r;
  420. }
  421. static void DES_encrypt2(uint32_t *data, const DES_key_schedule *ks, int enc) {
  422. uint32_t l, r, t, u;
  423. r = data[0];
  424. l = data[1];
  425. /* Things have been modified so that the initial rotate is done outside the
  426. * loop. This required the DES_SPtrans values in sp.h to be rotated 1 bit to
  427. * the right. One perl script later and things have a 5% speed up on a
  428. * sparc2. Thanks to Richard Outerbridge <71755.204@CompuServe.COM> for
  429. * pointing this out. */
  430. /* clear the top bits on machines with 8byte longs */
  431. r = ROTATE(r, 29) & 0xffffffffL;
  432. l = ROTATE(l, 29) & 0xffffffffL;
  433. /* I don't know if it is worth the effort of loop unrolling the
  434. * inner loop */
  435. if (enc) {
  436. D_ENCRYPT(ks, l, r, 0);
  437. D_ENCRYPT(ks, r, l, 1);
  438. D_ENCRYPT(ks, l, r, 2);
  439. D_ENCRYPT(ks, r, l, 3);
  440. D_ENCRYPT(ks, l, r, 4);
  441. D_ENCRYPT(ks, r, l, 5);
  442. D_ENCRYPT(ks, l, r, 6);
  443. D_ENCRYPT(ks, r, l, 7);
  444. D_ENCRYPT(ks, l, r, 8);
  445. D_ENCRYPT(ks, r, l, 9);
  446. D_ENCRYPT(ks, l, r, 10);
  447. D_ENCRYPT(ks, r, l, 11);
  448. D_ENCRYPT(ks, l, r, 12);
  449. D_ENCRYPT(ks, r, l, 13);
  450. D_ENCRYPT(ks, l, r, 14);
  451. D_ENCRYPT(ks, r, l, 15);
  452. } else {
  453. D_ENCRYPT(ks, l, r, 15);
  454. D_ENCRYPT(ks, r, l, 14);
  455. D_ENCRYPT(ks, l, r, 13);
  456. D_ENCRYPT(ks, r, l, 12);
  457. D_ENCRYPT(ks, l, r, 11);
  458. D_ENCRYPT(ks, r, l, 10);
  459. D_ENCRYPT(ks, l, r, 9);
  460. D_ENCRYPT(ks, r, l, 8);
  461. D_ENCRYPT(ks, l, r, 7);
  462. D_ENCRYPT(ks, r, l, 6);
  463. D_ENCRYPT(ks, l, r, 5);
  464. D_ENCRYPT(ks, r, l, 4);
  465. D_ENCRYPT(ks, l, r, 3);
  466. D_ENCRYPT(ks, r, l, 2);
  467. D_ENCRYPT(ks, l, r, 1);
  468. D_ENCRYPT(ks, r, l, 0);
  469. }
  470. /* rotate and clear the top bits on machines with 8byte longs */
  471. data[0] = ROTATE(l, 3) & 0xffffffffL;
  472. data[1] = ROTATE(r, 3) & 0xffffffffL;
  473. }
  474. void DES_encrypt3(uint32_t *data, const DES_key_schedule *ks1,
  475. const DES_key_schedule *ks2, const DES_key_schedule *ks3) {
  476. uint32_t l, r;
  477. l = data[0];
  478. r = data[1];
  479. IP(l, r);
  480. data[0] = l;
  481. data[1] = r;
  482. DES_encrypt2((uint32_t *)data, ks1, DES_ENCRYPT);
  483. DES_encrypt2((uint32_t *)data, ks2, DES_DECRYPT);
  484. DES_encrypt2((uint32_t *)data, ks3, DES_ENCRYPT);
  485. l = data[0];
  486. r = data[1];
  487. FP(r, l);
  488. data[0] = l;
  489. data[1] = r;
  490. }
  491. void DES_decrypt3(uint32_t *data, const DES_key_schedule *ks1,
  492. const DES_key_schedule *ks2, const DES_key_schedule *ks3) {
  493. uint32_t l, r;
  494. l = data[0];
  495. r = data[1];
  496. IP(l, r);
  497. data[0] = l;
  498. data[1] = r;
  499. DES_encrypt2((uint32_t *)data, ks3, DES_DECRYPT);
  500. DES_encrypt2((uint32_t *)data, ks2, DES_ENCRYPT);
  501. DES_encrypt2((uint32_t *)data, ks1, DES_DECRYPT);
  502. l = data[0];
  503. r = data[1];
  504. FP(r, l);
  505. data[0] = l;
  506. data[1] = r;
  507. }
  508. void DES_ecb_encrypt(const DES_cblock *in_block, DES_cblock *out_block,
  509. const DES_key_schedule *schedule, int is_encrypt) {
  510. uint32_t l;
  511. uint32_t ll[2];
  512. const uint8_t *in = in_block->bytes;
  513. uint8_t *out = out_block->bytes;
  514. c2l(in, l);
  515. ll[0] = l;
  516. c2l(in, l);
  517. ll[1] = l;
  518. DES_encrypt1(ll, schedule, is_encrypt);
  519. l = ll[0];
  520. l2c(l, out);
  521. l = ll[1];
  522. l2c(l, out);
  523. ll[0] = ll[1] = 0;
  524. }
  525. void DES_ncbc_encrypt(const uint8_t *in, uint8_t *out, size_t len,
  526. const DES_key_schedule *schedule, DES_cblock *ivec,
  527. int enc) {
  528. uint32_t tin0, tin1;
  529. uint32_t tout0, tout1, xor0, xor1;
  530. uint32_t tin[2];
  531. unsigned char *iv;
  532. iv = ivec->bytes;
  533. if (enc) {
  534. c2l(iv, tout0);
  535. c2l(iv, tout1);
  536. for (; len >= 8; len -= 8) {
  537. c2l(in, tin0);
  538. c2l(in, tin1);
  539. tin0 ^= tout0;
  540. tin[0] = tin0;
  541. tin1 ^= tout1;
  542. tin[1] = tin1;
  543. DES_encrypt1((uint32_t *)tin, schedule, DES_ENCRYPT);
  544. tout0 = tin[0];
  545. l2c(tout0, out);
  546. tout1 = tin[1];
  547. l2c(tout1, out);
  548. }
  549. if (len != 0) {
  550. c2ln(in, tin0, tin1, len);
  551. tin0 ^= tout0;
  552. tin[0] = tin0;
  553. tin1 ^= tout1;
  554. tin[1] = tin1;
  555. DES_encrypt1((uint32_t *)tin, schedule, DES_ENCRYPT);
  556. tout0 = tin[0];
  557. l2c(tout0, out);
  558. tout1 = tin[1];
  559. l2c(tout1, out);
  560. }
  561. iv = ivec->bytes;
  562. l2c(tout0, iv);
  563. l2c(tout1, iv);
  564. } else {
  565. c2l(iv, xor0);
  566. c2l(iv, xor1);
  567. for (; len >= 8; len -= 8) {
  568. c2l(in, tin0);
  569. tin[0] = tin0;
  570. c2l(in, tin1);
  571. tin[1] = tin1;
  572. DES_encrypt1((uint32_t *)tin, schedule, DES_DECRYPT);
  573. tout0 = tin[0] ^ xor0;
  574. tout1 = tin[1] ^ xor1;
  575. l2c(tout0, out);
  576. l2c(tout1, out);
  577. xor0 = tin0;
  578. xor1 = tin1;
  579. }
  580. if (len != 0) {
  581. c2l(in, tin0);
  582. tin[0] = tin0;
  583. c2l(in, tin1);
  584. tin[1] = tin1;
  585. DES_encrypt1((uint32_t *)tin, schedule, DES_DECRYPT);
  586. tout0 = tin[0] ^ xor0;
  587. tout1 = tin[1] ^ xor1;
  588. l2cn(tout0, tout1, out, len);
  589. xor0 = tin0;
  590. xor1 = tin1;
  591. }
  592. iv = ivec->bytes;
  593. l2c(xor0, iv);
  594. l2c(xor1, iv);
  595. }
  596. tin[0] = tin[1] = 0;
  597. }
  598. void DES_ecb3_encrypt(const DES_cblock *input, DES_cblock *output,
  599. const DES_key_schedule *ks1, const DES_key_schedule *ks2,
  600. const DES_key_schedule *ks3, int enc) {
  601. uint32_t l0, l1;
  602. uint32_t ll[2];
  603. const uint8_t *in = input->bytes;
  604. uint8_t *out = output->bytes;
  605. c2l(in, l0);
  606. c2l(in, l1);
  607. ll[0] = l0;
  608. ll[1] = l1;
  609. if (enc) {
  610. DES_encrypt3(ll, ks1, ks2, ks3);
  611. } else {
  612. DES_decrypt3(ll, ks1, ks2, ks3);
  613. }
  614. l0 = ll[0];
  615. l1 = ll[1];
  616. l2c(l0, out);
  617. l2c(l1, out);
  618. }
  619. void DES_ede3_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t len,
  620. const DES_key_schedule *ks1,
  621. const DES_key_schedule *ks2,
  622. const DES_key_schedule *ks3, DES_cblock *ivec,
  623. int enc) {
  624. uint32_t tin0, tin1;
  625. uint32_t tout0, tout1, xor0, xor1;
  626. uint32_t tin[2];
  627. uint8_t *iv;
  628. iv = ivec->bytes;
  629. if (enc) {
  630. c2l(iv, tout0);
  631. c2l(iv, tout1);
  632. for (; len >= 8; len -= 8) {
  633. c2l(in, tin0);
  634. c2l(in, tin1);
  635. tin0 ^= tout0;
  636. tin1 ^= tout1;
  637. tin[0] = tin0;
  638. tin[1] = tin1;
  639. DES_encrypt3((uint32_t *)tin, ks1, ks2, ks3);
  640. tout0 = tin[0];
  641. tout1 = tin[1];
  642. l2c(tout0, out);
  643. l2c(tout1, out);
  644. }
  645. if (len != 0) {
  646. c2ln(in, tin0, tin1, len);
  647. tin0 ^= tout0;
  648. tin1 ^= tout1;
  649. tin[0] = tin0;
  650. tin[1] = tin1;
  651. DES_encrypt3((uint32_t *)tin, ks1, ks2, ks3);
  652. tout0 = tin[0];
  653. tout1 = tin[1];
  654. l2c(tout0, out);
  655. l2c(tout1, out);
  656. }
  657. iv = ivec->bytes;
  658. l2c(tout0, iv);
  659. l2c(tout1, iv);
  660. } else {
  661. uint32_t t0, t1;
  662. c2l(iv, xor0);
  663. c2l(iv, xor1);
  664. for (; len >= 8; len -= 8) {
  665. c2l(in, tin0);
  666. c2l(in, tin1);
  667. t0 = tin0;
  668. t1 = tin1;
  669. tin[0] = tin0;
  670. tin[1] = tin1;
  671. DES_decrypt3((uint32_t *)tin, ks1, ks2, ks3);
  672. tout0 = tin[0];
  673. tout1 = tin[1];
  674. tout0 ^= xor0;
  675. tout1 ^= xor1;
  676. l2c(tout0, out);
  677. l2c(tout1, out);
  678. xor0 = t0;
  679. xor1 = t1;
  680. }
  681. if (len != 0) {
  682. c2l(in, tin0);
  683. c2l(in, tin1);
  684. t0 = tin0;
  685. t1 = tin1;
  686. tin[0] = tin0;
  687. tin[1] = tin1;
  688. DES_decrypt3((uint32_t *)tin, ks1, ks2, ks3);
  689. tout0 = tin[0];
  690. tout1 = tin[1];
  691. tout0 ^= xor0;
  692. tout1 ^= xor1;
  693. l2cn(tout0, tout1, out, len);
  694. xor0 = t0;
  695. xor1 = t1;
  696. }
  697. iv = ivec->bytes;
  698. l2c(xor0, iv);
  699. l2c(xor1, iv);
  700. }
  701. tin[0] = tin[1] = 0;
  702. }
  703. void DES_ede2_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t len,
  704. const DES_key_schedule *ks1,
  705. const DES_key_schedule *ks2,
  706. DES_cblock *ivec,
  707. int enc) {
  708. DES_ede3_cbc_encrypt(in, out, len, ks1, ks2, ks1, ivec, enc);
  709. }
  710. /* Deprecated functions. */
  711. void DES_set_key_unchecked(const DES_cblock *key, DES_key_schedule *schedule) {
  712. DES_set_key(key, schedule);
  713. }