Skip to content

Commit

Permalink
Replace lambdas in JcaPGPKeyConverter with anonymous classes
Browse files Browse the repository at this point in the history
  • Loading branch information
gefeili committed Dec 18, 2024
1 parent 716cb36 commit 9ef9d60
Showing 1 changed file with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,24 +795,52 @@ else if (pubKey.getAlgorithm().regionMatches(true, 0, "XDH", 0, 3))
// Modern Ed25519 (1.3.6.1.4.1.11591.15.1 & 1.3.101.112)
case PublicKeyAlgorithmTags.Ed25519:
{
return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, Ed25519PublicBCPGKey::new);
return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, new BCPGKeyOperation()
{
@Override
public BCPGKey getBCPGKey(byte[] key)
{
return new Ed25519PublicBCPGKey(key);
}
});
}

// Modern Ed448 (1.3.101.113)
case PublicKeyAlgorithmTags.Ed448:
{
return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, Ed448PublicBCPGKey::new);
return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, new BCPGKeyOperation()
{
@Override
public BCPGKey getBCPGKey(byte[] key)
{
return new Ed448PublicBCPGKey(key);
}
});
}

// Modern X25519 (1.3.6.1.4.1.3029.1.5.1 & 1.3.101.110)
case PublicKeyAlgorithmTags.X25519:
{
return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, X25519PublicBCPGKey::new);
return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, new BCPGKeyOperation()
{
@Override
public BCPGKey getBCPGKey(byte[] key)
{
return new X25519PublicBCPGKey(key);
}
});
}
// Modern X448 (1.3.101.111)
case PublicKeyAlgorithmTags.X448:
{
return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, X448PublicBCPGKey::new);
return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, new BCPGKeyOperation()
{
@Override
public BCPGKey getBCPGKey(byte[] key)
{
return new X448PublicBCPGKey(key);
}
});
}

default:
Expand Down

0 comments on commit 9ef9d60

Please sign in to comment.