There are certain subtle differences in behavior when we're encrypted
with the STK, such as allowing re-encryption even though the security
level stays the same. Because of this, add a flag to track whether we're
encrypted with an STK or not.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
        HCI_CONN_AUTH,
        HCI_CONN_SECURE,
        HCI_CONN_FIPS,
+       HCI_CONN_STK_ENCRYPT,
 };
 
 static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
 
         * using a distributed LTK.
         */
        if (ltk->type == SMP_STK) {
+               set_bit(HCI_CONN_STK_ENCRYPT, &conn->flags);
                list_del(<k->list);
                kfree(ltk);
+       } else {
+               clear_bit(HCI_CONN_STK_ENCRYPT, &conn->flags);
        }
 
        hci_dev_unlock(hdev);
 
 
                hci_le_start_enc(hcon, ediv, rand, stk);
                hcon->enc_key_size = smp->enc_key_size;
+               set_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags);
        } else {
                u8 stk[16], auth;
                __le64 rand = 0;
        hci_le_start_enc(hcon, key->ediv, key->rand, key->val);
        hcon->enc_key_size = key->enc_size;
 
+       /* We never store STKs for master role, so clear this flag */
+       clear_bit(HCI_CONN_STK_ENCRYPT, &hcon->flags);
+
        return true;
 }