1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 06:12:06 +01:00

Rename PublicKeyAlgorithm.EDDSA to EDDSA_LEGACY

This commit is contained in:
Paul Schaub 2024-02-21 14:52:48 +01:00
parent 412f804eee
commit e933af94c7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
8 changed files with 10 additions and 10 deletions

View file

@ -16,7 +16,7 @@ import org.pgpainless.key.generation.type.eddsa.EdDSACurve
/**
* For secret keys of types [PublicKeyAlgorithm.ECDSA], [PublicKeyAlgorithm.ECDH] and
* [PublicKeyAlgorithm.EDDSA], this method returns the name of the underlying elliptic curve.
* [PublicKeyAlgorithm.EDDSA_LEGACY], this method returns the name of the underlying elliptic curve.
*
* For other key types or unknown curves, this method throws an [IllegalArgumentException].
*
@ -28,7 +28,7 @@ fun PGPPublicKey.getCurveName(): String {
when (it) {
PublicKeyAlgorithm.ECDSA -> publicKeyPacket.key as ECDSAPublicBCPGKey
PublicKeyAlgorithm.ECDH -> publicKeyPacket.key as ECDHPublicBCPGKey
PublicKeyAlgorithm.EDDSA -> publicKeyPacket.key as EdDSAPublicBCPGKey
PublicKeyAlgorithm.EDDSA_LEGACY -> publicKeyPacket.key as EdDSAPublicBCPGKey
else -> throw IllegalArgumentException("No an elliptic curve public key ($it).")
}
}

View file

@ -60,7 +60,7 @@ enum class PublicKeyAlgorithm(
DIFFIE_HELLMAN(21, false, true),
/** Digital Signature Algorithm based on twisted Edwards Curves. */
EDDSA(22, true, false),
EDDSA_LEGACY(22, true, false),
;
fun isSigningCapable(): Boolean = signingCapable

View file

@ -10,7 +10,7 @@ import org.pgpainless.key.generation.type.KeyType
class EdDSA private constructor(val curve: EdDSACurve) : KeyType {
override val name = "EdDSA"
override val algorithm = PublicKeyAlgorithm.EDDSA
override val algorithm = PublicKeyAlgorithm.EDDSA_LEGACY
override val bitStrength = curve.bitStrength
override val algorithmSpec = ECNamedCurveGenParameterSpec(curve.curveName)

View file

@ -374,7 +374,7 @@ class Policy(
put(PublicKeyAlgorithm.ECDSA, 250)
// Note: EdDSA is not mentioned in the BSI document.
// We assume that the requirements are similar to other EC algorithms.
put(PublicKeyAlgorithm.EDDSA, 250)
put(PublicKeyAlgorithm.EDDSA_LEGACY, 250)
// §7.2.1
put(PublicKeyAlgorithm.DIFFIE_HELLMAN, 2000)
// §7.2.2

View file

@ -74,9 +74,9 @@ public class GenerateKeys {
KeyRingInfo keyInfo = new KeyRingInfo(secretKey);
assertEquals(3, keyInfo.getSecretKeys().size());
assertEquals(userId, keyInfo.getPrimaryUserId());
assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(),
assertEquals(PublicKeyAlgorithm.EDDSA_LEGACY.getAlgorithmId(),
keyInfo.getPublicKey().getAlgorithm());
assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(),
assertEquals(PublicKeyAlgorithm.EDDSA_LEGACY.getAlgorithmId(),
keyInfo.getSigningSubkeys().get(0).getAlgorithm());
assertEquals(PublicKeyAlgorithm.ECDH.getAlgorithmId(),
keyInfo.getEncryptionSubkeys(EncryptionPurpose.ANY).get(0).getAlgorithm());

View file

@ -38,7 +38,7 @@ public class GenerateEllipticCurveKeyTest {
.addUserId(UserId.onlyEmail("alice@wonderland.lit").toString())
.build();
assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(), keyRing.getPublicKey().getAlgorithm());
assertEquals(PublicKeyAlgorithm.EDDSA_LEGACY.getAlgorithmId(), keyRing.getPublicKey().getAlgorithm());
UnlockSecretKey.unlockSecretKey(keyRing.getSecretKey(), SecretKeyRingProtector.unprotectedKeys());
}
}

View file

@ -67,7 +67,7 @@ public class RefuseToAddWeakSubkeyTest {
minimalBitStrengths.put(PublicKeyAlgorithm.ECDSA, 250);
// Note: EdDSA is not mentioned in the BSI document.
// We assume that the requirements are similar to other EC algorithms.
minimalBitStrengths.put(PublicKeyAlgorithm.EDDSA, 250);
minimalBitStrengths.put(PublicKeyAlgorithm.EDDSA_LEGACY, 250);
// §7.2.1
minimalBitStrengths.put(PublicKeyAlgorithm.DIFFIE_HELLMAN, 2000);
// §7.2.2

View file

@ -144,7 +144,7 @@ public class OnePassSignatureBracketingTest {
// 4 is hash algo
assertEquals(HashAlgorithm.SHA512.getAlgorithmId(), encoded[4]);
// 5 is public key algo
assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(), encoded[5]);
assertEquals(PublicKeyAlgorithm.EDDSA_LEGACY.getAlgorithmId(), encoded[5]);
// [6,7,8,9,10,11,12,13] are key-id
boolean last = i == signatures.size() - 1;