1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26#if defined(lint) || defined(__lint) 27 28#include "arcfour.h" 29 30/* ARGSUSED */ 31void 32arcfour_crypt_aligned(ARCFour_key *key, size_t len, uchar_t *in, uchar_t *out) 33{} 34 35#else /* lint || __lint */ 36 37 .register %g2,#scratch 38 .register %g3,#scratch 39 40 .section ".text",#alloc,#execinstr 41 .file "arcfour_crypt_asm.s" 42 43 .section ".text",#alloc 44 .align 32 45 46 .section ".text",#alloc,#execinstr 47 .align 32 48 .skip 32 49 50/* 51 * SUBROUTINE arcfour_crypt_aligned 52 * 53 * void arcfour_crypt_aligned(ARCFour_key *key, size_t len, 54 * uchar_t *in, uchar_t *out); 55 * 56 * in and out should be aligned on an 8-byte boundary, but len can be anything 57 */ 58 .global arcfour_crypt_aligned 59 60 61arcfour_crypt_aligned: 62 63/* EXPORT DELETE START */ 64 save %sp,-144,%sp 65 66 srl %i1, 3, %l7 67 ldub [%i0+256], %g1 68 69 orcc %l7, %g0, %g0 70 ldub [%i0+257], %g2 71 72 add %g1, 1, %o1 73 bz %icc, .Loop2 74 add %i0, 0, %i5 75 76 add %o1, 1, %g1 77 and %o1, 255, %o1 78 79 and %g1, 255, %g1 80 ldub [%i5 + %o1], %o3 81 82 ldub [%i5 + %g1], %g3 83 84 add %g2, %o3, %o2 85 86 add %o2, %g3, %g2 87 and %o2, 255, %o2 88 89 and %g2, 255, %g2 90 ldub [%i5 + %o2], %o4 91 92 stb %o3, [%i5+%o2] 93 subcc %o2, %g1, %g0 94 95 stb %o4, [%i5 + %o1] 96 bz %icc, .L1A 97 add %o3,%o4,%o5 98.L1B: 99 and %o5, 255, %o5 100 ldub [%i5 + %g2], %g4 101 102 ldub [%i5 + %o5], %o5 103 add %g1, 1, %o1 104 105 and %o1, 255, %o1 106 stb %g3, [%i5 + %g2] 107 add %g3, %g4, %g5 108 109 and %g5, 255, %g5 110 stb %g4, [%i5 + %g1] 111 add %o1, 1, %g1 112 113 114 sllx %o5, 56, %o0 115 ldub [%i5 + %o1], %o3 116 and %g1, 255, %g1 117 118 ldub [%i5 + %g1], %g3 119 120 add %g2, %o3, %o2 121 ldub [%i5 + %g5], %g5 122 123 add %o2, %g3, %g2 124 and %o2, 255, %o2 125 126 sllx %g5, 48, %g5 127 ldub [%i5 + %o2], %o4 128 and %g2, 255, %g2 129 130 or %o0, %g5, %o0 131 stb %o3, [%i5+%o2] 132 subcc %o2, %g1, %g0 133 134 stb %o4, [%i5 + %o1] 135 bz %icc, .L2A 136 add %o3,%o4,%o5 137.L2B: 138 and %o5, 255, %o5 139 ldub [%i5 + %g2], %g4 140 141 ldub [%i5 + %o5], %o5 142 add %g1, 1, %o1 143 144 and %o1, 255, %o1 145 stb %g3, [%i5 + %g2] 146 add %g3, %g4, %g5 147 148 and %g5, 255, %g5 149 stb %g4, [%i5 + %g1] 150 add %o1, 1, %g1 151 152 153 sllx %o5, 40, %o5 154 ldub [%i5 + %o1], %o3 155 and %g1, 255, %g1 156 157 ldub [%i5 + %g1], %g3 158 or %o0, %o5, %o0 159 160 add %g2, %o3, %o2 161 ldub [%i5 + %g5], %g5 162 163 add %o2, %g3, %g2 164 and %o2, 255, %o2 165 166 sllx %g5, 32, %g5 167 ldub [%i5 + %o2], %o4 168 and %g2, 255, %g2 169 170 or %o0, %g5, %o0 171 stb %o3, [%i5+%o2] 172 subcc %o2, %g1, %g0 173 174 stb %o4, [%i5 + %o1] 175 bz %icc, .L3A 176 add %o3,%o4,%o5 177.L3B: 178 and %o5, 255, %o5 179 ldub [%i5 + %g2], %g4 180 181 ldub [%i5 + %o5], %o5 182 add %g1, 1, %o1 183 184 and %o1, 255, %o1 185 stb %g3, [%i5 + %g2] 186 add %g3, %g4, %g5 187 188 and %g5, 255, %g5 189 stb %g4, [%i5 + %g1] 190 add %o1, 1, %g1 191 192 193 sll %o5, 24, %o5 194 ldub [%i5 + %o1], %o3 195 and %g1, 255, %g1 196 197 sub %i1, 8, %i1 198 ldub [%i5 + %g1], %g3 199 or %o0, %o5, %o0 200 201 srl %i1, 3, %l7 202 ldub [%i5 + %g5], %g5 203 add %g2, %o3, %o2 204 205 add %o2, %g3, %g2 206 and %o2, 255, %o2 207 208 sll %g5, 16, %g5 209 ldub [%i5 + %o2], %o4 210 and %g2, 255, %g2 211 212 or %o0, %g5, %o0 213 stb %o3, [%i5+%o2] 214 subcc %o2, %g1, %g0 215 216 stb %o4, [%i5 + %o1] 217 bz %icc, .L4A 218 add %o3,%o4,%o5 219.L4B: 220 and %o5, 255, %o5 221 ldub [%i5 + %g2], %g4 222 add %g1, 1, %o1 223 224 orcc %l7, %g0, %g0 225 ldub [%i5 + %o5], %o5 226 and %o1, 255, %o1 227 228 add %g3, %g4, %g5 229 stb %g4, [%i5 + %g1] 230 add %o1, 1, %g1 231 232 stb %g3, [%i5 + %g2] 233 bz %icc, .EndLoop1 234 and %g5, 255, %g5 235 236 237.Loop1: 238 sll %o5, 8, %o5 239 ldub [%i5 + %o1], %o3 240 and %g1, 255, %g1 241 242 ldub [%i5 + %g1], %g3 243 or %o0, %o5, %o0 244 245 ldub [%i5 + %g5], %g5 246 add %g2, %o3, %o2 247 248 add %o2, %g3, %g2 249 ldx [%i2], %o7 250 and %o2, 255, %o2 251 252 and %g2, 255, %g2 253 ldub [%i5 + %o2], %o4 254 255 or %o0, %g5, %o0 256 stb %o3, [%i5+%o2] 257 subcc %o2, %g1, %g0 258 259 stb %o4, [%i5 + %o1] 260 bz %icc, .L5A 261 add %o3,%o4,%o5 262.L5B: 263 and %o5, 255, %o5 264 ldub [%i5 + %g2], %g4 265 266 ldub [%i5 + %o5], %o5 267 add %g1, 1, %o1 268 269 and %o1, 255, %o1 270 stb %g3, [%i5 + %g2] 271 add %g3, %g4, %g5 272 273 and %g5, 255, %g5 274 stb %g4, [%i5 + %g1] 275 add %o1, 1, %g1 276 277 278 xor %o0, %o7, %o7 279 ldub [%i5 + %o1], %o3 280 and %g1, 255, %g1 281 282 sllx %o5, 56, %o0 283 ldub [%i5 + %g1], %g3 284 285 add %g2, %o3, %o2 286 ldub [%i5 + %g5], %g5 287 288 add %o2, %g3, %g2 289 stx %o7, [%i3] 290 and %o2, 255, %o2 291 292 sllx %g5, 48, %g5 293 ldub [%i5 + %o2], %o4 294 and %g2, 255, %g2 295 296 or %o0, %g5, %o0 297 stb %o3, [%i5+%o2] 298 subcc %o2, %g1, %g0 299 300 stb %o4, [%i5 + %o1] 301 bz %icc, .L6A 302 add %o3,%o4,%o5 303.L6B: 304 and %o5, 255, %o5 305 ldub [%i5 + %g2], %g4 306 add %i3, 8, %i3 307 308 add %i2, 8, %i2 309 ldub [%i5 + %o5], %o5 310 add %g1, 1, %o1 311 312 and %o1, 255, %o1 313 stb %g3, [%i5 + %g2] 314 add %g3, %g4, %g5 315 316 and %g5, 255, %g5 317 stb %g4, [%i5 + %g1] 318 add %o1, 1, %g1 319 320 321 sllx %o5, 40, %o5 322 ldub [%i5 + %o1], %o3 323 and %g1, 255, %g1 324 325 ldub [%i5 + %g1], %g3 326 or %o0, %o5, %o0 327 328 add %g2, %o3, %o2 329 ldub [%i5 + %g5], %g5 330 331 add %o2, %g3, %g2 332 and %o2, 255, %o2 333 334 sllx %g5, 32, %g5 335 ldub [%i5 + %o2], %o4 336 and %g2, 255, %g2 337 338 or %o0, %g5, %o0 339 stb %o3, [%i5 + %o2] 340 subcc %o2, %g1, %g0 341 342 stb %o4, [%i5 + %o1] 343 bz %icc, .L7A 344 add %o3,%o4,%o5 345.L7B: 346 and %o5, 255, %o5 347 ldub [%i5 + %g2], %g4 348 349 ldub [%i5 + %o5], %o5 350 add %g1, 1, %o1 351 352 and %o1, 255, %o1 353 stb %g3, [%i5 + %g2] 354 add %g3, %g4, %g5 355 356 and %g5, 255, %g5 357 stb %g4, [%i5 + %g1] 358 add %o1, 1, %g1 359 360 361 sll %o5, 24, %o5 362 ldub [%i5 + %o1], %o3 363 and %g1, 255, %g1 364 365 sub %i1, 8, %i1 366 ldub [%i5 + %g1], %g3 367 or %o0, %o5, %o0 368 369 srl %i1, 3, %l7 370 ldub [%i5 + %g5], %g5 371 add %g2, %o3, %o2 372 373 add %o2, %g3, %g2 374 and %o2, 255, %o2 375 376 sll %g5, 16, %g5 377 ldub [%i5 + %o2], %o4 378 and %g2, 255, %g2 379 380 or %o0, %g5, %o0 381 stb %o3, [%i5 + %o2] 382 subcc %o2, %g1, %g0 383 384 stb %o4, [%i5 + %o1] 385 bz %icc, .L8A 386 add %o3,%o4,%o5 387.L8B: 388 and %o5, 255, %o5 389 ldub [%i5 + %g2], %g4 390 add %g1, 1, %o1 391 392 orcc %l7, %g0, %g0 393 ldub [%i5 + %o5], %o5 394 and %o1, 255, %o1 395 396 add %g3, %g4, %g5 397 stb %g4, [%i5 + %g1] 398 add %o1, 1, %g1 399 400 stb %g3, [%i5 + %g2] 401 bnz %icc, .Loop1 402 and %g5, 255, %g5 403 404 405.EndLoop1: 406 sll %o5, 8, %o5 407 ldub [%i5 + %g5], %g5 408 orcc %i1, %g0, %g0 409 410 or %o0, %o5, %o0 411 ldx [%i2], %o7 412 sub %g1, 2, %g1 413 414 and %g1, 255, %g1 415 stb %g1, [%i0 + 256] 416 or %o0, %g5, %o0 417 418 xor %o0, %o7, %o7 419 stx %o7, [%i3] 420 add %i2, 8, %i2 421 422 add %i3, 8, %i3 423 bnz %icc, .Loop2_1 424 stb %g2, [%i0 + 257] 425 426 ret 427 restore %g0,%g0,%g0 428 429 430.Loop2: 431 orcc %i1, %g0, %g0 432 bnz .Loop2_1 433 nop 434 ret 435 restore %g0,%g0,%g0 436 437.Loop2_1: 438 and %o1, 255, %g1 439 ldub [%i5 + %g1], %g3 440 441 add %g2, %g3, %g2 442 443 and %g2, 255, %g2 444 445 ldub [%i5 + %g2], %g4 446 447 stb %g3, [%i5 + %g2] 448 449 add %g3, %g4, %g5 450 stb %g4, [%i5 + %g1] 451 452 and %g5, 255, %g5 453 ldub [%i2], %o0 454 455 add %g1, 1, %o1 456 ldub [%i5 + %g5], %g5 457 subcc %i1, 1, %i1 458 459 add %i2, 1, %i2 460 add %i3, 1, %i3 461 462 xor %o0, %g5, %o0 463 bnz %icc, .Loop2_1 464 stb %o0, [%i3 - 1] 465 466 stb %g1, [%i0 + 256] 467 468 stb %g2, [%i0 + 257] 469 470 ret 471 restore %g0,%g0,%g0 472 473.L1A: 474 add %o2, %o3, %g2 475 or %o3, %g0, %g3 476 ba .L1B 477 and %g2, 255, %g2 478 479.L2A: 480 add %o2, %o3, %g2 481 or %o3, %g0, %g3 482 ba .L2B 483 and %g2, 255, %g2 484 485.L3A: 486 add %o2, %o3, %g2 487 or %o3, %g0, %g3 488 ba .L3B 489 and %g2, 255, %g2 490 491.L4A: 492 add %o2, %o3, %g2 493 or %o3, %g0, %g3 494 ba .L4B 495 and %g2, 255, %g2 496 497.L5A: 498 add %o2, %o3, %g2 499 or %o3, %g0, %g3 500 ba .L5B 501 and %g2, 255, %g2 502 503.L6A: 504 add %o2, %o3, %g2 505 or %o3, %g0, %g3 506 ba .L6B 507 and %g2, 255, %g2 508 509.L7A: 510 add %o2, %o3, %g2 511 or %o3, %g0, %g3 512 ba .L7B 513 and %g2, 255, %g2 514 515.L8A: 516 add %o2, %o3, %g2 517 or %o3, %g0, %g3 518 ba .L8B 519 and %g2, 255, %g2 520 521/* EXPORT DELETE END */ 522 .type arcfour_crypt_aligned,2 523 .size arcfour_crypt_aligned,(. - arcfour_crypt_aligned) 524 525#endif /* lint || __lint */ 526