@Test public void testUpdateKey() throws GeneralSecurityException, PasswordException, IOException { byte[] message = "Hopfen und Malz, Gott erhalt's!".getBytes(); Iterator<EmailIdentity> iterator = identities.iterator(); while (iterator.hasNext()) { EmailIdentity identity = iterator.next(); PublicKey publicKey = identity.getPublicSigningKey(); PrivateKey privateKey = identity.getPrivateSigningKey(); byte[] encodedPublicKey = publicKey.getEncoded().clone(); byte[] encodedPrivateKey = privateKey.getEncoded().clone(); CryptoImplementation cryptoImpl = identity.getCryptoImpl(); cryptoImpl.sign(message, privateKey, identities); boolean publicKeyChanged; boolean privateKeyChanged; if (!identitiesFile.exists()) publicKeyChanged = privateKeyChanged = false; else { Identities newIdentities = new Identities(identitiesFile, passwordHolder); PublicKey newPublicKey = newIdentities.get(identity).getPublicSigningKey(); PrivateKey newPrivateKey = newIdentities.get(identity).getPrivateSigningKey(); publicKeyChanged = !Arrays.equals(encodedPublicKey, newPublicKey.getEncoded()); privateKeyChanged = !Arrays.equals(encodedPrivateKey, newPrivateKey.getEncoded()); } assertFalse(publicKeyChanged); assertTrue(privateKeyChanged == (cryptoImpl instanceof NTRUEncrypt1087_GMSS512)); } }
@Override public void updateKey() throws GeneralSecurityException, PasswordException, IOException { save(); }
Identities extends ExportableData implements KeyUpdateHandler { @Override public void updateKey() throws GeneralSecurityException, PasswordException, IOException { save(); } }
Identities extends ExportableData implements KeyUpdateHandler { @Override public void updateKey() throws GeneralSecurityException, PasswordException, IOException { save(); } Identities(File identitiesFile, PasswordHolder passwordHolder); }
Identities extends ExportableData implements KeyUpdateHandler { @Override public void updateKey() throws GeneralSecurityException, PasswordException, IOException { save(); } Identities(File identitiesFile, PasswordHolder passwordHolder); void save(); void add(EmailIdentity identity); void remove(String key); void changePassword(byte[] oldPassword, DerivedKey newKey); void clearPasswordProtectedData(); void setDefault(EmailIdentity defaultIdentity); EmailIdentity getDefault(); EmailIdentity get(EmailDestination destination); EmailIdentity get(String key); Collection<EmailIdentity> getAll(); boolean isNone(); boolean contains(String base64Dest); int size(); int getSize(); EmailIdentity extractIdentity(String address); Iterator<EmailIdentity> iterator(); @Override void updateKey(); void identityUpdated(String key); void addIdentitiesListener(IdentitiesListener identitiesListener); void removeIdentitiesListener(IdentitiesListener identitiesListener); }
Identities extends ExportableData implements KeyUpdateHandler { @Override public void updateKey() throws GeneralSecurityException, PasswordException, IOException { save(); } Identities(File identitiesFile, PasswordHolder passwordHolder); void save(); void add(EmailIdentity identity); void remove(String key); void changePassword(byte[] oldPassword, DerivedKey newKey); void clearPasswordProtectedData(); void setDefault(EmailIdentity defaultIdentity); EmailIdentity getDefault(); EmailIdentity get(EmailDestination destination); EmailIdentity get(String key); Collection<EmailIdentity> getAll(); boolean isNone(); boolean contains(String base64Dest); int size(); int getSize(); EmailIdentity extractIdentity(String address); Iterator<EmailIdentity> iterator(); @Override void updateKey(); void identityUpdated(String key); void addIdentitiesListener(IdentitiesListener identitiesListener); void removeIdentitiesListener(IdentitiesListener identitiesListener);  }