summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mahesh KKV <maheshkkv@google.com> 2024-11-21 22:55:32 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-21 22:55:32 +0000
commit39800bbd0f402b5366e90b0f31fdf534b9f6f570 (patch)
treec0ebe0a54d923a65c137f9056b130d9e11797b29
parentdad3d56c33a71c444a4299bdedef1b0409289604 (diff)
parent5d47b033fcd9c13874b9042c5737c66ca0d05701 (diff)
Merge "Add PASN comeback cookie for secure ranging" into main
-rw-r--r--framework/api/current.txt6
-rw-r--r--framework/java/android/net/wifi/rtt/PasnConfig.java54
-rw-r--r--framework/java/android/net/wifi/rtt/RangingResult.java77
3 files changed, 130 insertions, 7 deletions
diff --git a/framework/api/current.txt b/framework/api/current.txt
index 8a01eaa2d9..78081ae190 100644
--- a/framework/api/current.txt
+++ b/framework/api/current.txt
@@ -1786,6 +1786,7 @@ package android.net.wifi.rtt {
method public int describeContents();
method public int getBaseAkms();
method public int getCiphers();
+ method @Nullable public byte[] getPasnComebackCookie();
method @Nullable public String getPassword();
method @Nullable public android.net.wifi.WifiSsid getWifiSsid();
method public void writeToParcel(@NonNull android.os.Parcel, int);
@@ -1809,6 +1810,7 @@ package android.net.wifi.rtt {
@FlaggedApi("com.android.wifi.flags.secure_ranging") public static final class PasnConfig.Builder {
ctor public PasnConfig.Builder(int, int);
method @NonNull public android.net.wifi.rtt.PasnConfig build();
+ method @NonNull public android.net.wifi.rtt.PasnConfig.Builder setPasnComebackCookie(@NonNull byte[]);
method @NonNull public android.net.wifi.rtt.PasnConfig.Builder setPassword(@NonNull String);
method @NonNull public android.net.wifi.rtt.PasnConfig.Builder setWifiSsid(@NonNull android.net.wifi.WifiSsid);
}
@@ -1860,6 +1862,8 @@ package android.net.wifi.rtt {
method @FlaggedApi("com.android.wifi.flags.android_v_wifi_api") public long getMinTimeBetweenNtbMeasurementsMicros();
method public int getNumAttemptedMeasurements();
method public int getNumSuccessfulMeasurements();
+ method @FlaggedApi("com.android.wifi.flags.secure_ranging") public long getPasnComebackAfterMillis();
+ method @FlaggedApi("com.android.wifi.flags.secure_ranging") @Nullable public byte[] getPasnComebackCookie();
method @Nullable public android.net.wifi.aware.PeerHandle getPeerHandle();
method public long getRangingTimestampMillis();
method public int getRssi();
@@ -1899,6 +1903,8 @@ package android.net.wifi.rtt {
method @FlaggedApi("com.android.wifi.flags.android_v_wifi_api") @NonNull public android.net.wifi.rtt.RangingResult.Builder setMinTimeBetweenNtbMeasurementsMicros(long);
method @FlaggedApi("com.android.wifi.flags.android_v_wifi_api") @NonNull public android.net.wifi.rtt.RangingResult.Builder setNumAttemptedMeasurements(int);
method @FlaggedApi("com.android.wifi.flags.android_v_wifi_api") @NonNull public android.net.wifi.rtt.RangingResult.Builder setNumSuccessfulMeasurements(int);
+ method @FlaggedApi("com.android.wifi.flags.secure_ranging") @NonNull public android.net.wifi.rtt.RangingResult.Builder setPasnComebackAfterMillis(long);
+ method @FlaggedApi("com.android.wifi.flags.secure_ranging") @NonNull public android.net.wifi.rtt.RangingResult.Builder setPasnComebackCookie(@NonNull byte[]);
method @FlaggedApi("com.android.wifi.flags.android_v_wifi_api") @NonNull public android.net.wifi.rtt.RangingResult.Builder setPeerHandle(@Nullable android.net.wifi.aware.PeerHandle);
method @FlaggedApi("com.android.wifi.flags.secure_ranging") @NonNull public android.net.wifi.rtt.RangingResult.Builder setRangingAuthenticated(boolean);
method @FlaggedApi("com.android.wifi.flags.secure_ranging") @NonNull public android.net.wifi.rtt.RangingResult.Builder setRangingFrameProtected(boolean);
diff --git a/framework/java/android/net/wifi/rtt/PasnConfig.java b/framework/java/android/net/wifi/rtt/PasnConfig.java
index f5c9251892..9688f5eee3 100644
--- a/framework/java/android/net/wifi/rtt/PasnConfig.java
+++ b/framework/java/android/net/wifi/rtt/PasnConfig.java
@@ -30,6 +30,7 @@ import com.android.wifi.flags.Flags;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -184,8 +185,8 @@ public final class PasnConfig implements Parcelable {
@Cipher
private final int mCiphers;
private final String mPassword;
-
private final WifiSsid mWifiSsid;
+ private final byte[] mPasnComebackCookie;
/**
* Return base AKMs (Authentication and Key Management).
@@ -222,12 +223,22 @@ public final class PasnConfig implements Parcelable {
return mWifiSsid;
}
+ /**
+ * Get PASN comeback cookie. See {@link Builder#setPasnComebackCookie(byte[])}.
+ **/
+ @Nullable
+ public byte[] getPasnComebackCookie() {
+ return mPasnComebackCookie;
+ }
+
+
private PasnConfig(@NonNull Parcel in) {
mBaseAkms = in.readInt();
mCiphers = in.readInt();
mPassword = in.readString();
mWifiSsid = (SdkLevel.isAtLeastT()) ? in.readParcelable(WifiSsid.class.getClassLoader(),
WifiSsid.class) : in.readParcelable(WifiSsid.class.getClassLoader());
+ mPasnComebackCookie = in.createByteArray();
}
public static final @NonNull Creator<PasnConfig> CREATOR = new Creator<PasnConfig>() {
@@ -252,6 +263,7 @@ public final class PasnConfig implements Parcelable {
dest.writeInt(mBaseAkms);
dest.writeInt(mCiphers);
dest.writeString(mPassword);
+ dest.writeByteArray(mPasnComebackCookie);
}
/**
@@ -293,6 +305,7 @@ public final class PasnConfig implements Parcelable {
mCiphers = builder.mCiphers;
mPassword = builder.mPassword;
mWifiSsid = builder.mWifiSsid;
+ mPasnComebackCookie = builder.mPasnComebackCookie;
}
/**
@@ -311,6 +324,7 @@ public final class PasnConfig implements Parcelable {
private final int mCiphers;
private String mPassword = null;
private WifiSsid mWifiSsid = null;
+ byte[] mPasnComebackCookie = null;
/**
* Builder
@@ -359,6 +373,32 @@ public final class PasnConfig implements Parcelable {
}
/**
+ * Set PASN comeback cookie. PASN authentication allows the station to provide comeback
+ * cookie which was indicated in the {@link RangingResult} by the AP with a deferral time.
+ * <p>
+ * When an AP receives a large volume of initial PASN Authentication frames, it can use
+ * the comeback after field in the PASN Parameters element to indicate a deferral time
+ * and optionally provide a comeback cookie which is an opaque sequence of octets. Upon
+ * receiving this response, the ranging initiator (STA) must wait for the specified time
+ * before retrying secure authentication, presenting the received cookie to the AP. See
+ * {@link RangingResult#getPasnComebackCookie()} and
+ * {@link RangingResult#getPasnComebackAfterMillis()}.
+ *
+ * @param pasnComebackCookie an opaque sequence of octets
+ * @return a reference to this Builder
+ */
+ @NonNull
+ public Builder setPasnComebackCookie(@NonNull byte[] pasnComebackCookie) {
+ Objects.requireNonNull(pasnComebackCookie, "PASN comeback cookie must not be null");
+ if (pasnComebackCookie.length > 255 || pasnComebackCookie.length == 0) {
+ throw new IllegalArgumentException("Cookie with invalid length "
+ + pasnComebackCookie.length);
+ }
+ mPasnComebackCookie = pasnComebackCookie;
+ return this;
+ }
+
+ /**
* Builds a {@link PasnConfig} object.
*/
@NonNull
@@ -372,17 +412,21 @@ public final class PasnConfig implements Parcelable {
if (this == o) return true;
if (!(o instanceof PasnConfig that)) return false;
return mBaseAkms == that.mBaseAkms && mCiphers == that.mCiphers && Objects.equals(
- mPassword, that.mPassword) && Objects.equals(mWifiSsid, that.mWifiSsid);
+ mPassword, that.mPassword) && Objects.equals(mWifiSsid, that.mWifiSsid)
+ && Arrays.equals(mPasnComebackCookie, that.mPasnComebackCookie);
}
@Override
public int hashCode() {
- return Objects.hash(mBaseAkms, mCiphers, mPassword, mWifiSsid);
+ int result = Objects.hash(mBaseAkms, mCiphers, mPassword, mWifiSsid);
+ result = 31 * result + Arrays.hashCode(mPasnComebackCookie);
+ return result;
}
@Override
public String toString() {
- return "PasnConfig{" + "mBaseAkms=" + mBaseAkms + ", mCiphers=" + mCiphers
- + ", mPassword='" + mPassword + '\'' + ", mWifiSsid=" + mWifiSsid + '}';
+ return "PasnConfig{" + "mBaseAkms=" + mBaseAkms + ", mCiphers=" + mCiphers + ", mPassword='"
+ + mPassword + '\'' + ", mWifiSsid=" + mWifiSsid + ", mPasnComebackCookie="
+ + Arrays.toString(mPasnComebackCookie) + '}';
}
}
diff --git a/framework/java/android/net/wifi/rtt/RangingResult.java b/framework/java/android/net/wifi/rtt/RangingResult.java
index 58c221132f..bf3c5e1338 100644
--- a/framework/java/android/net/wifi/rtt/RangingResult.java
+++ b/framework/java/android/net/wifi/rtt/RangingResult.java
@@ -119,6 +119,8 @@ public final class RangingResult implements Parcelable {
private final boolean mIsRangingFrameProtected;
private final boolean mIsSecureHeLtfEnabled;
private final int mSecureHeLtfProtocolVersion;
+ private final byte[] mPasnComebackCookie;
+ private final long mPasnComebackAfterMillis;
/**
* Builder class used to construct {@link RangingResult} objects.
@@ -152,6 +154,8 @@ public final class RangingResult implements Parcelable {
private boolean mIsRangingFrameProtected;
private boolean mIsSecureHeLtfEnabled;
private int mSecureHeLtfProtocolVersion;
+ private byte[] mPasnComebackCookie = null;
+ private long mPasnComebackAfterMillis = UNSPECIFIED;
/**
* Sets the Range result status.
@@ -566,6 +570,35 @@ public final class RangingResult implements Parcelable {
}
/**
+ * Set comeback cookie. See {@link #getPasnComebackCookie()}. If not set, default value
+ * is null.
+ *
+ * @param pasnComebackCookie an opaque sequence of octets
+ * @return The builder to facilitate chaining.
+ */
+ @NonNull
+ @FlaggedApi(Flags.FLAG_SECURE_RANGING)
+ public Builder setPasnComebackCookie(@NonNull byte[] pasnComebackCookie) {
+ mPasnComebackCookie = pasnComebackCookie;
+ return this;
+ }
+
+ /**
+ * Set comeback after time. See {@link #getPasnComebackAfterMillis()}. If not set default
+ * value is {@link RangingResult#UNSPECIFIED}.
+ *
+ * @param comebackAfterMillis the ranging initiator (STA) must wait for the specified
+ * time before retrying secure ranging
+ * @return The builder to facilitate chaining.
+ */
+ @NonNull
+ @FlaggedApi(Flags.FLAG_SECURE_RANGING)
+ public Builder setPasnComebackAfterMillis(long comebackAfterMillis) {
+ mPasnComebackAfterMillis = comebackAfterMillis;
+ return this;
+ }
+
+ /**
* Build {@link RangingResult}
* @return an instance of {@link RangingResult}
*/
@@ -613,6 +646,8 @@ public final class RangingResult implements Parcelable {
mIsRangingFrameProtected = builder.mIsRangingFrameProtected;
mIsSecureHeLtfEnabled = builder.mIsSecureHeLtfEnabled;
mSecureHeLtfProtocolVersion = builder.mSecureHeLtfProtocolVersion;
+ mPasnComebackCookie = builder.mPasnComebackCookie;
+ mPasnComebackAfterMillis = builder.mPasnComebackAfterMillis;
}
/**
@@ -1023,6 +1058,31 @@ public final class RangingResult implements Parcelable {
return mSecureHeLtfProtocolVersion;
}
+ /**
+ * Get PASN comeback cookie. PASN authentication allows an AP to indicate the deferral time
+ * and optionally a Cookie. See {@link #getPasnComebackAfterMillis()}
+ * <p>
+ * When an AP receives a large volume of initial PASN Authentication frames, it can use
+ * the comeback after field in the PASN Parameters element to indicate a deferral time
+ * and optionally provide a comeback cookie which is an opaque sequence of octets. Upon
+ * receiving this response, the ranging initiator (STA) must wait for the specified time
+ * before retrying secure authentication, presenting the received cookie to the AP.
+ **/
+ @FlaggedApi(Flags.FLAG_SECURE_RANGING)
+ @Nullable
+ public byte[] getPasnComebackCookie() {
+ return mPasnComebackCookie;
+ }
+
+ /**
+ * Get Comeback after time in milliseconds. See {@link #getPasnComebackCookie()}. A value 0
+ * indicates the ranging request operation can be tried immediately with the cookie.
+ */
+ @FlaggedApi(Flags.FLAG_SECURE_RANGING)
+ public long getPasnComebackAfterMillis() {
+ return mPasnComebackAfterMillis;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -1136,6 +1196,11 @@ public final class RangingResult implements Parcelable {
.append(", numTxSpatialStreams=").append(mNumTxSpatialStreams)
.append(", numRxSpatialStreams=").append(mNumRxSpatialStreams)
.append(", vendorData=").append(mVendorData)
+ .append(", isRangingAuthenticated").append(mIsRangingAuthenticated)
+ .append(", isRangingFrameProtected").append(mIsRangingFrameProtected)
+ .append(", isSecureHeLtfEnabled").append(mIsSecureHeLtfEnabled)
+ .append(", pasnComebackCookie").append(Arrays.toString(mPasnComebackCookie))
+ .append(", pasnComebackAfterMillis").append(mPasnComebackAfterMillis)
.append("]").toString();
}
@@ -1169,7 +1234,13 @@ public final class RangingResult implements Parcelable {
&& mR2iTxLtfRepetitions == lhs.mR2iTxLtfRepetitions
&& mNumTxSpatialStreams == lhs.mNumTxSpatialStreams
&& mNumRxSpatialStreams == lhs.mNumRxSpatialStreams
- && Objects.equals(mVendorData, lhs.mVendorData);
+ && Objects.equals(mVendorData, lhs.mVendorData)
+ && mIsRangingAuthenticated == lhs.mIsRangingAuthenticated
+ && mIsRangingFrameProtected == lhs.mIsRangingFrameProtected
+ && mIsSecureHeLtfEnabled == lhs.isSecureHeLtfEnabled()
+ && mPasnComebackAfterMillis == lhs.mPasnComebackAfterMillis
+ && Arrays.equals(mPasnComebackCookie, lhs.mPasnComebackCookie);
+
}
@Override
@@ -1179,6 +1250,8 @@ public final class RangingResult implements Parcelable {
Arrays.hashCode(mLcr), mResponderLocation, mTimestamp, mIs80211mcMeasurement,
mFrequencyMHz, mPacketBw, mIs80211azNtbMeasurement, mNtbMinMeasurementTime,
mNtbMaxMeasurementTime, mI2rTxLtfRepetitions, mR2iTxLtfRepetitions,
- mNumTxSpatialStreams, mR2iTxLtfRepetitions, mVendorData);
+ mNumTxSpatialStreams, mR2iTxLtfRepetitions, mVendorData, mIsRangingAuthenticated,
+ mIsRangingFrameProtected, mIsSecureHeLtfEnabled, mPasnComebackAfterMillis,
+ Arrays.hashCode(mPasnComebackCookie));
}
}