# WM_SetWEPKey

## Syntax

      #include <nitro/wm.h>

      WMErrCode WM_SetWEPKey(
              WMCallbackFunc  callback ,
              u16             wepmode ,
              const u16*      wepkey
      );

## Arguments

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

`wepmode`

Designates the 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

`wepkey`

Designates a 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. 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. This function performs that same processing as `WM_SetWEPKeyEx` when wepkey is set to 0. Encryption using WEP key is applied to authentication during connection and to data sent and received in infrastructure mode. The `wepmode` setting on the sender and receiver must match. Be aware that when connecting the parent that performed the WEP encryption configuration as a child via 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_SetWEPKeyEx`
`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.
2004/10/22 Changed the type of return values.
Initial version.

CONFIDENTIAL