# WifiAwareDataPathSecurityConfig.Builder

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                                   ||
| ↳ | [android.net.wifi.aware.WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) |

A builder class for a Wi-Fi Aware data-path security config to encrypt an Aware connection.

## Summary

|                                                                                                                                                                     Public constructors                                                                                                                                                                      ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#Builder(kotlin.Int))`(`cipherSuite:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Create a builder for a Wi-Fi Aware data-path security config to encrypt the link with specified cipher suite. |

|                                                                                                                                                                                                                                                                                                                                                                            Public methods                                                                                                                                                                                                                                                                                                                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig)                  | [build](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#build())`()` Create a[WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig)to set in[WifiAwareNetworkSpecifier.Builder.setDataPathSecurityConfig(WifiAwareDataPathSecurityConfig)](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig))to encrypt the link. |
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | [setPmk](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmk(kotlin.ByteArray))`(`pmk:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`)` Configure the PMK for the Wi-Fi Aware connection being requested.                                                                                                                                                                                                                                                                                    |
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | [setPmkId](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmkId(kotlin.ByteArray))`(`pmkId:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`)` Configure the PMKID for the Wi-Fi Aware connection being requested.                                                                                                                                                                                                                                                                            |
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | [setPskPassphrase](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPskPassphrase(kotlin.String))`(`pskPassphrase:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Configure the PSK Passphrase for the Wi-Fi Aware connection being requested.                                                                                                                                                                                                                                                     |

## Public constructors

### Builder

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(cipherSuite: Int)
```

Create a builder for a Wi-Fi Aware data-path security config to encrypt the link with specified cipher suite. Use[Characteristics.getSupportedCipherSuites()](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#getSupportedCipherSuites())to get the supported capabilities of the device.

- For shared key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256:kotlin.Int), either passphrase or PMK must be set.
- For public key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256:kotlin.Int). Both PMK and PMKID must be set.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cipherSuite` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The cipher suite to be used to encrypt the link. One of the[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128:kotlin.Int),[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256:kotlin.Int),[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256:kotlin.Int). Value is either`0`or a combination of[android.net.wifi.aware.Characteristics#WIFI_AWARE_CIPHER_SUITE_NONE](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NONE:kotlin.Int),[android.net.wifi.aware.Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128:kotlin.Int),[android.net.wifi.aware.Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256:kotlin.Int),[android.net.wifi.aware.Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128:kotlin.Int), and[android.net.wifi.aware.Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256:kotlin.Int) |

**See Also**

- [android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(WifiAwareDataPathSecurityConfig)](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig))

## Public methods

### build

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): WifiAwareDataPathSecurityConfig
```

Create a[WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig)to set in[WifiAwareNetworkSpecifier.Builder.setDataPathSecurityConfig(WifiAwareDataPathSecurityConfig)](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig))to encrypt the link.

|                                                                                                                                                                               Return                                                                                                                                                                                ||
|------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig) | A[WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig)to be used for encrypting the Wi-Fi Aware data-path. This value cannot be`null`. |

### setPmk

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setPmk(pmk: ByteArray): WifiAwareDataPathSecurityConfig.Builder
```

Configure the PMK for the Wi-Fi Aware connection being requested. For shared key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256:kotlin.Int), either passphrase or PMK must be set. For public key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256:kotlin.Int). Both PMK and PMKID must be set.

|                                                                                                                                                                                                                                                                                                                                                   Parameters                                                                                                                                                                                                                                                                                                                                                    ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pmk` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html):A PMK (pairwise master key, see IEEE 802.11i) specifying the key to use for encrypting the data-path. Alternatively, use the[setPskPassphrase(java.lang.String)](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPskPassphrase(kotlin.String))to specify a Passphrase instead for shared key cipher suite. Use the[setPmkId(byte[])](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmkId(kotlin.ByteArray))together for public key cipher suite. This value cannot be`null`. |

|                                                                                                                                                                                  Return                                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | the current[Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#)builder, enabling chaining of builder methods. This value cannot be`null`. |

### setPmkId

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setPmkId(pmkId: ByteArray): WifiAwareDataPathSecurityConfig.Builder
```

Configure the PMKID for the Wi-Fi Aware connection being requested. For public key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_PK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_PK_256:kotlin.Int). both PMK and PMKID must set[setPmk(byte[])](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmk(kotlin.ByteArray))

|                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                     ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pmkId` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html):A PMKID (pairwise master key associated identifier, see IEEE 802.11) is generated by Diffie-Hellman key exchange together with a Pairwise Master Key (PMK), specifying the identifier associated to the key to use for encrypting the data-path. Use the[setPmk(byte[])](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmk(kotlin.ByteArray))together for public key cipher suite. This value cannot be`null`. |

|                                                                                                                                                                                  Return                                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | the current[Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#)builder, enabling chaining of builder methods. This value cannot be`null`. |

### setPskPassphrase

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setPskPassphrase(pskPassphrase: String): WifiAwareDataPathSecurityConfig.Builder
```

Configure the PSK Passphrase for the Wi-Fi Aware connection being requested. For shared key cipher suite[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_128](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_128:kotlin.Int)and[Characteristics.WIFI_AWARE_CIPHER_SUITE_NCS_SK_256](https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#WIFI_AWARE_CIPHER_SUITE_NCS_SK_256:kotlin.Int), either passphrase or PMK must be set.

|                                                                                                                                                                                                Parameters                                                                                                                                                                                                ||
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pskPassphrase` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The passphrase to be used to encrypt the link. Alternatively, use the[setPmk(byte[])](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#setPmk(kotlin.ByteArray))to specify a PMK for shared key cipher suite. This value cannot be`null`. |

|                                                                                                                                                                                  Return                                                                                                                                                                                   ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WifiAwareDataPathSecurityConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#) | the current[Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig.Builder#)builder, enabling chaining of builder methods. This value cannot be`null`. |