getRSAPublicKey now returns a copy of the public key rather than the

object itself
This commit is contained in:
Dave
2015-01-06 23:54:15 +02:00
parent 4c2ae7fa8a
commit 88ceee62ac

View File

@@ -35,6 +35,7 @@ import java.security.NoSuchProviderException;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.security.spec.RSAPublicKeySpec;
import java.util.ArrayList; import java.util.ArrayList;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
@@ -157,7 +158,11 @@ public class NoUser implements Serializable {
} }
public final PublicKey getRSAPublicKey() { public final PublicKey getRSAPublicKey() {
return (RSAPublicKeyImpl) this.publicKey; try {
return new RSAPublicKeyImpl(this.getModulus(), this.getPublicExponent());
} catch (InvalidKeyException e) {
throw new NoDashFatalException("Invalid key while re-generating a RSAPublicKey.", e);
}
} }
private final byte[] decryptRSA(byte[] data) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { private final byte[] decryptRSA(byte[] data) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException {