views:

2662

answers:

1

We need to PGP encrypt files and send them over FTP to a third party. The files are encrypted with the DH/DSS public key of the third party and signed with our private key.

The third party have our public key and their own private key. The encryption/decryption works, but the third party are getting warnings when they try to verify our signature.

When we try to decrypt and verify similarly encrypted files using PGP Desktop the files verify without warning.

The third party are using "McAfee E-Business Server"

The exact warning is: WARNING: Bad signature, doesn't match file contents! Bad signature from user "users name" [email protected]

The code is a little involved, but I posted it on my blog. I can post it here instead of a link if that is more appropriate.

Any insight as to how to solve this issue is appreciated.

+1  A: 

While I can't give a thorough explanation as to the details of the problem, here is a solution that works. First of all it seems that the different PGP implementations are very sensitive to which program was used to genereate the keys in use.

The failing scenario:

  1. Create keys in PGP Desktop (RSA v4, 2048/2048)
  2. Encrypt in BouncyCastle (DH/DSS, Elgamal)
  3. Sign in BouncyCastle (With the RSA key)
  4. Decryption and signature verification success in PGP Desktop.
  5. Decryption success but signature verification fails in McAfee Business Server.

In order to make McAfee Business Server succeed in verifying the keys either create the keys in BouncyCastle using the code from the BouncyCastle source code.(Org.BouncyCastle.Bcpg.OpenPgp.Examples.RsaKeyRingGenerator) This code can be changed if you need specific key properties.

Another alternative is to use McAfee Business Server to generate the keys. For that you need access to the software. I did my tests with a trial version. (Which by the way was a pain in the neck to get up and running)

Update: I did all my tests on E-Business Server 8.5.3 (trial). I reached the point where I could encrypt and sign in Bounty and decrypt and verify in E-Business Server. Turns out the third party are using E-Business Server 7.0 which refused to verify the signature. In order to get everything working we needed to create V3 signatures.

We changed from:

PgpSignatureGenerator pgpSignatureGenerator = new PgpSignatureGenerator(m_encryptionKeys.SecretKey.PublicKey.Algorithm, HashAlgorithmTag.Sha1);

to

PgpV3SignatureGenerator pgpV3SignatureGenerator = new PgpV3SignatureGenerator(m_encryptionKeys.SecretKey.PublicKey.Algorithm, HashAlgorithmTag.Sha1);
Kim Major