Quantcast

a question about PGPPBEEncryptedData.getSymmetricAlgorithm

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

a question about PGPPBEEncryptedData.getSymmetricAlgorithm

Lou Wynn

Hi,

I've just used password based encryption in PGP. The PGPPBEEncryptedData class has the following function:

    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];
    }

I have a question about it. Why does it not directly return keyData.getEncAlgorithm()? I might have missed something because I don't see it necessary to call the expensive function, makeKeyFromPassPhrase, and then use the key to decrypt data. Because that function needs the algorithm to derive the key in the first place

-- 
Thanks,
Lou
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: a question about PGPPBEEncryptedData.getSymmetricAlgorithm

David Hook-3

The PBE key is not used to encrypt the data, it is used to encrypt a session key which is used to encrypt the data. The algorithm used by the session key is determined by the first byte of the sessionData with the session key making up the rest of it.

Regards,

David

On 05/05/17 15:47, Lou Wynn wrote:

Hi,

I've just used password based encryption in PGP. The PGPPBEEncryptedData class has the following function:

    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];
    }

I have a question about it. Why does it not directly return keyData.getEncAlgorithm()? I might have missed something because I don't see it necessary to call the expensive function, makeKeyFromPassPhrase, and then use the key to decrypt data. Because that function needs the algorithm to derive the key in the first place

-- 
Thanks,
Lou


Loading...