Skip to content

Commit a83472e

Browse files
author
Mika Leppänen
committed
Added Wi-Sun certificate and security test interfaces
Added interface to add/remove additional trusted certificates and to add/remove certificate revocation lists. Added test interfaces to add GTKs, to set key index, to set key lifetimes and to initiate node revocation of access procedure.
1 parent 7f4ebf1 commit a83472e

File tree

7 files changed

+278
-1
lines changed

7 files changed

+278
-1
lines changed

nanostack/net_interface.h

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ typedef struct {
235235
const uint8_t *key_chain[4]; /**< Certificate private key. */
236236
} arm_certificate_chain_entry_s;
237237

238+
/** Certificate structure. */
239+
typedef struct {
240+
const uint8_t *cert; /**< Certificate pointer. */
241+
uint16_t cert_len; /**< Certificate length. */
242+
} arm_certificate_entry_s;
243+
244+
/** Certificate Revocation List structure. */
245+
typedef struct {
246+
const uint8_t *crl; /**< Certificate Revocation List pointer. */
247+
uint16_t crl_len; /**< Certificate Revocation List length. */
248+
} arm_cert_revocation_list_entry_s;
249+
238250
/** Structure for the network keys used by net_network_key_get */
239251
typedef struct ns_keys_t
240252

@@ -880,12 +892,56 @@ extern int8_t arm_net_route_delete(const uint8_t *prefix, uint8_t prefix_len, co
880892
extern int8_t arm_nwk_6lowpan_border_router_nd_context_load(int8_t interface_id, uint8_t *contex_data); //NVM
881893

882894
/**
883-
* Set certificate chain for PANA
895+
* Set certificate chain
896+
*
884897
* \param chain_info Certificate chain.
885898
* \return 0 on success, negative on failure.
886899
*/
887900
extern int8_t arm_network_certificate_chain_set(const arm_certificate_chain_entry_s *chain_info);
888901

902+
/**
903+
* Add trusted certificate
904+
*
905+
* This is used to add trusted root or intermediate certificate in addition to those
906+
* added using certificate chain set call. Function can be called several times to add
907+
* more than one certificate.
908+
*
909+
* \param cert Certificate.
910+
* \return 0 on success, negative on failure.
911+
*/
912+
extern int8_t arm_network_trusted_certificate_add(const arm_certificate_entry_s *cert);
913+
914+
/**
915+
* Remove trusted certificate
916+
*
917+
* This is used to remove trusted root or intermediate certificate.
918+
*
919+
* \param cert Certificate.
920+
* \return 0 on success, negative on failure.
921+
*/
922+
extern int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cert);
923+
924+
/**
925+
* Add Certificate Revocation List
926+
*
927+
* This is used to add Certificate Revocation List (CRL). Function can be called several
928+
* times to add more than one Certificate Revocation List.
929+
*
930+
* \param crl Certificate revocation list
931+
* \return 0 on success, negative on failure.
932+
*/
933+
extern int8_t arm_network_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl);
934+
935+
/**
936+
* Remove Certificate Revocation List
937+
*
938+
* This is used to remove Certificate Revocation List.
939+
*
940+
* \param crl Certificate revocation list
941+
* \return 0 on success, negative on failure.
942+
*/
943+
extern int8_t arm_network_certificate_revocation_list_remove(const arm_cert_revocation_list_entry_s *crl);
944+
889945
/**
890946
* \brief Add PSK key to TLS library.
891947
*

nanostack/net_ws_test.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,83 @@ int ws_test_pan_size_set(int8_t interface_id, uint16_t pan_size);
7272
*/
7373
int ws_test_max_child_count_set(int8_t interface_id, uint16_t child_count);
7474

