abhijit
abhijit

Reputation: 385

Is it possible to check a pgp encrypted file without decrypting it?

On Linux, I have access to PGP. However, I do not have PGP SDK service running on a particular box to which I have access to. Normally, I use "pgp --verify --passphrase " to verify the .pgp files. Is it possible to verify a file (I only need to check if the file is encrypted or not) using pgp but not where PGP SDK service is required?

Upvotes: 0

Views: 4829

Answers (1)

Jens Erat
Jens Erat

Reputation: 38722

RHEL already brings GnuPG, which is a fully compliant implementation of OpenPGP. Using gpg --list-only --list-packets you can dump the contents of an OpenPGP file (either sending the contents into STDIN or providing an additional option containing a file name).

An example output for my own key:

$ echo foo | gpg --recipient a4ff2279 --encrypt | gpg2 --list-only --list-packets
# off=0 ctb=85 tag=1 hlen=3 plen=524
:pubkey enc packet: version 3, algo 1, keyid CC73B287A4388025
    data: [4096 bits]
# off=527 ctb=d2 tag=18 hlen=2 plen=63 new-ctb
:encrypted data packet:
    length: 63
    mdc_method: 2

If you want to test for encrypted information, look for the :pubkey enc packet line if you only want to match public-private-key cryptography, the :encrypted data packet will be available in both public-private-key cryptography and with symmetric encryption.

PGP probably provides similar interfaces, but I have few experience with it and currently no setup around to play with it. Anyway, if using PGP make sure you're not using one of the very old, outdated versions suffering from some flaws and limited compatibility with newer releases of the standard.

Upvotes: 1

Related Questions