1 11 package org.eclipse.team.internal.ccvs.ssh; 12 13 public class Blowfish extends Cipher { 14 private int[] P = new int[18]; 15 private int[][] S = new int[4][256]; 16 17 private int lastEncipherXL = 0; 18 private int lastEncipherXR = 0; 19 private int lastDecipherXL = 0; 20 private int lastDecipherXR = 0; 21 22 private final static int[] INIT_DATA = 23 { 24 0x243f6a88, 25 0x85a308d3, 26 0x13198a2e, 27 0x03707344, 28 0xa4093822, 29 0x299f31d0, 30 0x082efa98, 31 0xec4e6c89, 32 0x452821e6, 33 0x38d01377, 34 0xbe5466cf, 35 0x34e90c6c, 36 0xc0ac29b7, 37 0xc97c50dd, 38 0x3f84d5b5, 39 0xb5470917, 40 0x9216d5d9, 41 0x8979fb1b, 42 0xd1310ba6, 43 0x98dfb5ac, 44 0x2ffd72db, 45 0xd01adfb7, 46 0xb8e1afed, 47 0x6a267e96, 48 0xba7c9045, 49 0xf12c7f99, 50 0x24a19947, 51 0xb3916cf7, 52 0x0801f2e2, 53 0x858efc16, 54 0x636920d8, 55 0x71574e69, 56 0xa458fea3, 57 0xf4933d7e, 58 0x0d95748f, 59 0x728eb658, 60 0x718bcd58, 61 0x82154aee, 62 0x7b54a41d, 63 0xc25a59b5, 64 0x9c30d539, 65 0x2af26013, 66 0xc5d1b023, 67 0x286085f0, 68 0xca417918, 69 0xb8db38ef, 70 0x8e79dcb0, 71 0x603a180e, 72 0x6c9e0e8b, 73 0xb01e8a3e, 74 0xd71577c1, 75 0xbd314b27, 76 0x78af2fda, 77 0x55605c60, 78 0xe65525f3, 79 0xaa55ab94, 80 0x57489862, 81 0x63e81440, 82 0x55ca396a, 83 0x2aab10b6, 84 0xb4cc5c34, 85 0x1141e8ce, 86 0xa15486af, 87 0x7c72e993, 88 0xb3ee1411, 89 0x636fbc2a, 90 0x2ba9c55d, 91 0x741831f6, 92 0xce5c3e16, 93 0x9b87931e, 94 0xafd6ba33, 95 0x6c24cf5c, 96 0x7a325381, 97 0x28958677, 98 0x3b8f4898, 99 0x6b4bb9af, 100 0xc4bfe81b, 101 0x66282193, 102 0x61d809cc, 103 0xfb21a991, 104 0x487cac60, 105 0x5dec8032, 106 0xef845d5d, 107 0xe98575b1, 108 0xdc262302, 109 0xeb651b88, 110 0x23893e81, 111 0xd396acc5, 112 0x0f6d6ff3, 113 0x83f44239, 114 0x2e0b4482, 115 0xa4842004, 116 0x69c8f04a, 117 0x9e1f9b5e, 118 0x21c66842, 119 0xf6e96c9a, 120 0x670c9c61, 121 0xabd388f0, 122 0x6a51a0d2, 123 0xd8542f68, 124 0x960fa728, 125 0xab5133a3, 126 0x6eef0b6c, 127 0x137a3be4, 128 0xba3bf050, 129 0x7efb2a98, 130 0xa1f1651d, 131 0x39af0176, 132 0x66ca593e, 133 0x82430e88, 134 0x8cee8619, 135 0x456f9fb4, 136 0x7d84a5c3, 137 0x3b8b5ebe, 138 0xe06f75d8, 139 0x85c12073, 140 0x401a449f, 141 0x56c16aa6, 142 0x4ed3aa62, 143 0x363f7706, 144 0x1bfedf72, 145 0x429b023d, 146 0x37d0d724, 147 0xd00a1248, 148 0xdb0fead3, 149 0x49f1c09b, 150 0x075372c9, 151 0x80991b7b, 152 0x25d479d8, 153 0xf6e8def7, 154 0xe3fe501a, 155 0xb6794c3b, 156 0x976ce0bd, 157 0x04c006ba, 158 0xc1a94fb6, 159 0x409f60c4, 160 0x5e5c9ec2, 161 0x196a2463, 162 0x68fb6faf, 163 0x3e6c53b5, 164 0x1339b2eb, 165 0x3b52ec6f, 166 0x6dfc511f, 167 0x9b30952c, 168 0xcc814544, 169 0xaf5ebd09, 170 0xbee3d004, 171 0xde334afd, 172 0x660f2807, 173 0x192e4bb3, 174 0xc0cba857, 175 0x45c8740f, 176 0xd20b5f39, 177 0xb9d3fbdb, 178 0x5579c0bd, 179 0x1a60320a, 180 0xd6a100c6, 181 0x402c7279, 182 0x679f25fe, 183 0xfb1fa3cc, 184 0x8ea5e9f8, 185 0xdb3222f8, 186 0x3c7516df, 187 0xfd616b15, 188 0x2f501ec8, 189 0xad0552ab, 190 0x323db5fa, 191 0xfd238760, 192 0x53317b48, 193 0x3e00df82, 194 0x9e5c57bb, 195 0xca6f8ca0, 196 0x1a87562e, 197 0xdf1769db, 198 0xd542a8f6, 199 0x287effc3, 200 0xac6732c6, 201 0x8c4f5573, 202 0x695b27b0, 203 0xbbca58c8, 204 0xe1ffa35d, 205 0xb8f011a0, 206 0x10fa3d98, 207 0xfd2183b8, 208 0x4afcb56c, 209 0x2dd1d35b, 210 0x9a53e479, 211 0xb6f84565, 212 0xd28e49bc, 213 0x4bfb9790, 214 0xe1ddf2da, 215 0xa4cb7e33, 216 0x62fb1341, 217 0xcee4c6e8, 218 0xef20cada, 219 0x36774c01, 220 0xd07e9efe, 221 0x2bf11fb4, 222 0x95dbda4d, 223 0xae909198, 224 0xeaad8e71, 225 0x6b93d5a0, 226 0xd08ed1d0, 227 0xafc725e0, 228 0x8e3c5b2f, 229 0x8e7594b7, 230 0x8ff6e2fb, 231 0xf2122b64, 232 0x8888b812, 233 0x900df01c, 234 0x4fad5ea0, 235 0x688fc31c, 236 0xd1cff191, 237 0xb3a8c1ad, 238 0x2f2f2218, 239 0xbe0e1777, 240 0xea752dfe, 241 0x8b021fa1, 242 0xe5a0cc0f, 243 0xb56f74e8, 244 0x18acf3d6, 245 0xce89e299, 246 0xb4a84fe0, 247 0xfd13e0b7, 248 0x7cc43b81, 249 0xd2ada8d9, 250 0x165fa266, 251 0x80957705, 252 0x93cc7314, 253 0x211a1477, 254 0xe6ad2065, 255 0x77b5fa86, 256 0xc75442f5, 257 0xfb9d35cf, 258 0xebcdaf0c, 259 0x7b3e89a0, 260 0xd6411bd3, 261 0xae1e7e49, 262 0x00250e2d, 263 0x2071b35e, 264 0x226800bb, 265 0x57b8e0af, 266 0x2464369b, 267 0xf009b91e, 268 0x5563911d, 269 0x59dfa6aa, 270 0x78c14389, 271 0xd95a537f, 272 0x207d5ba2, 273 0x02e5b9c5, 274 0x83260376, 275 0x6295cfa9, 276 0x11c81968, 277 0x4e734a41, 278 0xb3472dca, 279 0x7b14a94a, 280 0x1b510052, 281 0x9a532915, 282 0xd60f573f, 283 0xbc9bc6e4, 284 0x2b60a476, 285 0x81e67400, 286 0x08ba6fb5, 287 0x571be91f, 288 0xf296ec6b, 289 0x2a0dd915, 290 0xb6636521, 291 0xe7b9f9b6, 292 0xff34052e, 293 0xc5855664, 294 0x53b02d5d, 295 0xa99f8fa1, 296 0x08ba4799, 297 0x6e85076a, 298 0x4b7a70e9, 299 0xb5b32944, 300 0xdb75092e, 301 0xc4192623, 302 0xad6ea6b0, 303 0x49a7df7d, 304 0x9cee60b8, 305 0x8fedb266, 306 0xecaa8c71, 307 0x699a17ff, 308 0x5664526c, 309 0xc2b19ee1, 310 0x193602a5, 311 0x75094c29, 312 0xa0591340, 313 0xe4183a3e, 314 0x3f54989a, 315 0x5b429d65, 316 0x6b8fe4d6, 317 0x99f73fd6, 318 0xa1d29c07, 319 0xefe830f5, 320 0x4d2d38e6, 321 0xf0255dc1, 322 0x4cdd2086, 323 0x8470eb26, 324 0x6382e9c6, 325 0x021ecc5e, 326 0x09686b3f, 327 0x3ebaefc9, 328 0x3c971814, 329 0x6b6a70a1, 330 0x687f3584, 331 0x52a0e286, 332 0xb79c5305, 333 0xaa500737, 334 0x3e07841c, 335 0x7fdeae5c, 336 0x8e7d44ec, 337 0x5716f2b8, 338 0xb03ada37, 339 0xf0500c0d, 340 0xf01c1f04, 341 0x0200b3ff, 342 0xae0cf51a, 343 0x3cb574b2, 344 0x25837a58, 345 0xdc0921bd, 346 0xd19113f9, 347 0x7ca92ff6, 348 0x94324773, 349 0x22f54701, 350 0x3ae5e581, 351 0x37c2dadc, 352 0xc8b57634, 353 0x9af3dda7, 354 0xa9446146, 355 0x0fd0030e, 356 0xecc8c73e, 357 0xa4751e41, 358 0xe238cd99, 359 0x3bea0e2f, 360 0x3280bba1, 361 0x183eb331, 362 0x4e548b38, 363 0x4f6db908, 364 0x6f420d03, 365 0xf60a04bf, 366 0x2cb81290, 367 0x24977c79, 368 0x5679b072, 369 0xbcaf89af, 370 0xde9a771f, 371 0xd9930810, 372 0xb38bae12, 373 0xdccf3f2e, 374 0x5512721f, 375 0x2e6b7124, 376 0x501adde6, 377 0x9f84cd87, 378 0x7a584718, 379 0x7408da17, 380 0xbc9f9abc, 381 0xe94b7d8c, 382 0xec7aec3a, 383 0xdb851dfa, 384 0x63094366, 385 0xc464c3d2, 386 0xef1c1847, 387 0x3215d908, 388 0xdd433b37, 389 0x24c2ba16, 390 0x12a14d43, 391 0x2a65c451, 392 0x50940002, 393 0x133ae4dd, 394 0x71dff89e, 395 0x10314e55, 396 0x81ac77d6, 397 0x5f11199b, 398 0x043556f1, 399 0xd7a3c76b, 400 0x3c11183b, 401 0x5924a509, 402 0xf28fe6ed, 403 0x97f1fbfa, 404 0x9ebabf2c, 405 0x1e153c6e, 406 0x86e34570, 407 0xeae96fb1, 408 0x860e5e0a, 409 0x5a3e2ab3, 410 0x771fe71c, 411 0x4e3d06fa, 412 0x2965dcb9, 413 0x99e71d0f, 414 0x803e89d6, 415 0x5266c825, 416 0x2e4cc978, 417 0x9c10b36a, 418 0xc6150eba, 419 0x94e2ea78, 420 0xa5fc3c53, 421 0x1e0a2df4, 422 0xf2f74ea7, 423 0x361d2b3d, 424 0x1939260f, 425 0x19c27960, 426 0x5223a708, 427 0xf71312b6, 428 0xebadfe6e, 429 0xeac31f66, 430 0xe3bc4595, 431 0xa67bc883, 432 0xb17f37d1, 433 0x018cff28, 434 0xc332ddef, 435 0xbe6c5aa5, 436 0x65582185, 437 0x68ab9802, 438 0xeecea50f, 439 0xdb2f953b, 440 0x2aef7dad, 441 0x5b6e2f84, 442 0x1521b628, 443 0x29076170, 444 0xecdd4775, 445 0x619f1510, 446 0x13cca830, 447 0xeb61bd96, 448 0x0334fe1e, 449 0xaa0363cf, 450 0xb5735c90, 451 0x4c70a239, 452 0xd59e9e0b, 453 0xcbaade14, 454 0xeecc86bc, 455 0x60622ca7, 456 0x9cab5cab, 457 0xb2f3846e, 458 0x648b1eaf, 459 0x19bdf0ca, 460 0xa02369b9, 461 0x655abb50, 462 0x40685a32, 463 0x3c2ab4b3, 464 0x319ee9d5, 465 0xc021b8f7, 466 0x9b540b19, 467 0x875fa099, 468 0x95f7997e, 469 0x623d7da8, 470 0xf837889a, 471 0x97e32d77, 472 0x11ed935f, 473 0x16681281, 474 0x0e358829, 475 0xc7e61fd6, 476 0x96dedfa1, 477 0x7858ba99, 478 0x57f584a5, 479 0x1b227263, 480 0x9b83c3ff, 481 0x1ac24696, 482 0xcdb30aeb, 483 0x532e3054, 484 0x8fd948e4, 485 0x6dbc3128, 486 0x58ebf2ef, 487 0x34c6ffea, 488 0xfe28ed61, 489 0xee7c3c73, 490 0x5d4a14d9, 491 0xe864b7e3, 492 0x42105d14, 493 0x203e13e0, 494 0x45eee2b6, 495 0xa3aaabea, 496 0xdb6c4f15, 497 0xfacb4fd0, 498 0xc742f442, 499 0xef6abbb5, 500 0x654f3b1d, 501 0x41cd2105, 502 0xd81e799e, 503 0x86854dc7, 504 0xe44b476a, 505 0x3d816250, 506 0xcf62a1f2, 507 0x5b8d2646, 508 0xfc8883a0, 509 0xc1c7b6a3, 510 0x7f1524c3, 511 0x69cb7492, 512 0x47848a0b, 513 0x5692b285, 514 0x095bbf00, 515 0xad19489d, 516 0x1462b174, 517 0x23820e00, 518 0x58428d2a, 519 0x0c55f5ea, 520 0x1dadf43e, 521 0x233f7061, 522 0x3372f092, 523 0x8d937e41, 524 0xd65fecf1, 525 0x6c223bdb, 526 0x7cde3759, 527 0xcbee7460, 528 0x4085f2a7, 529 0xce77326e, 530 0xa6078084, 531 0x19f8509e, 532 0xe8efd855, 533 0x61d99735, 534 0xa969a7aa, 535 0xc50c06c2, 536 0x5a04abfc, 537 0x800bcadc, 538 0x9e447a2e, 539 0xc3453484, 540 0xfdd56705, 541 0x0e1e9ec9, 542 0xdb73dbd3, 543 0x105588cd, 544 0x675fda79, 545 0xe3674340, 546 0xc5c43465, 547 0x713e38d8, 548 0x3d28f89e, 549 0xf16dff20, 550 0x153e21e7, 551 0x8fb03d4a, 552 0xe6e39f2b, 553 0xdb83adf7, 554 0xe93d5a68, 555 0x948140f7, 556 0xf64c261c, 557 0x94692934, 558 0x411520f7, 559 0x7602d4f7, 560 0xbcf46b2e, 561 0xd4a20068, 562 0xd4082471, 563 0x3320f46a, 564 0x43b7d4b7, 565 0x500061af, 566 0x1e39f62e, 567 0x97244546, 568 0x14214f74, 569 0xbf8b8840, 570 0x4d95fc1d, 571 0x96b591af, 572 0x70f4ddd3, 573 0x66a02f45, 574 0xbfbc09ec, 575 0x03bd9785, 576 0x7fac6dd0, 577 0x31cb8504, 578 0x96eb27b3, 579 0x55fd3941, 580 0xda2547e6, 581 0xabca0a9a, 582 0x28507825, 583 0x530429f4, 584 0x0a2c86da, 585 0xe9b66dfb, 586 0x68dc1462, 587 0xd7486900, 588 0x680ec0a4, 589 0x27a18dee, 590 0x4f3ffea2, 591 0xe887ad8c, 592 0xb58ce006, 593 0x7af4d6b6, 594 0xaace1e7c, 595 0xd3375fec, 596 0xce78a399, 597 0x406b2a42, 598 0x20fe9e35, 599 0xd9f385b9, 600 0xee39d7ab, 601 0x3b124e8b, 602 0x1dc9faf7, 603 0x4b6d1856, 604 0x26a36631, 605 0xeae397b2, 606 0x3a6efa74, 607 0xdd5b4332, 608 0x6841e7f7, 609 0xca7820fb, 610 0xfb0af54e, 611 0xd8feb397, 612 0x454056ac, 613 0xba489527, 614 0x55533a3a, 615 0x20838d87, 616 0xfe6ba9b7, 617 0xd096954b, 618 0x55a867bc, 619 0xa1159a58, 620 0xcca92963, 621 0x99e1db33, 622 0xa62a4a56, 623 0x3f3125f9, 624 0x5ef47e1c, 625 0x9029317c, 626 0xfdf8e802, 627 0x04272f70, 628 0x80bb155c, 629 0x05282ce3, 630 0x95c11548, 631 0xe4c66d22, 632 0x48c1133f, 633 0xc70f86dc, 634 0x07f9c9ee, 635 0x41041f0f, 636 0x404779a4, 637 0x5d886e17, 638 0x325f51eb, 639 0xd59bc0d1, 640 0xf2bcc18f, 641 0x41113564, 642 0x257b7834, 643 0x602a9c60, 644 0xdff8e8a3, 645 0x1f636c1b, 646 0x0e12b4c2, 647 0x02e1329e, 648 0xaf664fd1, 649 0xcad18115, 650 0x6b2395e0, 651 0x333e92e1, 652 0x3b240b62, 653 0xeebeb922, 654 0x85b2a20e, 655 0xe6ba0d99, 656 0xde720c8c, 657 0x2da2f728, 658 0xd0127845, 659 0x95b794fd, 660 0x647d0862, 661 0xe7ccf5f0, 662 0x5449a36f, 663 0x877d48fa, 664 0xc39dfd27, 665 0xf33e8d1e, 666 0x0a476341, 667 0x992eff74, 668 0x3a6f6eab, 669 0xf4f8fd37, 670 0xa812dc60, 671 0xa1ebddf8, 672 0x991be14c, 673 0xdb6e6b0d, 674 0xc67b5510, 675 0x6d672c37, 676 0x2765d43b, 677 0xdcd0e804, 678 0xf1290dc7, 679 0xcc00ffa3, 680 0xb5390f92, 681 0x690fed0b, 682 0x667b9ffb, 683 0xcedb7d9c, 684 0xa091cf0b, 685 0xd9155ea3, 686 0xbb132f88, 687 0x515bad24, 688 0x7b9479bf, 689 0x763bd6eb, 690 0x37392eb3, 691 0xcc115979, 692 0x8026e297, 693 0xf42e312d, 694 0x6842ada7, 695 0xc66a2b3b, 696 0x12754ccc, 697 0x782ef11c, 698 0x6a124237, 699 0xb79251e7, 700 0x06a1bbe6, 701 0x4bfb6350, 702 0x1a6b1018, 703 0x11caedfa, 704 0x3d25bdd8, 705 0xe2e1c3c9, 706 0x44421659, 707 0x0a121386, 708 0xd90cec6e, 709 0xd5abea2a, 710 0x64af674e, 711 0xda86a85f, 712 0xbebfe988, 713 0x64e4c3fe, 714 0x9dbc8057, 715 0xf0f7c086, 716 0x60787bf8, 717 0x6003604d, 718 0xd1fd8346, 719 0xf6381fb0, 720 0x7745ae04, 721 0xd736fccc, 722 0x83426b33, 723 0xf01eab71, 724 0xb0804187, 725 0x3c005e5f, 726 0x77a057be, 727 0xbde8ae24, 728 0x55464299, 729 0xbf582e61, 730 0x4e58f48f, 731 0xf2ddfda2, 732 0xf474ef38, 733 0x8789bdc2, 734 0x5366f9c3, 735 0xc8b38e74, 736 0xb475f255, 737 0x46fcd9b9, 738 0x7aeb2661, 739 0x8b1ddf84, 740 0x846a0e79, 741 0x915f95e2, 742 0x466e598e, 743 0x20b45770, 744 0x8cd55591, 745 0xc902de4c, 746 0xb90bace1, 747 0xbb8205d0, 748 0x11a86248, 749 0x7574a99e, 750 0xb77f19b6, 751 0xe0a9dc09, 752 0x662d09a1, 753 0xc4324633, 754 0xe85a1f02, 755 0x09f0be8c, 756 0x4a99a025, 757 0x1d6efe10, 758 0x1ab93d1d, 759 0x0ba5a4df, 760 0xa186f20f, 761 0x2868f169, 762 0xdcb7da83, 763 0x573906fe, 764 0xa1e2ce9b, 765 0x4fcd7f52, 766 0x50115e01, 767 0xa70683fa, 768 0xa002b5c4, 769 0x0de6d027, 770 0x9af88c27, 771 0x773f8641, 772 0xc3604c06, 773 0x61a806b5, 774 0xf0177a28, 775 0xc0f586e0, 776 0x006058aa, 777 0x30dc7d62, 778 0x11e69ed7, 779 0x2338ea63, 780 0x53c2dd94, 781 0xc2c21634, 782 0xbbcbee56, 783 0x90bcb6de, 784 0xebfc7da1, 785 0xce591d76, 786 0x6f05e409, 787 0x4b7c0188, 788 0x39720a3d, 789 0x7c927c24, 790 0x86e3725f, 791 0x724d9db9, 792 0x1ac15bb4, 793 0xd39eb8fc, 794 0xed545578, 795 0x08fca5b5, 796 0xd83d7cd3, 797 0x4dad0fc4, 798 0x1e50ef5e, 799 0xb161e6f8, 800 0xa28514d9, 801 0x6c51133c, 802 0x6fd5c7e7, 803 0x56e14ec4, 804 0x362abfce, 805 0xddc6c837, 806 0xd79a3234, 807 0x92638212, 808 0x670efa8e, 809 0x406000e0, 810 0x3a39ce37, 811 0xd3faf5cf, 812 0xabc27737, 813 0x5ac52d1b, 814 0x5cb0679e, 815 0x4fa33742, 816 0xd3822740, 817 0x99bc9bbe, 818 0xd5118e9d, 819 0xbf0f7315, 820 0xd62d1c7e, 821 0xc700c47b, 822 0xb78c1b6b, 823 0x21a19045, 824 0xb26eb1be, 825 0x6a366eb4, 826 0x5748ab2f, 827 0xbc946e79, 828 0xc6a376d2, 829 0x6549c2c8, 830 0x530ff8ee, 831 0x468dde7d, 832 0xd5730a1d, 833 0x4cd04dc6, 834 0x2939bbdb, 835 0xa9ba4650, 836 0xac9526e8, 837 0xbe5ee304, 838 0xa1fad5f0, 839 0x6a2d519a, 840 0x63ef8ce2, 841 0x9a86ee22, 842 0xc089c2b8, 843 0x43242ef6, 844 0xa51e03aa, 845 0x9cf2d0a4, 846 0x83c061ba, 847 0x9be96a4d, 848 0x8fe51550, 849 0xba645bd6, 850 0x2826a2f9, 851 0xa73a3ae1, 852 0x4ba99586, 853 0xef5562e9, 854 0xc72fefd3, 855 0xf752f7da, 856 0x3f046f69, 857 0x77fa0a59, 858 0x80e4a915, 859 0x87b08601, 860 0x9b09e6ad, 861 0x3b3ee593, 862 0xe990fd5a, 863 0x9e34d797, 864 0x2cf0b7d9, 865 0x022b8b51, 866 0x96d5ac3a, 867 0x017da67d, 868 0xd1cf3ed6, 869 0x7c7d2d28, 870 0x1f9f25cf, 871 0xadf2b89b, 872 0x5ad6b472, 873 0x5a88f54c, 874 0xe029ac71, 875 0xe019a5e6, 876 0x47b0acfd, 877 0xed93fa9b, 878 0xe8d3c48d, 879 0x283b57cc, 880 0xf8d56629, 881 0x79132e28, 882 0x785f0191, 883 0xed756055, 884 0xf7960e44, 885 0xe3d35e8c, 886 0x15056dd4, 887 0x88f46dba, 888 0x03a16125, 889 0x0564f0bd, 890 0xc3eb9e15, 891 0x3c9057a2, 892 0x97271aec, 893 0xa93a072a, 894 0x1b3f6d9b, 895 0x1e6321f5, 896 0xf59c66fb, 897 0x26dcf319, 898 0x7533d928, 899 0xb155fdf5, 900 0x03563482, 901 0x8aba3cbb, 902 0x28517711, 903 0xc20ad9f8, 904 0xabcc5167, 905 0xccad925f, 906 0x4de81751, 907 0x3830dc8e, 908 0x379d5862, 909 0x9320f991, 910 0xea7a90c2, 911 0xfb3e7bce, 912 0x5121ce64, 913 0x774fbe32, 914 0xa8b6e37e, 915 0xc3293d46, 916 0x48de5369, 917 0x6413e680, 918 0xa2ae0810, 919 0xdd6db224, 920 0x69852dfd, 921 0x09072166, 922 0xb39a460a, 923 0x6445c0dd, 924 0x586cdecf, 925 0x1c20c8ae, 926 0x5bbef7dd, 927 0x1b588d40, 928 0xccd2017f, 929 0x6bb4e3bb, 930 0xdda26a7e, 931 0x3a59ff45, 932 0x3e350a44, 933 0xbcb4cdd5, 934 0x72eacea8, 935 0xfa6484bb, 936 0x8d6612ae, 937 0xbf3c6f47, 938 0xd29be463, 939 0x542f5d9e, 940 0xaec2771b, 941 0xf64e6370, 942 0x740e0d8d, 943 0xe75b1357, 944 0xf8721671, 945 0xaf537d5d, 946 0x4040cb08, 947 0x4eb4e2cc, 948 0x34d2466a, 949 0x0115af84, 950 0xe1b00428, 951 0x95983a1d, 952 0x06b89fb4, 953 0xce6ea048, 954 0x6f3f3b82, 955 0x3520ab82, 956 0x011a1d4b, 957 0x277227f8, 958 0x611560b1, 959 0xe7933fdc, 960 0xbb3a792b, 961 0x344525bd, 962 0xa08839e1, 963 0x51ce794b, 964 0x2f32c9b7, 965 0xa01fbac9, 966 0xe01cc87e, 967 0xbcc7d1f6, 968 0xcf0111c3, 969 0xa1e8aac7, 970 0x1a908749, 971 0xd44fbd9a, 972 0xd0dadecb, 973 0xd50ada38, 974 0x0339c32a, 975 0xc6913667, 976 0x8df9317c, 977 0xe0b12b4f, 978 0xf79e59b7, 979 0x43f5bb3a, 980 0xf2d519ff, 981 0x27d9459c, 982 0xbf97222c, 983 0x15e6fc2a, 984 0x0f91fc71, 985 0x9b941525, 986 0xfae59361, 987 0xceb69ceb, 988 0xc2a86459, 989 0x12baa8d1, 990 0xb6c1075e, 991 0xe3056a0c, 992 0x10d25065, 993 0xcb03a442, 994 0xe0ec6e0e, 995 0x1698db3b, 996 0x4c98a0be, 997 0x3278e964, 998 0x9f1f9532, 999 0xe0d392df, 1000 0xd3a0342b, 1001 0x8971f21e, 1002 0x1b0a7441, 1003 0x4ba3348c, 1004 0xc5be7120, 1005 0xc37632d8, 1006 0xdf359f8d, 1007 0x9b992f2e, 1008 0xe60b6f47, 1009 0x0fe3f11d, 1010 0xe54cda54, 1011 0x1edad891, 1012 0xce6279cf, 1013 0xcd3e7e6f, 1014 0x1618b166, 1015 0xfd2c1d05, 1016 0x848fd2c5, 1017 0xf6fb2299, 1018 0xf523f357, 1019 0xa6327623, 1020 0x93a83531, 1021 0x56cccd02, 1022 0xacf08162, 1023 0x5a75ebb5, 1024 0x6e163697, 1025 0x88d273cc, 1026 0xde966292, 1027 0x81b949d0, 1028 0x4c50901b, 1029 0x71c65614, 1030 0xe6c6c7bd, 1031 0x327a140a, 1032 0x45e1d006, 1033 0xc3f27b9a, 1034 0xc9aa53fd, 1035 0x62a80f00, 1036 0xbb25bfe2, 1037 0x35bdd2f6, 1038 0x71126905, 1039 0xb2040222, 1040 0xb6cbcf7c, 1041 0xcd769c2b, 1042 0x53113ec0, 1043 0x1640e3d3, 1044 0x38abbd60, 1045 0x2547adf0, 1046 0xba38209c, 1047 0xf746ce76, 1048 0x77afa1c5, 1049 0x20756060, 1050 0x85cbfe4e, 1051 0x8ae88dd8, 1052 0x7aaaf9b0, 1053 0x4cf9aa7e, 1054 0x1948c25c, 1055 0x02fb8a8c, 1056 0x01c36ae4, 1057 0xd6ebe1f9, 1058 0x90d4f869, 1059 0xa65cdea0, 1060 0x3f09252d, 1061 0xc208e69f, 1062 0xb74e6132, 1063 0xce77e25b, 1064 0x578fdfe3, 1065 0x3ac372e6 }; 1066public void decipher(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { 1067 int xL = lastDecipherXL; 1068 int xR = lastDecipherXR; 1069 1070 int dataXL; 1071 int dataXR; 1072 1073 int[] xLxR = new int[2]; 1074 1075 for (int i = 0; i < len; i = i + 8) { 1076 dataXL = (src[srcOff + i] & 0xff) | ((src[srcOff + i + 1] & 0xff) << 8) | ((src[srcOff + i + 2] & 0xff) << 16) | ((src[srcOff + i + 3] & 0xff) << 24); 1077 dataXR = (src[srcOff + i + 4] & 0xff) | ((src[srcOff + i + 5] & 0xff) << 8) | ((src[srcOff + i + 6] & 0xff) << 16) | ((src[srcOff + i + 7] & 0xff) << 24); 1078 1079 decipher(dataXL, dataXR, xLxR); 1080 1081 xL ^= xLxR[0]; 1082 xR ^= xLxR[1]; 1083 1084 dst[dstOff + i] = (byte) (xL & 0xff); 1085 dst[dstOff + i + 1] = (byte) ((xL >> 8) & 0xff); 1086 dst[dstOff + i + 2] = (byte) ((xL >> 16) & 0xff); 1087 dst[dstOff + i + 3] = (byte) ((xL >> 24) & 0xff); 1088 dst[dstOff + i + 4] = (byte) (xR & 0xff); 1089 dst[dstOff + i + 5] = (byte) ((xR >> 8) & 0xff); 1090 dst[dstOff + i + 6] = (byte) ((xR >> 16) & 0xff); 1091 dst[dstOff + i + 7] = (byte) ((xR >> 24) & 0xff); 1092 1093 xL = dataXL; 1094 xR = dataXR; 1095 } 1096 1097 lastDecipherXL = xL; 1098 lastDecipherXR = xR; 1099} 1100private void decipher(int xL, int xR, int[] xLxR) { 1101 xL ^= P[17]; 1102 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[16]; 1103 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[15]; 1104 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[14]; 1105 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[13]; 1106 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[12]; 1107 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[11]; 1108 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[10]; 1109 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[9]; 1110 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[8]; 1111 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[7]; 1112 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[6]; 1113 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[5]; 1114 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[4]; 1115 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[3]; 1116 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[2]; 1117 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[1]; 1118 xR ^= P[0]; 1119 1120 xLxR[0] = xR; 1121 xLxR[1] = xL; 1122} 1123public void encipher(byte[] src, int srcOff, byte[] dst, int dstOff, int len) { 1124 int xL = lastEncipherXL; 1125 int xR = lastEncipherXR; 1126 1127 int[] xLxR = new int[2]; 1128 1129 for (int i = 0; i < len; i = i + 8) { 1130 xL ^= (src[srcOff + i] & 0xff) | ((src[srcOff + i + 1] & 0xff) << 8) | ((src[srcOff + i + 2] & 0xff) << 16) | ((src[srcOff + i + 3] & 0xff) << 24); 1131 xR ^= (src[srcOff + i + 4] & 0xff) | ((src[srcOff + i + 5] & 0xff) << 8) | ((src[srcOff + i + 6] & 0xff) << 16) | ((src[srcOff + i + 7] & 0xff) << 24); 1132 1133 encipher(xL, xR, xLxR); 1134 1135 xL = xLxR[0]; 1136 xR = xLxR[1]; 1137 1138 dst[dstOff + i] = (byte) (xL & 0xff); 1139 dst[dstOff + i + 1] = (byte) ((xL >> 8) & 0xff); 1140 dst[dstOff + i + 2] = (byte) ((xL >> 16) & 0xff); 1141 dst[dstOff + i + 3] = (byte) ((xL >> 24) & 0xff); 1142 dst[dstOff + i + 4] = (byte) (xR & 0xff); 1143 dst[dstOff + i + 5] = (byte) ((xR >> 8) & 0xff); 1144 dst[dstOff + i + 6] = (byte) ((xR >> 16) & 0xff); 1145 dst[dstOff + i + 7] = (byte) ((xR >> 24) & 0xff); 1146 } 1147 1148 lastEncipherXL = xL; 1149 lastEncipherXR = xR; 1150} 1151private void encipher(int xL, int xR, int[] xLxR) { 1152 xL ^= P[0]; 1153 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[1]; 1154 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[2]; 1155 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[3]; 1156 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[4]; 1157 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[5]; 1158 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[6]; 1159 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[7]; 1160 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[8]; 1161 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[9]; 1162 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[10]; 1163 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[11]; 1164 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[12]; 1165 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[13]; 1166 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[14]; 1167 xR ^= (((S[0][(xL >> 24) & 0xff] + S[1][(xL >> 16) & 0xff]) ^ (S[2][(xL >> 8) & 0xff])) + (S[3][xL & 0xff])) ^ P[15]; 1168 xL ^= (((S[0][(xR >> 24) & 0xff] + S[1][(xR >> 16) & 0xff]) ^ (S[2][(xR >> 8) & 0xff])) + (S[3][xR & 0xff])) ^ P[16]; 1169 xR ^= P[17]; 1170 1171 xLxR[0] = xR; 1172 xLxR[1] = xL; 1173} 1174public void setKey(byte key[]) { 1175 int data = 0; 1176 int offset = 0; 1177 1178 for (int i = 0; i < P.length; ++i) { 1179 P[i] = INIT_DATA[offset++]; 1180 } 1181 1182 for (int i = 0; i < S.length; ++i) { 1183 for (int j = 0; j < S[i].length; ++j) { 1184 S[i][j] = INIT_DATA[offset++]; 1185 } 1186 } 1187 1188 offset = 0; 1189 for (int i = 0; i < P.length; ++i) { 1190 data = 0; 1191 for (int k = 0; k < 4; ++k) { 1192 data = (data << 8) | (key[offset++] & 0xff); 1193 if (offset >= key.length) { 1194 offset = 0; 1195 } 1196 } 1197 P[i] = P[i] ^ data; 1198 } 1199 1200 int[] lr = new int[] { 0, 0 }; 1201 for (int i = 0; i < P.length; i += 2) { 1202 encipher(lr[0], lr[1], lr); 1203 P[i] = lr[0]; 1204 P[i + 1] = lr[1]; 1205 } 1206 1207 for (int i = 0; i < S.length; ++i) { 1208 for (int j = 0; j < S[i].length; j += 2) { 1209 encipher(lr[0], lr[1], lr); 1210 S[i][j] = lr[0]; 1211 S[i][j + 1] = lr[1]; 1212 } 1213 } 1214 1215 lastEncipherXL = 0; 1216 lastEncipherXR = 0; 1217 lastDecipherXL = 0; 1218 lastDecipherXR = 0; 1219} 1220} 1221 | Popular Tags |