75+
/**
76+
* Sets Group Transient Keys.
77+
*
78+
* Sets Group Transient Keys (GTKs). Up to four GTKs can be set (GTKs from index
79+
* 0 to 3). At least one GTK must be set. GTKs provided in this function call are
80+
* compared to current GTKs on node or border router GTK storage. If GTK is new
81+
* or modified it is updated to GTK storage. If GTK is same as previous one, no
82+
* changes are made. If GTK is NULL then it is removed from GTK storage. When a
83+
* new GTK is inserted or GTK is modified, GTK lifetime is set to default. If GTKs
84+
* are set to border router after bootstrap, border router initiates GTK update
85+
* to network.
86+
*
87+
* \param interface_id Network interface ID.
88+
* \param gtk GTK array, if GTK is not set, pointer for the index shall be NULL.
89+
*
90+
* \return 0 GTKs are set
91+
* \return <0 GTK set has failed
92+
*/
93+
int ws_test_gtk_set(int8_t interface_id, uint8_t *gtk[4]);
94+
95+
/**
96+
* Sets index of active key.
97+
*
98+
* Sets index of active Group Transient Key (GTK) to border router. If index is
99+
* set after bootstrap, initiates dissemination of new key index to network.
100+
*
101+
* \param interface_id Network interface ID.
102+
* \param index Key index
103+
*
104+
* \return 0 Active key index has been set
105+
* \return <0 Active key index set has failed
106+
*/
107+
int ws_test_active_key_set(int8_t interface_id, uint8_t index);
108+
109+
/**
110+
* Sets lifetime for keys
111+
*
112+
* Sets Group Transient Key (GTK), Pairwise Master Key (PMK) and
113+
* Pairwise Transient Key (PTK) lifetimes.
114+
*
115+
* \param interface_id Network interface ID.
116+
* \param gtk_lifetime GTK lifetime in minutes
117+
* \param pmk_lifetime PMK lifetime in minutes
118+
* \param ptk_lifetime PTK lifetime in minutes
119+
*
120+
* \return 0 Lifetimes are set
121+
* \return <0 Lifetime set has failed
122+
*/
123+
int ws_test_key_lifetime_set(
124+
int8_t interface_id,
125+
uint32_t gtk_lifetime,
126+
uint32_t pmk_lifetime,
127+
uint32_t ptk_lifetime
128+
);
129+
130+
/**
131+
* Sets time configurations for GTK keys
132+
*
133+
* Sets GTK Revocation Lifetime Reduction and GTK New Activation Time values
134+
* as parts of the GTK lifetime (e.g. value 3 is 1/3 * lifetime). Sets GTK
135+
* maximum mismatch time in minutes.
136+
*
137+
* \param interface_id Network interface ID.
138+
* \param revocat_lifetime_reduct GTK Revocation Lifetime Reduction (1 / value * GTK lifetime)
139+
* \param new_activation_time GTK New Activation Time (1 / value * GTK lifetime)
140+
* \param max_mismatch GTK maximum mismatch in minutes
141+
*
142+
* \return 0 Lifetimes are set
143+
* \return <0 Lifetime set has failed.
144+
*/
145+
int ws_test_gtk_time_settings_set(
146+
int8_t interface_id,
147+
uint8_t revocat_lifetime_reduct,
148+
uint8_t new_activation_time,
149+
uint32_t max_mismatch
150+
);
151+
75152
#ifdef __cplusplus
76153
}
77154
#endif

nanostack/ws_bbr_api.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,38 @@ int ws_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
6868
*/
6969
void ws_bbr_stop(int8_t interface_id);
7070

71+
/**
72+
* Remove node's keys from border router
73+
*
74+
* Removes node's keys from border router i.e. Pairwise Master Key (PMK)
75+
* and Pairwise Transient Key (PTK). This function is used on revocation of
76+
* node's access procedure after authentication service is configured
77+
* to reject authentication attempts of the node (e.g. node's certificate is
78+
* revoked). Sub sequential calls to function can be used to remove several
79+
* nodes from border router.
80+
*
81+
* \param interface_id Network interface ID.
82+
* \param eui64 EUI-64 of revoked node
83+
*
84+
* \return 0, Node's keys has been removed
85+
* \return <0 Node's key remove has failed (e.g. unknown address)
86+
*/
87+
int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64);
88+
89+
/**
90+
* Start revocation of node's access
91+
*
92+
* Starts revocation of node's access procedure on border router. Before
93+
* the call to this function, authentication service must be configured to
94+
* reject authentication attempts of the removed nodes (e.g. certificates
95+
* of the nodes are revoked). Also the keys for the nodes must be removed
96+
* from the border router.
97+
*
98+
* \param interface_id Network interface ID.
99+
*
100+
* \return 0, Revocation started OK.
101+
* \return <0 Revocation start failed.
102+
*/
103+
int ws_bbr_node_access_revoke_start(int8_t interface_id);
71104

