Skip to content

Commit dfcebef

Browse files
author
Mika Leppänen
committed
Added support for new certificate modification functions
Added support to PAE controller for own certificate add, own certificates remove and trusted certificates remove. Own certificate modification functions enable using der coded certificates on application side.
1 parent fd4b2e9 commit dfcebef

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

source/6LoWPAN/ws/ws_pae_controller.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,40 @@ int8_t ws_pae_controller_certificate_chain_set(const arm_certificate_chain_entry
769769
return 0;
770770
}
771771

772+
int8_t ws_pae_controller_own_certificate_add(const arm_certificate_entry_s *cert)
773+
{
774+
if (!cert) {
775+
return -1;
776+
}
777+
778+
int8_t ret = -1;
779+
780+
ns_list_foreach(pae_controller_t, entry, &pae_controller_list) {
781+
for (uint8_t i = 0; i < SEC_PROT_CERT_CHAIN_DEPTH; i++) {
782+
if (entry->certs.own_cert_chain.cert[i] == NULL) {
783+
sec_prot_certs_cert_set(&entry->certs.own_cert_chain, i, (uint8_t *) cert->cert, cert->cert_len);
784+
// Set private key if set for the certificate that is added
785+
if (cert->key && cert->key_len > 0) {
786+
sec_prot_certs_priv_key_set(&entry->certs.own_cert_chain, (uint8_t *) cert->key, cert->key_len);
787+
}
788+
ret = 0;
789+
break;
790+
}
791+
}
792+
}
793+
794+
return ret;
795+
}
796+
797+
int8_t ws_pae_controller_own_certificates_remove(void)
798+
{
799+
ns_list_foreach(pae_controller_t, entry, &pae_controller_list) {
800+
sec_prot_certs_chain_entry_init(&entry->certs.own_cert_chain);
801+
}
802+
803+
return 0;
804+
}
805+
772806
int8_t ws_pae_controller_trusted_certificate_add(const arm_certificate_entry_s *cert)
773807
{
774808
if (!cert) {
@@ -816,6 +850,15 @@ int8_t ws_pae_controller_trusted_certificate_remove(const arm_certificate_entry_
816850
return ret;
817851
}
818852

853+
int8_t ws_pae_controller_trusted_certificates_remove(void)
854+
{
855+
ns_list_foreach(pae_controller_t, entry, &pae_controller_list) {
856+
sec_prot_certs_chain_list_delete(&entry->certs.trusted_cert_chain_list);
857+
}
858+
859+
return 0;
860+
}
861+
819862
int8_t ws_pae_controller_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl)
820863
{
821864
if (!crl) {

source/6LoWPAN/ws/ws_pae_controller.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,26 @@ int8_t ws_pae_controller_timing_adjust(uint8_t timing);
158158
*/
159159
int8_t ws_pae_controller_certificate_chain_set(const arm_certificate_chain_entry_s *chain);
160160

161+
/**
162+
* ws_pae_controller_own_certificate_add add own certificate to certificate chain
163+
*
164+
* \param cert own certificate
165+
*
166+
* \return < 0 failure
167+
* \return >= 0 success
168+
*
169+
*/
170+
int8_t ws_pae_controller_own_certificate_add(const arm_certificate_entry_s *cert);
171+
172+
/**
173+
* ws_pae_controller_own_certificates_remove removes own certificates
174+
*
175+
* \return < 0 failure
176+
* \return >= 0 success
177+
*
178+
*/
179+
int8_t ws_pae_controller_own_certificates_remove(void);
180+
161181
/**
162182
* ws_pae_controller_trusted_certificate_add add trusted certificate
163183
*
@@ -180,6 +200,15 @@ int8_t ws_pae_controller_trusted_certificate_add(const arm_certificate_entry_s *
180200
*/
181201
int8_t ws_pae_controller_trusted_certificate_remove(const arm_certificate_entry_s *cert);
182202

203+
/**
204+
* ws_pae_controller_trusted_certificates_remove removes trusted certificates
205+
*
206+
* \return < 0 failure
207+
* \return >= 0 success
208+
*
209+
*/
210+
int8_t ws_pae_controller_trusted_certificates_remove(void);
211+
183212
/**
184213
* ws_pae_controller_certificate_revocation_list_add add certification revocation list
185214
*

source/libNET/src/ns_net.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,18 +988,30 @@ int8_t arm_network_trusted_certificate_remove(const arm_certificate_entry_s *cer
988988

989989
int8_t arm_network_trusted_certificates_remove(void)
990990
{
991+
#ifdef HAVE_WS
992+
return ws_pae_controller_trusted_certificates_remove();
993+
#else
991994
return -1;
995+
#endif
992996
}
993997

994998
int8_t arm_network_own_certificate_add(const arm_certificate_entry_s *cert)
995999
{
1000+
#ifdef HAVE_WS
1001+
return ws_pae_controller_own_certificate_add(cert);
1002+
#else
9961003
(void) cert;
9971004
return -1;
1005+
#endif
9981006
}
9991007

10001008
extern int8_t arm_network_own_certificates_remove(void)
10011009
{
1010+
#ifdef HAVE_WS
1011+
return ws_pae_controller_own_certificates_remove();
1012+
#else
10021013
return -1;
1014+
#endif
10031015
}
10041016

10051017
int8_t arm_network_certificate_revocation_list_add(const arm_cert_revocation_list_entry_s *crl)

0 commit comments

Comments
 (0)