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

Commit 3b4792a4 authored by Hai Shalom's avatar Hai Shalom Committed by Android (Google) Code Review
Browse files

Merge "[SAE] Add support to add SAE Authentication algorithm"

parents 3e5cf0eb b37d4c65
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30313,6 +30313,7 @@ package android.net.wifi {
  @Deprecated public static class WifiConfiguration.AuthAlgorithm {
    field @Deprecated public static final int LEAP = 2; // 0x2
    field @Deprecated public static final int OPEN = 0; // 0x0
    field @Deprecated public static final int SAE = 3; // 0x3
    field @Deprecated public static final int SHARED = 1; // 0x1
    field @Deprecated public static final String[] strings;
    field @Deprecated public static final String varName = "auth_alg";
+9 −1
Original line number Diff line number Diff line
@@ -253,9 +253,12 @@ public class WifiConfiguration implements Parcelable {
        /** LEAP/Network EAP (only used with LEAP) */
        public static final int LEAP = 2;

        /** SAE (Used only for WPA3-Personal) */
        public static final int SAE = 3;

        public static final String varName = "auth_alg";

        public static final String[] strings = { "OPEN", "SHARED", "LEAP" };
        public static final String[] strings = { "OPEN", "SHARED", "LEAP", "SAE" };
    }

    /**
@@ -468,10 +471,13 @@ public class WifiConfiguration implements Parcelable {
                break;
            case SECURITY_TYPE_SAE:
                allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE);
                allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
                allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
                requirePMF = true;
                break;
            case SECURITY_TYPE_EAP_SUITE_B:
                allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192);
                allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
                allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
                allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher.BIP_GMAC_256);
                // Note: allowedSuiteBCiphers bitset will be set by the service once the
@@ -480,6 +486,8 @@ public class WifiConfiguration implements Parcelable {
                break;
            case SECURITY_TYPE_OWE:
                allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE);
                allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
                allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
                requirePMF = true;
                break;
            case SECURITY_TYPE_WAPI_PSK:
+57 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package android.net.wifi;

import static android.net.wifi.WifiConfiguration.SECURITY_TYPE_EAP_SUITE_B;
import static android.net.wifi.WifiConfiguration.SECURITY_TYPE_OWE;
import static android.net.wifi.WifiConfiguration.SECURITY_TYPE_SAE;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -328,4 +332,57 @@ public class WifiConfigurationTest {
            assertNotNull(NetworkSelectionStatus.DISABLE_REASON_INFOS.get(i));
        }
    }

    /**
     * Ensure that {@link WifiConfiguration#setSecurityParams(int)} sets up the
     * {@link WifiConfiguration} object correctly for SAE security type.
     * @throws Exception
     */
    @Test
    public void testSetSecurityParamsForSae() throws Exception {
        WifiConfiguration config = new WifiConfiguration();

        config.setSecurityParams(SECURITY_TYPE_SAE);

        assertTrue(config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SAE));
        assertTrue(config.allowedPairwiseCiphers.get(WifiConfiguration.PairwiseCipher.CCMP));
        assertTrue(config.allowedGroupCiphers.get(WifiConfiguration.GroupCipher.CCMP));
        assertTrue(config.requirePMF);
    }

    /**
     * Ensure that {@link WifiConfiguration#setSecurityParams(int)} sets up the
     * {@link WifiConfiguration} object correctly for OWE security type.
     * @throws Exception
     */
    @Test
    public void testSetSecurityParamsForOwe() throws Exception {
        WifiConfiguration config = new WifiConfiguration();

        config.setSecurityParams(SECURITY_TYPE_OWE);

        assertTrue(config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.OWE));
        assertTrue(config.allowedPairwiseCiphers.get(WifiConfiguration.PairwiseCipher.CCMP));
        assertTrue(config.allowedGroupCiphers.get(WifiConfiguration.GroupCipher.CCMP));
        assertTrue(config.requirePMF);
    }

    /**
     * Ensure that {@link WifiConfiguration#setSecurityParams(int)} sets up the
     * {@link WifiConfiguration} object correctly for Suite-B security type.
     * @throws Exception
     */
    @Test
    public void testSetSecurityParamsForSuiteB() throws Exception {
        WifiConfiguration config = new WifiConfiguration();

        config.setSecurityParams(SECURITY_TYPE_EAP_SUITE_B);

        assertTrue(config.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.SUITE_B_192));
        assertTrue(config.allowedPairwiseCiphers.get(WifiConfiguration.PairwiseCipher.GCMP_256));
        assertTrue(config.allowedGroupCiphers.get(WifiConfiguration.GroupCipher.GCMP_256));
        assertTrue(config.allowedGroupManagementCiphers
                .get(WifiConfiguration.GroupMgmtCipher.BIP_GMAC_256));
        assertTrue(config.requirePMF);
    }
}