72105
#endif /* WS_BBR_API_H_ */

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,18 @@ void ws_bbr_stop(int8_t interface_id)
471471
(void)interface_id;
472472
#endif
473473
}
474+
475+
int ws_bbr_node_keys_remove(int8_t interface_id, uint8_t *eui64)
476+
{
477+
(void) interface_id;
478+
(void) eui64;
479+
480+
return -1;
481+
}
482+
483+
int ws_bbr_node_access_revoke_start(int8_t interface_id)
484+
{
485+
(void) interface_id;
486+
487+
return -1;
488+
}

source/6LoWPAN/ws/ws_empty_functions.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,41 @@ int ws_test_max_child_count_set(int8_t interface_id, uint16_t child_count)
145145
return -1;
146146
}
147147

148+
int ws_test_gtk_set(int8_t interface_id, uint8_t *gtk[4])
149+
{
150+
(void) interface_id;
151+
(void) gtk;
152+
153+
return -1;
154+
}
155+
156+
int ws_test_active_key_set(int8_t interface_id, uint8_t index)
157+
{
158+
(void) interface_id;
159+
(void) index;
160+
161+
return -1;
162+
}
163+
164+
int ws_test_key_lifetime_set(int8_t interface_id, uint32_t gtk_lifetime, uint32_t pmk_lifetime, uint32_t ptk_lifetime)
165+
{
166+
(void) interface_id;
167+
(void) gtk_lifetime;
168+
(void) pmk_lifetime;
169+
(void) ptk_lifetime;
170+
171+
return -1;
172+
}
173+
174+
int ws_test_gtk_time_settings_set(int8_t interface_id, uint8_t revocat_lifetime_reduct, uint8_t new_activation_time, uint32_t max_mismatch)
175+
{
176+
(void) interface_id;
177+
(void) revocat_lifetime_reduct;
178+
(void) new_activation_time;
179+
(void) max_mismatch;
180+
181+
return -1;
182+
}
183+
148184
#endif // no HAVE_WS
149185

source/6LoWPAN/ws/ws_test_api.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,40 @@ int ws_test_max_child_count_set(int8_t interface_id, uint16_t child_count)
5555
return 0;
5656
}
5757

58+
int ws_test_gtk_set(int8_t interface_id, uint8_t *gtk[4])
59+
{
60+
(void) interface_id;
61+
(void) gtk;
62+
63+
return 0;
64+
}
65+
66+
int ws_test_active_key_set(int8_t interface_id, uint8_t index)
67+
{
68+
(void) interface_id;
69+
(void) index;
70+
71+
return 0;
72+
}
73+
74+
int ws_test_key_lifetime_set(int8_t interface_id, uint32_t gtk_lifetime, uint32_t pmk_lifetime, uint32_t ptk_lifetime)
75+
{
76+
(void) interface_id;
77+
(void) gtk_lifetime;
78+
(void) pmk_lifetime;
79+
(void) ptk_lifetime;
80+
81+
return 0;
82+
}
83+
84+
int ws_test_gtk_time_settings_set(int8_t interface_id, uint8_t revocat_lifetime_reduct, uint8_t new_activation_time, uint32_t max_mismatch)
85+
{
86+
(void) interface_id;
87+
(void) revocat_lifetime_reduct;
88+
(void) new_activation_time;
89+
(void) max_mismatch;
90+
91+
return 0;
92+
}
93+
5894
#endif // HAVE_WS

source/libNET/src/ns_net.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,30 @@ int8_t arm_network_certificate_chain_set(const arm_certificate_chain_entry_s *ch
942942
return pana_interface_certificate_chain_set(chain_info);
943943
}
944944

945+
int8_t arm_network_trusted_certificate_add(const arm_certificate_entry_s *cert)
946+
{
947+
(void) cert;
948+
return -1;
949+
}
950+
951+
int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cert)
952+
{
953+
(void) cert;
954+
return -1;
955+
}
956+
957+
int8_t arm_network_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl)
958+
{
959+
(void) crl;
960+
return -1;
961+
}
962+
963+
int8_t arm_network_certificate_revocation_list_remove(const arm_cert_revocation_list_entry_s *crl)
964+
{
965+
(void) crl;
966+
return -1;
967+
}
968+
945969
/**
946970
* \brief Read Pana server security key material
947971
*

0 commit comments

Comments
 (0)