From 893e9333186fb10562da1306cd3d4f6cfcbb450e Mon Sep 17 00:00:00 2001
From: Matthias Ringwald <matthias@ringwald.ch>
Date: Mon, 27 Jun 2016 16:55:29 +0200
Subject: [PATCH] sm: truncate LTK for SC as needed

---
 src/ble/sm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ble/sm.c b/src/ble/sm.c
index 7ea8255d5..c628a0793 100644
--- a/src/ble/sm.c
+++ b/src/ble/sm.c
@@ -1407,6 +1407,7 @@ static void sm_sc_cmac_done(uint8_t * hash){
             break;            
         case SM_SC_W4_CALCULATE_F5_LTK:
             memcpy(setup->sm_ltk, hash, 16);
+            sm_truncate_key(setup->sm_ltk, sm_conn->sm_actual_encryption_key_size);
             sm_conn->sm_engine_state = SM_SC_W2_CALCULATE_F6_FOR_DHKEY_CHECK;
             break; 
         case SM_SC_W4_CALCULATE_F6_FOR_DHKEY_CHECK: