I am working on a project wherein I am using the OpenPGP java API for encrypting and decrypting data.
I am using
OpenPGP java API - cryptix-openpgp-20050418-snap
Java version - JDK 1.5.0
Data is encrypted using - MEGACRYPTION/MVS V5.4 (A encryption software used by mainframe application and supports PGP)
I am able to decrypt the file using the PGP Desktop tool, however, when I try to decrypt a file from a particular agency, I get the following error
cryptix.message.MessageException: cryptix.openpgp.PGPDataFormatException: Unknown version for public key encrypted session key packet.
at cryptix.openpgp.provider.PGPMessageFactory.generateBinary(PGPMessageFactory.java:207)
at cryptix.openpgp.provider.PGPMessageFactory.engineGenerateMessages(PGPMessageFactory.java:76)
at cryptix.message.MessageFactory.generateMessages(MessageFactory.java:142)
at com.bis.crypto.AsymmetricDecryptor.decrypt(AsymmetricDecryptor.java:93)
at com.bis.crypto.AsymmetricDecryptor.main(AsymmetricDecryptor.java:314)
I am getting this error at the following point in the PGP code:
Class - cryptix.openpgp.packet.PGPPublicKeyEncryptedSessionKeyPacket
Method call -
public void decodeBody (PGPPacketDataInputStream in,
PGPAlgorithmFactory factory)
throws IOException, PGPFatalDataFormatException, PGPDataFormatException
{
version = in.readByte();
if ((version != 3) && (version != 2)) {
in.readByteArray(); // read all remaining bytes
throw new PGPDataFormatException("Unknown version for "+
"public key encrypted session key packet.");
}
keyid = new byte[8];
in.readFully(keyid);
pubalgid = in.readUnsignedByte();
I modified the PGP code to allow version 113 which the version that comes up when the data is being decrypted, but this gives me another error � �cryptix.message.MessageException: cryptix.openpgp.PGPDataFormatException: Zero length packet.�
Thanks for your help in advance
Joseph