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

Commit c6c53274 authored by Etan Cohen's avatar Etan Cohen
Browse files

[AWARE] Add API to expose supported cipher suites

Provide a new Aware capabilities API which exposes the supported
cipher suites. These cipher suites are used to negotiate the data-
path. The framework automatially selects the strongest cipher suite
when it initiates a negotiation.

Bug: 145697276
Bug: 111446262
Test: atest com.android.server.wifi.aware
Test: (CTS) atest SingleDeviceTest
Change-Id: Ic9ec46a2aa578fa97cb174ca9745c5320ff07b52
parent 243a6fa6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -30382,8 +30382,11 @@ package android.net.wifi.aware {
    method public int getMaxMatchFilterLength();
    method public int getMaxServiceNameLength();
    method public int getMaxServiceSpecificInfoLength();
    method public int getSupportedCipherSuites();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.aware.Characteristics> CREATOR;
    field public static final int WIFI_AWARE_CIPHER_SUITE_NCS_SK_128 = 1; // 0x1
    field public static final int WIFI_AWARE_CIPHER_SUITE_NCS_SK_256 = 2; // 0x2
  }
  public class DiscoverySession implements java.lang.AutoCloseable {
+36 −1
Original line number Diff line number Diff line
@@ -16,10 +16,14 @@

package android.net.wifi.aware;

import android.annotation.IntDef;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * The characteristics of the Wi-Fi Aware implementation.
 */
@@ -31,6 +35,8 @@ public final class Characteristics implements Parcelable {
            "key_max_service_specific_info_length";
    /** @hide */
    public static final String KEY_MAX_MATCH_FILTER_LENGTH = "key_max_match_filter_length";
    /** @hide */
    public static final String KEY_SUPPORTED_CIPHER_SUITES = "key_supported_cipher_suites";

    private Bundle mCharacteristics = new Bundle();

@@ -71,12 +77,41 @@ public final class Characteristics implements Parcelable {
     * {@link PublishConfig.Builder#setMatchFilter(java.util.List)} and
     * {@link SubscribeConfig.Builder#setMatchFilter(java.util.List)}.
     *
     * @return A positive integer, maximum legngth of byte array for Aware discovery match filter.
     * @return A positive integer, maximum length of byte array for Aware discovery match filter.
     */
    public int getMaxMatchFilterLength() {
        return mCharacteristics.getInt(KEY_MAX_MATCH_FILTER_LENGTH);
    }

    /** @hide */
    @IntDef(flag = true, prefix = { "WIFI_AWARE_CIPHER_SUITE_" }, value = {
            WIFI_AWARE_CIPHER_SUITE_NCS_SK_128,
            WIFI_AWARE_CIPHER_SUITE_NCS_SK_256,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface WifiAwareCipherSuites {}

    /**
     * Wi-Fi Aware supported ciphier suite representing NCS SK 128: 128 bit shared-key.
     */
    public static final int WIFI_AWARE_CIPHER_SUITE_NCS_SK_128 = 1 << 0;

    /**
     * Wi-Fi Aware supported ciphier suite representing NCS SK 256: 256 bit shared-key.
     */
    public static final int WIFI_AWARE_CIPHER_SUITE_NCS_SK_256 = 1 << 1;

    /**
     * Returns the set of cipher suites supported by the device for use in Wi-Fi Aware data-paths.
     * The device automatically picks the strongest cipher suite when initiating a data-path setup.
     *
     * @return A set of flags from {@link #WIFI_AWARE_CIPHER_SUITE_NCS_SK_128}, or
     * {@link #WIFI_AWARE_CIPHER_SUITE_NCS_SK_256}.
     */
    public @WifiAwareCipherSuites int getSupportedCipherSuites() {
        return mCharacteristics.getInt(KEY_SUPPORTED_CIPHER_SUITES);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeBundle(mCharacteristics);