libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
security.c File Reference
#include "security.h"
#include "../../core/misc/byteswap.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

int libwifi_get_rsn_info (struct libwifi_rsn_info *info, const unsigned char *tag_data, const unsigned char *tag_end)
 RSN Information is supplied via the raw tag data. More...
 
void libwifi_enumerate_rsn_suites (struct libwifi_rsn_info *rsn_info, struct libwifi_bss *bss)
 This function will enumerate over a supplied struct libwifi_rsn_info and write the following into a supplied struct libwifi_bss: More...
 
int libwifi_get_wpa_info (struct libwifi_wpa_info *info, const unsigned char *tag_data, const unsigned char *tag_end)
 Similar to libwifi_get_rsn_info, WPA Information is supplied via the raw tag data. More...
 
void libwifi_enumerate_wpa_suites (struct libwifi_wpa_info *wpa_info, struct libwifi_bss *bss)
 Similarly to libwifi_enumerate_wpa_suites, this function will enumerate over a supplied struct libwifi_wpa_info and write the following into a supplied struct libwifi_bss: More...
 
void libwifi_get_security_type (struct libwifi_bss *bss, char *buf)
 Enumerate the security types (WEP, WPA, WPA2, WPA3, etc) in a given libwifi_bss, formatted into the given buffer. More...
 
void libwifi_get_group_ciphers (struct libwifi_bss *bss, char *buf)
 Enumerate the group ciphers (CCMP, GCMP128, etc) in a given libwifi_bss, formatted into the given buffer. More...
 
void libwifi_get_pairwise_ciphers (struct libwifi_bss *bss, char *buf)
 Enumerate the pairwise ciphers (GROUP, CCMP, BIP_CMAC128, etc) in a given libwifi_bss, formatted into the given buffer. More...
 
void libwifi_get_auth_key_suites (struct libwifi_bss *bss, char *buf)
 Enumerate the auth key management suites in a given libwifi_bss, formatted into the given buffer. More...
 
void _libwifi_add_sec_item (char *buf, int *offset, int *append, char *item)
 Internal function for adding a formatted string to a buffer for use with libwifi_get_* security functions. More...
 

Function Documentation

◆ _libwifi_add_sec_item()

void _libwifi_add_sec_item ( char *  buf,
int *  offset,
int *  append,
char *  item 
)

Internal function for adding a formatted string to a buffer for use with libwifi_get_* security functions.

Parameters
bufA buffer of length LIBWIFI_SECURITY_BUF_LEN
offsetA pointer to the current buffer offset variable
appendA pointer to the append state variable
itemA pointer to the string to append to the given buf

Definition at line 677 of file security.c.

◆ libwifi_enumerate_rsn_suites()

void libwifi_enumerate_rsn_suites ( struct libwifi_rsn_info rsn_info,
struct libwifi_bss bss 
)

This function will enumerate over a supplied struct libwifi_rsn_info and write the following into a supplied struct libwifi_bss:

Enumerate the RSN cipher suites in a libwifi_rsn_info.

  • Group Cipher Suite
  • Up to 3 Pairwise Cipher Suites
  • Up to 3 Auth Key Management Suites
  • The WPA Type (WPA2 or WPA3)

The bss->encryption_info field is a 64-bit wide bitmask. The larger length is required to accomodate the different types of cipher suites without having any overlap between group cipher and pairwise cipher.

Definition at line 123 of file security.c.

◆ libwifi_enumerate_wpa_suites()

void libwifi_enumerate_wpa_suites ( struct libwifi_wpa_info wpa_info,
struct libwifi_bss bss 
)

Similarly to libwifi_enumerate_wpa_suites, this function will enumerate over a supplied struct libwifi_wpa_info and write the following into a supplied struct libwifi_bss:

Enumerate the WPA cipher suites in a libwifi_wpa_info.

  • Multicast Cipher Suite
  • Up to 3 Unicast Cipher Suites
  • Up to 3 Auth Key Management Suites

The bss->encryption_info field is a 64-bit wide bitmask. The larger length is required to accomodate the different types of cipher suites without having any overlap between group cipher and pairwise cipher.

Definition at line 399 of file security.c.

◆ libwifi_get_auth_key_suites()

void libwifi_get_auth_key_suites ( struct libwifi_bss bss,
char *  buf 
)

Enumerate the auth key management suites in a given libwifi_bss, formatted into the given buffer.

Parameters
bssA libwifi_bss struct
bufA buffer of length LIBWIFI_SECURITY_BUF_LEN

Definition at line 601 of file security.c.

◆ libwifi_get_group_ciphers()

void libwifi_get_group_ciphers ( struct libwifi_bss bss,
char *  buf 
)

Enumerate the group ciphers (CCMP, GCMP128, etc) in a given libwifi_bss, formatted into the given buffer.

Parameters
bssA libwifi_bss struct
bufA buffer of length LIBWIFI_SECURITY_BUF_LEN

Definition at line 494 of file security.c.

◆ libwifi_get_pairwise_ciphers()

void libwifi_get_pairwise_ciphers ( struct libwifi_bss bss,
char *  buf 
)

Enumerate the pairwise ciphers (GROUP, CCMP, BIP_CMAC128, etc) in a given libwifi_bss, formatted into the given buffer.

Parameters
bssA libwifi_bss struct
bufA buffer of length LIBWIFI_SECURITY_BUF_LEN

Definition at line 546 of file security.c.

◆ libwifi_get_rsn_info()

int libwifi_get_rsn_info ( struct libwifi_rsn_info info,
const unsigned char *  tag_data,
const unsigned char *  tag_end 
)

RSN Information is supplied via the raw tag data.

Get the RSN related information and store it in a libwifi_rsn_info.

The supplied data is then "walked" through as a pointer to extract the details of the tag and write them into a struct libwifi_rsn_info.

libwifi supports a maximum of 3 Pairwise Cipher Suites and 3 Auth Key Management Suites. The Version, Group Cipher Suite and Capabilities fields are all required.

Definition at line 32 of file security.c.

◆ libwifi_get_security_type()

void libwifi_get_security_type ( struct libwifi_bss bss,
char *  buf 
)

Enumerate the security types (WEP, WPA, WPA2, WPA3, etc) in a given libwifi_bss, formatted into the given buffer.

Parameters
bssA libwifi_bss struct
bufA buffer of length LIBWIFI_SECURITY_BUF_LEN

Definition at line 469 of file security.c.

◆ libwifi_get_wpa_info()

int libwifi_get_wpa_info ( struct libwifi_wpa_info info,
const unsigned char *  tag_data,
const unsigned char *  tag_end 
)

Similar to libwifi_get_rsn_info, WPA Information is supplied via the raw tag data.

Get the WPA related information and store it in a libwifi_wpa_info.

The supplied data is then "walked" through as a pointer to extract the details of the tag and write them into a struct libwifi_wpa_info.

libwifi supports a maximum of 3 Unicast Cipher Suites and 3 Auth Key Management Suites. The Version and Multicast Cipher Suite fields are required.

Definition at line 315 of file security.c.