# WM_SetWEPKeyEx

## Syntax

      #include <nitro/wm.h>

      WMErrCode WM_SetWEPKeyEx(
              WMCallbackFunc  callback ,
              u16             wepmode ,
              u16             wepkeyid ,
              const u8*       wepkey
      );

## Arguments

`callback` | Callback function to call when the asynchronous process completes. This callback is called from within the interrupt handler.

`wepmode`

Operations mode of the encryption communications feature. Use a value from 0-3, as shown below.

- 0: No encryption features
- 1: RC4 ( 40-bit) encryption mode
- 2: RC4 ( 104-bit) encryption mode
- 3: RC4 (128-bit) encryption mode

`wepkeyid` | Value from 0 to 3 that indicates which of the 4 WEP keys will be used.

`wepkey`

Pointer to the encryption key data (80 bytes).
The key data is made up of 4 data items, each of which are 20 bytes. Of each 20 bytes,

- In 40-bit mode, 5 bytes
- In 104-bit mode, 13 bytes
- In 128-bit mode, 16 bytes

are used.
Note that this data is forcibly cached.

## Return Values

Returns the results of the `WMErrCode` enumerated type process.

## Description

Configures the encryption feature and the encryption keys. Configure advanced settings with the `WM_SetWEPKey` function. It is executable when WM is in an IDLE state. If the return value of the function was `WM_ERRCODE_OPERATING`, the callback is generated after the encryption feature configuration process has completed. WEP key encryption is applied to the authentication process when connecting and to the sending and receiving of data in infrastructure mode. The `wepmode` argument must be configured in the same way as its communications partner. The `wepkeyid` argument is used in the selection of the encryption data string when sending data. Conversely, the WEP key of the ID designated by the send side is used in decryption when data is received. Since it can be confirmed that the keys are identical by encrypting the child device and decrypting the parent device in shared key authentication, designation of an ID on the parent device has no real meaning. Also, the IDs of the WEP keys designated by the access point must be identical when encrypting receive data in infrastructure mode. Be aware that when connecting the parent that performed the WEP encryption configuration as a child through this function, once the WEP configurations have been performed with this function, the `authMode` of the `WM_StartConnectEx` function must be designated as shared key authentication (`WM_AUTHMODE_SHARED_KEY`).

## Notes

The `wepkey` data is forcibly stored in the internal cache. To avoid overwriting surrounding memory regions, be sure to pass data that is 32-byte aligned.
See the Wireless Communication Library Manual (AboutWirelessManager.pdf) for additional details.

## See Also

`WM_SetWEPKey`
`WM_StartConnectEx`

## Revision History

2008/12/17 Added a note about how data passed in arguments is forcibly cached internally.
2005/06/08 Added the fact that the callback is called from the interrupt handler.
2005/03/07 Made addition to Description.
2005/03/02 Added mention of the specifiable range of the wepmode argument.
2005/02/14 Initial version.

CONFIDENTIAL