Tag: pgp

Bouncycastle PGP解密并validation

我正在尝试使用java BouncyCastle库解密和validationPGP消息,但遇到了问题,抱怨PartialInputStream的过早结束。 我知道加密工作正常,因为我可以在命令行上使用gpg解密和validation使用加密函数创建的消息。 这是代码: public static void signEncryptMessage(InputStream in, OutputStream out, PGPPublicKey publicKey, PGPPrivateKey secretKey, SecureRandom rand) throws Exception { out = new ArmoredOutputStream(out); PGPEncryptedDataGenerator encryptedDataGenerator = new PGPEncryptedDataGenerator(new BcPGPDataEncryptorBuilder(PGPEncryptedData.AES_256).setWithIntegrityPacket(true).setSecureRandom(rand)); encryptedDataGenerator.addMethod(new BcPublicKeyKeyEncryptionMethodGenerator(publicKey)); OutputStream compressedOut = new PGPCompressedDataGenerator(PGPCompressedData.ZIP).open(encryptedDataGenerator.open(out, 4096), new byte[4096]); PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(new BcPGPContentSignerBuilder(publicKey.getAlgorithm(), HashAlgorithmTags.SHA512)); signatureGenerator.init(PGPSignature.BINARY_DOCUMENT, secretKey); signatureGenerator.generateOnePassVersion(true).encode(compressedOut); OutputStream finalOut = new PGPLiteralDataGenerator().open(compressedOut, […]

如何解密签名的pgp加密文件?

如何使用BouncyCastle Java API解密和validation使用PGP加密的文件?