aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Kesting <ckesting@google.com>2019-08-14 20:12:08 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-08-14 20:12:08 +0000
commit245b55ed3a41b1428ff8ef1f25530037086ae8f4 (patch)
tree94096b46ca8a56c755ffc960a7ef0736ce9d4c9f
parentf32cda311c18bf7727d54fd275f81009f7b54d78 (diff)
parentd58e65d2198c91469bed5f3f865c21ce69d150fe (diff)
downloadike-245b55ed3a41b1428ff8ef1f25530037086ae8f4.tar.gz
Merge "Require UICC Apptype for authentication in EAP."
-rw-r--r--src/java/com/android/ike/eap/EapSessionConfig.java15
-rw-r--r--src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachine.java2
-rw-r--r--tests/iketests/src/java/com/android/ike/eap/EapSessionConfigTest.java8
-rw-r--r--tests/iketests/src/java/com/android/ike/eap/EapSimTest.java6
-rw-r--r--tests/iketests/src/java/com/android/ike/eap/EapTestUtils.java4
-rw-r--r--tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachineTest.java4
-rw-r--r--tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimStateTest.java4
-rw-r--r--tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java5
8 files changed, 34 insertions, 14 deletions
diff --git a/src/java/com/android/ike/eap/EapSessionConfig.java b/src/java/com/android/ike/eap/EapSessionConfig.java
index 255bdfba..a5e55273 100644
--- a/src/java/com/android/ike/eap/EapSessionConfig.java
+++ b/src/java/com/android/ike/eap/EapSessionConfig.java
@@ -18,6 +18,8 @@ package com.android.ike.eap;
import static com.android.ike.eap.message.EapData.EAP_TYPE_SIM;
+import android.telephony.TelephonyManager.UiccAppType;
+
import com.android.ike.eap.message.EapData.EapMethod;
import com.android.internal.annotations.VisibleForTesting;
@@ -73,10 +75,11 @@ public final class EapSessionConfig {
* Sets the configuration for EAP SIM.
*
* @param subId int the client's subId to be authenticated
+ * @param apptype the {@link UiccAppType} apptype to be used for authentication
* @return Builder this, to facilitate chaining.
*/
- public Builder setEapSimConfig(int subId) {
- mEapConfigs.put(EAP_TYPE_SIM, new EapSimConfig(subId));
+ public Builder setEapSimConfig(int subId, @UiccAppType int apptype) {
+ mEapConfigs.put(EAP_TYPE_SIM, new EapSimConfig(subId, apptype));
return this;
}
@@ -107,10 +110,12 @@ public final class EapSessionConfig {
private abstract static class EapUiccConfig extends EapMethodConfig {
public final int subId;
+ public final int apptype;
- private EapUiccConfig(@EapMethod int methodType, int subId) {
+ private EapUiccConfig(@EapMethod int methodType, int subId, @UiccAppType int apptype) {
super(methodType);
this.subId = subId;
+ this.apptype = apptype;
}
}
@@ -119,8 +124,8 @@ public final class EapSessionConfig {
*/
public static class EapSimConfig extends EapUiccConfig {
@VisibleForTesting
- public EapSimConfig(int subId) {
- super(EAP_TYPE_SIM, subId);
+ public EapSimConfig(int subId, @UiccAppType int apptype) {
+ super(EAP_TYPE_SIM, subId, apptype);
}
}
}
diff --git a/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachine.java b/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachine.java
index a9e73f53..0cf5180a 100644
--- a/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachine.java
+++ b/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachine.java
@@ -531,7 +531,7 @@ class EapSimMethodStateMachine extends EapMethodStateMachine {
String base64Challenge =
Base64.encodeToString(formattedRand.array(), Base64.NO_WRAP);
String challengeResponse = mTelephonyManager.getIccAuthentication(
- TelephonyManager.APPTYPE_USIM,
+ mEapSimConfig.apptype,
TelephonyManager.AUTHTYPE_EAP_SIM,
base64Challenge);
byte[] challengeResponseBytes = Base64.decode(challengeResponse, Base64.DEFAULT);
diff --git a/tests/iketests/src/java/com/android/ike/eap/EapSessionConfigTest.java b/tests/iketests/src/java/com/android/ike/eap/EapSessionConfigTest.java
index fea098c6..aa7d8443 100644
--- a/tests/iketests/src/java/com/android/ike/eap/EapSessionConfigTest.java
+++ b/tests/iketests/src/java/com/android/ike/eap/EapSessionConfigTest.java
@@ -16,11 +16,12 @@
package com.android.ike.eap;
+import static android.telephony.TelephonyManager.APPTYPE_USIM;
+
import static com.android.ike.eap.message.EapData.EAP_TYPE_SIM;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.android.ike.eap.EapSessionConfig.EapMethodConfig;
@@ -36,14 +37,15 @@ public class EapSessionConfigTest {
public void testBuild() {
EapSessionConfig result = new EapSessionConfig.Builder()
.setEapIdentity(EAP_IDENTITY)
- .setEapSimConfig(SUB_ID)
+ .setEapSimConfig(SUB_ID, APPTYPE_USIM)
.build();
assertArrayEquals(EAP_IDENTITY, result.eapIdentity);
EapMethodConfig eapMethodConfig = result.eapConfigs.get(EAP_TYPE_SIM);
assertEquals(EAP_TYPE_SIM, eapMethodConfig.methodType);
- assertTrue(eapMethodConfig instanceof EapSimConfig);
+ EapSimConfig eapSimConfig = (EapSimConfig) eapMethodConfig;
+ assertEquals(APPTYPE_USIM, eapSimConfig.apptype);
}
@Test
diff --git a/tests/iketests/src/java/com/android/ike/eap/EapSimTest.java b/tests/iketests/src/java/com/android/ike/eap/EapSimTest.java
index 25e9139b..9051d1d5 100644
--- a/tests/iketests/src/java/com/android/ike/eap/EapSimTest.java
+++ b/tests/iketests/src/java/com/android/ike/eap/EapSimTest.java
@@ -16,6 +16,8 @@
package com.android.ike.eap;
+import static android.telephony.TelephonyManager.APPTYPE_USIM;
+
import static com.android.ike.TestUtils.hexStringToByteArray;
import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_REQUEST_AKA_IDENTITY_PACKET;
import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_REQUEST_NOTIFICATION_PACKET;
@@ -112,7 +114,9 @@ public class EapSimTest {
mMockCallback = mock(IEapCallback.class);
mTestLooper = new TestLooper();
- mEapSessionConfig = new EapSessionConfig.Builder().setEapSimConfig(SUB_ID).build();
+ mEapSessionConfig = new EapSessionConfig.Builder()
+ .setEapSimConfig(SUB_ID, APPTYPE_USIM)
+ .build();
mEapAuthenticator =
new EapAuthenticator(
mTestLooper.getLooper(),
diff --git a/tests/iketests/src/java/com/android/ike/eap/EapTestUtils.java b/tests/iketests/src/java/com/android/ike/eap/EapTestUtils.java
index b7a3ff33..aa374552 100644
--- a/tests/iketests/src/java/com/android/ike/eap/EapTestUtils.java
+++ b/tests/iketests/src/java/com/android/ike/eap/EapTestUtils.java
@@ -16,6 +16,8 @@
package com.android.ike.eap;
+import static android.telephony.TelephonyManager.APPTYPE_USIM;
+
import java.util.HashMap;
/**
@@ -47,6 +49,6 @@ public class EapTestUtils {
* @return a new EapSessionConfig with EAP-SIM configs set
*/
public static EapSessionConfig getDummyEapSimSessionConfig() {
- return new EapSessionConfig.Builder().setEapSimConfig(0).build();
+ return new EapSessionConfig.Builder().setEapSimConfig(0, APPTYPE_USIM).build();
}
}
diff --git a/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachineTest.java b/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachineTest.java
index 5847619a..711a6a32 100644
--- a/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachineTest.java
+++ b/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimMethodStateMachineTest.java
@@ -16,6 +16,8 @@
package com.android.ike.eap.statemachine;
+import static android.telephony.TelephonyManager.APPTYPE_USIM;
+
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.ike.TestUtils.hexStringToByteArray;
@@ -101,7 +103,7 @@ public class EapSimMethodStateMachineTest {
@Before
public void setUp() {
mContext = getInstrumentation().getContext();
- mEapSimConfig = new EapSimConfig(SUB_ID);
+ mEapSimConfig = new EapSimConfig(SUB_ID, APPTYPE_USIM);
mEapSimMethodStateMachine =
spy(new EapSimMethodStateMachine(mContext, mEapSimConfig, new SecureRandom()));
}
diff --git a/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimStateTest.java b/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimStateTest.java
index 507ca1e2..ad9ddc75 100644
--- a/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimStateTest.java
+++ b/tests/iketests/src/java/com/android/ike/eap/statemachine/EapSimStateTest.java
@@ -16,6 +16,8 @@
package com.android.ike.eap.statemachine;
+import static android.telephony.TelephonyManager.APPTYPE_USIM;
+
import static com.android.ike.TestUtils.hexStringToByteArray;
import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_RESPONSE_NOTIFICATION_PACKET;
import static com.android.ike.eap.message.EapTestMessageDefinitions.EAP_SIM_CLIENT_ERROR_INSUFFICIENT_CHALLENGES;
@@ -58,7 +60,7 @@ public class EapSimStateTest {
protected TelephonyManager mMockTelephonyManager;
protected EapSimTypeDataDecoder mMockEapSimTypeDataDecoder;
- protected EapSimConfig mEapSimConfig = new EapSimConfig(SUB_ID);
+ protected EapSimConfig mEapSimConfig = new EapSimConfig(SUB_ID, APPTYPE_USIM);
protected EapSimMethodStateMachine mEapSimMethodStateMachine;
@Before
diff --git a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java
index 3fbc7ad9..3a0eb6d1 100644
--- a/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java
+++ b/tests/iketests/src/java/com/android/ike/ikev2/IkeSessionStateMachineTest.java
@@ -60,6 +60,7 @@ import android.net.IpSecManager;
import android.net.IpSecManager.UdpEncapsulationSocket;
import android.os.Looper;
import android.os.test.TestLooper;
+import android.telephony.TelephonyManager;
import com.android.ike.TestUtils;
import com.android.ike.eap.EapAuthenticator;
@@ -437,7 +438,9 @@ public final class IkeSessionStateMachineTest {
mIpSecManager = mMockIpSecTestUtils.getIpSecManager();
mContext = mMockIpSecTestUtils.getContext();
mUdpEncapSocket = mIpSecManager.openUdpEncapsulationSocket();
- mEapSessionConfig = new EapSessionConfig.Builder().setEapSimConfig(EAP_SIM_SUB_ID).build();
+ mEapSessionConfig = new EapSessionConfig.Builder()
+ .setEapSimConfig(EAP_SIM_SUB_ID, TelephonyManager.APPTYPE_USIM)
+ .build();
mMockEapAuthenticatorFactory = mock(IkeEapAuthenticatorFactory.class);
mMockEapAuthenticator = mock(EapAuthenticator.class);