/** * encrypt the private key into a byte array with strong encryption based on a passphrase to * unlock the key * * @param passphrase * @throws L2pSecurityException */ private void encryptPrivateKey(String passphrase) throws L2pSecurityException { try { salt = CryptoTools.generateSalt(); super.encryptPrivateKey(CryptoTools.generateKeyForPassphrase(passphrase, salt)); } catch (CryptoException e) { throw new L2pSecurityException("problems with key generation for passphrase", e); } }
/** * unlock the private key * * @param passphrase * @throws L2pSecurityException */ public void unlockPrivateKey(String passphrase) throws L2pSecurityException { try { SecretKey key = CryptoTools.generateKeyForPassphrase(passphrase, salt); super.unlockPrivateKey(key); this.passphrase = passphrase; } catch (CryptoException e) { throw new L2pSecurityException("unable to create key from passphrase", e); } }
/** * atm constructor for the MockAgent class, just don't know, how agent creation will take place * later * * @param id * @param pair * @param passphrase * @param salt * @throws L2pSecurityException * @throws CryptoException */ protected PassphraseAgent(long id, KeyPair pair, String passphrase, byte[] salt) throws L2pSecurityException, CryptoException { super(id, pair, CryptoTools.generateKeyForPassphrase(passphrase, salt)); this.salt = salt.clone(); this.passphrase = null; // done in consturctor of superclass // lockPrivateKey(); }