In the main package of suppliers there is a utility class PublicKeyFactory . The createKey method returns an AsymmetricKeyParameter that you use for any type of public key, for example,
SubjectPublicKeyInfo pkInfo = pkcs10CertReq.getSubjectPublicKeyInfo(); RSAKeyParameters rsa = (RSAKeyParameters) PublicKeyFactory.createKey(pkInfo);
EDIT 1:
In addition, to create java.security.PublicKey
you need to follow several steps:
RSAPublicKeySpec rsaSpec = new RSAPublicKeySpec(rsa.getModulus(), rsa.getExponent()); KeyFactory kf = KeyFactory.getInstance("RSA"); PublicKey rsaPub = kf.generatePublic(rsaSpec);
source share