diff -r 92cbbfc996f3 -r 56aaa6cb3693 src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java Fri May 11 14:55:56 2018 -0700 +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java Fri May 11 15:53:12 2018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.security.interfaces.*; import java.security.spec.*; +import sun.security.rsa.RSAPublicKeyImpl; import static sun.security.pkcs11.TemplateManager.*; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; @@ -60,7 +61,7 @@ } else if ("X.509".equals(key.getFormat())) { // let SunRsaSign provider parse for us, then recurse byte[] encoded = key.getEncoded(); - key = new sun.security.rsa.RSAPublicKeyImpl(encoded); + key = RSAPublicKeyImpl.newKey(encoded); return implTranslatePublicKey(key); } else { throw new InvalidKeyException("PublicKey must be instance " @@ -113,7 +114,7 @@ if (keySpec instanceof X509EncodedKeySpec) { try { byte[] encoded = ((X509EncodedKeySpec)keySpec).getEncoded(); - PublicKey key = new sun.security.rsa.RSAPublicKeyImpl(encoded); + PublicKey key = RSAPublicKeyImpl.newKey(encoded); return implTranslatePublicKey(key); } catch (InvalidKeyException e) { throw new InvalidKeySpecException