2

I get some warnings due to use of RSAPublicKeyImpl:

warning: RSAPublicKeyImpl is internal proprietary API and may be removed in a future release import sun.security.rsa.RSAPublicKeyImpl;

I have tried to find a replacement, but with no luck. What is the open source alternative for this class?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Eugenio Cuevas
  • 10,858
  • 3
  • 29
  • 51

2 Answers2

9

class RSAPublicKeySpec supports at least a part of the implementation that you're looking for. Namely it can be created from the exponent and modulus as BigInteger.

You can use this to get an RSAPublicKey from an encoded byte[]:

RSAPublicKey publicKey = (RSAPublicKey)KeyFactory.getInstance("RSA").generatePublic(
        new X509EncodedKeySpec(bytes));
Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • 1
    Just small note for PrivateKey - RSAPrivateKey privateKey = (RSAPrivateKey) KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(priv)); works in similar way – kulatamicuda May 28 '19 at 15:39
0

I am not sure, but try Bouncy castle library https://www.bouncycastle.org/java.html

Several mounth ago I also had same issue as you, and I successfully solved it by using AES cryptyng alghoritm

user2858470
  • 113
  • 1
  • 2
  • 9