Could save one check like this, but up to you:
```
if (value instanceof RSAPublicKey) {
  ..
} else if (value instanceof DSAPublicKey) {
  ..
} else {
  throw new ...
}
```