Key the Blowfish cipher @param key an array containing the key @param sign_ext_bug true to implement the 2x bug @param safety bit 16 is set when the safety measure is requested
(byte key[], boolean sign_ext_bug, int safety)
| 573 | * @param safety bit 16 is set when the safety measure is requested |
| 574 | */ |
| 575 | private void key(byte key[], boolean sign_ext_bug, int safety) { |
| 576 | int i; |
| 577 | int koffp[] = { 0 }; |
| 578 | int lr[] = { 0, 0 }; |
| 579 | int plen = P.length, slen = S.length; |
| 580 | |
| 581 | for (i = 0; i < plen; i++) |
| 582 | if (!sign_ext_bug) |
| 583 | P[i] = P[i] ^ streamtoword(key, koffp); |
| 584 | else |
| 585 | P[i] = P[i] ^ streamtoword_bug(key, koffp); |
| 586 | |
| 587 | for (i = 0; i < plen; i += 2) { |
| 588 | encipher(lr, 0); |
| 589 | P[i] = lr[0]; |
| 590 | P[i + 1] = lr[1]; |
| 591 | } |
| 592 | |
| 593 | for (i = 0; i < slen; i += 2) { |
| 594 | encipher(lr, 0); |
| 595 | S[i] = lr[0]; |
| 596 | S[i + 1] = lr[1]; |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | /** |
| 601 | * Perform the "enhanced key schedule" step described by |
no test coverage detected