### Question:
AES256v2Cryptor implements JNCryptor { @Override public SecretKey keyForPassword(char[] password, byte[] salt) throws CryptorException { Validate.notNull(salt, "Salt value cannot be null."); Validate.isTrue(salt.length == SALT_LENGTH, "Salt value must be %d bytes.", SALT_LENGTH); try { SecretKeyFactory factory = SecretKeyFactory .getInstance(KEY_DERIVATION_ALGORITHM); SecretKey tmp = factory.generateSecret(new PBEKeySpec(password, salt, PBKDF_ITERATIONS, AES_256_KEY_SIZE * 8)); return new SecretKeySpec(tmp.getEncoded(), AES_NAME); } catch (GeneralSecurityException e) { throw new CryptorException(String.format( "Failed to generate key from password using %s.", KEY_DERIVATION_ALGORITHM), e); } } AES256v2Cryptor(); @Override SecretKey keyForPassword(char[] password, byte[] salt); @Override byte[] decryptData(byte[] ciphertext, char[] password); @Override byte[] encryptData(byte[] plaintext, char[] password); @Override int getVersionNumber(); @Override byte[] decryptData(byte[] ciphertext, SecretKey decryptionKey,
      SecretKey hmacKey); @Override byte[] encryptData(byte[] plaintext, SecretKey encryptionKey,
      SecretKey hmacKey);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testBadSaltLengthForKey() throws Exception { new AES256v2Cryptor().keyForPassword(null, new byte[AES256v2Cryptor.SALT_LENGTH + 1]); }