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

Commit 2429df65 authored by pkanwar's avatar pkanwar Committed by Pankaj Kanwar
Browse files

Address IMSI privacy issues.

Added getCarrierInfoForImsiEncryption and
setCarrierInfoForImsiEncryption methods.

CP from master

Bug: 35606429
Test: runtest --path ..ImsiEncryptionInfoTest.java
Change-Id: I1b1f31b0e74a4ed8fb04d6362face696dfa5d4bf
parent 538289b3
Loading
Loading
Loading
Loading
+52 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.telephony;

import android.telephony.ImsiEncryptionInfo;

 /**
 * This class provides methods to retreive information from the CarrierKeyProvider.
 */
public class CarrierInfoManager {
    private static final String TAG = "CarrierInfoManager";

    /**
     * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
     * @param keyType whether the key is being used for WLAN or ePDG.
     * @return ImsiEncryptionInfo which contains the information including the public key to be
     *         used for encryption.
     */
    public static ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
        //TODO implementation will be done in subsequent CL.
        return null;
    }

    /**
     * Sets the Carrier specific information that will be used to encrypt the IMSI and IMPI.
     * This includes the public key and the key identifier. This information will be stored in the
     * device keystore.
     * @param imsiEncryptionInfo which includes the Key Type, the Public Key
     *        {@link java.security.PublicKey} and the Key Identifier.
     *        The keyIdentifier Attribute value pair that helps a server locate
     *        the private key to decrypt the permanent identity.
     */
    public static void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
        //TODO implementation will be done in subsequent CL.
        return;
    }
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@ import android.provider.Telephony;
import android.telecom.VideoProfile;
import android.telecom.VideoProfile;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.CellLocation;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
@@ -1490,6 +1491,16 @@ public class GsmCdmaPhone extends Phone {
        }
        }
    }
    }


    @Override
    public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
        return CarrierInfoManager.getCarrierInfoForImsiEncryption(keyType);
    }

    @Override
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
        CarrierInfoManager.setCarrierInfoForImsiEncryption(imsiEncryptionInfo);
    }

    @Override
    @Override
    public String getGroupIdLevel1() {
    public String getGroupIdLevel1() {
        if (isPhoneTypeGsm()) {
        if (isPhoneTypeGsm()) {
+23 −0
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import android.telephony.CellInfo;
import android.telephony.CellInfoCdma;
import android.telephony.CellInfoCdma;
import android.telephony.CellLocation;
import android.telephony.CellLocation;
import android.telephony.ClientRequestStats;
import android.telephony.ClientRequestStats;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneStateListener;
import android.telephony.PhoneStateListener;
import android.telephony.RadioAccessFamily;
import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.Rlog;
@@ -2925,6 +2926,28 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return mImsPhone;
        return mImsPhone;
    }
    }


    /**
     * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
     * @param keyType whether the key is being used for WLAN or ePDG.
     * @return ImsiEncryptionInfo which includes the Key Type, the Public Key
     *        {@link java.security.PublicKey} and the Key Identifier.
     *        The keyIdentifier This is used by the server to help it locate the private key to
     *        decrypt the permanent identity.
     */
    public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) {
        return null;
    }

    /**
     * Sets the carrier information needed to encrypt the IMSI and IMPI.
     * @param imsiEncryptionInfo Carrier specific information that will be used to encrypt the
     *        IMSI and IMPI. This includes the Key type, the Public key
     *        {@link java.security.PublicKey} and the Key identifier.
     */
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) {
        return;
    }

    /**
    /**
     * Return if UT capability of ImsPhone is enabled or not
     * Return if UT capability of ImsPhone is enabled or not
     */
     */
+20 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@ import android.os.ResultReceiver;
import android.os.WorkSource;
import android.os.WorkSource;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.CellLocation;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.ServiceState;


import com.android.internal.telephony.PhoneConstants.*; // ????
import com.android.internal.telephony.PhoneConstants.*; // ????
@@ -825,4 +827,22 @@ public interface PhoneInternalInterface {
     *            Callback message is empty on completion
     *            Callback message is empty on completion
     */
     */
    public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response);
    public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response);

    /*
    * Sets the carrier information needed to encrypt the IMSI and IMPI.
    * @param imsiEncryptionInfo Carrier specific information that will be used to encrypt the
    *        IMSI and IMPI. This includes the Key type, the Public key
    *        {@link java.security.PublicKey} and the Key identifier.
    */
    public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo);

    /**
     * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
     * @param keyType whether the key is being used for WLAN or ePDG.
     * @return ImsiEncryptionInfo which includes the Key Type, the Public Key
     *        {@link java.security.PublicKey} and the Key Identifier.
     *        The keyIdentifier This is used by the server to help it locate the private key to
     *        decrypt the permanent identity.
     */
    public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType);
}
}
+30 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Binder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.telephony.ImsiEncryptionInfo;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.Rlog;
import android.telephony.Rlog;
@@ -103,6 +104,35 @@ public class PhoneSubInfoController extends IPhoneSubInfo.Stub {
        }
        }
    }
    }


    public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int subId, int keyType,
            String callingPackage) {
        Phone phone = getPhone(subId);
        if (phone != null) {
            if (!checkReadPhoneState(callingPackage, "getCarrierInfoForImsiEncryption")) {
                return null;
            }
            return phone.getCarrierInfoForImsiEncryption(keyType);
        } else {
            loge("getCarrierInfoForImsiEncryption phone is null for Subscription:" + subId);
            return null;
        }
    }

    public void setCarrierInfoForImsiEncryption(int subId, String callingPackage,
                                                ImsiEncryptionInfo imsiEncryptionInfo) {
        Phone phone = getPhone(subId);
        if (phone != null) {
            if (!checkReadPhoneState(callingPackage, "setCarrierInfoForImsiEncryption")) {
                return;
            }
            phone.setCarrierInfoForImsiEncryption(imsiEncryptionInfo);
        } else {
            loge("setCarrierInfoForImsiEncryption phone is null for Subscription:" + subId);
            return;
        }
    }


    public String getDeviceSvn(String callingPackage) {
    public String getDeviceSvn(String callingPackage) {
        return getDeviceSvnUsingSubId(getDefaultSubscription(), callingPackage);
        return getDeviceSvnUsingSubId(getDefaultSubscription(), callingPackage);
    }
    }
Loading