summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-03-23 00:10:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-23 00:10:34 +0000
commite8de163ec30f575280b907b0e4f836c67b43948d (patch)
treeb0a38e11f737d0c880a5b12f3dfec78aad730dee /service
parent167b90b5e002698378728a54a417a08c317d29dc (diff)
parent2bce4620efc197b7423b842dbb8884ccecf76a1f (diff)
Merge "[AWARE] Data-path Passphrase security: connect to HAL"
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java66
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java14
2 files changed, 46 insertions, 34 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
index 7990db7d1..afe6db13a 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
@@ -21,6 +21,7 @@ import android.hardware.wifi.V1_0.NanBandIndex;
import android.hardware.wifi.V1_0.NanBandSpecificConfig;
import android.hardware.wifi.V1_0.NanCipherSuiteType;
import android.hardware.wifi.V1_0.NanConfigRequest;
+import android.hardware.wifi.V1_0.NanDataPathSecurityType;
import android.hardware.wifi.V1_0.NanEnableRequest;
import android.hardware.wifi.V1_0.NanInitiateDataPathRequest;
import android.hardware.wifi.V1_0.NanMatchAlg;
@@ -302,12 +303,12 @@ public class WifiAwareNativeApi {
req.baseConfigs.ttlSec = (short) publishConfig.mTtlSec;
req.baseConfigs.discoveryWindowPeriod = 1;
req.baseConfigs.discoveryCount = (byte) publishConfig.mPublishCount;
- convertLcByteToUcByteArray(publishConfig.mServiceName, req.baseConfigs.serviceName);
+ convertNativeByteArrayToArrayList(publishConfig.mServiceName, req.baseConfigs.serviceName);
// TODO: what's the right value on publish?
req.baseConfigs.discoveryMatchIndicator = NanMatchAlg.MATCH_ONCE;
- convertLcByteToUcByteArray(publishConfig.mServiceSpecificInfo,
+ convertNativeByteArrayToArrayList(publishConfig.mServiceSpecificInfo,
req.baseConfigs.serviceSpecificInfo);
- convertLcByteToUcByteArray(publishConfig.mMatchFilter,
+ convertNativeByteArrayToArrayList(publishConfig.mMatchFilter,
publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_UNSOLICITED
? req.baseConfigs.txMatchFilter : req.baseConfigs.rxMatchFilter);
req.baseConfigs.useRssiThreshold = false;
@@ -317,7 +318,7 @@ public class WifiAwareNativeApi {
req.baseConfigs.disableFollowupReceivedIndication = false;
// TODO: configure ranging and security
- req.baseConfigs.securityEnabledInNdp = false;
+ req.baseConfigs.securityConfig.securityType = NanDataPathSecurityType.OPEN;
req.baseConfigs.rangingRequired = false;
req.autoAcceptDataPathRequests = false;
@@ -364,11 +365,12 @@ public class WifiAwareNativeApi {
req.baseConfigs.ttlSec = (short) subscribeConfig.mTtlSec;
req.baseConfigs.discoveryWindowPeriod = 1;
req.baseConfigs.discoveryCount = (byte) subscribeConfig.mSubscribeCount;
- convertLcByteToUcByteArray(subscribeConfig.mServiceName, req.baseConfigs.serviceName);
+ convertNativeByteArrayToArrayList(subscribeConfig.mServiceName,
+ req.baseConfigs.serviceName);
req.baseConfigs.discoveryMatchIndicator = subscribeConfig.mMatchStyle;
- convertLcByteToUcByteArray(subscribeConfig.mServiceSpecificInfo,
+ convertNativeByteArrayToArrayList(subscribeConfig.mServiceSpecificInfo,
req.baseConfigs.serviceSpecificInfo);
- convertLcByteToUcByteArray(subscribeConfig.mMatchFilter,
+ convertNativeByteArrayToArrayList(subscribeConfig.mMatchFilter,
subscribeConfig.mSubscribeType == SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE
? req.baseConfigs.txMatchFilter : req.baseConfigs.rxMatchFilter);
req.baseConfigs.useRssiThreshold = false;
@@ -378,7 +380,7 @@ public class WifiAwareNativeApi {
req.baseConfigs.disableFollowupReceivedIndication = false;
// TODO: configure ranging and security
- req.baseConfigs.securityEnabledInNdp = false;
+ req.baseConfigs.securityConfig.securityType = NanDataPathSecurityType.OPEN;
req.baseConfigs.rangingRequired = false;
req.subscribeType = subscribeConfig.mSubscribeType;
@@ -433,7 +435,7 @@ public class WifiAwareNativeApi {
copyArray(dest, req.addr);
req.isHighPriority = false;
req.shouldUseDiscoveryWindow = true;
- convertLcByteToUcByteArray(message, req.serviceSpecificInfo);
+ convertNativeByteArrayToArrayList(message, req.serviceSpecificInfo);
req.disableFollowupResultIndication = false;
try {
@@ -585,7 +587,7 @@ public class WifiAwareNativeApi {
/**
* Initiates setting up a data-path between device and peer. Security is provided by either
- * PMK or Passphrase - if both are null then an open (unencrypted) link is set up.
+ * PMK or Passphrase (not both) - if both are null then an open (unencrypted) link is set up.
*
* @param transactionId Transaction ID for the transaction - used in the async callback to
* match with the original request.
@@ -628,14 +630,19 @@ public class WifiAwareNativeApi {
req.channelRequestType = channelRequestType;
req.channel = channel;
req.ifaceName = interfaceName;
- if (pmk == null || pmk.length == 0) {
- req.securityRequired = false;
- } else {
- req.securityRequired = true;
- req.cipherType = getStrongestCipherSuiteType(capabilities.supportedCipherSuites);
- convertLcByteToUcByteArray(pmk, req.pmk);
+ req.securityConfig.securityType = NanDataPathSecurityType.OPEN;
+ if (pmk != null && pmk.length != 0) {
+ req.securityConfig.cipherType = getStrongestCipherSuiteType(
+ capabilities.supportedCipherSuites);
+ req.securityConfig.securityType = NanDataPathSecurityType.PMK;
+ copyArray(pmk, req.securityConfig.pmk);
+ }
+ if (passphrase != null && passphrase.length() != 0) {
+ req.securityConfig.cipherType = getStrongestCipherSuiteType(
+ capabilities.supportedCipherSuites);
+ req.securityConfig.securityType = NanDataPathSecurityType.PASSPHRASE;
+ convertNativeByteArrayToArrayList(passphrase.getBytes(), req.securityConfig.passphrase);
}
- // TODO: b/35866810 connect passphrase to HAL!
try {
WifiStatus status = iface.initiateDataPathRequest(transactionId, req);
@@ -652,8 +659,8 @@ public class WifiAwareNativeApi {
}
/**
- * Responds to a data request from a peer. Security is provided by either PMK or Passphrase -
- * if both are null then an open (unencrypted) link is set up.
+ * Responds to a data request from a peer. Security is provided by either PMK or Passphrase (not
+ * both) - if both are null then an open (unencrypted) link is set up.
*
* @param transactionId Transaction ID for the transaction - used in the async callback to
* match with the original request.
@@ -687,14 +694,19 @@ public class WifiAwareNativeApi {
req.acceptRequest = accept;
req.ndpInstanceId = ndpId;
req.ifaceName = interfaceName;
- if (pmk == null || pmk.length == 0) {
- req.securityRequired = false;
- } else {
- req.securityRequired = true;
- req.cipherType = getStrongestCipherSuiteType(capabilities.supportedCipherSuites);
- convertLcByteToUcByteArray(pmk, req.pmk);
+ req.securityConfig.securityType = NanDataPathSecurityType.OPEN;
+ if (pmk != null && pmk.length != 0) {
+ req.securityConfig.cipherType = getStrongestCipherSuiteType(
+ capabilities.supportedCipherSuites);
+ req.securityConfig.securityType = NanDataPathSecurityType.PMK;
+ copyArray(pmk, req.securityConfig.pmk);
+ }
+ if (passphrase != null && passphrase.length() != 0) {
+ req.securityConfig.cipherType = getStrongestCipherSuiteType(
+ capabilities.supportedCipherSuites);
+ req.securityConfig.securityType = NanDataPathSecurityType.PASSPHRASE;
+ convertNativeByteArrayToArrayList(passphrase.getBytes(), req.securityConfig.passphrase);
}
- // TODO: b/35866810 connect passphrase to HAL!
try {
WifiStatus status = iface.respondToDataPathIndicationRequest(transactionId, req);
@@ -769,7 +781,7 @@ public class WifiAwareNativeApi {
*
* @return A newly allocated ArrayList<> if 'to' is null, otherwise null.
*/
- private ArrayList<Byte> convertLcByteToUcByteArray(byte[] from, ArrayList<Byte> to) {
+ private ArrayList<Byte> convertNativeByteArrayToArrayList(byte[] from, ArrayList<Byte> to) {
if (from == null) {
from = new byte[0];
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
index 892463ab2..6f1925f75 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
@@ -302,13 +302,13 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub {
Log.v(TAG, "eventMatch: discoverySessionId=" + event.discoverySessionId + ", peerId="
+ event.peerId + ", addr=" + String.valueOf(HexEncoding.encode(event.addr))
+ ", serviceSpecificInfo=" + Arrays.toString(
- convertUcByteToLcByteArray(event.serviceSpecificInfo)) + ", matchFilter="
- + Arrays.toString(convertUcByteToLcByteArray(event.matchFilter)));
+ convertArrayListToNativeByteArray(event.serviceSpecificInfo)) + ", matchFilter="
+ + Arrays.toString(convertArrayListToNativeByteArray(event.matchFilter)));
}
mWifiAwareStateManager.onMatchNotification(event.discoverySessionId, event.peerId,
- event.addr, convertUcByteToLcByteArray(event.serviceSpecificInfo),
- convertUcByteToLcByteArray(event.matchFilter));
+ event.addr, convertArrayListToNativeByteArray(event.serviceSpecificInfo),
+ convertArrayListToNativeByteArray(event.matchFilter));
}
@Override
@@ -330,7 +330,7 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub {
}
mWifiAwareStateManager.onMessageReceivedNotification(event.discoverySessionId, event.peerId,
- event.addr, convertUcByteToLcByteArray(event.serviceSpecificInfo));
+ event.addr, convertArrayListToNativeByteArray(event.serviceSpecificInfo));
}
@Override
@@ -370,7 +370,7 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub {
mWifiAwareStateManager.onDataPathConfirmNotification(event.ndpInstanceId,
event.peerNdiMacAddr, event.dataPathSetupSuccess, event.status.status,
- convertUcByteToLcByteArray(event.appInfo));
+ convertArrayListToNativeByteArray(event.appInfo));
}
@Override
@@ -389,7 +389,7 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub {
*
* @return A newly allocated byte[].
*/
- private byte[] convertUcByteToLcByteArray(ArrayList<Byte> from) {
+ private byte[] convertArrayListToNativeByteArray(ArrayList<Byte> from) {
if (from == null) {
return null;
}