1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-14 12:49:39 +02:00

Remove workaround for publicKey.getBitStrength() == -1 in BC

see https://github.com/bcgit/bc-java/issues/972
This commit is contained in:
Paul Schaub 2022-01-10 14:38:58 +01:00
parent e374951ed0
commit 01839728f0
4 changed files with 10 additions and 53 deletions

View file

@ -29,9 +29,8 @@ import org.pgpainless.key.generation.type.rsa.RsaLength;
import org.pgpainless.key.generation.type.xdh.XDHSpec;
import org.pgpainless.key.info.KeyInfo;
import org.pgpainless.key.util.UserId;
import org.pgpainless.util.BCUtil;
import org.pgpainless.util.TestAllImplementations;
import org.pgpainless.util.Passphrase;
import org.pgpainless.util.TestAllImplementations;
public class BrainpoolKeyGenerationTest {
@ -96,22 +95,22 @@ public class BrainpoolKeyGenerationTest {
PGPSecretKey ecdsaPrim = iterator.next();
KeyInfo ecdsaInfo = new KeyInfo(ecdsaPrim);
assertEquals(EllipticCurve._BRAINPOOLP384R1.getName(), ecdsaInfo.getCurveName());
assertEquals(384, BCUtil.getBitStrength(ecdsaPrim.getPublicKey()));
assertEquals(384, ecdsaPrim.getPublicKey().getBitStrength());
PGPSecretKey eddsaSub = iterator.next();
KeyInfo eddsaInfo = new KeyInfo(eddsaSub);
assertEquals(EdDSACurve._Ed25519.getName(), eddsaInfo.getCurveName());
assertEquals(256, BCUtil.getBitStrength(eddsaSub.getPublicKey()));
assertEquals(256, eddsaSub.getPublicKey().getBitStrength());
PGPSecretKey xdhSub = iterator.next();
KeyInfo xdhInfo = new KeyInfo(xdhSub);
assertEquals(XDHSpec._X25519.getCurveName(), xdhInfo.getCurveName());
assertEquals(256, BCUtil.getBitStrength(xdhSub.getPublicKey()));
assertEquals(256, xdhSub.getPublicKey().getBitStrength());
PGPSecretKey rsaSub = iterator.next();
KeyInfo rsaInfo = new KeyInfo(rsaSub);
assertThrows(IllegalArgumentException.class, rsaInfo::getCurveName, "RSA is not a curve-based encryption system");
assertEquals(3072, BCUtil.getBitStrength(rsaSub.getPublicKey()));
assertEquals(3072, rsaSub.getPublicKey().getBitStrength());
}
public PGPSecretKeyRing generateKey(KeySpec primaryKey, KeySpec subKey, String userId) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {