net/tls: fix log flooding and data aborts
authorJunyeon LEE <junyeon2.lee@samsung.com>
Thu, 6 Apr 2017 08:12:22 +0000 (17:12 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:08 +0000 (12:02 +0900)
This commit fixes two minor tls issues:
 . Log flooding when CONFIG_HW_DH_PARAM is enabled
 . Data abort at security APIs when called before see_init()

Change-Id: Ied77bc66adc732b21c472a9005fb28fe3eb421e3
Signed-off-by: Junyeon LEE <junyeon2.lee@samsung.com>
os/net/tls/see_api.c
os/net/tls/ssl_srv.c

index 1deda83..457d0ad 100644 (file)
@@ -306,10 +306,14 @@ int see_mutex_free(see_mutex_t *m)
 
 int see_mutex_lock(see_mutex_t *m)
 {
-       if (m == NULL || !m->valid) {
+       if (m == NULL) {
                return -1;
        }
 
+       if (!m->valid) {
+               see_init();
+       }
+
        if (pthread_mutex_lock(&m->mutex) != 0) {
                return -1;
        }
index 9831e66..d53c5a3 100644 (file)
@@ -2485,7 +2485,9 @@ static int ssl_write_server_key_exchange(mbedtls_ssl_context *ssl)
                p += len;
                n += len;
 
+#if !defined(CONFIG_HW_DH_PARAM)
                MBEDTLS_SSL_DEBUG_MPI(3, "DHM: X ", &ssl->handshake->dhm_ctx.X);
+#endif
                MBEDTLS_SSL_DEBUG_MPI(3, "DHM: P ", &ssl->handshake->dhm_ctx.P);
                MBEDTLS_SSL_DEBUG_MPI(3, "DHM: G ", &ssl->handshake->dhm_ctx.G);
                MBEDTLS_SSL_DEBUG_MPI(3, "DHM: GX", &ssl->handshake->dhm_ctx.GX);