Discussion:
ElGamal signature?
Marco หงุ่ยตระกูล-Schulze
2014-09-17 04:13:03 UTC
Permalink
Hello *,

I tried to sign (and verify) using ElGamal in analogy to RSA like this:

AsymmetricCipherKeyPairGenerator keyPairGenerator = new
ElGamalKeyPairGenerator();
// Found here:
http://stackoverflow.com/questions/13733260/generate-dsa-elgamal-key-pair-with-bouncy-castle-that-imports-in-gpg-without-err
// Generating a safe prime is a very long process so it's better to use
// a pre-generated safe prime, I took this from
http://www.cryptopp.com/fom-serve/cache/71.html
BigInteger primeModulous = new BigInteger("36F0255DDE....
BigInteger baseGenerator = new BigInteger("2", 16);
keyPairGenerator.init(new ElGamalKeyGenerationParameters(random, new
ElGamalParameters(primeModulous, baseGenerator)));
AsymmetricCipherKeyPair keyPair = keyPairGenerator.generateKeyPair();

Signer signer = new GenericSigner(new ElGamalEngine(), new SHA1Digest());
signer.init(true, keyPair.getPrivate());

The last line fails:

java.lang.IllegalArgumentException: ElGamalPublicKeyParameters are
required for encryption.
at org.bouncycastle.crypto.engines.ElGamalEngine.init(Unknown Source)
at org.bouncycastle.crypto.signers.GenericSigner.init(Unknown Source)
at
co.codewizards.bc20140916.BcSignerTest.signAndVerifyElGamalManyRoundsGeneratedKey(BcSignerTest.java:172)
...

Is this a bug or does this mean, I cannot use every
AsymmetricBlockCipher with a GenericSigner? Which are supported besides
RSAEngine?

Best regards, Marco :-)
David Hook
2014-09-17 05:15:22 UTC
Permalink
Only RSA for signing.

The bug with the GenericSigner is now fixed - update on github appearing
shortly.

Regards,

David
Post by Marco หงุ่ยตระกูล-Schulze
Hello *,
AsymmetricCipherKeyPairGenerator keyPairGenerator = new
ElGamalKeyPairGenerator();
http://stackoverflow.com/questions/13733260/generate-dsa-elgamal-key-pair-with-bouncy-castle-that-imports-in-gpg-without-err
// Generating a safe prime is a very long process so it's better to use
// a pre-generated safe prime, I took this from
http://www.cryptopp.com/fom-serve/cache/71.html
BigInteger primeModulous = new BigInteger("36F0255DDE....
BigInteger baseGenerator = new BigInteger("2", 16);
keyPairGenerator.init(new ElGamalKeyGenerationParameters(random, new
ElGamalParameters(primeModulous, baseGenerator)));
AsymmetricCipherKeyPair keyPair = keyPairGenerator.generateKeyPair();
Signer signer = new GenericSigner(new ElGamalEngine(), new SHA1Digest());
signer.init(true, keyPair.getPrivate());
java.lang.IllegalArgumentException: ElGamalPublicKeyParameters are
required for encryption.
at org.bouncycastle.crypto.engines.ElGamalEngine.init(Unknown Source)
at org.bouncycastle.crypto.signers.GenericSigner.init(Unknown Source)
at
co.codewizards.bc20140916.BcSignerTest.signAndVerifyElGamalManyRoundsGeneratedKey(BcSignerTest.java:172)
...
Is this a bug or does this mean, I cannot use every
AsymmetricBlockCipher with a GenericSigner? Which are supported besides
RSAEngine?
Best regards, Marco :-)
Marco หงุ่ยตระกูล-Schulze
2014-09-18 17:18:35 UTC
Permalink
Hello David,

thanks a lot for the clarification concerning the GenericSigner and most
importantly for fixing the signature bug! Especially the speed of your
bugfix is impressive!

When will there be a new release?

Are there SNAPSHOT JARs on any maven repository? I searched for them but
found only real releases.

I checked out from GitHub and tried to build BC myself using Gradle, but
I'm getting the following error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':mail:compile'.
Could not resolve javax.mail:mail:1.4.+.
Required by:
bc-java:mail:1.51-b08
Could not GET
'http://repo1.maven.org/maven2/javax/mail/mail/1.4.7/mail-1.4.7.pom'.
Connection reset
I tried it multiple times yesterday and today. I don't think it's a
problem of my internet connection here, because other builds work fine
and it's always the same file (if it was a network error, it would
likely affect different files). Is this a known problem of the central
maven repository? Is there any known workaround?

Best regards, Marco :-)
Only RSA for signing.
The bug with the GenericSigner is now fixed - update on github
appearing shortly.
Regards,
David
David Hook
2014-09-23 07:02:52 UTC
Permalink
There's now a new beta in

http://www.bouncycastle.org/betas

Regards,

David
Post by Marco หงุ่ยตระกูล-Schulze
Hello David,
thanks a lot for the clarification concerning the GenericSigner and most
importantly for fixing the signature bug! Especially the speed of your
bugfix is impressive!
When will there be a new release?
Are there SNAPSHOT JARs on any maven repository? I searched for them but
found only real releases.
I checked out from GitHub and tried to build BC myself using Gradle, but
FAILURE: Build failed with an exception.
Could not resolve all dependencies for configuration ':mail:compile'.
Could not resolve javax.mail:mail:1.4.+.
bc-java:mail:1.51-b08
Could not GET
'http://repo1.maven.org/maven2/javax/mail/mail/1.4.7/mail-1.4.7.pom'.
Connection reset
I tried it multiple times yesterday and today. I don't think it's a
problem of my internet connection here, because other builds work fine
and it's always the same file (if it was a network error, it would
likely affect different files). Is this a known problem of the central
maven repository? Is there any known workaround?
Best regards, Marco :-)
Only RSA for signing.
The bug with the GenericSigner is now fixed - update on github
appearing shortly.
Regards,
David
Loading...