Disallow KeyFactory.translateKey between public and private

This fixes the bug where OpenSSL-backed KeyFactory instances (RSA,
DSA, EC) could translateKey from PrivateKey to PublicKey and vice
versa when presented with "opaque" keys whose translation is
performed via their primary encoded form.

(cherry picked from commit ddee4ef28dcce942e25fd7a24f27239cd74807fa)

Change-Id: Ia24a2591a06ac82c5225a3a9e3069af7a01a0c37
3 files changed