Skip to content

Change in encrypted cipher (after 1.80) ! #2208

@Muthu-Palaniyappan-OL

Description

@Muthu-Palaniyappan-OL
    String staticVector = "lbsTNi0WXIg=";
    String password = "HJQScqUp1l3zfy27RA4dvAE251WW2T+rKb7JQOXgvMQB7hCl/VFQE3WXyAL4PYRmIo8gK/kqQu/UykAiThrDYOVynrUED0Cg==KiT2on42Kp";
    String inputTextMsg = "Hi";

    SecureRandom consistentSecureRandom = new ConsistentByteProvider(Base64.decodeBase64(staticVector));
    JcePGPDataEncryptorBuilder builder = new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5);
    builder.setWithIntegrityPacket(false);
    builder.setSecureRandom(consistentSecureRandom);
    PGPEncryptedDataGenerator generator = new PGPEncryptedDataGenerator(builder);
    generator.setForceSessionKey(false);
    JcePBEKeyEncryptionMethodGenerator method = new JcePBEKeyEncryptionMethodGenerator(
        password.toCharArray(), 
        1
    );
    method.setSecureRandom(consistentSecureRandom);
    generator.addMethod(method);
    ByteArrayOutputStream encOut = new ByteArrayOutputStream();
    OutputStream cOut = generator.open(encOut, new byte[1024]);

    cOut.write(inputTextMsg.getBytes());
    cOut.close();

    byte[] encrypted = encOut.toByteArray();

After bouncycastle 1.80, i believe we changed the way we generate OPENPGP encrypted cipherTexts (i mostly think it's because of => #1938) ?

I could see this because if i run the above code in 1.78 encrypted byte size is 40 byte and the same code in 1.80 it gives me 64 bytes !! Yes, i can still decrypt the msg encrypted using 1.78 !! but i would like to have a simple toggle to bring back the old behaviour !

Do you guys have a way to bring back the old behaviour ? If there is a toggle to bring back the old packet size it would be better !

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions