Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0611f477 authored by Kenny Root's avatar Kenny Root Committed by Android Git Automerger
Browse files

am 90e42717: Merge changes I5d2be3c5,I9017256b

* commit '90e42717':
  Add argument to binder call to check key types
  Use hostname verifier directly instead of instance
parents 5d34e4d6 90e42717
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -81,9 +81,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
        }
    };

    private static final HostnameVerifier HOSTNAME_VERIFIER =
        HttpsURLConnection.getDefaultHostnameVerifier();

    private SSLSocketFactory mInsecureFactory = null;
    private SSLSocketFactory mSecureFactory = null;
    private TrustManager[] mTrustManagers = null;
@@ -196,7 +193,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
            if (session == null) {
                throw new SSLException("Cannot verify SSL socket without session");
            }
            if (!HOSTNAME_VERIFIER.verify(hostname, session)) {
            if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(hostname, session)) {
                throw new SSLPeerUnverifiedException("Cannot verify hostname: " + hostname);
            }
        }
+3 −2
Original line number Diff line number Diff line
@@ -444,12 +444,13 @@ public interface IKeystoreService extends IInterface {
            }

            @Override
            public int is_hardware_backed() throws RemoteException {
            public int is_hardware_backed(String keyType) throws RemoteException {
                Parcel _data = Parcel.obtain();
                Parcel _reply = Parcel.obtain();
                int _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeString(keyType);
                    mRemote.transact(Stub.TRANSACTION_is_hardware_backed, _data, _reply, 0);
                    _reply.readException();
                    _result = _reply.readInt();
@@ -593,7 +594,7 @@ public interface IKeystoreService extends IInterface {
    public int duplicate(String srcKey, int srcUid, String destKey, int destUid)
            throws RemoteException;

    public int is_hardware_backed() throws RemoteException;
    public int is_hardware_backed(String string) throws RemoteException;

    public int clear_uid(long uid) throws RemoteException;
}
+4 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

@@ -364,7 +365,8 @@ public final class KeyChain {
     * "RSA").
     */
    public static boolean isKeyAlgorithmSupported(String algorithm) {
        return "RSA".equals(algorithm);
        final String algUpper = algorithm.toUpperCase(Locale.US);
        return "DSA".equals(algUpper) || "EC".equals(algUpper) || "RSA".equals(algUpper);
    }

    /**
@@ -379,7 +381,7 @@ public final class KeyChain {
            return false;
        }

        return KeyStore.getInstance().isHardwareBacked();
        return KeyStore.getInstance().isHardwareBacked(algorithm);
    }

    private static X509Certificate toCertificate(byte[] bytes) {
+8 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;

import java.util.Locale;

/**
 * @hide This should not be made public in its present form because it
 * assumes that private and secret key bytes are available and would
@@ -306,9 +308,14 @@ public class KeyStore {
        }
    }

    // TODO remove this when it's removed from Settings
    public boolean isHardwareBacked() {
        return isHardwareBacked("RSA");
    }

    public boolean isHardwareBacked(String keyType) {
        try {
            return mBinder.is_hardware_backed() == NO_ERROR;
            return mBinder.is_hardware_backed(keyType.toUpperCase(Locale.US)) == NO_ERROR;
        } catch (RemoteException e) {
            Log.w(TAG, "Cannot connect to keystore", e);
            return false;