On 2017-08-08 21:42, Xuelei Fan wrote:
On 8/8/2017 8:45 AM, Anders Rundgren wrote:
Object myOwnEncrypt(PublicKey publicKey) throws SecurityException {
if (publicKey instanceof RSAKey) {
// RSA
} else {
// It should be EC
}
}
The code above is not reliable unless one understand the underlying
JCA/JCE provider behavior exactly this way. For a certain provider, an
RSA key may be not an instance of RSAKey. I would use
key.getAlgorithm() instead.
You mean that some providers do not always adhere even to RSAPublicKey (which
extends RSAKey)?
Well, then there's a lot of broken stuff out there.
Anders
Xuelei
CC:ing the creator of OKP keys.
https://tools.ietf.org/html/rfc8037#section-2
Anders