Skip to content

Commit

Permalink
Prevent conversion issue for EdDSA keys with leading 0
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Jun 2, 2024
1 parent 7cb20f8 commit 47ca97b
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,22 +367,13 @@ else if (ecdhK.getCurveOID().equals(EdECObjectIdentifiers.id_X448))
// Modern Ed25519 (1.3.6.1.4.1.11591.15.1 & 1.3.101.112)
case PublicKeyAlgorithmTags.Ed25519:
{
BCPGKey key = publicPk.getKey();
if (key instanceof Ed25519PublicBCPGKey)
{
return implGetPublicKeyX509(BigIntegers.asUnsignedByteArray(new BigInteger(1, publicPk.getKey().getEncoded())),
0, EdECObjectIdentifiers.id_Ed25519, "EdDSA");
}
else
{
return implGetPublicKeyX509(BigIntegers.asUnsignedByteArray(((EdDSAPublicBCPGKey)publicPk.getKey()).getEncodedPoint()),
return implGetPublicKeyX509(publicPk.getKey().getEncoded(),
0, EdECObjectIdentifiers.id_Ed25519, "EdDSA");
}
}
// Modern Ed448 (1.3.101.113)
case PublicKeyAlgorithmTags.Ed448:
{
return implGetPublicKeyX509(BigIntegers.asUnsignedByteArray(new BigInteger(1, publicPk.getKey().getEncoded())),
return implGetPublicKeyX509(publicPk.getKey().getEncoded(),
0, EdECObjectIdentifiers.id_Ed448, "EdDSA");
}
case PublicKeyAlgorithmTags.ELGAMAL_ENCRYPT:
Expand Down

0 comments on commit 47ca97b

Please sign in to comment.