@ Override public void decryptBlock ( byte [ ] data , int offset , byte [ ] dest , int destOffset ) { // w128_t x; // x.q[0] = ((uint64_t *) blk)[0] ^ key->k[9].q[0]; // x.q[1] = ((uint64_t *) blk)[1] ^ key->k[9].q[1]; Kuz128 x = new Kuz128 ( ) ; x . setQ ( 0 , ByteStrings . bytesToLong ( data , offset ) ^ key . getK ( ) [ 9 ] . getQ ( 0 ) ) ; x . setQ ( 1 , ByteStrings . bytesToLong ( data , offset + 8 ) ^ key . getK ( ) [ 9 ] . getQ ( 1 ) ) ; for ( int i = 8 ; i >= 0 ; i -- ) { // kuz_l_inv(&x); KuznechikMath . kuz_l_inv ( x ) ; for ( int j = 0 ; j < 16 ; j ++ ) { // x.b[j] = kuz_pi_inv[x.b[j]]; x . getB ( ) [ j ] = KuznechikTables . kuz_pi_inv [ x . getB ( ) [ j ] & 0xFF ] ; } // x.q[0] ^= key->k[i].q[0]; x . setQ ( 0 , x . getQ ( 0 ) ^ key . getK ( ) [ i ] . getQ ( 0 ) ) ; // x.q[1] ^= key->k[i].q[1]; x . setQ ( 1 , x . getQ ( 1 ) ^ key . getK ( ) [ i ] . getQ ( 1 ) ) ; } // ((uint64_t *) blk)[0] = x.q[0]; // ((uint64_t *) blk)[1] = x.q[1]; ByteStrings . write ( dest , destOffset , ByteStrings . longToBytes ( x . getQ ( 0 ) ) , 0 , 8 ) ; ByteStrings . write ( dest , destOffset + 8 , ByteStrings . longToBytes ( x . getQ ( 1 ) ) , 0 , 8 ) ; }
Decrypting block with Kuznechik encryption