Skip to content

Commit 8088a86

Browse files
author
Mika Leppänen
committed
Added and fixed security protocols comments
1 parent cc32457 commit 8088a86

File tree

15 files changed

+174
-24
lines changed

15 files changed

+174
-24
lines changed

source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#ifdef HAVE_WS
3737

38-
#define TRACE_GROUP "eaptls_secp"
38+
#define TRACE_GROUP "eapt"
3939

4040
typedef enum {
4141
EAP_TLS_STATE_INIT = SEC_STATE_INIT,
@@ -63,7 +63,7 @@ static const trickle_params_t eap_tls_trickle_params = {
6363
.Imin = 50, /* 5000ms; ticks are 100ms */
6464
.Imax = 150, /* 15000ms */
6565
.k = 0, /* infinity - no consistency checking */
66-
.TimerExpirations = 4 //TRICKLE_EXPIRATIONS_INFINITE
66+
.TimerExpirations = 4
6767
};
6868

6969
static uint16_t eap_tls_sec_prot_size(void);

source/Security/protocols/eap_tls_sec_prot/eap_tls_sec_prot.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,29 @@
1818
#ifndef EAP_TLS_SEC_PROT_H_
1919
#define EAP_TLS_SEC_PROT_H_
2020

21+
/*
22+
* EAP-TLS security protocol. Specified in RFC 5216 and and Wi-SUN FANWG-FANTPS.
23+
*
24+
*/
25+
26+
/**
27+
* eap_tls_supp_sec_prot_register register authenticator EAP-TLS protocol to KMP service
28+
*
29+
* \param service KMP service
30+
*
31+
* \return < 0 failure
32+
* \return >= 0 success
33+
*/
2134
int8_t eap_tls_supp_sec_prot_register(kmp_service_t *service);
35+
36+
/**
37+
* eap_tls_auth_sec_prot_register register authenticator EAP-TLS protocol to KMP service
38+
*
39+
* \param service KMP service
40+
*
41+
* \return < 0 failure
42+
* \return >= 0 success
43+
*/
2244
int8_t eap_tls_auth_sec_prot_register(kmp_service_t *service);
2345

2446
#endif /* EAP_TLS_SEC_PROT_H_ */

source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#ifdef HAVE_WS
4040

41-
#define TRACE_GROUP "fwh_secp"
41+
#define TRACE_GROUP "afwh"
4242

4343
typedef enum {
4444
FWH_STATE_INIT = SEC_STATE_INIT,
@@ -76,7 +76,7 @@ static const trickle_params_t fwh_trickle_params = {
7676
.Imin = 50, /* 5000ms; ticks are 100ms */
7777
.Imax = 150, /* 15000ms */
7878
.k = 0, /* infinity - no consistency checking */
79-
.TimerExpirations = 4 //TRICKLE_EXPIRATIONS_INFINITE
79+
.TimerExpirations = 4
8080
};
8181

8282
static uint16_t auth_fwh_sec_prot_size(void);

source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818
#ifndef AUTH_FWH_SEC_PROT_H_
1919
#define AUTH_FWH_SEC_PROT_H_
2020

21+
/*
22+
* Authenticator Four Way Handshake (4WH) security protocol. 4WH protocol is
23+
* specified in IEEE 802.11 and Wi-SUN FANWG-FANTPS.
24+
*
25+
*/
26+
27+
/**
28+
* auth_fwh_sec_prot_register register authenticator 4WH protocol to KMP service
29+
*
30+
* \param service KMP service
31+
*
32+
* \return < 0 failure
33+
* \return >= 0 success
34+
*/
2135
int8_t auth_fwh_sec_prot_register(kmp_service_t *service);
2236

2337
#endif /* AUTH_FWH_SEC_PROT_H_ */

source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#ifdef HAVE_WS
4040

41-
#define TRACE_GROUP "fwh_secp"
41+
#define TRACE_GROUP "sfwh"
4242

4343
typedef enum {
4444
FWH_STATE_INIT = SEC_STATE_INIT,
@@ -80,7 +80,7 @@ static const trickle_params_t fwh_trickle_params = {
8080
.Imin = 50, /* 5000ms; ticks are 100ms */
8181
.Imax = 150, /* 15000ms */
8282
.k = 0, /* infinity - no consistency checking */
83-
.TimerExpirations = 4 //TRICKLE_EXPIRATIONS_INFINITE
83+
.TimerExpirations = 4
8484
};
8585

8686
static uint16_t supp_fwh_sec_prot_size(void);

source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818
#ifndef SUPP_FWH_SEC_PROT_H_
1919
#define SUPP_FWH_SEC_PROT_H_
2020

21+
/*
22+
* Supplicant Four Way Handshake (4WH) security protocol. 4WH protocol is
23+
* specified in IEEE 802.11 and Wi-SUN FANWG-FANTPS.
24+
*
25+
*/
26+
27+
/**
28+
* supp_fwh_sec_prot_register register supplicant 4WH protocol to KMP service
29+
*
30+
* \param service KMP service
31+
*
32+
* \return < 0 failure
33+
* \return >= 0 success
34+
*/
2135
int8_t supp_fwh_sec_prot_register(kmp_service_t *service);
2236

2337
#endif /* SUPP_FWH_SEC_PROT_H_ */

source/Security/protocols/gkh_sec_prot/gkh_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#ifdef HAVE_WS
3737

38-
#define TRACE_GROUP "gkh_secp"
38+
#define TRACE_GROUP "cgkh"
3939

4040
typedef enum {
4141
GKH_STATE_INIT = SEC_STATE_INIT,
@@ -64,7 +64,7 @@ static const trickle_params_t gkh_trickle_params = {
6464
.Imin = 50, /* 5000ms; ticks are 100ms */
6565
.Imax = 150, /* 15000ms */
6666
.k = 0, /* infinity - no consistency checking */
67-
.TimerExpirations = 4 //TRICKLE_EXPIRATIONS_INFINITE
67+
.TimerExpirations = 4
6868
};
6969

7070
static uint16_t gkh_sec_prot_size(void);

source/Security/protocols/gkh_sec_prot/gkh_sec_prot.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,30 @@
1818
#ifndef GKH_SEC_PROT_H_
1919
#define GKH_SEC_PROT_H_
2020

21+
/*
22+
* Group Key Handshake (GKH) security protocol. GKH protocol is specified
23+
* in IEEE 802.11 and Wi-SUN FANWG-FANTPS.
24+
*
25+
*/
26+
27+
/**
28+
* gkh_supp_sec_prot_register register authenticator GKH protocol to KMP service
29+
*
30+
* \param service KMP service
31+
*
32+
* \return < 0 failure
33+
* \return >= 0 success
34+
*/
2135
int8_t gkh_supp_sec_prot_register(kmp_service_t *service);
36+
37+
/**
38+
* gkh_auth_sec_prot_register register supplicant GKH protocol to KMP service
39+
*
40+
* \param service KMP service
41+
*
42+
* \return < 0 failure
43+
* \return >= 0 success
44+
*/
2245
int8_t gkh_auth_sec_prot_register(kmp_service_t *service);
2346

2447
#endif /* GKH_SEC_PROT_H_ */

source/Security/protocols/key_sec_prot/key_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#ifdef HAVE_WS
3838

39-
#define TRACE_GROUP "key_secp"
39+
#define TRACE_GROUP "ksep"
4040

4141
typedef enum {
4242
KEY_INIT = 0,

source/Security/protocols/key_sec_prot/key_sec_prot.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
#ifndef KEY_SEC_PROT_H_
1919
#define KEY_SEC_PROT_H_
2020

21+
/*
22+
* EAPOL-Key security protocol. Protocol is used for sending and receiving
23+
* initial EAPOL-Key message that is used to start the supplicant
24+
* authentication. Specified in Wi-SUN FANWG-FANTPS.
25+
*
26+
*/
27+
28+
/**
29+
* key_sec_prot_register register EAPOL-Key protocol to KMP service
30+
*
31+
* \param service KMP service
32+
*
33+
* \return < 0 failure
34+
* \return >= 0 success
35+
*/
2136
int8_t key_sec_prot_register(kmp_service_t *service);
2237

2338
#endif /* KEY_SEC_PROT_H_ */

source/Security/protocols/sec_prot.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
#ifndef SEC_PROT_H_
1919
#define SEC_PROT_H_
2020

21+
/*
22+
* Interface between KMP API and key management security protocols. Interface
23+
* provides abstraction for different security protocols for KMP API module.
24+
*
25+
* For security protocols it provides access to network, timing, callback
26+
* security keys and network address services.
27+
*
28+
*/
29+
2130
typedef enum {
2231
SEC_RESULT_OK = 0,
2332
SEC_RESULT_ERR_NO_MEM = -1,
@@ -172,7 +181,6 @@ typedef void sec_prot_timer_timeout(sec_prot_t *prot, uint16_t ticks);
172181
*/
173182
typedef void sec_prot_eui64_addr_get(sec_prot_t *prot, uint8_t *local_eui64, uint8_t *remote_eui64);
174183

175-
176184
// Security protocol data
177185
struct sec_prot_s {
178186
sec_prot_create_request *create_req; /**< Create request */
@@ -202,6 +210,4 @@ struct sec_prot_s {
202210
uint8_t data; /**< Protocol internal data */
203211
};
204212

205-
206-
207213
#endif /* SEC_PROT_H_ */

source/Security/protocols/sec_prot_keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#ifdef HAVE_WS
3131

32-
#define TRACE_GROUP "skeys"
32+
#define TRACE_GROUP "spke"
3333

3434
sec_prot_keys_t *sec_prot_keys_create(sec_prot_gtk_keys_t *gtks)
3535
{

source/Security/protocols/sec_prot_keys.h

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,87 @@
1818
#ifndef SEC_PROT_KEYS_H_
1919
#define SEC_PROT_KEYS_H_
2020

21+
/*
22+
* Security protocols Wi-Sun EAPOL key storage module. This is used by Wi-Sun EAPOL
23+
* protocols to store and update key information.
24+
*
25+
*/
26+
2127
#define PMK_LEN 32
2228
#define PTK_LEN 48
2329
#define GTK_LEN 16
2430

2531
#define PMKID_LEN 16
2632

2733
typedef struct {
28-
uint8_t key[GTK_LEN]; /**< GTK (128 bits) */
34+
uint8_t key[GTK_LEN]; /**< Group Transient Key (128 bits) */
2935
uint32_t lifetime; /**< Lifetime is seconds */
30-
uint8_t set:1; /**< GTK set (valid value) */
31-
uint8_t live:1; /**< GTK live (as indicated by authenticator) */
32-
uint8_t hash:1; /**< GTK matches to hash */
36+
uint8_t set:1; /**< Group Transient Key set (valid value) */
37+
uint8_t live:1; /**< Group Transient Key live (as indicated by authenticator) */
38+
uint8_t hash:1; /**< Group Transient Key matches to hash */
3339
} gtk_key_t;
3440

3541
typedef struct {
36-
gtk_key_t gtk[4]; /**< 4 GTKs */
42+
gtk_key_t gtk[4]; /**< 4 Group Transient Keys */
3743
} sec_prot_gtk_keys_t;
3844

3945
// Security key data
4046
typedef struct {
41-
uint64_t pmk_key_replay_cnt; /**< PMK key replay counter */
42-
uint8_t pmk[PMK_LEN]; /**< PMK (256 bits) */
43-
uint8_t ptk[PTK_LEN]; /**< PTK (384 bits) */
44-
int8_t gtk_set_index; /**< GTK to insert */
45-
sec_prot_gtk_keys_t *gtks; /**< GTKs */
47+
uint64_t pmk_key_replay_cnt; /**< Pairwise Master Key replay counter */
48+
uint8_t pmk[PMK_LEN]; /**< Pairwise Master Key (256 bits) */
49+
uint8_t ptk[PTK_LEN]; /**< Pairwise Transient key (384 bits) */
50+
int8_t gtk_set_index; /**< Group Transient Key to insert */
51+
sec_prot_gtk_keys_t *gtks; /**< Group Transient Key */
4652
} sec_prot_keys_t;
4753

54+
/**
55+
* sec_prot_keys_create allocates memory for security keys
56+
*
57+
* \param gtks GTK keys
58+
*
59+
* \return security keys or NULL
60+
*/
4861
sec_prot_keys_t *sec_prot_keys_create(sec_prot_gtk_keys_t *gtks);
62+
63+
/**
64+
* sec_prot_keys_init initialises security keys
65+
*
66+
* \param sec_keys security keys
67+
* \param gtks GTK keys
68+
*
69+
*/
4970
void sec_prot_keys_init(sec_prot_keys_t *sec_keys, sec_prot_gtk_keys_t *gtks);
71+
72+
/**
73+
* sec_prot_keys_delete frees security keys memory
74+
*
75+
* \param sec_keys security keys
76+
*
77+
*/
5078
void sec_prot_keys_delete(sec_prot_keys_t *sec_keys);
79+
80+
/**
81+
* sec_prot_keys_gtks_create allocates memory for GTK keys
82+
*
83+
* \return GTK keys or NULL
84+
*
85+
*/
5186
sec_prot_gtk_keys_t *sec_prot_keys_gtks_create(void);
87+
88+
/**
89+
* sec_prot_keys_gtks_init initialises GTK keys
90+
*
91+
* \param gtks GTK keys
92+
*
93+
*/
5294
void sec_prot_keys_gtks_init(sec_prot_gtk_keys_t *gtks);
95+
96+
/**
97+
* sec_prot_keys_gtks_delete frees GTK keys memory
98+
*
99+
* \param gtks GTK keys
100+
*
101+
*/
53102
void sec_prot_keys_gtks_delete(sec_prot_gtk_keys_t *gtks);
54103

55104
#endif /* SEC_PROT_KEYS_H_ */

source/Security/protocols/sec_prot_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#ifdef HAVE_WS
4242

43-
#define TRACE_GROUP "fwh_secp"
43+
#define TRACE_GROUP "secl"
4444

4545
void sec_prot_init(sec_prot_common_t *data)
4646
{

source/Security/protocols/sec_prot_lib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#ifndef SEC_PROT_LIB_H_
1919
#define SEC_PROT_LIB_H_
2020

21+
/*
22+
* Library functions used by security protocols. These include helper functions
23+
* related to different hash functions, common message handling functions, and
24+
* common timer and state machine functions.
25+
*
26+
*/
27+
2128
#define FWH_NONCE_LENGTH 32
2229
#define EUI64_LEN 8
2330

0 commit comments

Comments
 (0)