@Test public void testGetKey() throws IOException, GeneralSecurityException { passwordCache.setPassword(PASSWORD); DerivedKey derivedKey = passwordCache.getKey(); assertEquals(derivedKey.scryptParams, FileEncryptionConstants.KDF_PARAMETERS); byte[] expectedKey = FileEncryptionUtil.getEncryptionKey(PASSWORD, derivedKey.salt, derivedKey.scryptParams); assertArrayEquals(expectedKey, derivedKey.key); PasswordCache newPasswordCache = TestUtil.createPasswordCache(testDir); newPasswordCache = TestUtil.createPasswordCache(testDir); newPasswordCache.setPassword(PASSWORD); byte[] oldSalt = derivedKey.salt; byte[] newSalt = passwordCache.getKey().salt; assertArrayEquals(oldSalt, newSalt); Configuration configuration = TestUtil.createConfiguration(testDir); File derivParamsFile = configuration.getKeyDerivationParametersFile(); boolean deleted = derivParamsFile.delete(); assertTrue("Can't delete derivation parameters cache file: <" + derivParamsFile.getAbsolutePath() + ">", deleted); passwordCache.setPassword(PASSWORD); newSalt = passwordCache.getKey().salt; assertFalse(Arrays.equals(oldSalt, newSalt)); }
@Override public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException { if (derivedKey == null) createDerivedKey(); return derivedKey; }
PasswordCache extends I2PAppThread implements PasswordHolder { @Override public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException { if (derivedKey == null) createDerivedKey(); return derivedKey; } }
PasswordCache extends I2PAppThread implements PasswordHolder { @Override public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException { if (derivedKey == null) createDerivedKey(); return derivedKey; } PasswordCache(Configuration configuration); }
PasswordCache extends I2PAppThread implements PasswordHolder { @Override public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException { if (derivedKey == null) createDerivedKey(); return derivedKey; } PasswordCache(Configuration configuration); synchronized void setPassword(byte[] password); synchronized byte[] getPassword(); @Override synchronized DerivedKey getKey(); boolean isPasswordInCache(); void clear(); void addPasswordCacheListener(PasswordCacheListener listener); void removePasswordCacheListener(PasswordCacheListener listener); @Override void run(); }
PasswordCache extends I2PAppThread implements PasswordHolder { @Override public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException { if (derivedKey == null) createDerivedKey(); return derivedKey; } PasswordCache(Configuration configuration); synchronized void setPassword(byte[] password); synchronized byte[] getPassword(); @Override synchronized DerivedKey getKey(); boolean isPasswordInCache(); void clear(); void addPasswordCacheListener(PasswordCacheListener listener); void removePasswordCacheListener(PasswordCacheListener listener); @Override void run();  }