/** * Builds a symmetric-key decryptor for the specified passphrase. */ protected PBEDataDecryptorFactory buildSymmetricKeyDecryptor( String passphrase) { char[] chars = !Util.isEmpty(passphrase) ? passphrase.toCharArray() : new char[0]; return new BcPBEDataDecryptorFactory(chars, new BcPGPDigestCalculatorProvider()); }
/** * Return the symmetric key algorithm required to decrypt the data protected by this object. * * @param dataDecryptorFactory decryptor factory to use to recover the session data. * @return the integer encryption algorithm code. * @throws PGPException if the session data cannot be recovered. */ public int getSymmetricAlgorithm( PBEDataDecryptorFactory dataDecryptorFactory) throws PGPException { byte[] key = dataDecryptorFactory.makeKeyFromPassPhrase(keyData.getEncAlgorithm(), keyData.getS2K()); byte[] sessionData = dataDecryptorFactory.recoverSessionData(keyData.getEncAlgorithm(), key, keyData.getSecKeyData()); return sessionData[0]; }