diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 90929d563b0ce741fa125119a90c4341c70160e2..17d921d4d987bac3f768635d40b15772203991d1 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -1649,7 +1649,7 @@ foreach(myExe s1ap
     ${OPENAIR3_DIR}/TEST/test_${myExe}.c
     )
   target_link_libraries (test_${myExe}
-    -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} fdproto fdcore
+    -Wl,--start-group SECU_CN UTIL LFDS -Wl,--end-group m rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${NETTLE_LIBRARIES} ${CONFIG_LIBRARIES} 
     )
 endforeach(myExe)
 
diff --git a/openair3/TEST/test_kdf.c b/openair3/TEST/test_kdf.c
index 2a66527773218f57e2cbeac2bf7876d9806ecf66..121efcb9532c011e8179b4d99f560a25911a6166 100644
--- a/openair3/TEST/test_kdf.c
+++ b/openair3/TEST/test_kdf.c
@@ -42,9 +42,9 @@ static
 void do_kdf(uint8_t *key, unsigned key_length, uint8_t *data, unsigned data_length,
             uint8_t *exp, unsigned exp_length)
 {
-  uint8_t *result;
+  uint8_t result[32];
 
-  kdf(key, key_length, data, data_length, &result, 32);
+  kdf(key, key_length, data, data_length, result, 32);
 
   if (compare_buffer(result, exp_length, exp, exp_length) != 0) {
     fail("Fail: kdf\n");
diff --git a/openair3/TEST/test_secu_kenb.c b/openair3/TEST/test_secu_kenb.c
index 16f6a8eadc9faceb802eabfb151f30b5648d4332..967e45722907580815bfc0aeac45def5611c38da 100644
--- a/openair3/TEST/test_secu_kenb.c
+++ b/openair3/TEST/test_secu_kenb.c
@@ -39,15 +39,15 @@ static
 void do_derive_kenb(uint32_t nas_count, const uint8_t *kasme, const unsigned length,
                     const uint8_t *kenb_exp)
 {
-  uint8_t *kenb;
+  uint8_t kenb[32];
 
-  derive_keNB(kasme, nas_count, &kenb);
+  memset(kenb, 0, sizeof(kenb));
+  derive_keNB(kasme, nas_count, kenb);
 
   if (compare_buffer(kenb_exp, length, kenb, length) != 0) {
     fail("Fail: kenb derivation\n");
   }
 
-  free(kenb);
 }
 
 void doit (void)
diff --git a/openair3/TEST/test_secu_knas.c b/openair3/TEST/test_secu_knas.c
index ecf213f7b3027e8b931e0c42b77835bbf476f4d5..9b9cdc415a18db118cdaf7d6ea6e573865ce6704 100644
--- a/openair3/TEST/test_secu_knas.c
+++ b/openair3/TEST/test_secu_knas.c
@@ -39,21 +39,23 @@ static
 void derive_knas_keys(algorithm_type_dist_t atd, uint8_t *kasme, unsigned length,
                       uint8_t *knas_enc_exp, uint8_t *knas_int_exp)
 {
-  uint8_t *knas_enc;
-  uint8_t *knas_int;
+  uint8_t *knas_enc = NULL;
+  uint8_t *knas_int = NULL;
 
-  derive_key_nas_enc(atd, kasme, &knas_enc);
-  derive_key_nas_int(atd, kasme, &knas_int);
+  knas_enc = calloc(1, 32);
+  knas_int = calloc(1, 32);
+
+  derive_key_nas_enc(atd, kasme, knas_enc);
+  derive_key_nas_int(atd, kasme, knas_int);
 
   /* Compare both keys with expected */
-  if (compare_buffer(knas_enc, 32, knas_enc_exp, 32) != 0) {
+  if (compare_buffer(knas_enc, 16, &knas_enc_exp[16], 16) != 0) {
     fail("Fail: knas_enc derivation\n");
   }
 
-  if (compare_buffer(knas_int, 32, knas_int_exp, 32) != 0) {
+  if (compare_buffer(knas_int, 16, &knas_int_exp[16], 16) != 0) {
     fail("Fail: knas_int derivation\n");
   }
-
   free(knas_enc);
   free(knas_int);
 }
diff --git a/openair3/TEST/test_secu_knas_encrypt_eea1.c b/openair3/TEST/test_secu_knas_encrypt_eea1.c
index 9c54828ff4dcafd516fa2af3ae332f3ac08c4be1..83a4077d892b820db034b815a34dd7ba17303605 100755
--- a/openair3/TEST/test_secu_knas_encrypt_eea1.c
+++ b/openair3/TEST/test_secu_knas_encrypt_eea1.c
@@ -40,14 +40,15 @@ void eea1_encrypt(uint8_t direction, uint32_t count,
                   uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
                   uint32_t length, uint8_t *expected)
 {
-  nas_stream_cipher_t *nas_cipher;
-  uint8_t *result;
-  uint32_t zero_bits = length & 7;
-  uint32_t byte_length = length >> 3;
+  nas_stream_cipher_t *nas_cipher  = NULL;
+  uint8_t             *result      = NULL;
+  uint32_t             zero_bits   = length & 7;
+  uint32_t             byte_length = length >> 3;
 
   if (zero_bits > 0)
     byte_length += 1;
 
+  result     = calloc(1, byte_length);
   nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
 
   nas_cipher->direction  = direction;
@@ -58,7 +59,7 @@ void eea1_encrypt(uint8_t direction, uint32_t count,
   nas_cipher->blength    = length;
   nas_cipher->message    = message;
 
-  if (nas_stream_encrypt_eea1(nas_cipher, &result) != 0)
+  if (nas_stream_encrypt_eea1(nas_cipher, result) != 0)
     fail("Fail: nas_stream_encrypt_eea1\n");
 
   if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
diff --git a/openair3/TEST/test_secu_knas_encrypt_eea2.c b/openair3/TEST/test_secu_knas_encrypt_eea2.c
index 712da6d947f713369cd9901b65eedfbe2e8e57ed..d0ff01c1e6bf36f1b1f18055046a6b64b079c2b0 100644
--- a/openair3/TEST/test_secu_knas_encrypt_eea2.c
+++ b/openair3/TEST/test_secu_knas_encrypt_eea2.c
@@ -40,14 +40,15 @@ void eea2_encrypt(uint8_t direction, uint32_t count,
                   uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
                   uint32_t length, uint8_t *expected)
 {
-  nas_stream_cipher_t *nas_cipher;
-  uint8_t *result;
-  uint32_t zero_bits = length & 7;
-  uint32_t byte_length = length >> 3;
+  nas_stream_cipher_t *nas_cipher  = NULL;
+  uint8_t             *result      = NULL;
+  uint32_t             zero_bits   = length & 7;
+  uint32_t             byte_length = length >> 3;
 
   if (zero_bits > 0)
     byte_length += 1;
 
+  result     = calloc(1, byte_length);
   nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
 
   nas_cipher->direction  = direction;
@@ -58,7 +59,7 @@ void eea2_encrypt(uint8_t direction, uint32_t count,
   nas_cipher->blength    = length;
   nas_cipher->message    = message;
 
-  if (nas_stream_encrypt_eea2(nas_cipher, &result) != 0)
+  if (nas_stream_encrypt_eea2(nas_cipher, result) != 0)
     fail("Fail: nas_stream_encrypt_eea2\n");
 
   if (compare_buffer(result, byte_length, expected, byte_length) != 0) {