des_enc.m4 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094
  1. ! des_enc.m4
  2. ! des_enc.S (generated from des_enc.m4)
  3. !
  4. ! UltraSPARC assembler version of the LibDES/SSLeay/OpenSSL des_enc.c file.
  5. !
  6. ! Version 1.0. 32-bit version.
  7. !
  8. ! June 8, 2000.
  9. !
  10. ! Version 2.0. 32/64-bit, PIC-ification, blended CPU adaptation
  11. ! by Andy Polyakov.
  12. !
  13. ! January 1, 2003.
  14. !
  15. ! Assembler version: Copyright Svend Olaf Mikkelsen.
  16. !
  17. ! Original C code: Copyright Eric A. Young.
  18. !
  19. ! This code can be freely used by LibDES/SSLeay/OpenSSL users.
  20. !
  21. ! The LibDES/SSLeay/OpenSSL copyright notices must be respected.
  22. !
  23. ! This version can be redistributed.
  24. !
  25. ! To expand the m4 macros: m4 -B 8192 des_enc.m4 > des_enc.S
  26. !
  27. ! Global registers 1 to 5 are used. This is the same as done by the
  28. ! cc compiler. The UltraSPARC load/store little endian feature is used.
  29. !
  30. ! Instruction grouping often refers to one CPU cycle.
  31. !
  32. ! Assemble through gcc: gcc -c -mcpu=ultrasparc -o des_enc.o des_enc.S
  33. !
  34. ! Assemble through cc: cc -c -xarch=v8plusa -o des_enc.o des_enc.S
  35. !
  36. ! Performance improvement according to './apps/openssl speed des'
  37. !
  38. ! 32-bit build:
  39. ! 23% faster than cc-5.2 -xarch=v8plus -xO5
  40. ! 115% faster than gcc-3.2.1 -m32 -mcpu=ultrasparc -O5
  41. ! 64-bit build:
  42. ! 50% faster than cc-5.2 -xarch=v9 -xO5
  43. ! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5
  44. !
  45. .ident "des_enc.m4 2.1"
  46. .file "des_enc-sparc.S"
  47. #if defined(__SUNPRO_C) && defined(__sparcv9)
  48. # define ABI64 /* They've said -xarch=v9 at command line */
  49. #elif defined(__GNUC__) && defined(__arch64__)
  50. # define ABI64 /* They've said -m64 at command line */
  51. #endif
  52. #ifdef ABI64
  53. .register %g2,#scratch
  54. .register %g3,#scratch
  55. # define FRAME -192
  56. # define BIAS 2047
  57. # define LDPTR ldx
  58. # define STPTR stx
  59. # define ARG0 128
  60. # define ARGSZ 8
  61. # ifndef OPENSSL_SYSNAME_ULTRASPARC
  62. # define OPENSSL_SYSNAME_ULTRASPARC
  63. # endif
  64. #else
  65. # define FRAME -96
  66. # define BIAS 0
  67. # define LDPTR ld
  68. # define STPTR st
  69. # define ARG0 68
  70. # define ARGSZ 4
  71. #endif
  72. #define LOOPS 7
  73. #define global0 %g0
  74. #define global1 %g1
  75. #define global2 %g2
  76. #define global3 %g3
  77. #define global4 %g4
  78. #define global5 %g5
  79. #define local0 %l0
  80. #define local1 %l1
  81. #define local2 %l2
  82. #define local3 %l3
  83. #define local4 %l4
  84. #define local5 %l5
  85. #define local7 %l6
  86. #define local6 %l7
  87. #define in0 %i0
  88. #define in1 %i1
  89. #define in2 %i2
  90. #define in3 %i3
  91. #define in4 %i4
  92. #define in5 %i5
  93. #define in6 %i6
  94. #define in7 %i7
  95. #define out0 %o0
  96. #define out1 %o1
  97. #define out2 %o2
  98. #define out3 %o3
  99. #define out4 %o4
  100. #define out5 %o5
  101. #define out6 %o6
  102. #define out7 %o7
  103. #define stub stb
  104. changequote({,})
  105. ! Macro definitions:
  106. ! {ip_macro}
  107. !
  108. ! The logic used in initial and final permutations is the same as in
  109. ! the C code. The permutations are done with a clever shift, xor, and
  110. ! technique.
  111. !
  112. ! The macro also loads address sbox 1 to 5 to global 1 to 5, address
  113. ! sbox 6 to local6, and addres sbox 8 to out3.
  114. !
  115. ! Rotates the halfs 3 left to bring the sbox bits in convenient positions.
  116. !
  117. ! Loads key first round from address in parameter 5 to out0, out1.
  118. !
  119. ! After the the original LibDES initial permutation, the resulting left
  120. ! is in the variable initially used for right and vice versa. The macro
  121. ! implements the possibility to keep the halfs in the original registers.
  122. !
  123. ! parameter 1 left
  124. ! parameter 2 right
  125. ! parameter 3 result left (modify in first round)
  126. ! parameter 4 result right (use in first round)
  127. ! parameter 5 key address
  128. ! parameter 6 1/2 for include encryption/decryption
  129. ! parameter 7 1 for move in1 to in3
  130. ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
  131. ! parameter 9 1 for load ks3 and ks2 to in4 and in3
  132. define(ip_macro, {
  133. ! {ip_macro}
  134. ! $1 $2 $4 $3 $5 $6 $7 $8 $9
  135. ld [out2+256], local1
  136. srl $2, 4, local4
  137. xor local4, $1, local4
  138. ifelse($7,1,{mov in1, in3},{nop})
  139. ld [out2+260], local2
  140. and local4, local1, local4
  141. ifelse($8,1,{mov in3, in4},{})
  142. ifelse($8,2,{mov in4, in3},{})
  143. ld [out2+280], out4 ! loop counter
  144. sll local4, 4, local1
  145. xor $1, local4, $1
  146. ld [out2+264], local3
  147. srl $1, 16, local4
  148. xor $2, local1, $2
  149. ifelse($9,1,{LDPTR KS3, in4},{})
  150. xor local4, $2, local4
  151. nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
  152. ifelse($9,1,{LDPTR KS2, in3},{})
  153. and local4, local2, local4
  154. nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
  155. sll local4, 16, local1
  156. xor $2, local4, $2
  157. srl $2, 2, local4
  158. xor $1, local1, $1
  159. sethi %hi(16711680), local5
  160. xor local4, $1, local4
  161. and local4, local3, local4
  162. or local5, 255, local5
  163. sll local4, 2, local2
  164. xor $1, local4, $1
  165. srl $1, 8, local4
  166. xor $2, local2, $2
  167. xor local4, $2, local4
  168. add global1, 768, global4
  169. and local4, local5, local4
  170. add global1, 1024, global5
  171. ld [out2+272], local7
  172. sll local4, 8, local1
  173. xor $2, local4, $2
  174. srl $2, 1, local4
  175. xor $1, local1, $1
  176. ld [$5], out0 ! key 7531
  177. xor local4, $1, local4
  178. add global1, 256, global2
  179. ld [$5+4], out1 ! key 8642
  180. and local4, local7, local4
  181. add global1, 512, global3
  182. sll local4, 1, local1
  183. xor $1, local4, $1
  184. sll $1, 3, local3
  185. xor $2, local1, $2
  186. sll $2, 3, local2
  187. add global1, 1280, local6 ! address sbox 8
  188. srl $1, 29, local4
  189. add global1, 1792, out3 ! address sbox 8
  190. srl $2, 29, local1
  191. or local4, local3, $4
  192. or local2, local1, $3
  193. ifelse($6, 1, {
  194. ld [out2+284], local5 ! 0x0000FC00 used in the rounds
  195. or local2, local1, $3
  196. xor $4, out0, local1
  197. call .des_enc.1
  198. and local1, 252, local1
  199. },{})
  200. ifelse($6, 2, {
  201. ld [out2+284], local5 ! 0x0000FC00 used in the rounds
  202. or local2, local1, $3
  203. xor $4, out0, local1
  204. call .des_dec.1
  205. and local1, 252, local1
  206. },{})
  207. })
  208. ! {rounds_macro}
  209. !
  210. ! The logic used in the DES rounds is the same as in the C code,
  211. ! except that calculations for sbox 1 and sbox 5 begin before
  212. ! the previous round is finished.
  213. !
  214. ! In each round one half (work) is modified based on key and the
  215. ! other half (use).
  216. !
  217. ! In this version we do two rounds in a loop repeated 7 times
  218. ! and two rounds seperately.
  219. !
  220. ! One half has the bits for the sboxes in the following positions:
  221. !
  222. ! 777777xx555555xx333333xx111111xx
  223. !
  224. ! 88xx666666xx444444xx222222xx8888
  225. !
  226. ! The bits for each sbox are xor-ed with the key bits for that box.
  227. ! The above xx bits are cleared, and the result used for lookup in
  228. ! the sbox table. Each sbox entry contains the 4 output bits permuted
  229. ! into 32 bits according to the P permutation.
  230. !
  231. ! In the description of DES, left and right are switched after
  232. ! each round, except after last round. In this code the original
  233. ! left and right are kept in the same register in all rounds, meaning
  234. ! that after the 16 rounds the result for right is in the register
  235. ! originally used for left.
  236. !
  237. ! parameter 1 first work (left in first round)
  238. ! parameter 2 first use (right in first round)
  239. ! parameter 3 enc/dec 1/-1
  240. ! parameter 4 loop label
  241. ! parameter 5 key address register
  242. ! parameter 6 optional address for key next encryption/decryption
  243. ! parameter 7 not empty for include retl
  244. !
  245. ! also compares in2 to 8
  246. define(rounds_macro, {
  247. ! {rounds_macro}
  248. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  249. xor $2, out0, local1
  250. ld [out2+284], local5 ! 0x0000FC00
  251. ba $4
  252. and local1, 252, local1
  253. .align 32
  254. $4:
  255. ! local6 is address sbox 6
  256. ! out3 is address sbox 8
  257. ! out4 is loop counter
  258. ld [global1+local1], local1
  259. xor $2, out1, out1 ! 8642
  260. xor $2, out0, out0 ! 7531
  261. ! fmovs %f0, %f0 ! fxor used for alignment
  262. srl out1, 4, local0 ! rotate 4 right
  263. and out0, local5, local3 ! 3
  264. ! fmovs %f0, %f0
  265. ld [$5+$3*8], local7 ! key 7531 next round
  266. srl local3, 8, local3 ! 3
  267. and local0, 252, local2 ! 2
  268. ! fmovs %f0, %f0
  269. ld [global3+local3],local3 ! 3
  270. sll out1, 28, out1 ! rotate
  271. xor $1, local1, $1 ! 1 finished, local1 now sbox 7
  272. ld [global2+local2], local2 ! 2
  273. srl out0, 24, local1 ! 7
  274. or out1, local0, out1 ! rotate
  275. ldub [out2+local1], local1 ! 7 (and 0xFC)
  276. srl out1, 24, local0 ! 8
  277. and out1, local5, local4 ! 4
  278. ldub [out2+local0], local0 ! 8 (and 0xFC)
  279. srl local4, 8, local4 ! 4
  280. xor $1, local2, $1 ! 2 finished local2 now sbox 6
  281. ld [global4+local4],local4 ! 4
  282. srl out1, 16, local2 ! 6
  283. xor $1, local3, $1 ! 3 finished local3 now sbox 5
  284. ld [out3+local0],local0 ! 8
  285. and local2, 252, local2 ! 6
  286. add global1, 1536, local5 ! address sbox 7
  287. ld [local6+local2], local2 ! 6
  288. srl out0, 16, local3 ! 5
  289. xor $1, local4, $1 ! 4 finished
  290. ld [local5+local1],local1 ! 7
  291. and local3, 252, local3 ! 5
  292. xor $1, local0, $1 ! 8 finished
  293. ld [global5+local3],local3 ! 5
  294. xor $1, local2, $1 ! 6 finished
  295. subcc out4, 1, out4
  296. ld [$5+$3*8+4], out0 ! key 8642 next round
  297. xor $1, local7, local2 ! sbox 5 next round
  298. xor $1, local1, $1 ! 7 finished
  299. srl local2, 16, local2 ! sbox 5 next round
  300. xor $1, local3, $1 ! 5 finished
  301. ld [$5+$3*16+4], out1 ! key 8642 next round again
  302. and local2, 252, local2 ! sbox5 next round
  303. ! next round
  304. xor $1, local7, local7 ! 7531
  305. ld [global5+local2], local2 ! 5
  306. srl local7, 24, local3 ! 7
  307. xor $1, out0, out0 ! 8642
  308. ldub [out2+local3], local3 ! 7 (and 0xFC)
  309. srl out0, 4, local0 ! rotate 4 right
  310. and local7, 252, local1 ! 1
  311. sll out0, 28, out0 ! rotate
  312. xor $2, local2, $2 ! 5 finished local2 used
  313. srl local0, 8, local4 ! 4
  314. and local0, 252, local2 ! 2
  315. ld [local5+local3], local3 ! 7
  316. srl local0, 16, local5 ! 6
  317. or out0, local0, out0 ! rotate
  318. ld [global2+local2], local2 ! 2
  319. srl out0, 24, local0
  320. ld [$5+$3*16], out0 ! key 7531 next round
  321. and local4, 252, local4 ! 4
  322. and local5, 252, local5 ! 6
  323. ld [global4+local4], local4 ! 4
  324. xor $2, local3, $2 ! 7 finished local3 used
  325. and local0, 252, local0 ! 8
  326. ld [local6+local5], local5 ! 6
  327. xor $2, local2, $2 ! 2 finished local2 now sbox 3
  328. srl local7, 8, local2 ! 3 start
  329. ld [out3+local0], local0 ! 8
  330. xor $2, local4, $2 ! 4 finished
  331. and local2, 252, local2 ! 3
  332. ld [global1+local1], local1 ! 1
  333. xor $2, local5, $2 ! 6 finished local5 used
  334. ld [global3+local2], local2 ! 3
  335. xor $2, local0, $2 ! 8 finished
  336. add $5, $3*16, $5 ! enc add 8, dec add -8 to key pointer
  337. ld [out2+284], local5 ! 0x0000FC00
  338. xor $2, out0, local4 ! sbox 1 next round
  339. xor $2, local1, $2 ! 1 finished
  340. xor $2, local2, $2 ! 3 finished
  341. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  342. bne,pt %icc, $4
  343. #else
  344. bne $4
  345. #endif
  346. and local4, 252, local1 ! sbox 1 next round
  347. ! two rounds more:
  348. ld [global1+local1], local1
  349. xor $2, out1, out1
  350. xor $2, out0, out0
  351. srl out1, 4, local0 ! rotate
  352. and out0, local5, local3
  353. ld [$5+$3*8], local7 ! key 7531
  354. srl local3, 8, local3
  355. and local0, 252, local2
  356. ld [global3+local3],local3
  357. sll out1, 28, out1 ! rotate
  358. xor $1, local1, $1 ! 1 finished, local1 now sbox 7
  359. ld [global2+local2], local2
  360. srl out0, 24, local1
  361. or out1, local0, out1 ! rotate
  362. ldub [out2+local1], local1
  363. srl out1, 24, local0
  364. and out1, local5, local4
  365. ldub [out2+local0], local0
  366. srl local4, 8, local4
  367. xor $1, local2, $1 ! 2 finished local2 now sbox 6
  368. ld [global4+local4],local4
  369. srl out1, 16, local2
  370. xor $1, local3, $1 ! 3 finished local3 now sbox 5
  371. ld [out3+local0],local0
  372. and local2, 252, local2
  373. add global1, 1536, local5 ! address sbox 7
  374. ld [local6+local2], local2
  375. srl out0, 16, local3
  376. xor $1, local4, $1 ! 4 finished
  377. ld [local5+local1],local1
  378. and local3, 252, local3
  379. xor $1, local0, $1
  380. ld [global5+local3],local3
  381. xor $1, local2, $1 ! 6 finished
  382. cmp in2, 8
  383. ifelse($6,{}, {}, {ld [out2+280], out4}) ! loop counter
  384. xor $1, local7, local2 ! sbox 5 next round
  385. xor $1, local1, $1 ! 7 finished
  386. ld [$5+$3*8+4], out0
  387. srl local2, 16, local2 ! sbox 5 next round
  388. xor $1, local3, $1 ! 5 finished
  389. and local2, 252, local2
  390. ! next round (two rounds more)
  391. xor $1, local7, local7 ! 7531
  392. ld [global5+local2], local2
  393. srl local7, 24, local3
  394. xor $1, out0, out0 ! 8642
  395. ldub [out2+local3], local3
  396. srl out0, 4, local0 ! rotate
  397. and local7, 252, local1
  398. sll out0, 28, out0 ! rotate
  399. xor $2, local2, $2 ! 5 finished local2 used
  400. srl local0, 8, local4
  401. and local0, 252, local2
  402. ld [local5+local3], local3
  403. srl local0, 16, local5
  404. or out0, local0, out0 ! rotate
  405. ld [global2+local2], local2
  406. srl out0, 24, local0
  407. ifelse($6,{}, {}, {ld [$6], out0}) ! key next encryption/decryption
  408. and local4, 252, local4
  409. and local5, 252, local5
  410. ld [global4+local4], local4
  411. xor $2, local3, $2 ! 7 finished local3 used
  412. and local0, 252, local0
  413. ld [local6+local5], local5
  414. xor $2, local2, $2 ! 2 finished local2 now sbox 3
  415. srl local7, 8, local2 ! 3 start
  416. ld [out3+local0], local0
  417. xor $2, local4, $2
  418. and local2, 252, local2
  419. ld [global1+local1], local1
  420. xor $2, local5, $2 ! 6 finished local5 used
  421. ld [global3+local2], local2
  422. srl $1, 3, local3
  423. xor $2, local0, $2
  424. ifelse($6,{}, {}, {ld [$6+4], out1}) ! key next encryption/decryption
  425. sll $1, 29, local4
  426. xor $2, local1, $2
  427. ifelse($7,{}, {}, {retl})
  428. xor $2, local2, $2
  429. })
  430. ! {fp_macro}
  431. !
  432. ! parameter 1 right (original left)
  433. ! parameter 2 left (original right)
  434. ! parameter 3 1 for optional store to [in0]
  435. ! parameter 4 1 for load input/output address to local5/7
  436. !
  437. ! The final permutation logic switches the halfes, meaning that
  438. ! left and right ends up the the registers originally used.
  439. define(fp_macro, {
  440. ! {fp_macro}
  441. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  442. ! initially undo the rotate 3 left done after initial permutation
  443. ! original left is received shifted 3 right and 29 left in local3/4
  444. sll $2, 29, local1
  445. or local3, local4, $1
  446. srl $2, 3, $2
  447. sethi %hi(0x55555555), local2
  448. or $2, local1, $2
  449. or local2, %lo(0x55555555), local2
  450. srl $2, 1, local3
  451. sethi %hi(0x00ff00ff), local1
  452. xor local3, $1, local3
  453. or local1, %lo(0x00ff00ff), local1
  454. and local3, local2, local3
  455. sethi %hi(0x33333333), local4
  456. sll local3, 1, local2
  457. xor $1, local3, $1
  458. srl $1, 8, local3
  459. xor $2, local2, $2
  460. xor local3, $2, local3
  461. or local4, %lo(0x33333333), local4
  462. and local3, local1, local3
  463. sethi %hi(0x0000ffff), local1
  464. sll local3, 8, local2
  465. xor $2, local3, $2
  466. srl $2, 2, local3
  467. xor $1, local2, $1
  468. xor local3, $1, local3
  469. or local1, %lo(0x0000ffff), local1
  470. and local3, local4, local3
  471. sethi %hi(0x0f0f0f0f), local4
  472. sll local3, 2, local2
  473. ifelse($4,1, {LDPTR INPUT, local5})
  474. xor $1, local3, $1
  475. ifelse($4,1, {LDPTR OUTPUT, local7})
  476. srl $1, 16, local3
  477. xor $2, local2, $2
  478. xor local3, $2, local3
  479. or local4, %lo(0x0f0f0f0f), local4
  480. and local3, local1, local3
  481. sll local3, 16, local2
  482. xor $2, local3, local1
  483. srl local1, 4, local3
  484. xor $1, local2, $1
  485. xor local3, $1, local3
  486. and local3, local4, local3
  487. sll local3, 4, local2
  488. xor $1, local3, $1
  489. ! optional store:
  490. ifelse($3,1, {st $1, [in0]})
  491. xor local1, local2, $2
  492. ifelse($3,1, {st $2, [in0+4]})
  493. })
  494. ! {fp_ip_macro}
  495. !
  496. ! Does initial permutation for next block mixed with
  497. ! final permutation for current block.
  498. !
  499. ! parameter 1 original left
  500. ! parameter 2 original right
  501. ! parameter 3 left ip
  502. ! parameter 4 right ip
  503. ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
  504. ! 2: mov in4 to in3
  505. !
  506. ! also adds -8 to length in2 and loads loop counter to out4
  507. define(fp_ip_macro, {
  508. ! {fp_ip_macro}
  509. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  510. define({temp1},{out4})
  511. define({temp2},{local3})
  512. define({ip1},{local1})
  513. define({ip2},{local2})
  514. define({ip4},{local4})
  515. define({ip5},{local5})
  516. ! $1 in local3, local4
  517. ld [out2+256], ip1
  518. sll out5, 29, temp1
  519. or local3, local4, $1
  520. srl out5, 3, $2
  521. ifelse($5,2,{mov in4, in3})
  522. ld [out2+272], ip5
  523. srl $4, 4, local0
  524. or $2, temp1, $2
  525. srl $2, 1, temp1
  526. xor temp1, $1, temp1
  527. and temp1, ip5, temp1
  528. xor local0, $3, local0
  529. sll temp1, 1, temp2
  530. xor $1, temp1, $1
  531. and local0, ip1, local0
  532. add in2, -8, in2
  533. sll local0, 4, local7
  534. xor $3, local0, $3
  535. ld [out2+268], ip4
  536. srl $1, 8, temp1
  537. xor $2, temp2, $2
  538. ld [out2+260], ip2
  539. srl $3, 16, local0
  540. xor $4, local7, $4
  541. xor temp1, $2, temp1
  542. xor local0, $4, local0
  543. and temp1, ip4, temp1
  544. and local0, ip2, local0
  545. sll temp1, 8, temp2
  546. xor $2, temp1, $2
  547. sll local0, 16, local7
  548. xor $4, local0, $4
  549. srl $2, 2, temp1
  550. xor $1, temp2, $1
  551. ld [out2+264], temp2 ! ip3
  552. srl $4, 2, local0
  553. xor $3, local7, $3
  554. xor temp1, $1, temp1
  555. xor local0, $3, local0
  556. and temp1, temp2, temp1
  557. and local0, temp2, local0
  558. sll temp1, 2, temp2
  559. xor $1, temp1, $1
  560. sll local0, 2, local7
  561. xor $3, local0, $3
  562. srl $1, 16, temp1
  563. xor $2, temp2, $2
  564. srl $3, 8, local0
  565. xor $4, local7, $4
  566. xor temp1, $2, temp1
  567. xor local0, $4, local0
  568. and temp1, ip2, temp1
  569. and local0, ip4, local0
  570. sll temp1, 16, temp2
  571. xor $2, temp1, local4
  572. sll local0, 8, local7
  573. xor $4, local0, $4
  574. srl $4, 1, local0
  575. xor $3, local7, $3
  576. srl local4, 4, temp1
  577. xor local0, $3, local0
  578. xor $1, temp2, $1
  579. and local0, ip5, local0
  580. sll local0, 1, local7
  581. xor temp1, $1, temp1
  582. xor $3, local0, $3
  583. xor $4, local7, $4
  584. sll $3, 3, local5
  585. and temp1, ip1, temp1
  586. sll temp1, 4, temp2
  587. xor $1, temp1, $1
  588. ifelse($5,1,{LDPTR KS2, in4})
  589. sll $4, 3, local2
  590. xor local4, temp2, $2
  591. ! reload since used as temporar:
  592. ld [out2+280], out4 ! loop counter
  593. srl $3, 29, local0
  594. ifelse($5,1,{add in4, 120, in4})
  595. ifelse($5,1,{LDPTR KS1, in3})
  596. srl $4, 29, local7
  597. or local0, local5, $4
  598. or local2, local7, $3
  599. })
  600. ! {load_little_endian}
  601. !
  602. ! parameter 1 address
  603. ! parameter 2 destination left
  604. ! parameter 3 destination right
  605. ! parameter 4 temporar
  606. ! parameter 5 label
  607. define(load_little_endian, {
  608. ! {load_little_endian}
  609. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  610. ! first in memory to rightmost in register
  611. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  612. andcc $1, 3, global0
  613. bne,pn %icc, $5
  614. nop
  615. lda [$1] 0x88, $2
  616. add $1, 4, $4
  617. ba,pt %icc, $5a
  618. lda [$4] 0x88, $3
  619. #endif
  620. $5:
  621. ldub [$1+3], $2
  622. ldub [$1+2], $4
  623. sll $2, 8, $2
  624. or $2, $4, $2
  625. ldub [$1+1], $4
  626. sll $2, 8, $2
  627. or $2, $4, $2
  628. ldub [$1+0], $4
  629. sll $2, 8, $2
  630. or $2, $4, $2
  631. ldub [$1+3+4], $3
  632. ldub [$1+2+4], $4
  633. sll $3, 8, $3
  634. or $3, $4, $3
  635. ldub [$1+1+4], $4
  636. sll $3, 8, $3
  637. or $3, $4, $3
  638. ldub [$1+0+4], $4
  639. sll $3, 8, $3
  640. or $3, $4, $3
  641. $5a:
  642. })
  643. ! {load_little_endian_inc}
  644. !
  645. ! parameter 1 address
  646. ! parameter 2 destination left
  647. ! parameter 3 destination right
  648. ! parameter 4 temporar
  649. ! parameter 4 label
  650. !
  651. ! adds 8 to address
  652. define(load_little_endian_inc, {
  653. ! {load_little_endian_inc}
  654. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  655. ! first in memory to rightmost in register
  656. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  657. andcc $1, 3, global0
  658. bne,pn %icc, $5
  659. nop
  660. lda [$1] 0x88, $2
  661. add $1, 4, $1
  662. lda [$1] 0x88, $3
  663. ba,pt %icc, $5a
  664. add $1, 4, $1
  665. #endif
  666. $5:
  667. ldub [$1+3], $2
  668. ldub [$1+2], $4
  669. sll $2, 8, $2
  670. or $2, $4, $2
  671. ldub [$1+1], $4
  672. sll $2, 8, $2
  673. or $2, $4, $2
  674. ldub [$1+0], $4
  675. sll $2, 8, $2
  676. or $2, $4, $2
  677. ldub [$1+3+4], $3
  678. add $1, 8, $1
  679. ldub [$1+2+4-8], $4
  680. sll $3, 8, $3
  681. or $3, $4, $3
  682. ldub [$1+1+4-8], $4
  683. sll $3, 8, $3
  684. or $3, $4, $3
  685. ldub [$1+0+4-8], $4
  686. sll $3, 8, $3
  687. or $3, $4, $3
  688. $5a:
  689. })
  690. ! {load_n_bytes}
  691. !
  692. ! Loads 1 to 7 bytes little endian
  693. ! Remaining bytes are zeroed.
  694. !
  695. ! parameter 1 address
  696. ! parameter 2 length
  697. ! parameter 3 destination register left
  698. ! parameter 4 destination register right
  699. ! parameter 5 temp
  700. ! parameter 6 temp2
  701. ! parameter 7 label
  702. ! parameter 8 return label
  703. define(load_n_bytes, {
  704. ! {load_n_bytes}
  705. ! $1 $2 $5 $6 $7 $8 $7 $8 $9
  706. $7.0: call .+8
  707. sll $2, 2, $6
  708. add %o7,$7.jmp.table-$7.0,$5
  709. add $5, $6, $5
  710. mov 0, $4
  711. ld [$5], $5
  712. jmp %o7+$5
  713. mov 0, $3
  714. $7.7:
  715. ldub [$1+6], $5
  716. sll $5, 16, $5
  717. or $3, $5, $3
  718. $7.6:
  719. ldub [$1+5], $5
  720. sll $5, 8, $5
  721. or $3, $5, $3
  722. $7.5:
  723. ldub [$1+4], $5
  724. or $3, $5, $3
  725. $7.4:
  726. ldub [$1+3], $5
  727. sll $5, 24, $5
  728. or $4, $5, $4
  729. $7.3:
  730. ldub [$1+2], $5
  731. sll $5, 16, $5
  732. or $4, $5, $4
  733. $7.2:
  734. ldub [$1+1], $5
  735. sll $5, 8, $5
  736. or $4, $5, $4
  737. $7.1:
  738. ldub [$1+0], $5
  739. ba $8
  740. or $4, $5, $4
  741. .align 4
  742. $7.jmp.table:
  743. .word 0
  744. .word $7.1-$7.0
  745. .word $7.2-$7.0
  746. .word $7.3-$7.0
  747. .word $7.4-$7.0
  748. .word $7.5-$7.0
  749. .word $7.6-$7.0
  750. .word $7.7-$7.0
  751. })
  752. ! {store_little_endian}
  753. !
  754. ! parameter 1 address
  755. ! parameter 2 source left
  756. ! parameter 3 source right
  757. ! parameter 4 temporar
  758. define(store_little_endian, {
  759. ! {store_little_endian}
  760. ! $1 $2 $3 $4 $5 $6 $7 $8 $9
  761. ! rightmost in register to first in memory
  762. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  763. andcc $1, 3, global0
  764. bne,pn %icc, $5
  765. nop
  766. sta $2, [$1] 0x88
  767. add $1, 4, $4
  768. ba,pt %icc, $5a
  769. sta $3, [$4] 0x88
  770. #endif
  771. $5:
  772. and $2, 255, $4
  773. stub $4, [$1+0]
  774. srl $2, 8, $4
  775. and $4, 255, $4
  776. stub $4, [$1+1]
  777. srl $2, 16, $4
  778. and $4, 255, $4
  779. stub $4, [$1+2]
  780. srl $2, 24, $4
  781. stub $4, [$1+3]
  782. and $3, 255, $4
  783. stub $4, [$1+0+4]
  784. srl $3, 8, $4
  785. and $4, 255, $4
  786. stub $4, [$1+1+4]
  787. srl $3, 16, $4
  788. and $4, 255, $4
  789. stub $4, [$1+2+4]
  790. srl $3, 24, $4
  791. stub $4, [$1+3+4]
  792. $5a:
  793. })
  794. ! {store_n_bytes}
  795. !
  796. ! Stores 1 to 7 bytes little endian
  797. !
  798. ! parameter 1 address
  799. ! parameter 2 length
  800. ! parameter 3 source register left
  801. ! parameter 4 source register right
  802. ! parameter 5 temp
  803. ! parameter 6 temp2
  804. ! parameter 7 label
  805. ! parameter 8 return label
  806. define(store_n_bytes, {
  807. ! {store_n_bytes}
  808. ! $1 $2 $5 $6 $7 $8 $7 $8 $9
  809. $7.0: call .+8
  810. sll $2, 2, $6
  811. add %o7,$7.jmp.table-$7.0,$5
  812. add $5, $6, $5
  813. ld [$5], $5
  814. jmp %o7+$5
  815. nop
  816. $7.7:
  817. srl $3, 16, $5
  818. and $5, 0xff, $5
  819. stub $5, [$1+6]
  820. $7.6:
  821. srl $3, 8, $5
  822. and $5, 0xff, $5
  823. stub $5, [$1+5]
  824. $7.5:
  825. and $3, 0xff, $5
  826. stub $5, [$1+4]
  827. $7.4:
  828. srl $4, 24, $5
  829. stub $5, [$1+3]
  830. $7.3:
  831. srl $4, 16, $5
  832. and $5, 0xff, $5
  833. stub $5, [$1+2]
  834. $7.2:
  835. srl $4, 8, $5
  836. and $5, 0xff, $5
  837. stub $5, [$1+1]
  838. $7.1:
  839. and $4, 0xff, $5
  840. ba $8
  841. stub $5, [$1]
  842. .align 4
  843. $7.jmp.table:
  844. .word 0
  845. .word $7.1-$7.0
  846. .word $7.2-$7.0
  847. .word $7.3-$7.0
  848. .word $7.4-$7.0
  849. .word $7.5-$7.0
  850. .word $7.6-$7.0
  851. .word $7.7-$7.0
  852. })
  853. define(testvalue,{1})
  854. define(register_init, {
  855. ! For test purposes:
  856. sethi %hi(testvalue), local0
  857. or local0, %lo(testvalue), local0
  858. ifelse($1,{},{}, {mov local0, $1})
  859. ifelse($2,{},{}, {mov local0, $2})
  860. ifelse($3,{},{}, {mov local0, $3})
  861. ifelse($4,{},{}, {mov local0, $4})
  862. ifelse($5,{},{}, {mov local0, $5})
  863. ifelse($6,{},{}, {mov local0, $6})
  864. ifelse($7,{},{}, {mov local0, $7})
  865. ifelse($8,{},{}, {mov local0, $8})
  866. mov local0, local1
  867. mov local0, local2
  868. mov local0, local3
  869. mov local0, local4
  870. mov local0, local5
  871. mov local0, local7
  872. mov local0, local6
  873. mov local0, out0
  874. mov local0, out1
  875. mov local0, out2
  876. mov local0, out3
  877. mov local0, out4
  878. mov local0, out5
  879. mov local0, global1
  880. mov local0, global2
  881. mov local0, global3
  882. mov local0, global4
  883. mov local0, global5
  884. })
  885. .section ".text"
  886. .align 32
  887. .des_enc:
  888. ! key address in3
  889. ! loads key next encryption/decryption first round from [in4]
  890. rounds_macro(in5, out5, 1, .des_enc.1, in3, in4, retl)
  891. .align 32
  892. .des_dec:
  893. ! implemented with out5 as first parameter to avoid
  894. ! register exchange in ede modes
  895. ! key address in4
  896. ! loads key next encryption/decryption first round from [in3]
  897. rounds_macro(out5, in5, -1, .des_dec.1, in4, in3, retl)
  898. ! void DES_encrypt1(data, ks, enc)
  899. ! *******************************
  900. .align 32
  901. .global DES_encrypt1
  902. .type DES_encrypt1,#function
  903. DES_encrypt1:
  904. save %sp, FRAME, %sp
  905. call .PIC.me.up
  906. mov .PIC.me.up-(.-4),out0
  907. ld [in0], in5 ! left
  908. cmp in2, 0 ! enc
  909. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  910. be,pn %icc, .encrypt.dec ! enc/dec
  911. #else
  912. be .encrypt.dec
  913. #endif
  914. ld [in0+4], out5 ! right
  915. ! parameter 6 1/2 for include encryption/decryption
  916. ! parameter 7 1 for move in1 to in3
  917. ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
  918. ip_macro(in5, out5, in5, out5, in3, 0, 1, 1)
  919. rounds_macro(in5, out5, 1, .des_encrypt1.1, in3, in4) ! in4 not used
  920. fp_macro(in5, out5, 1) ! 1 for store to [in0]
  921. ret
  922. restore
  923. .encrypt.dec:
  924. add in1, 120, in3 ! use last subkey for first round
  925. ! parameter 6 1/2 for include encryption/decryption
  926. ! parameter 7 1 for move in1 to in3
  927. ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
  928. ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include dec, ks in4
  929. fp_macro(out5, in5, 1) ! 1 for store to [in0]
  930. ret
  931. restore
  932. .DES_encrypt1.end:
  933. .size DES_encrypt1,.DES_encrypt1.end-DES_encrypt1
  934. ! void DES_encrypt2(data, ks, enc)
  935. !*********************************
  936. ! encrypts/decrypts without initial/final permutation
  937. .align 32
  938. .global DES_encrypt2
  939. .type DES_encrypt2,#function
  940. DES_encrypt2:
  941. save %sp, FRAME, %sp
  942. call .PIC.me.up
  943. mov .PIC.me.up-(.-4),out0
  944. ! Set sbox address 1 to 6 and rotate halfs 3 left
  945. ! Errors caught by destest? Yes. Still? *NO*
  946. !sethi %hi(DES_SPtrans), global1 ! address sbox 1
  947. !or global1, %lo(DES_SPtrans), global1 ! sbox 1
  948. add global1, 256, global2 ! sbox 2
  949. add global1, 512, global3 ! sbox 3
  950. ld [in0], out5 ! right
  951. add global1, 768, global4 ! sbox 4
  952. add global1, 1024, global5 ! sbox 5
  953. ld [in0+4], in5 ! left
  954. add global1, 1280, local6 ! sbox 6
  955. add global1, 1792, out3 ! sbox 8
  956. ! rotate
  957. sll in5, 3, local5
  958. mov in1, in3 ! key address to in3
  959. sll out5, 3, local7
  960. srl in5, 29, in5
  961. srl out5, 29, out5
  962. add in5, local5, in5
  963. add out5, local7, out5
  964. cmp in2, 0
  965. ! we use our own stackframe
  966. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  967. be,pn %icc, .encrypt2.dec ! decryption
  968. #else
  969. be .encrypt2.dec
  970. #endif
  971. STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
  972. ld [in3], out0 ! key 7531 first round
  973. mov LOOPS, out4 ! loop counter
  974. ld [in3+4], out1 ! key 8642 first round
  975. sethi %hi(0x0000FC00), local5
  976. call .des_enc
  977. mov in3, in4
  978. ! rotate
  979. sll in5, 29, in0
  980. srl in5, 3, in5
  981. sll out5, 29, in1
  982. add in5, in0, in5
  983. srl out5, 3, out5
  984. LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
  985. add out5, in1, out5
  986. st in5, [in0]
  987. st out5, [in0+4]
  988. ret
  989. restore
  990. .encrypt2.dec:
  991. add in3, 120, in4
  992. ld [in4], out0 ! key 7531 first round
  993. mov LOOPS, out4 ! loop counter
  994. ld [in4+4], out1 ! key 8642 first round
  995. sethi %hi(0x0000FC00), local5
  996. mov in5, local1 ! left expected in out5
  997. mov out5, in5
  998. call .des_dec
  999. mov local1, out5
  1000. .encrypt2.finish:
  1001. ! rotate
  1002. sll in5, 29, in0
  1003. srl in5, 3, in5
  1004. sll out5, 29, in1
  1005. add in5, in0, in5
  1006. srl out5, 3, out5
  1007. LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
  1008. add out5, in1, out5
  1009. st out5, [in0]
  1010. st in5, [in0+4]
  1011. ret
  1012. restore
  1013. .DES_encrypt2.end:
  1014. .size DES_encrypt2, .DES_encrypt2.end-DES_encrypt2
  1015. ! void DES_encrypt3(data, ks1, ks2, ks3)
  1016. ! **************************************
  1017. .align 32
  1018. .global DES_encrypt3
  1019. .type DES_encrypt3,#function
  1020. DES_encrypt3:
  1021. save %sp, FRAME, %sp
  1022. call .PIC.me.up
  1023. mov .PIC.me.up-(.-4),out0
  1024. ld [in0], in5 ! left
  1025. add in2, 120, in4 ! ks2
  1026. ld [in0+4], out5 ! right
  1027. mov in3, in2 ! save ks3
  1028. ! parameter 6 1/2 for include encryption/decryption
  1029. ! parameter 7 1 for mov in1 to in3
  1030. ! parameter 8 1 for mov in3 to in4
  1031. ! parameter 9 1 for load ks3 and ks2 to in4 and in3
  1032. ip_macro(in5, out5, in5, out5, in3, 1, 1, 0, 0)
  1033. call .des_dec
  1034. mov in2, in3 ! preload ks3
  1035. call .des_enc
  1036. nop
  1037. fp_macro(in5, out5, 1)
  1038. ret
  1039. restore
  1040. .DES_encrypt3.end:
  1041. .size DES_encrypt3,.DES_encrypt3.end-DES_encrypt3
  1042. ! void DES_decrypt3(data, ks1, ks2, ks3)
  1043. ! **************************************
  1044. .align 32
  1045. .global DES_decrypt3
  1046. .type DES_decrypt3,#function
  1047. DES_decrypt3:
  1048. save %sp, FRAME, %sp
  1049. call .PIC.me.up
  1050. mov .PIC.me.up-(.-4),out0
  1051. ld [in0], in5 ! left
  1052. add in3, 120, in4 ! ks3
  1053. ld [in0+4], out5 ! right
  1054. mov in2, in3 ! ks2
  1055. ! parameter 6 1/2 for include encryption/decryption
  1056. ! parameter 7 1 for mov in1 to in3
  1057. ! parameter 8 1 for mov in3 to in4
  1058. ! parameter 9 1 for load ks3 and ks2 to in4 and in3
  1059. ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 0)
  1060. call .des_enc
  1061. add in1, 120, in4 ! preload ks1
  1062. call .des_dec
  1063. nop
  1064. fp_macro(out5, in5, 1)
  1065. ret
  1066. restore
  1067. .DES_decrypt3.end:
  1068. .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3
  1069. ! input: out0 offset between .PIC.me.up and caller
  1070. ! output: out0 pointer to .PIC.me.up
  1071. ! out2 pointer to .des_and
  1072. ! global1 pointer to DES_SPtrans
  1073. .align 32
  1074. .PIC.me.up:
  1075. add out0,%o7,out0 ! pointer to .PIC.me.up
  1076. sethi %hi(.des_and-.PIC.me.up),out2
  1077. or out2,%lo(.des_and-.PIC.me.up),out2
  1078. add out0,out2,out2
  1079. retl
  1080. add out2,.PIC.DES_SPtrans-.des_and,global1
  1081. ! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc)
  1082. ! *****************************************************************
  1083. .align 32
  1084. .global DES_ncbc_encrypt
  1085. .type DES_ncbc_encrypt,#function
  1086. DES_ncbc_encrypt:
  1087. save %sp, FRAME, %sp
  1088. define({INPUT}, { [%sp+BIAS+ARG0+0*ARGSZ] })
  1089. define({OUTPUT}, { [%sp+BIAS+ARG0+1*ARGSZ] })
  1090. define({IVEC}, { [%sp+BIAS+ARG0+4*ARGSZ] })
  1091. call .PIC.me.up
  1092. mov .PIC.me.up-(.-4),out0
  1093. cmp in5, 0 ! enc
  1094. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1095. be,pn %icc, .ncbc.dec
  1096. #else
  1097. be .ncbc.dec
  1098. #endif
  1099. STPTR in4, IVEC
  1100. ! addr left right temp label
  1101. load_little_endian(in4, in5, out5, local3, .LLE1) ! iv
  1102. addcc in2, -8, in2 ! bytes missing when first block done
  1103. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1104. bl,pn %icc, .ncbc.enc.seven.or.less
  1105. #else
  1106. bl .ncbc.enc.seven.or.less
  1107. #endif
  1108. mov in3, in4 ! schedule
  1109. .ncbc.enc.next.block:
  1110. load_little_endian(in0, out4, global4, local3, .LLE2) ! block
  1111. .ncbc.enc.next.block_1:
  1112. xor in5, out4, in5 ! iv xor
  1113. xor out5, global4, out5 ! iv xor
  1114. ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
  1115. ip_macro(in5, out5, in5, out5, in3, 0, 0, 2)
  1116. .ncbc.enc.next.block_2:
  1117. !// call .des_enc ! compares in2 to 8
  1118. ! rounds inlined for alignment purposes
  1119. add global1, 768, global4 ! address sbox 4 since register used below
  1120. rounds_macro(in5, out5, 1, .ncbc.enc.1, in3, in4) ! include encryption ks in3
  1121. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1122. bl,pn %icc, .ncbc.enc.next.block_fp
  1123. #else
  1124. bl .ncbc.enc.next.block_fp
  1125. #endif
  1126. add in0, 8, in0 ! input address
  1127. ! If 8 or more bytes are to be encrypted after this block,
  1128. ! we combine final permutation for this block with initial
  1129. ! permutation for next block. Load next block:
  1130. load_little_endian(in0, global3, global4, local5, .LLE12)
  1131. ! parameter 1 original left
  1132. ! parameter 2 original right
  1133. ! parameter 3 left ip
  1134. ! parameter 4 right ip
  1135. ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
  1136. ! 2: mov in4 to in3
  1137. !
  1138. ! also adds -8 to length in2 and loads loop counter to out4
  1139. fp_ip_macro(out0, out1, global3, global4, 2)
  1140. store_little_endian(in1, out0, out1, local3, .SLE10) ! block
  1141. ld [in3], out0 ! key 7531 first round next block
  1142. mov in5, local1
  1143. xor global3, out5, in5 ! iv xor next block
  1144. ld [in3+4], out1 ! key 8642
  1145. add global1, 512, global3 ! address sbox 3 since register used
  1146. xor global4, local1, out5 ! iv xor next block
  1147. ba .ncbc.enc.next.block_2
  1148. add in1, 8, in1 ! output adress
  1149. .ncbc.enc.next.block_fp:
  1150. fp_macro(in5, out5)
  1151. store_little_endian(in1, in5, out5, local3, .SLE1) ! block
  1152. addcc in2, -8, in2 ! bytes missing when next block done
  1153. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1154. bpos,pt %icc, .ncbc.enc.next.block ! also jumps if 0
  1155. #else
  1156. bpos .ncbc.enc.next.block
  1157. #endif
  1158. add in1, 8, in1
  1159. .ncbc.enc.seven.or.less:
  1160. cmp in2, -8
  1161. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1162. ble,pt %icc, .ncbc.enc.finish
  1163. #else
  1164. ble .ncbc.enc.finish
  1165. #endif
  1166. nop
  1167. add in2, 8, local1 ! bytes to load
  1168. ! addr, length, dest left, dest right, temp, temp2, label, ret label
  1169. load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB1, .ncbc.enc.next.block_1)
  1170. ! Loads 1 to 7 bytes little endian to global4, out4
  1171. .ncbc.enc.finish:
  1172. LDPTR IVEC, local4
  1173. store_little_endian(local4, in5, out5, local5, .SLE2) ! ivec
  1174. ret
  1175. restore
  1176. .ncbc.dec:
  1177. STPTR in0, INPUT
  1178. cmp in2, 0 ! length
  1179. add in3, 120, in3
  1180. LDPTR IVEC, local7 ! ivec
  1181. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1182. ble,pn %icc, .ncbc.dec.finish
  1183. #else
  1184. ble .ncbc.dec.finish
  1185. #endif
  1186. mov in3, in4 ! schedule
  1187. STPTR in1, OUTPUT
  1188. mov in0, local5 ! input
  1189. load_little_endian(local7, in0, in1, local3, .LLE3) ! ivec
  1190. .ncbc.dec.next.block:
  1191. load_little_endian(local5, in5, out5, local3, .LLE4) ! block
  1192. ! parameter 6 1/2 for include encryption/decryption
  1193. ! parameter 7 1 for mov in1 to in3
  1194. ! parameter 8 1 for mov in3 to in4
  1195. ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryprion ks in4
  1196. fp_macro(out5, in5, 0, 1) ! 1 for input and output address to local5/7
  1197. ! in2 is bytes left to be stored
  1198. ! in2 is compared to 8 in the rounds
  1199. xor out5, in0, out4 ! iv xor
  1200. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1201. bl,pn %icc, .ncbc.dec.seven.or.less
  1202. #else
  1203. bl .ncbc.dec.seven.or.less
  1204. #endif
  1205. xor in5, in1, global4 ! iv xor
  1206. ! Load ivec next block now, since input and output address might be the same.
  1207. load_little_endian_inc(local5, in0, in1, local3, .LLE5) ! iv
  1208. store_little_endian(local7, out4, global4, local3, .SLE3)
  1209. STPTR local5, INPUT
  1210. add local7, 8, local7
  1211. addcc in2, -8, in2
  1212. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1213. bg,pt %icc, .ncbc.dec.next.block
  1214. #else
  1215. bg .ncbc.dec.next.block
  1216. #endif
  1217. STPTR local7, OUTPUT
  1218. .ncbc.dec.store.iv:
  1219. LDPTR IVEC, local4 ! ivec
  1220. store_little_endian(local4, in0, in1, local5, .SLE4)
  1221. .ncbc.dec.finish:
  1222. ret
  1223. restore
  1224. .ncbc.dec.seven.or.less:
  1225. load_little_endian_inc(local5, in0, in1, local3, .LLE13) ! ivec
  1226. store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB1, .ncbc.dec.store.iv)
  1227. .DES_ncbc_encrypt.end:
  1228. .size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
  1229. ! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
  1230. ! **************************************************************************
  1231. .align 32
  1232. .global DES_ede3_cbc_encrypt
  1233. .type DES_ede3_cbc_encrypt,#function
  1234. DES_ede3_cbc_encrypt:
  1235. save %sp, FRAME, %sp
  1236. define({KS1}, { [%sp+BIAS+ARG0+3*ARGSZ] })
  1237. define({KS2}, { [%sp+BIAS+ARG0+4*ARGSZ] })
  1238. define({KS3}, { [%sp+BIAS+ARG0+5*ARGSZ] })
  1239. call .PIC.me.up
  1240. mov .PIC.me.up-(.-4),out0
  1241. LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc
  1242. LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
  1243. cmp local3, 0 ! enc
  1244. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1245. be,pn %icc, .ede3.dec
  1246. #else
  1247. be .ede3.dec
  1248. #endif
  1249. STPTR in4, KS2
  1250. STPTR in5, KS3
  1251. load_little_endian(local4, in5, out5, local3, .LLE6) ! ivec
  1252. addcc in2, -8, in2 ! bytes missing after next block
  1253. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1254. bl,pn %icc, .ede3.enc.seven.or.less
  1255. #else
  1256. bl .ede3.enc.seven.or.less
  1257. #endif
  1258. STPTR in3, KS1
  1259. .ede3.enc.next.block:
  1260. load_little_endian(in0, out4, global4, local3, .LLE7)
  1261. .ede3.enc.next.block_1:
  1262. LDPTR KS2, in4
  1263. xor in5, out4, in5 ! iv xor
  1264. xor out5, global4, out5 ! iv xor
  1265. LDPTR KS1, in3
  1266. add in4, 120, in4 ! for decryption we use last subkey first
  1267. nop
  1268. ip_macro(in5, out5, in5, out5, in3)
  1269. .ede3.enc.next.block_2:
  1270. call .des_enc ! ks1 in3
  1271. nop
  1272. call .des_dec ! ks2 in4
  1273. LDPTR KS3, in3
  1274. call .des_enc ! ks3 in3 compares in2 to 8
  1275. nop
  1276. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1277. bl,pn %icc, .ede3.enc.next.block_fp
  1278. #else
  1279. bl .ede3.enc.next.block_fp
  1280. #endif
  1281. add in0, 8, in0
  1282. ! If 8 or more bytes are to be encrypted after this block,
  1283. ! we combine final permutation for this block with initial
  1284. ! permutation for next block. Load next block:
  1285. load_little_endian(in0, global3, global4, local5, .LLE11)
  1286. ! parameter 1 original left
  1287. ! parameter 2 original right
  1288. ! parameter 3 left ip
  1289. ! parameter 4 right ip
  1290. ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
  1291. ! 2: mov in4 to in3
  1292. !
  1293. ! also adds -8 to length in2 and loads loop counter to out4
  1294. fp_ip_macro(out0, out1, global3, global4, 1)
  1295. store_little_endian(in1, out0, out1, local3, .SLE9) ! block
  1296. mov in5, local1
  1297. xor global3, out5, in5 ! iv xor next block
  1298. ld [in3], out0 ! key 7531
  1299. add global1, 512, global3 ! address sbox 3
  1300. xor global4, local1, out5 ! iv xor next block
  1301. ld [in3+4], out1 ! key 8642
  1302. add global1, 768, global4 ! address sbox 4
  1303. ba .ede3.enc.next.block_2
  1304. add in1, 8, in1
  1305. .ede3.enc.next.block_fp:
  1306. fp_macro(in5, out5)
  1307. store_little_endian(in1, in5, out5, local3, .SLE5) ! block
  1308. addcc in2, -8, in2 ! bytes missing when next block done
  1309. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1310. bpos,pt %icc, .ede3.enc.next.block
  1311. #else
  1312. bpos .ede3.enc.next.block
  1313. #endif
  1314. add in1, 8, in1
  1315. .ede3.enc.seven.or.less:
  1316. cmp in2, -8
  1317. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1318. ble,pt %icc, .ede3.enc.finish
  1319. #else
  1320. ble .ede3.enc.finish
  1321. #endif
  1322. nop
  1323. add in2, 8, local1 ! bytes to load
  1324. ! addr, length, dest left, dest right, temp, temp2, label, ret label
  1325. load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB2, .ede3.enc.next.block_1)
  1326. .ede3.enc.finish:
  1327. LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
  1328. store_little_endian(local4, in5, out5, local5, .SLE6) ! ivec
  1329. ret
  1330. restore
  1331. .ede3.dec:
  1332. STPTR in0, INPUT
  1333. add in5, 120, in5
  1334. STPTR in1, OUTPUT
  1335. mov in0, local5
  1336. add in3, 120, in3
  1337. STPTR in3, KS1
  1338. cmp in2, 0
  1339. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1340. ble %icc, .ede3.dec.finish
  1341. #else
  1342. ble .ede3.dec.finish
  1343. #endif
  1344. STPTR in5, KS3
  1345. LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local7 ! iv
  1346. load_little_endian(local7, in0, in1, local3, .LLE8)
  1347. .ede3.dec.next.block:
  1348. load_little_endian(local5, in5, out5, local3, .LLE9)
  1349. ! parameter 6 1/2 for include encryption/decryption
  1350. ! parameter 7 1 for mov in1 to in3
  1351. ! parameter 8 1 for mov in3 to in4
  1352. ! parameter 9 1 for load ks3 and ks2 to in4 and in3
  1353. ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 1) ! inc .des_dec ks3 in4
  1354. call .des_enc ! ks2 in3
  1355. LDPTR KS1, in4
  1356. call .des_dec ! ks1 in4
  1357. nop
  1358. fp_macro(out5, in5, 0, 1) ! 1 for input and output address local5/7
  1359. ! in2 is bytes left to be stored
  1360. ! in2 is compared to 8 in the rounds
  1361. xor out5, in0, out4
  1362. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1363. bl,pn %icc, .ede3.dec.seven.or.less
  1364. #else
  1365. bl .ede3.dec.seven.or.less
  1366. #endif
  1367. xor in5, in1, global4
  1368. load_little_endian_inc(local5, in0, in1, local3, .LLE10) ! iv next block
  1369. store_little_endian(local7, out4, global4, local3, .SLE7) ! block
  1370. STPTR local5, INPUT
  1371. addcc in2, -8, in2
  1372. add local7, 8, local7
  1373. #ifdef OPENSSL_SYSNAME_ULTRASPARC
  1374. bg,pt %icc, .ede3.dec.next.block
  1375. #else
  1376. bg .ede3.dec.next.block
  1377. #endif
  1378. STPTR local7, OUTPUT
  1379. .ede3.dec.store.iv:
  1380. LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
  1381. store_little_endian(local4, in0, in1, local5, .SLE8) ! ivec
  1382. .ede3.dec.finish:
  1383. ret
  1384. restore
  1385. .ede3.dec.seven.or.less:
  1386. load_little_endian_inc(local5, in0, in1, local3, .LLE14) ! iv
  1387. store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB2, .ede3.dec.store.iv)
  1388. .DES_ede3_cbc_encrypt.end:
  1389. .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt
  1390. .align 256
  1391. .type .des_and,#object
  1392. .size .des_and,284
  1393. .des_and:
  1394. ! This table is used for AND 0xFC when it is known that register
  1395. ! bits 8-31 are zero. Makes it possible to do three arithmetic
  1396. ! operations in one cycle.
  1397. .byte 0, 0, 0, 0, 4, 4, 4, 4
  1398. .byte 8, 8, 8, 8, 12, 12, 12, 12
  1399. .byte 16, 16, 16, 16, 20, 20, 20, 20
  1400. .byte 24, 24, 24, 24, 28, 28, 28, 28
  1401. .byte 32, 32, 32, 32, 36, 36, 36, 36
  1402. .byte 40, 40, 40, 40, 44, 44, 44, 44
  1403. .byte 48, 48, 48, 48, 52, 52, 52, 52
  1404. .byte 56, 56, 56, 56, 60, 60, 60, 60
  1405. .byte 64, 64, 64, 64, 68, 68, 68, 68
  1406. .byte 72, 72, 72, 72, 76, 76, 76, 76
  1407. .byte 80, 80, 80, 80, 84, 84, 84, 84
  1408. .byte 88, 88, 88, 88, 92, 92, 92, 92
  1409. .byte 96, 96, 96, 96, 100, 100, 100, 100
  1410. .byte 104, 104, 104, 104, 108, 108, 108, 108
  1411. .byte 112, 112, 112, 112, 116, 116, 116, 116
  1412. .byte 120, 120, 120, 120, 124, 124, 124, 124
  1413. .byte 128, 128, 128, 128, 132, 132, 132, 132
  1414. .byte 136, 136, 136, 136, 140, 140, 140, 140
  1415. .byte 144, 144, 144, 144, 148, 148, 148, 148
  1416. .byte 152, 152, 152, 152, 156, 156, 156, 156
  1417. .byte 160, 160, 160, 160, 164, 164, 164, 164
  1418. .byte 168, 168, 168, 168, 172, 172, 172, 172
  1419. .byte 176, 176, 176, 176, 180, 180, 180, 180
  1420. .byte 184, 184, 184, 184, 188, 188, 188, 188
  1421. .byte 192, 192, 192, 192, 196, 196, 196, 196
  1422. .byte 200, 200, 200, 200, 204, 204, 204, 204
  1423. .byte 208, 208, 208, 208, 212, 212, 212, 212
  1424. .byte 216, 216, 216, 216, 220, 220, 220, 220
  1425. .byte 224, 224, 224, 224, 228, 228, 228, 228
  1426. .byte 232, 232, 232, 232, 236, 236, 236, 236
  1427. .byte 240, 240, 240, 240, 244, 244, 244, 244
  1428. .byte 248, 248, 248, 248, 252, 252, 252, 252
  1429. ! 5 numbers for initil/final permutation
  1430. .word 0x0f0f0f0f ! offset 256
  1431. .word 0x0000ffff ! 260
  1432. .word 0x33333333 ! 264
  1433. .word 0x00ff00ff ! 268
  1434. .word 0x55555555 ! 272
  1435. .word 0 ! 276
  1436. .word LOOPS ! 280
  1437. .word 0x0000FC00 ! 284
  1438. .global DES_SPtrans
  1439. .type DES_SPtrans,#object
  1440. .size DES_SPtrans,2048
  1441. .align 64
  1442. DES_SPtrans:
  1443. .PIC.DES_SPtrans:
  1444. ! nibble 0
  1445. .word 0x02080800, 0x00080000, 0x02000002, 0x02080802
  1446. .word 0x02000000, 0x00080802, 0x00080002, 0x02000002
  1447. .word 0x00080802, 0x02080800, 0x02080000, 0x00000802
  1448. .word 0x02000802, 0x02000000, 0x00000000, 0x00080002
  1449. .word 0x00080000, 0x00000002, 0x02000800, 0x00080800
  1450. .word 0x02080802, 0x02080000, 0x00000802, 0x02000800
  1451. .word 0x00000002, 0x00000800, 0x00080800, 0x02080002
  1452. .word 0x00000800, 0x02000802, 0x02080002, 0x00000000
  1453. .word 0x00000000, 0x02080802, 0x02000800, 0x00080002
  1454. .word 0x02080800, 0x00080000, 0x00000802, 0x02000800
  1455. .word 0x02080002, 0x00000800, 0x00080800, 0x02000002
  1456. .word 0x00080802, 0x00000002, 0x02000002, 0x02080000
  1457. .word 0x02080802, 0x00080800, 0x02080000, 0x02000802
  1458. .word 0x02000000, 0x00000802, 0x00080002, 0x00000000
  1459. .word 0x00080000, 0x02000000, 0x02000802, 0x02080800
  1460. .word 0x00000002, 0x02080002, 0x00000800, 0x00080802
  1461. ! nibble 1
  1462. .word 0x40108010, 0x00000000, 0x00108000, 0x40100000
  1463. .word 0x40000010, 0x00008010, 0x40008000, 0x00108000
  1464. .word 0x00008000, 0x40100010, 0x00000010, 0x40008000
  1465. .word 0x00100010, 0x40108000, 0x40100000, 0x00000010
  1466. .word 0x00100000, 0x40008010, 0x40100010, 0x00008000
  1467. .word 0x00108010, 0x40000000, 0x00000000, 0x00100010
  1468. .word 0x40008010, 0x00108010, 0x40108000, 0x40000010
  1469. .word 0x40000000, 0x00100000, 0x00008010, 0x40108010
  1470. .word 0x00100010, 0x40108000, 0x40008000, 0x00108010
  1471. .word 0x40108010, 0x00100010, 0x40000010, 0x00000000
  1472. .word 0x40000000, 0x00008010, 0x00100000, 0x40100010
  1473. .word 0x00008000, 0x40000000, 0x00108010, 0x40008010
  1474. .word 0x40108000, 0x00008000, 0x00000000, 0x40000010
  1475. .word 0x00000010, 0x40108010, 0x00108000, 0x40100000
  1476. .word 0x40100010, 0x00100000, 0x00008010, 0x40008000
  1477. .word 0x40008010, 0x00000010, 0x40100000, 0x00108000
  1478. ! nibble 2
  1479. .word 0x04000001, 0x04040100, 0x00000100, 0x04000101
  1480. .word 0x00040001, 0x04000000, 0x04000101, 0x00040100
  1481. .word 0x04000100, 0x00040000, 0x04040000, 0x00000001
  1482. .word 0x04040101, 0x00000101, 0x00000001, 0x04040001
  1483. .word 0x00000000, 0x00040001, 0x04040100, 0x00000100
  1484. .word 0x00000101, 0x04040101, 0x00040000, 0x04000001
  1485. .word 0x04040001, 0x04000100, 0x00040101, 0x04040000
  1486. .word 0x00040100, 0x00000000, 0x04000000, 0x00040101
  1487. .word 0x04040100, 0x00000100, 0x00000001, 0x00040000
  1488. .word 0x00000101, 0x00040001, 0x04040000, 0x04000101
  1489. .word 0x00000000, 0x04040100, 0x00040100, 0x04040001
  1490. .word 0x00040001, 0x04000000, 0x04040101, 0x00000001
  1491. .word 0x00040101, 0x04000001, 0x04000000, 0x04040101
  1492. .word 0x00040000, 0x04000100, 0x04000101, 0x00040100
  1493. .word 0x04000100, 0x00000000, 0x04040001, 0x00000101
  1494. .word 0x04000001, 0x00040101, 0x00000100, 0x04040000
  1495. ! nibble 3
  1496. .word 0x00401008, 0x10001000, 0x00000008, 0x10401008
  1497. .word 0x00000000, 0x10400000, 0x10001008, 0x00400008
  1498. .word 0x10401000, 0x10000008, 0x10000000, 0x00001008
  1499. .word 0x10000008, 0x00401008, 0x00400000, 0x10000000
  1500. .word 0x10400008, 0x00401000, 0x00001000, 0x00000008
  1501. .word 0x00401000, 0x10001008, 0x10400000, 0x00001000
  1502. .word 0x00001008, 0x00000000, 0x00400008, 0x10401000
  1503. .word 0x10001000, 0x10400008, 0x10401008, 0x00400000
  1504. .word 0x10400008, 0x00001008, 0x00400000, 0x10000008
  1505. .word 0x00401000, 0x10001000, 0x00000008, 0x10400000
  1506. .word 0x10001008, 0x00000000, 0x00001000, 0x00400008
  1507. .word 0x00000000, 0x10400008, 0x10401000, 0x00001000
  1508. .word 0x10000000, 0x10401008, 0x00401008, 0x00400000
  1509. .word 0x10401008, 0x00000008, 0x10001000, 0x00401008
  1510. .word 0x00400008, 0x00401000, 0x10400000, 0x10001008
  1511. .word 0x00001008, 0x10000000, 0x10000008, 0x10401000
  1512. ! nibble 4
  1513. .word 0x08000000, 0x00010000, 0x00000400, 0x08010420
  1514. .word 0x08010020, 0x08000400, 0x00010420, 0x08010000
  1515. .word 0x00010000, 0x00000020, 0x08000020, 0x00010400
  1516. .word 0x08000420, 0x08010020, 0x08010400, 0x00000000
  1517. .word 0x00010400, 0x08000000, 0x00010020, 0x00000420
  1518. .word 0x08000400, 0x00010420, 0x00000000, 0x08000020
  1519. .word 0x00000020, 0x08000420, 0x08010420, 0x00010020
  1520. .word 0x08010000, 0x00000400, 0x00000420, 0x08010400
  1521. .word 0x08010400, 0x08000420, 0x00010020, 0x08010000
  1522. .word 0x00010000, 0x00000020, 0x08000020, 0x08000400
  1523. .word 0x08000000, 0x00010400, 0x08010420, 0x00000000
  1524. .word 0x00010420, 0x08000000, 0x00000400, 0x00010020
  1525. .word 0x08000420, 0x00000400, 0x00000000, 0x08010420
  1526. .word 0x08010020, 0x08010400, 0x00000420, 0x00010000
  1527. .word 0x00010400, 0x08010020, 0x08000400, 0x00000420
  1528. .word 0x00000020, 0x00010420, 0x08010000, 0x08000020
  1529. ! nibble 5
  1530. .word 0x80000040, 0x00200040, 0x00000000, 0x80202000
  1531. .word 0x00200040, 0x00002000, 0x80002040, 0x00200000
  1532. .word 0x00002040, 0x80202040, 0x00202000, 0x80000000
  1533. .word 0x80002000, 0x80000040, 0x80200000, 0x00202040
  1534. .word 0x00200000, 0x80002040, 0x80200040, 0x00000000
  1535. .word 0x00002000, 0x00000040, 0x80202000, 0x80200040
  1536. .word 0x80202040, 0x80200000, 0x80000000, 0x00002040
  1537. .word 0x00000040, 0x00202000, 0x00202040, 0x80002000
  1538. .word 0x00002040, 0x80000000, 0x80002000, 0x00202040
  1539. .word 0x80202000, 0x00200040, 0x00000000, 0x80002000
  1540. .word 0x80000000, 0x00002000, 0x80200040, 0x00200000
  1541. .word 0x00200040, 0x80202040, 0x00202000, 0x00000040
  1542. .word 0x80202040, 0x00202000, 0x00200000, 0x80002040
  1543. .word 0x80000040, 0x80200000, 0x00202040, 0x00000000
  1544. .word 0x00002000, 0x80000040, 0x80002040, 0x80202000
  1545. .word 0x80200000, 0x00002040, 0x00000040, 0x80200040
  1546. ! nibble 6
  1547. .word 0x00004000, 0x00000200, 0x01000200, 0x01000004
  1548. .word 0x01004204, 0x00004004, 0x00004200, 0x00000000
  1549. .word 0x01000000, 0x01000204, 0x00000204, 0x01004000
  1550. .word 0x00000004, 0x01004200, 0x01004000, 0x00000204
  1551. .word 0x01000204, 0x00004000, 0x00004004, 0x01004204
  1552. .word 0x00000000, 0x01000200, 0x01000004, 0x00004200
  1553. .word 0x01004004, 0x00004204, 0x01004200, 0x00000004
  1554. .word 0x00004204, 0x01004004, 0x00000200, 0x01000000
  1555. .word 0x00004204, 0x01004000, 0x01004004, 0x00000204
  1556. .word 0x00004000, 0x00000200, 0x01000000, 0x01004004
  1557. .word 0x01000204, 0x00004204, 0x00004200, 0x00000000
  1558. .word 0x00000200, 0x01000004, 0x00000004, 0x01000200
  1559. .word 0x00000000, 0x01000204, 0x01000200, 0x00004200
  1560. .word 0x00000204, 0x00004000, 0x01004204, 0x01000000
  1561. .word 0x01004200, 0x00000004, 0x00004004, 0x01004204
  1562. .word 0x01000004, 0x01004200, 0x01004000, 0x00004004
  1563. ! nibble 7
  1564. .word 0x20800080, 0x20820000, 0x00020080, 0x00000000
  1565. .word 0x20020000, 0x00800080, 0x20800000, 0x20820080
  1566. .word 0x00000080, 0x20000000, 0x00820000, 0x00020080
  1567. .word 0x00820080, 0x20020080, 0x20000080, 0x20800000
  1568. .word 0x00020000, 0x00820080, 0x00800080, 0x20020000
  1569. .word 0x20820080, 0x20000080, 0x00000000, 0x00820000
  1570. .word 0x20000000, 0x00800000, 0x20020080, 0x20800080
  1571. .word 0x00800000, 0x00020000, 0x20820000, 0x00000080
  1572. .word 0x00800000, 0x00020000, 0x20000080, 0x20820080
  1573. .word 0x00020080, 0x20000000, 0x00000000, 0x00820000
  1574. .word 0x20800080, 0x20020080, 0x20020000, 0x00800080
  1575. .word 0x20820000, 0x00000080, 0x00800080, 0x20020000
  1576. .word 0x20820080, 0x00800000, 0x20800000, 0x20000080
  1577. .word 0x00820000, 0x00020080, 0x20020080, 0x20800000
  1578. .word 0x00000080, 0x20820000, 0x00820080, 0x00000000
  1579. .word 0x20000000, 0x20800080, 0x00020000, 0x00820080