Bouncy Castle PGP Decryption Issue

后端 未结 2 2009
一整个雨季
一整个雨季 2021-02-18 21:37

I\'ve had a application using Bouncy Castle for PGP decryption which has run without any issues for the past 8 months or so, and the past 2 days all of a sudden an issue has com

2条回答
  •  清酒与你
    2021-02-18 22:10

    This could be important (Source: http://www.opensourcejavaphp.net/csharp/itextsharp/PgpPublicKeyEncryptedData.cs.html) :

    It explains the value of your keyData.Algorithm being different, but the why I am still unsure of. It is most likely the input file that is the case. It could be different (client using a different key?)

    private static IBufferedCipher GetKeyCipher(
                PublicKeyAlgorithmTag algorithm)
            {
                try
                {
                    switch (algorithm)
                    {
                        case PublicKeyAlgorithmTag.RsaEncrypt:
                        case PublicKeyAlgorithmTag.RsaGeneral:
                            return CipherUtilities.GetCipher("RSA//PKCS1Padding");
                        case PublicKeyAlgorithmTag.ElGamalEncrypt:
                        case PublicKeyAlgorithmTag.ElGamalGeneral:
                            return CipherUtilities.GetCipher("ElGamal/ECB/PKCS1Padding");
                        default:
                            throw new PgpException("unknown asymmetric algorithm: " + algorithm);
                    }
                }
                catch (PgpException e)
                {
                    throw e;
                }
                catch (Exception e)
                {
                    throw new PgpException("Exception creating cipher", e);
                }
            }
    

提交回复
热议问题