Merge "Radio Interface changes to pass the encryption object, including the key,to the modem."
This commit is contained in:
@@ -17,6 +17,7 @@ package android.telephony;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import java.util.Date;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
@@ -34,22 +35,31 @@ import java.security.spec.X509EncodedKeySpec;
|
|||||||
public final class ImsiEncryptionInfo implements Parcelable {
|
public final class ImsiEncryptionInfo implements Parcelable {
|
||||||
|
|
||||||
private static final String LOG_TAG = "ImsiEncryptionInfo";
|
private static final String LOG_TAG = "ImsiEncryptionInfo";
|
||||||
private static final boolean DBG = false;
|
|
||||||
|
|
||||||
|
|
||||||
private final String mcc;
|
private final String mcc;
|
||||||
private final String mnc;
|
private final String mnc;
|
||||||
private final PublicKey publicKey;
|
private final PublicKey publicKey;
|
||||||
private final String keyIdentifier;
|
private final String keyIdentifier;
|
||||||
private final int keyType;
|
private final int keyType;
|
||||||
|
//Date-Time in UTC when the key will expire.
|
||||||
|
private final Date expirationTime;
|
||||||
|
|
||||||
public ImsiEncryptionInfo(String mcc, String mnc, int keyType, String keyIdentifier,
|
public ImsiEncryptionInfo(String mcc, String mnc, int keyType, String keyIdentifier,
|
||||||
PublicKey publicKey) {
|
byte[] key, Date expirationTime) {
|
||||||
|
this(mcc, mnc, keyType, keyIdentifier, makeKeyObject(key), expirationTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImsiEncryptionInfo(String mcc, String mnc, int keyType, String keyIdentifier,
|
||||||
|
PublicKey publicKey, Date expirationTime) {
|
||||||
|
// todo need to validate that ImsiEncryptionInfo is being created with the correct params.
|
||||||
|
// Including validating that the public key is in "X.509" format. This will be done in
|
||||||
|
// a subsequent CL.
|
||||||
this.mcc = mcc;
|
this.mcc = mcc;
|
||||||
this.mnc = mnc;
|
this.mnc = mnc;
|
||||||
this.keyType = keyType;
|
this.keyType = keyType;
|
||||||
this.publicKey = publicKey;
|
this.publicKey = publicKey;
|
||||||
this.keyIdentifier = keyIdentifier;
|
this.keyIdentifier = keyIdentifier;
|
||||||
|
this.expirationTime = expirationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImsiEncryptionInfo(Parcel in) {
|
public ImsiEncryptionInfo(Parcel in) {
|
||||||
@@ -61,7 +71,7 @@ public final class ImsiEncryptionInfo implements Parcelable {
|
|||||||
mnc = in.readString();
|
mnc = in.readString();
|
||||||
keyIdentifier = in.readString();
|
keyIdentifier = in.readString();
|
||||||
keyType = in.readInt();
|
keyType = in.readInt();
|
||||||
|
expirationTime = new Date(in.readLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMnc() {
|
public String getMnc() {
|
||||||
@@ -84,6 +94,10 @@ public final class ImsiEncryptionInfo implements Parcelable {
|
|||||||
return this.publicKey;
|
return this.publicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getExpirationTime() {
|
||||||
|
return this.expirationTime;
|
||||||
|
}
|
||||||
|
|
||||||
private static PublicKey makeKeyObject(byte[] publicKeyBytes) {
|
private static PublicKey makeKeyObject(byte[] publicKeyBytes) {
|
||||||
try {
|
try {
|
||||||
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(publicKeyBytes);
|
X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(publicKeyBytes);
|
||||||
@@ -91,7 +105,7 @@ public final class ImsiEncryptionInfo implements Parcelable {
|
|||||||
} catch (InvalidKeySpecException | NoSuchAlgorithmException ex) {
|
} catch (InvalidKeySpecException | NoSuchAlgorithmException ex) {
|
||||||
Log.e(LOG_TAG, "Error makeKeyObject: unable to convert into PublicKey", ex);
|
Log.e(LOG_TAG, "Error makeKeyObject: unable to convert into PublicKey", ex);
|
||||||
}
|
}
|
||||||
return null;
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Implement the Parcelable interface */
|
/** Implement the Parcelable interface */
|
||||||
@@ -122,6 +136,7 @@ public final class ImsiEncryptionInfo implements Parcelable {
|
|||||||
dest.writeString(mnc);
|
dest.writeString(mnc);
|
||||||
dest.writeString(keyIdentifier);
|
dest.writeString(keyIdentifier);
|
||||||
dest.writeInt(keyType);
|
dest.writeInt(keyType);
|
||||||
|
dest.writeLong(expirationTime.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,6 +147,7 @@ public final class ImsiEncryptionInfo implements Parcelable {
|
|||||||
+ "publicKey=" + publicKey
|
+ "publicKey=" + publicKey
|
||||||
+ ", keyIdentifier=" + keyIdentifier
|
+ ", keyIdentifier=" + keyIdentifier
|
||||||
+ ", keyType=" + keyType
|
+ ", keyType=" + keyType
|
||||||
|
+ ", expirationTime=" + expirationTime
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user