Merge "Keystore 2.0: Fix diagnosing invalid key in CipherSpiBase."
This commit is contained in:
@@ -123,8 +123,9 @@ abstract class AndroidKeyStoreCipherSpiBase extends CipherSpi implements KeyStor
|
|||||||
throws InvalidKeyException {
|
throws InvalidKeyException {
|
||||||
resetAll();
|
resetAll();
|
||||||
|
|
||||||
if (!(key instanceof AndroidKeyStorePrivateKey
|
// Public key operations get diverted to the default provider.
|
||||||
|| key instanceof AndroidKeyStoreSecretKey)) {
|
if (opmode == Cipher.ENCRYPT_MODE
|
||||||
|
&& (key instanceof PrivateKey || key instanceof PublicKey)) {
|
||||||
try {
|
try {
|
||||||
mCipher = Cipher.getInstance(getTransform());
|
mCipher = Cipher.getInstance(getTransform());
|
||||||
String transform = getTransform();
|
String transform = getTransform();
|
||||||
@@ -184,8 +185,9 @@ abstract class AndroidKeyStoreCipherSpiBase extends CipherSpi implements KeyStor
|
|||||||
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException {
|
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException {
|
||||||
resetAll();
|
resetAll();
|
||||||
|
|
||||||
if (!(key instanceof AndroidKeyStorePrivateKey
|
// Public key operations get diverted to the default provider.
|
||||||
|| key instanceof AndroidKeyStoreSecretKey)) {
|
if (opmode == Cipher.ENCRYPT_MODE
|
||||||
|
&& (key instanceof PrivateKey || key instanceof PublicKey)) {
|
||||||
try {
|
try {
|
||||||
mCipher = Cipher.getInstance(getTransform());
|
mCipher = Cipher.getInstance(getTransform());
|
||||||
mCipher.init(opmode, key, params, random);
|
mCipher.init(opmode, key, params, random);
|
||||||
@@ -213,8 +215,9 @@ abstract class AndroidKeyStoreCipherSpiBase extends CipherSpi implements KeyStor
|
|||||||
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException {
|
SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException {
|
||||||
resetAll();
|
resetAll();
|
||||||
|
|
||||||
if (!(key instanceof AndroidKeyStorePrivateKey
|
// Public key operations get diverted to the default provider.
|
||||||
|| key instanceof AndroidKeyStoreSecretKey)) {
|
if (opmode == Cipher.ENCRYPT_MODE
|
||||||
|
&& (key instanceof PrivateKey || key instanceof PublicKey)) {
|
||||||
try {
|
try {
|
||||||
mCipher = Cipher.getInstance(getTransform());
|
mCipher = Cipher.getInstance(getTransform());
|
||||||
mCipher.init(opmode, key, params, random);
|
mCipher.init(opmode, key, params, random);
|
||||||
|
|||||||
Reference in New Issue
Block a user