Re: Decrypting openpgp data created by gpg

Lahiru Dissanayake <[email protected]> Tue, 19 Feb 2013 23:48:48 +0800
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <CAHeAcfBT086DekXyUOLVw+jgkpBTAf1FNr_hD8FuY+=WQKH7jA@mail.gmail.com>
Hi Peter,

The PGP data format can use multiple levels of nesting, you need to check
> the
> CRYPT_ENVINFO_CONTENTTYPE attribute to see what the inner content is and if
> necessary process that further.  My guess is that what you're getting out
> of
> the encrypted envelope is signed data (CRYPT_CONTENT_SIGNEDDATA) or
> compressed
> data (CRYPT_CONTENT_COMPRESSEDDATA), so you need to de-envelope that as
> well
> until you get to plain data, CRYPT_CONTENT_DATA.


Yep, that was the problem with decrypting. Thank you.

Meanwhile, I've been having some other issues as well. I need to create an
open pgp envelop that uses cast5 and includes integrity checking.

1. To specify cast5 encryption, I tried using the line:
cryptSetAttribute( cryptEnvelope, CRYPT_OPTION_ENCR_ALGO, CRYPT_ALGO_CAST );
right after creating a new envelop, but it returns CRYPT_ERROR_PARAM3 as
the status. It returns CRYPT_OK if I specify it as AES, 3DES, etc.

2. To add integrity checking, I tried the line:
cryptSetAttribute( cryptEnvelope, CRYPT_ENVINFO_INTEGRITY,
CRYPT_INTEGRITY_FULL );
which returns CRYPT_OK, but when I add that line to my code, I get
CRYPT_ERROR_INTERNAL when I push data into the envelope.

3. When de-enveloping public key encrypted data, I'd like to specify a
private key context that I have loaded from a keyset, rather than giving
the keyset itself. However, when I specify the private key (after getting
CRYPT_ENVINFO_PRIVATEKEY as a required resource to decrypt the data) as
cryptSetAttribute( cryptEnvelope, CRYPT_ENVINFO_PRIVATEKEY,
pgpPrivateKeyContext );
the function returns CRYPT_ERROR_PARAM2 as the status. This doesn't happen
when I specify the envelope format as CRYPT_FORMAT_CRYPTLIB though.
Supplying the keyset to the envelop (and later supplying the required
password) works with both formats.

4. Is there a way to load an openpgp keyring from a byte array in memory,
as opposed from a disk file?

Thanks,
Lahiru

_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.