private static Key pad(final Key key){
  final byte[] keyBytes=key.getEncoded();
  final int keySize=keyBytes.length;
  final int paddingSize=8 - (keySize % 8);
  final byte[] paddedKeyBytes=Arrays.copyOf(keyBytes,keySize + paddingSize);
  for (int i=0; i < paddingSize; i++) {
    paddedKeyBytes[keySize + i]=(byte)(i + 1);
  }
  return new SecretKeySpec(paddedKeyBytes,DUMMY_KEY_ALGORITHM);
}

private static Key pad ( final Key key ) { final byte [ ] keyBytes = key . getEncoded ( ) ; final int keySize = keyBytes . length ; final int paddingSize = 8 - ( keySize % 8 ) ; final byte [ ] paddedKeyBytes = Arrays . copyOf ( keyBytes , keySize + paddingSize ) ; for ( int i = 0 ; i < paddingSize ; i ++ ) { paddedKeyBytes [ keySize + i ] = ( byte ) ( i + 1 ) ; } return new SecretKeySpec ( paddedKeyBytes , DUMMY_KEY_ALGORITHM ) ; }
aeswrap implementation only supports encoded keys that are multiple of 8 bytes . this method always adds padding , even if it ' s not needed , in order to avoid ambiguity .
