private int[] expandKey(byte[] uKey){
  int[] key=new int[52];
  if (uKey.length < 16) {
    byte[] tmp=new byte[16];
    System.arraycopy(uKey,0,tmp,tmp.length - uKey.length,uKey.length);
    uKey=tmp;
  }
  for (int i=0; i < 8; i++) {
    key[i]=bytesToWord(uKey,i * 2);
  }
  for (int i=8; i < 52; i++) {
    if ((i & 7) < 6) {
      key[i]=((key[i - 7] & 127) << 9 | key[i - 6] >> 7) & MASK;
    }
 else     if ((i & 7) == 6) {
      key[i]=((key[i - 7] & 127) << 9 | key[i - 14] >> 7) & MASK;
    }
 else {
      key[i]=((key[i - 15] & 127) << 9 | key[i - 14] >> 7) & MASK;
    }
  }
  return key;
}

private int [ ] expandKey ( byte [ ] uKey ) { int [ ] key = new int [ 52 ] ; if ( uKey . length < 16 ) { byte [ ] tmp = new byte [ 16 ] ; System . arraycopy ( uKey , 0 , tmp , tmp . length - uKey . length , uKey . length ) ; uKey = tmp ; } for ( int i = 0 ; i < 8 ; i ++ ) { key [ i ] = bytesToWord ( uKey , i * 2 ) ; } for ( int i = 8 ; i < 52 ; i ++ ) { if ( ( i & 7 ) < 6 ) { key [ i ] = ( ( key [ i - 7 ] & 127 ) << 9 | key [ i - 6 ] > > 7 ) & MASK ; } else if ( ( i & 7 ) == 6 ) { key [ i ] = ( ( key [ i - 7 ] & 127 ) << 9 | key [ i - 14 ] > > 7 ) & MASK ; } else { key [ i ] = ( ( key [ i - 15 ] & 127 ) << 9 | key [ i - 14 ] > > 7 ) & MASK ; } } return key ; }
the following function is used to expand the user key to the encryption subkey . the first 16 bytes are the user key , and the rest of the subkey is calculated by rotating the previous 16 bytes by 25 bits to the left , and so on until the subkey is completed .
