I am tasked to explain the variation of gpg errors that happened in one of my batch script. Currently when I perform gpg decrypt for a specified file it returns 2. The problem with this is when I search the form, it shows that the file has been decrypted properly but the error code is causing the script to stop because it only assumed that 0 is the only success value.
gpg -o XXX --decrypt XXX.gpg
RETVAL=$?
if [ RETVAL -ne 0 ]; then
    exit 1
fi
I searched the net and found the header list for gpg. It defines error 2 as Unknown Packet.
The normal error text being displayed is [gpg: [don't know]: invalid packet (ctb=14)]. What exactly does the unknown packet mean? I am trying to search any documents on understanding the error codes. After showing all the verbose information using the [-vv] option. I compared the resulting gpg file decryption with a file that returns 0 code. The only thing I noticed is the byte of the key is different.
The decryption of the gpg that is error free have the following log:
:pubkey enc packet: version 3, algo 16, keyid <16-hexdigit>
    data    1023 bits
    data    1024 bits
The decryption of the gpg causing error have the following log:
:pubkey enc packet: version 3, algo 16, keyid <16-hexdigit>
    data    1022 bits
    data    1022 bits
What does this mean? why can it still be decrypted properly even if the key bit is not the same? Note that the key-id and passphrase used to decrypt the two file are the same. Also, does anyone know any detailed resource on explaining the error of gpg.
