问题
使用Bouncy Castle加密的邮件将被gpg版本2解密,但是没有gpg版本1的错误。
问题
加密GnuPG消息
以下Java类将消息加密为PGP加密消息:
@Test
public void testEncryptPGP() throws Exception {
GnuPG gpg = new GnuPG();
String res = gpg.encryptPGP(pgpKey, msg);
System.out.println(res);
}
这个小junit做了一个简单的测试来加密“Hello world!”
HttpResponseRedirect
使用gpg2进行解密会导致臭名昭着的无效数据包错误,但邮件将被解密。
$ LANG=C gpg2 -vvvv -d xxx.asc > xxx.txt gpg: using character set 'iso-8859-1' gpg: armor: BEGIN PGP MESSAGE gpg: armor header: Version: BCPG v1.53 # off=0 ctb=85 tag=1 hlen=3 plen=524 :pubkey enc packet: version 3, algo 1, keyid *** data: [4096 bits] gpg: public key is *** gpg: public key encrypted data: good DEK # off=527 ctb=d2 tag=18 hlen=3 plen=4137 new-ctb :encrypted data packet: length: 4137 mdc_method: 2 gpg: encrypted with 4096-bit RSA key, ID ***, created 2013-09-01 "Hostmaster <hostmaster@example.com>" gpg: AES256 encrypted data # off=549 ctb=c8 tag=8 hlen=2 plen=31 new-ctb :compressed packet: algo=1 # off=552 ctb=cb tag=11 hlen=2 plen=26 new-ctb :literal data packet: mode b (62), created 1450355926, name="_CONSOLE", raw data: 12 bytes gpg: Note: sender requested "for-your-eyes-only" gpg: decryption failed: Invalid packet
现在与gpg版本1相同 - 没有错误。
gpg: using character set iso-8859-1 gpg: armor: BEGIN PGP MESSAGE gpg: armor header: Version: BCPG v1.53 :pubkey enc packet: version 3, algo 1, keyid *** data: [4096 bits] gpg: public key is *** You need a passphrase to unlock the secret key for user: "Hostmaster <hostmaster@example.com>" 4096-bit RSA key, ID ***, created 2013-09-01 gpg: public key encrypted data: good DEK :encrypted data packet: length: 4137 mdc_method: 2 gpg: encrypted with 4096-bit RSA key, ID ***, created 2013-09-01 "Hostmaster <hostmaster@example.com>" gpg: AES256 encrypted data :compressed packet: algo=1 :literal data packet: mode b (62), created 1450355926, name="_CONSOLE", raw data: 12 bytes gpg: NOTE: sender requested "for-your-eyes-only" gpg: decryption okay