Re: RECOVERING FROM A BAD PASSPHRASE: PGPPBEEncryptedData.getDataStream(...)

William Swartzendruber <[email protected]> Tue, 8 Jan 2019 18:54:52 -0700
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <CAHtLsAU0_O+tNKbw26k6xeNiNTG7=mr5zMrswi568U55HzacZg@mail.gmail.com>
The best thing I could think of was to wrap the BcPGPObjectFactory in a
BufferedInputStream and to mark() and reset() that.

Is that what you meant?

On Thu, Dec 20, 2018 at 5:05 PM David Hook <dgh-rTAZ0PM/[email protected]> wrote:

>
> The issue here is that the PGP API is a streaming one, so having started
> decryption and failed, the data is already partially read. You need to
> reset the stream to recover from an incorrect passphrase.
>
> Regards,
>
> David
>
> On 12/12/18 5:01 pm, William Swartzendruber wrote:
> > Hello:
> >
> > I am encountering an issue where attempting to unlock an encrypted
> > data stream via PGPPBEEncryptedData.getDataStream(...) will leave the
> > instance in a bad state if the passphrase is incorrect.  Attempting to
> > get the data stream again results in:
> >
> > PGPDataValidationException("data check failed")
> >
> > Is there a way to recover from someone entering the incorrect passphrase?
> >
> > This is bcpg-jdk15on-1.60
> >
> > I appreciate any assistance or clarification in this manner.
>
>
>
>