Skip to content

Commit 1cb994e

Browse files
authored
Move security _pkey into X.509 condition (ARMmbed#99)
The private key member is only used when X.509 certificates are in use. Move it into the condition X.509 condition. This avoids compilation errors if mbed TLS is present with both X.509 and private key disabled.
1 parent 36d36ce commit 1cb994e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

source/coap_security_handler.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct coap_security_s {
5151
#if defined(MBEDTLS_X509_CRT_PARSE_C)
5252
mbedtls_x509_crt _cacert;
5353
mbedtls_x509_crt _owncert;
54-
#endif
5554
mbedtls_pk_context _pkey;
55+
#endif
5656

5757
uint8_t _pw[64];
5858
uint8_t _pw_len;
@@ -109,8 +109,8 @@ static int coap_security_handler_init(coap_security_t *sec){
109109
#if defined(MBEDTLS_X509_CRT_PARSE_C)
110110
mbedtls_x509_crt_init( &sec->_cacert );
111111
mbedtls_x509_crt_init( &sec->_owncert );
112-
#endif
113112
mbedtls_pk_init( &sec->_pkey );
113+
#endif
114114

115115
memset(&sec->_cookie, 0, sizeof(simple_cookie_t));
116116
memset(&sec->_keyblk, 0, sizeof(key_block_t));
@@ -145,9 +145,8 @@ static void coap_security_handler_reset(coap_security_t *sec){
145145
#if defined(MBEDTLS_X509_CRT_PARSE_C)
146146
mbedtls_x509_crt_free(&sec->_cacert);
147147
mbedtls_x509_crt_free(&sec->_owncert);
148-
#endif
149-
150148
mbedtls_pk_free(&sec->_pkey);
149+
#endif
151150

152151
mbedtls_entropy_free( &sec->_entropy );
153152
mbedtls_ctr_drbg_free( &sec->_ctr_drbg );

0 commit comments

Comments
 (0)