Hi,
I am using BouncyCastle library for cryptography. I was using DSA/RSA keys initially to transfer the message and it was all working fine
Now I have to switch to DSA + ElGamal key pair for the signing/encryption of the message. but it doesn't seems to be working.
The first step that I perform before sending the message is signing. here is the snippet
...
PGPSignatureGenerator signer = new PGPSignatureGenerator(signingKey.getPublicKey().getAlgorithm(), PGPUtil.SHA256, PgpConfigurationData.BOUNCE_CASTLE_NAME);
...
where signingKey is the secret key. The "signingKey.getPublicKey().getAlgorithm()" return 16 , which is basically evaluates to "ELGAMAL_ENCRYPT" and an exception is thrown "no such algorithm: SHA256withElGamal for provider BC"
....
case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT: // in some malformed cases.
case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
encAlg = "ElGamal";
break;
default:
throw new PGPException("unknown algorithm tag in signature:" + keyAlgorithm);
....
I am using the gpg --gen-key utility in unix . The option that is gives during key creation are
- (1) DSA and Elgamal (default)
- (2) DSA (sign only)
- (5) RSA (sign only
)
I don't understand where is the problem , Am I generation the keys incorrectly or do I have to switch to some other provider.
Thanks!