You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/06/06 14:29:18 UTC

[2/4] incubator-mynewt-core git commit: BLE Host - Rename SM identifiers for consistency.

BLE Host - Rename SM identifiers for consistency.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6c8d7bd3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6c8d7bd3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6c8d7bd3

Branch: refs/heads/develop
Commit: 6c8d7bd3d619b74a47809ddf92a3706f3bfe31a5
Parents: baa7a02
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Jun 6 19:43:37 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Jun 6 19:43:37 2016 +0800

----------------------------------------------------------------------
 apps/bletiny/src/cmd.c                 |  12 +-
 apps/bletiny/src/main.c                |   2 +-
 net/nimble/host/include/host/ble_sm.h  |  20 +-
 net/nimble/host/src/ble_sm.c           | 279 ++++++++++++++--------------
 net/nimble/host/src/ble_sm_lgcy.c      |  51 +++--
 net/nimble/host/src/ble_sm_priv.h      |  55 +++---
 net/nimble/host/src/ble_sm_sc.c        | 111 +++++------
 net/nimble/host/src/host_hci.c         |   4 +-
 net/nimble/host/src/test/ble_sm_test.c | 128 +++++++------
 9 files changed, 332 insertions(+), 330 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index b4ad2d7..c9e38a9 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -1950,7 +1950,7 @@ cmd_passkey(int argc, char **argv)
 #endif
 
     uint16_t conn_handle;
-    struct ble_sm_passkey pk;
+    struct ble_sm_io pk;
     char *yesno;
     int rc;
 
@@ -1965,8 +1965,8 @@ cmd_passkey(int argc, char **argv)
     }
 
     switch (pk.action) {
-        case BLE_SM_PKACT_INPUT:
-        case BLE_SM_PKACT_DISP:
+        case BLE_SM_IOACT_INPUT:
+        case BLE_SM_IOACT_DISP:
            /* passkey is 6 digit number */
            pk.passkey = parse_arg_long_bounds("key", 0, 999999, &rc);
            if (rc != 0) {
@@ -1974,14 +1974,14 @@ cmd_passkey(int argc, char **argv)
            }
            break;
 
-        case BLE_SM_PKACT_OOB:
+        case BLE_SM_IOACT_OOB:
             rc = parse_arg_byte_stream_exact_length("oob", pk.oob, 16);
             if (rc != 0) {
                 return rc;
             }
             break;
 
-        case BLE_SM_PKACT_NUMCMP:
+        case BLE_SM_IOACT_NUMCMP:
             yesno = parse_arg_find("yesno");
             if (yesno == NULL) {
                 return EINVAL;
@@ -2007,7 +2007,7 @@ cmd_passkey(int argc, char **argv)
          return EINVAL;
     }
 
-    rc = ble_sm_set_tk(conn_handle, &pk);
+    rc = ble_sm_inject_io(conn_handle, &pk);
     if (rc != 0) {
         console_printf("error providing passkey; rc=%d\n", rc);
         return rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 98ea6ab..6e97f84 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -970,7 +970,7 @@ bletiny_gap_event(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
     case BLE_GAP_EVENT_PASSKEY_ACTION:
         console_printf("passkey action event; action=%d",
                        ctxt->passkey_action.action);
-        if (ctxt->passkey_action.action == BLE_SM_PKACT_NUMCMP) {
+        if (ctxt->passkey_action.action == BLE_SM_IOACT_NUMCMP) {
             console_printf(" numcmp=%lu",
                            (unsigned long)ctxt->passkey_action.numcmp);
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/include/host/ble_sm.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_sm.h b/net/nimble/host/include/host/ble_sm.h
index cf62a23..cc3b779 100644
--- a/net/nimble/host/include/host/ble_sm.h
+++ b/net/nimble/host/include/host/ble_sm.h
@@ -72,15 +72,16 @@
 
 /*
  * The security manager asks the application to perform a key generation
- * action.  The application passes the passkey back to SM via ble_sm_set_tk().
+ * action.  The application passes the passkey back to SM via
+ * ble_sm_inject_io().
  */
-#define BLE_SM_PKACT_NONE                       0
-#define BLE_SM_PKACT_OOB                        1
-#define BLE_SM_PKACT_INPUT                      2
-#define BLE_SM_PKACT_DISP                       3
-#define BLE_SM_PKACT_NUMCMP                     4
+#define BLE_SM_IOACT_NONE                       0
+#define BLE_SM_IOACT_OOB                        1
+#define BLE_SM_IOACT_INPUT                      2
+#define BLE_SM_IOACT_DISP                       3
+#define BLE_SM_IOACT_NUMCMP                     4
 
-struct ble_sm_passkey {
+struct ble_sm_io {
     uint8_t action;
     union {
         uint32_t passkey;
@@ -90,9 +91,10 @@ struct ble_sm_passkey {
 };
 
 #if NIMBLE_OPT(SM)
-int ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey);
+int ble_sm_inject_io(uint16_t conn_handle, struct ble_sm_io *pkey);
 #else
-#define ble_sm_set_tk(conn_handle, pkey) ((void)(conn_handle), BLE_HS_ENOTSUP)
+#define ble_sm_inject_io(conn_handle, pkey) \
+    ((void)(conn_handle), BLE_HS_ENOTSUP)
 #endif
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/ble_sm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c
index 256d3fd..526ea8a 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -60,30 +60,30 @@ typedef void ble_sm_rx_fn(uint16_t conn_handle, uint8_t op,
                           struct os_mbuf **om, struct ble_sm_result *res);
 
 static ble_sm_rx_fn ble_sm_rx_noop;
-static ble_sm_rx_fn ble_sm_rx_pair_req;
-static ble_sm_rx_fn ble_sm_rx_pair_rsp;
-static ble_sm_rx_fn ble_sm_rx_pair_confirm;
-static ble_sm_rx_fn ble_sm_rx_pair_random;
-static ble_sm_rx_fn ble_sm_rx_pair_fail;
-static ble_sm_rx_fn ble_sm_rx_enc_info;
-static ble_sm_rx_fn ble_sm_rx_master_id;
-static ble_sm_rx_fn ble_sm_rx_id_info;
-static ble_sm_rx_fn ble_sm_rx_id_addr_info;
-static ble_sm_rx_fn ble_sm_rx_sign_info;
-static ble_sm_rx_fn ble_sm_rx_sec_req;
+static ble_sm_rx_fn ble_sm_pair_req_rx;
+static ble_sm_rx_fn ble_sm_pair_rsp_rx;
+static ble_sm_rx_fn ble_sm_confirm_rx;
+static ble_sm_rx_fn ble_sm_random_rx;
+static ble_sm_rx_fn ble_sm_fail_rx;
+static ble_sm_rx_fn ble_sm_enc_info_rx;
+static ble_sm_rx_fn ble_sm_master_id_rx;
+static ble_sm_rx_fn ble_sm_id_info_rx;
+static ble_sm_rx_fn ble_sm_id_addr_info_rx;
+static ble_sm_rx_fn ble_sm_sign_info_rx;
+static ble_sm_rx_fn ble_sm_sec_req_rx;
 
 static ble_sm_rx_fn * const ble_sm_dispatch[] = {
-   [BLE_SM_OP_PAIR_REQ] = ble_sm_rx_pair_req,
-   [BLE_SM_OP_PAIR_RSP] = ble_sm_rx_pair_rsp,
-   [BLE_SM_OP_PAIR_CONFIRM] = ble_sm_rx_pair_confirm,
-   [BLE_SM_OP_PAIR_RANDOM] = ble_sm_rx_pair_random,
-   [BLE_SM_OP_PAIR_FAIL] = ble_sm_rx_pair_fail,
-   [BLE_SM_OP_ENC_INFO] = ble_sm_rx_enc_info,
-   [BLE_SM_OP_MASTER_ID] = ble_sm_rx_master_id,
-   [BLE_SM_OP_IDENTITY_INFO] = ble_sm_rx_id_info,
-   [BLE_SM_OP_IDENTITY_ADDR_INFO] = ble_sm_rx_id_addr_info,
-   [BLE_SM_OP_SIGN_INFO] = ble_sm_rx_sign_info,
-   [BLE_SM_OP_SEC_REQ] = ble_sm_rx_sec_req,
+   [BLE_SM_OP_PAIR_REQ] = ble_sm_pair_req_rx,
+   [BLE_SM_OP_PAIR_RSP] = ble_sm_pair_rsp_rx,
+   [BLE_SM_OP_PAIR_CONFIRM] = ble_sm_confirm_rx,
+   [BLE_SM_OP_PAIR_RANDOM] = ble_sm_random_rx,
+   [BLE_SM_OP_PAIR_FAIL] = ble_sm_fail_rx,
+   [BLE_SM_OP_ENC_INFO] = ble_sm_enc_info_rx,
+   [BLE_SM_OP_MASTER_ID] = ble_sm_master_id_rx,
+   [BLE_SM_OP_IDENTITY_INFO] = ble_sm_id_info_rx,
+   [BLE_SM_OP_IDENTITY_ADDR_INFO] = ble_sm_id_addr_info_rx,
+   [BLE_SM_OP_SIGN_INFO] = ble_sm_sign_info_rx,
+   [BLE_SM_OP_SEC_REQ] = ble_sm_sec_req_rx,
    [BLE_SM_OP_PAIR_KEYPRESS_NOTIFY] = ble_sm_rx_noop,
 #if NIMBLE_OPT_SM_SC
    [BLE_SM_OP_PAIR_PUBLIC_KEY] = ble_sm_sc_public_key_rx,
@@ -97,30 +97,30 @@ static ble_sm_rx_fn * const ble_sm_dispatch[] = {
 typedef void ble_sm_state_fn(struct ble_sm_proc *proc,
                              struct ble_sm_result *res, void *arg);
 
-static ble_sm_state_fn ble_sm_pair_go;
-static ble_sm_state_fn ble_sm_confirm_go;
-static ble_sm_state_fn ble_sm_random_go;
-static ble_sm_state_fn ble_sm_ltk_start_go;
-static ble_sm_state_fn ble_sm_ltk_restore_go;
-static ble_sm_state_fn ble_sm_enc_start_go;
-static ble_sm_state_fn ble_sm_enc_restore_go;
-static ble_sm_state_fn ble_sm_key_exch_go;
-static ble_sm_state_fn ble_sm_sec_req_go;
+static ble_sm_state_fn ble_sm_pair_exec;
+static ble_sm_state_fn ble_sm_confirm_exec;
+static ble_sm_state_fn ble_sm_random_exec;
+static ble_sm_state_fn ble_sm_ltk_start_exec;
+static ble_sm_state_fn ble_sm_ltk_restore_exec;
+static ble_sm_state_fn ble_sm_enc_start_exec;
+static ble_sm_state_fn ble_sm_enc_restore_exec;
+static ble_sm_state_fn ble_sm_key_exch_exec;
+static ble_sm_state_fn ble_sm_sec_req_exec;
 
 static ble_sm_state_fn * const
 ble_sm_state_dispatch[BLE_SM_PROC_STATE_CNT] = {
-    [BLE_SM_PROC_STATE_PAIR]          = ble_sm_pair_go,
-    [BLE_SM_PROC_STATE_CONFIRM]       = ble_sm_confirm_go,
-    [BLE_SM_PROC_STATE_RANDOM]        = ble_sm_random_go,
-    [BLE_SM_PROC_STATE_LTK_START]     = ble_sm_ltk_start_go,
-    [BLE_SM_PROC_STATE_LTK_RESTORE]   = ble_sm_ltk_restore_go,
-    [BLE_SM_PROC_STATE_ENC_START]     = ble_sm_enc_start_go,
-    [BLE_SM_PROC_STATE_ENC_RESTORE]   = ble_sm_enc_restore_go,
-    [BLE_SM_PROC_STATE_KEY_EXCH]      = ble_sm_key_exch_go,
-    [BLE_SM_PROC_STATE_SEC_REQ]       = ble_sm_sec_req_go,
+    [BLE_SM_PROC_STATE_PAIR]          = ble_sm_pair_exec,
+    [BLE_SM_PROC_STATE_CONFIRM]       = ble_sm_confirm_exec,
+    [BLE_SM_PROC_STATE_RANDOM]        = ble_sm_random_exec,
+    [BLE_SM_PROC_STATE_LTK_START]     = ble_sm_ltk_start_exec,
+    [BLE_SM_PROC_STATE_LTK_RESTORE]   = ble_sm_ltk_restore_exec,
+    [BLE_SM_PROC_STATE_ENC_START]     = ble_sm_enc_start_exec,
+    [BLE_SM_PROC_STATE_ENC_RESTORE]   = ble_sm_enc_restore_exec,
+    [BLE_SM_PROC_STATE_KEY_EXCH]      = ble_sm_key_exch_exec,
+    [BLE_SM_PROC_STATE_SEC_REQ]       = ble_sm_sec_req_exec,
 #if NIMBLE_OPT_SM_SC
-    [BLE_SM_PROC_STATE_PUBLIC_KEY]    = ble_sm_sc_public_key_go,
-    [BLE_SM_PROC_STATE_DHKEY_CHECK]   = ble_sm_sc_dhkey_check_go,
+    [BLE_SM_PROC_STATE_PUBLIC_KEY]    = ble_sm_sc_public_key_exec,
+    [BLE_SM_PROC_STATE_DHKEY_CHECK]   = ble_sm_sc_dhkey_check_exec,
 #else
     [BLE_SM_PROC_STATE_PUBLIC_KEY]    = NULL,
     [BLE_SM_PROC_STATE_DHKEY_CHECK]   = NULL,
@@ -714,28 +714,28 @@ ble_sm_build_authreq(void)
 }
 
 static int
-ble_sm_passkey_action(struct ble_sm_proc *proc)
+ble_sm_io_action(struct ble_sm_proc *proc)
 {
     if (proc->flags & BLE_SM_PROC_F_SC) {
-        return ble_sm_sc_passkey_action(proc);
+        return ble_sm_sc_io_action(proc);
     } else {
-        return ble_sm_lgcy_passkey_action(proc);
+        return ble_sm_lgcy_io_action(proc);
     }
 }
 
 int
-ble_sm_pkact_state(uint8_t action)
+ble_sm_ioact_state(uint8_t action)
 {
     switch (action) {
-    case BLE_SM_PKACT_NONE:
+    case BLE_SM_IOACT_NONE:
         return BLE_SM_PROC_STATE_NONE;
 
-    case BLE_SM_PKACT_NUMCMP:
+    case BLE_SM_IOACT_NUMCMP:
         return BLE_SM_PROC_STATE_DHKEY_CHECK;
 
-    case BLE_SM_PKACT_OOB:
-    case BLE_SM_PKACT_INPUT:
-    case BLE_SM_PKACT_DISP:
+    case BLE_SM_IOACT_OOB:
+    case BLE_SM_IOACT_INPUT:
+    case BLE_SM_IOACT_DISP:
         return BLE_SM_PROC_STATE_CONFIRM;
 
     default:
@@ -747,10 +747,10 @@ ble_sm_pkact_state(uint8_t action)
 int
 ble_sm_proc_can_advance(struct ble_sm_proc *proc)
 {
-    uint8_t pkact;
+    uint8_t ioact;
 
-    pkact = ble_sm_sc_passkey_action(proc);
-    if (ble_sm_pkact_state(pkact) != proc->state) {
+    ioact = ble_sm_sc_io_action(proc);
+    if (ble_sm_ioact_state(ioact) != proc->state) {
         return 1;
     }
 
@@ -764,7 +764,7 @@ ble_sm_proc_can_advance(struct ble_sm_proc *proc)
 }
 
 static void
-ble_sm_go(struct ble_sm_proc *proc, struct ble_sm_result *res, void *arg)
+ble_sm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, void *arg)
 {
     ble_sm_state_fn *cb;
 
@@ -793,7 +793,7 @@ ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res)
 
         if (proc != NULL) {
             if (res->execute) {
-                ble_sm_go(proc, res, res->state_arg);
+                ble_sm_exec(proc, res, res->state_arg);
             }
 
             if (res->app_status != 0) {
@@ -827,7 +827,7 @@ ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res)
         }
 
         if (res->app_status == 0 &&
-            res->passkey_action.action != BLE_SM_PKACT_NONE) {
+            res->passkey_action.action != BLE_SM_IOACT_NONE) {
 
             ble_gap_passkey_event(conn_handle, &res->passkey_action);
         }
@@ -886,8 +886,8 @@ ble_sm_start_encrypt_tx(struct hci_start_encrypt *cmd)
 }
 
 static void
-ble_sm_enc_start_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                    void *arg)
+ble_sm_enc_start_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                      void *arg)
 {
     struct hci_start_encrypt cmd;
     int rc;
@@ -908,8 +908,8 @@ ble_sm_enc_start_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
 }
 
 static void
-ble_sm_enc_restore_go(struct ble_sm_proc *proc,
-                            struct ble_sm_result *res, void *arg)
+ble_sm_enc_restore_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                        void *arg)
 {
     struct hci_start_encrypt *cmd;
 
@@ -922,7 +922,7 @@ ble_sm_enc_restore_go(struct ble_sm_proc *proc,
 }
 
 void
-ble_sm_rx_encryption_change(struct hci_encrypt_change *evt)
+ble_sm_enc_change_rx(struct hci_encrypt_change *evt)
 {
     struct ble_sm_result res;
     struct ble_sm_proc *proc;
@@ -974,7 +974,26 @@ ble_sm_rx_encryption_change(struct hci_encrypt_change *evt)
  *****************************************************************************/
 
 static int
-ble_sm_lt_key_req_reply_tx(uint16_t conn_handle, uint8_t *ltk)
+ble_sm_retrieve_ltk(struct hci_le_lt_key_req *evt, uint8_t peer_addr_type,
+                    uint8_t *peer_addr, struct ble_store_value_sec *value_sec)
+{
+    struct ble_store_key_sec key_sec;
+    int rc;
+
+    /* Tell applicaiton to look up LTK by peer address and ediv/rand pair. */
+    memset(&key_sec, 0, sizeof key_sec);
+    key_sec.peer_addr_type = peer_addr_type;
+    memcpy(key_sec.peer_addr, peer_addr, 6);
+    key_sec.ediv = evt->encrypted_diversifier;
+    key_sec.rand_num = evt->random_number;
+    key_sec.ediv_rand_present = 1;
+
+    rc = ble_store_read_slv_sec(&key_sec, value_sec);
+    return rc;
+}
+
+static int
+ble_sm_ltk_req_reply_tx(uint16_t conn_handle, uint8_t *ltk)
 {
     struct hci_lt_key_req_reply cmd;
     uint16_t ack_conn_handle;
@@ -1004,7 +1023,7 @@ ble_sm_lt_key_req_reply_tx(uint16_t conn_handle, uint8_t *ltk)
 }
 
 static int
-ble_sm_lt_key_req_neg_reply_tx(uint16_t conn_handle)
+ble_sm_ltk_req_neg_reply_tx(uint16_t conn_handle)
 {
     uint16_t ack_conn_handle;
     uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_LT_KEY_REQ_NEG_REPLY_LEN];
@@ -1030,12 +1049,12 @@ ble_sm_lt_key_req_neg_reply_tx(uint16_t conn_handle)
 }
 
 static void
-ble_sm_ltk_start_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                    void *arg)
+ble_sm_ltk_start_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                      void *arg)
 {
     BLE_HS_DBG_ASSERT(!(proc->flags & BLE_SM_PROC_F_INITIATOR));
 
-    res->app_status = ble_sm_lt_key_req_reply_tx(proc->conn_handle, proc->ltk);
+    res->app_status = ble_sm_ltk_req_reply_tx(proc->conn_handle, proc->ltk);
     if (res->app_status == 0) {
         proc->state = BLE_SM_PROC_STATE_ENC_START;
     } else {
@@ -1044,8 +1063,8 @@ ble_sm_ltk_start_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
 }
 
 static void
-ble_sm_ltk_restore_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                      void *arg)
+ble_sm_ltk_restore_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                        void *arg)
 {
     struct ble_store_value_sec *value_sec;
 
@@ -1055,7 +1074,7 @@ ble_sm_ltk_restore_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
 
     if (value_sec != NULL) {
         /* Store provided a key; send it to the controller. */
-        res->app_status = ble_sm_lt_key_req_reply_tx(
+        res->app_status = ble_sm_ltk_req_reply_tx(
             proc->conn_handle, value_sec->ltk);
 
         if (res->app_status == 0) {
@@ -1070,7 +1089,7 @@ ble_sm_ltk_restore_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
         /* Application does not have the requested key in its database.  Send a
          * negative reply to the controller.
          */
-        ble_sm_lt_key_req_neg_reply_tx(proc->conn_handle);
+        ble_sm_ltk_req_neg_reply_tx(proc->conn_handle);
         res->app_status = BLE_HS_ENOENT;
     }
 
@@ -1080,27 +1099,8 @@ ble_sm_ltk_restore_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
     }
 }
 
-static int
-ble_sm_retrieve_ltk(struct hci_le_lt_key_req *evt, uint8_t peer_addr_type,
-                    uint8_t *peer_addr, struct ble_store_value_sec *value_sec)
-{
-    struct ble_store_key_sec key_sec;
-    int rc;
-
-    /* Tell applicaiton to look up LTK by peer address and ediv/rand pair. */
-    memset(&key_sec, 0, sizeof key_sec);
-    key_sec.peer_addr_type = peer_addr_type;
-    memcpy(key_sec.peer_addr, peer_addr, 6);
-    key_sec.ediv = evt->encrypted_diversifier;
-    key_sec.rand_num = evt->random_number;
-    key_sec.ediv_rand_present = 1;
-
-    rc = ble_store_read_slv_sec(&key_sec, value_sec);
-    return rc;
-}
-
 int
-ble_sm_rx_lt_key_req(struct hci_le_lt_key_req *evt)
+ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt)
 {
     struct ble_store_value_sec value_sec;
     struct ble_sm_result res;
@@ -1201,7 +1201,7 @@ ble_sm_our_pair_rand(struct ble_sm_proc *proc)
 }
 
 uint8_t *
-ble_sm_their_pair_rand(struct ble_sm_proc *proc)
+ble_sm_peer_pair_rand(struct ble_sm_proc *proc)
 {
     if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         return proc->rands;
@@ -1211,19 +1211,19 @@ ble_sm_their_pair_rand(struct ble_sm_proc *proc)
 }
 
 static void
-ble_sm_random_go(struct ble_sm_proc *proc,
-                       struct ble_sm_result *res, void *arg)
+ble_sm_random_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                   void *arg)
 {
     if (proc->flags & BLE_SM_PROC_F_SC) {
-        ble_sm_sc_random_go(proc, res);
+        ble_sm_sc_random_exec(proc, res);
     } else {
-        ble_sm_lgcy_random_go(proc, res);
+        ble_sm_lgcy_random_exec(proc, res);
     }
 }
 
 static void
-ble_sm_rx_pair_random(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
-                      struct ble_sm_result *res)
+ble_sm_random_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+                 struct ble_sm_result *res)
 {
     struct ble_sm_pair_random cmd;
     struct ble_sm_proc *proc;
@@ -1246,12 +1246,12 @@ ble_sm_rx_pair_random(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
     if (proc == NULL) {
         res->app_status = BLE_HS_ENOENT;
     } else {
-        memcpy(ble_sm_their_pair_rand(proc), cmd.value, 16);
+        memcpy(ble_sm_peer_pair_rand(proc), cmd.value, 16);
 
         if (proc->flags & BLE_SM_PROC_F_SC) {
             ble_sm_sc_random_rx(proc, res);
         } else {
-            ble_sm_lgcy_rx_pair_random(proc, res);
+            ble_sm_lgcy_random_rx(proc, res);
         }
     }
     ble_hs_unlock();
@@ -1262,24 +1262,24 @@ ble_sm_rx_pair_random(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
  *****************************************************************************/
 
 static void
-ble_sm_confirm_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                  void *arg)
+ble_sm_confirm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                    void *arg)
 {
     if (!(proc->flags & BLE_SM_PROC_F_SC)) {
-        ble_sm_lgcy_confirm_go(proc, res);
+        ble_sm_lgcy_confirm_exec(proc, res);
     } else {
-        ble_sm_sc_confirm_go(proc, res);
+        ble_sm_sc_confirm_exec(proc, res);
     }
 }
 
 static void
-ble_sm_rx_pair_confirm(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
-                       struct ble_sm_result *res)
+ble_sm_confirm_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+                  struct ble_sm_result *res)
 {
     struct ble_sm_pair_confirm cmd;
     struct ble_sm_proc *proc;
     struct ble_sm_proc *prev;
-    uint8_t pkact;
+    uint8_t ioact;
 
     res->app_status = ble_hs_misc_pullup_base(om, BLE_SM_PAIR_CONFIRM_SZ);
     if (res->app_status != 0) {
@@ -1303,8 +1303,8 @@ ble_sm_rx_pair_confirm(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
             proc->state = BLE_SM_PROC_STATE_RANDOM;
             res->execute = 1;
         } else {
-            pkact = ble_sm_passkey_action(proc);
-            if (ble_sm_pkact_state(pkact) == proc->state) {
+            ioact = ble_sm_io_action(proc);
+            if (ble_sm_ioact_state(ioact) == proc->state) {
                 proc->flags |= BLE_SM_PROC_F_ADVANCE_ON_IO;
             }
             if (ble_sm_proc_can_advance(proc)) {
@@ -1372,10 +1372,11 @@ ble_sm_pair_cfg(struct ble_sm_proc *proc)
 }
 
 static void
-ble_sm_pair_go(struct ble_sm_proc *proc, struct ble_sm_result *res, void *arg)
+ble_sm_pair_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                 void *arg)
 {
     struct ble_sm_pair_cmd cmd;
-    uint8_t pkact;
+    uint8_t ioact;
     int is_req;
     int rc;
 
@@ -1412,9 +1413,9 @@ ble_sm_pair_go(struct ble_sm_proc *proc, struct ble_sm_result *res, void *arg)
         ble_sm_pair_cfg(proc);
         proc->state = ble_sm_state_after_pair(proc);
 
-        pkact = ble_sm_passkey_action(proc);
-        if (ble_sm_pkact_state(pkact) == proc->state) {
-            res->passkey_action.action = pkact;
+        ioact = ble_sm_io_action(proc);
+        if (ble_sm_ioact_state(ioact) == proc->state) {
+            res->passkey_action.action = ioact;
         }
     }
 
@@ -1436,7 +1437,7 @@ err:
 }
 
 static void
-ble_sm_rx_pair_req(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_pair_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                    struct ble_sm_result *res)
 {
     struct ble_sm_pair_cmd req;
@@ -1498,13 +1499,13 @@ ble_sm_rx_pair_req(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 }
 
 static void
-ble_sm_rx_pair_rsp(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_pair_rsp_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                    struct ble_sm_result *res)
 {
     struct ble_sm_pair_cmd rsp;
     struct ble_sm_proc *proc;
     struct ble_sm_proc *prev;
-    uint8_t pkact;
+    uint8_t ioact;
 
     res->app_status = ble_hs_misc_pullup_base(om, BLE_SM_PAIR_CMD_SZ);
     if (res->app_status != 0) {
@@ -1531,9 +1532,9 @@ ble_sm_rx_pair_rsp(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
         } else {
             ble_sm_pair_cfg(proc);
 
-            pkact = ble_sm_passkey_action(proc);
-            if (ble_sm_pkact_state(pkact) == proc->state) {
-                res->passkey_action.action = pkact;
+            ioact = ble_sm_io_action(proc);
+            if (ble_sm_ioact_state(ioact) == proc->state) {
+                res->passkey_action.action = ioact;
             } else {
                 proc->state = ble_sm_state_after_pair(proc);
                 res->execute = 1;
@@ -1549,8 +1550,8 @@ ble_sm_rx_pair_rsp(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
  *****************************************************************************/
 
 static void
-ble_sm_sec_req_go(struct ble_sm_proc *proc,
-                        struct ble_sm_result *res, void *arg)
+ble_sm_sec_req_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                    void *arg)
 {
     struct ble_sm_sec_req cmd;
     int rc;
@@ -1564,7 +1565,7 @@ ble_sm_sec_req_go(struct ble_sm_proc *proc,
 }
 
 static void
-ble_sm_rx_sec_req(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_sec_req_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                   struct ble_sm_result *res)
 {
     struct ble_sm_sec_req cmd;
@@ -1640,8 +1641,8 @@ ble_sm_rx_sec_req(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
  *****************************************************************************/
 
 static void
-ble_sm_key_exch_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                   void *arg)
+ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                     void *arg)
 {
     struct ble_sm_id_addr_info addr_info;
     struct ble_sm_sign_info sign_info;
@@ -1771,7 +1772,7 @@ ble_sm_key_rxed(struct ble_sm_proc *proc, struct ble_sm_result *res)
 }
 
 static void
-ble_sm_rx_enc_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_enc_info_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                    struct ble_sm_result *res)
 {
     struct ble_sm_enc_info cmd;
@@ -1806,7 +1807,7 @@ ble_sm_rx_enc_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 }
 
 static void
-ble_sm_rx_master_id(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_master_id_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                     struct ble_sm_result *res)
 {
     struct ble_sm_master_id cmd;
@@ -1842,7 +1843,7 @@ ble_sm_rx_master_id(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 }
 
 static void
-ble_sm_rx_id_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_id_info_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                   struct ble_sm_result *res)
 {
     struct ble_sm_id_info cmd;
@@ -1877,7 +1878,7 @@ ble_sm_rx_id_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 }
 
 static void
-ble_sm_rx_id_addr_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_id_addr_info_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                        struct ble_sm_result *res)
 {
     struct ble_sm_id_addr_info cmd;
@@ -1913,7 +1914,7 @@ ble_sm_rx_id_addr_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
 }
 
 static void
-ble_sm_rx_sign_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+ble_sm_sign_info_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
                     struct ble_sm_result *res)
 {
     struct ble_sm_sign_info cmd;
@@ -1952,8 +1953,8 @@ ble_sm_rx_sign_info(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
  *****************************************************************************/
 
 static void
-ble_sm_rx_pair_fail(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
-                    struct ble_sm_result *res)
+ble_sm_fail_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
+               struct ble_sm_result *res)
 {
     struct ble_sm_pair_fail cmd;
 
@@ -2179,7 +2180,7 @@ ble_sm_create_chan(void)
 }
 
 int
-ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey)
+ble_sm_inject_io(uint16_t conn_handle, struct ble_sm_io *pkey)
 {
     struct ble_sm_result res;
     struct ble_sm_proc *proc;
@@ -2195,18 +2196,18 @@ ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey)
         res.app_status = BLE_HS_ENOENT;
     } else if (proc->flags & BLE_SM_PROC_F_IO_INJECTED) {
         res.app_status = BLE_HS_EALREADY;
-    } else if (pkey->action != ble_sm_passkey_action(proc)) {
+    } else if (pkey->action != ble_sm_io_action(proc)) {
         /* Response doesn't match what we asked for. */
         res.app_status = BLE_HS_EINVAL;
         res.sm_err = BLE_SM_ERR_PASSKEY;
-    } else if (ble_sm_pkact_state(pkey->action) != proc->state) {
+    } else if (ble_sm_ioact_state(pkey->action) != proc->state) {
         /* Procedure is not ready for user input. */
         res.app_status = BLE_HS_EINVAL;
         res.sm_err = BLE_SM_ERR_UNSPECIFIED;
     } else {
         /* Add the passkey range. */
         switch (pkey->action) {
-        case BLE_SM_PKACT_OOB:
+        case BLE_SM_IOACT_OOB:
             if (pkey->oob == NULL) {
                 res.app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_OOB);
                 res.sm_err = BLE_SM_ERR_OOB;
@@ -2221,8 +2222,8 @@ ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey)
             }
             break;
 
-        case BLE_SM_PKACT_INPUT:
-        case BLE_SM_PKACT_DISP:
+        case BLE_SM_IOACT_INPUT:
+        case BLE_SM_IOACT_DISP:
             if (pkey->passkey > 999999) {
                 res.app_status = BLE_HS_EINVAL;
                 res.sm_err = BLE_SM_ERR_PASSKEY;
@@ -2241,7 +2242,7 @@ ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey)
             }
             break;
 
-        case BLE_SM_PKACT_NUMCMP:
+        case BLE_SM_IOACT_NUMCMP:
             if (!pkey->numcmp_accept) {
                 res.app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_NUMCMP);
                 res.sm_err = BLE_SM_ERR_NUMCMP;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/ble_sm_lgcy.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_lgcy.c b/net/nimble/host/src/ble_sm_lgcy.c
index 92c9284..19451fa 100644
--- a/net/nimble/host/src/ble_sm_lgcy.c
+++ b/net/nimble/host/src/ble_sm_lgcy.c
@@ -29,21 +29,21 @@
  * Create some shortened names for the passkey actions so that the table is
  * easier to read.
  */
-#define PKACT_NONE  BLE_SM_PKACT_NONE
-#define PKACT_OOB   BLE_SM_PKACT_OOB
-#define PKACT_INPUT BLE_SM_PKACT_INPUT
-#define PKACT_DISP  BLE_SM_PKACT_DISP
+#define IOACT_NONE  BLE_SM_IOACT_NONE
+#define IOACT_OOB   BLE_SM_IOACT_OOB
+#define IOACT_INPUT BLE_SM_IOACT_INPUT
+#define IOACT_DISP  BLE_SM_IOACT_DISP
 
 /* This is the initiator passkey action action dpeneding on the io
  * capabilties of both parties
  */
 static const uint8_t ble_sm_lgcy_init_pka[5 /*resp*/ ][5 /*init */] =
 {
-    {PKACT_NONE,    PKACT_NONE,   PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_DISP,    PKACT_DISP,   PKACT_INPUT, PKACT_NONE, PKACT_DISP},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_NONE,  PKACT_NONE, PKACT_NONE},
-    {PKACT_DISP,    PKACT_DISP,   PKACT_INPUT, PKACT_NONE, PKACT_DISP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_DISP,    IOACT_DISP,   IOACT_INPUT, IOACT_NONE, IOACT_DISP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_NONE,  IOACT_NONE, IOACT_NONE},
+    {IOACT_DISP,    IOACT_DISP,   IOACT_INPUT, IOACT_NONE, IOACT_DISP},
 };
 
 /* This is the responder passkey action action depending on the io
@@ -51,24 +51,24 @@ static const uint8_t ble_sm_lgcy_init_pka[5 /*resp*/ ][5 /*init */] =
  */
 static const uint8_t ble_sm_lgcy_resp_pka[5 /*init*/ ][5 /*resp */] =
 {
-    {PKACT_NONE,    PKACT_NONE,   PKACT_DISP,  PKACT_NONE, PKACT_DISP},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_DISP,  PKACT_NONE, PKACT_DISP},
-    {PKACT_INPUT,   PKACT_INPUT,  PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_NONE,  PKACT_NONE, PKACT_NONE},
-    {PKACT_INPUT,   PKACT_INPUT,  PKACT_DISP,  PKACT_NONE, PKACT_INPUT},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_DISP,  IOACT_NONE, IOACT_DISP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_DISP,  IOACT_NONE, IOACT_DISP},
+    {IOACT_INPUT,   IOACT_INPUT,  IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_NONE,  IOACT_NONE, IOACT_NONE},
+    {IOACT_INPUT,   IOACT_INPUT,  IOACT_DISP,  IOACT_NONE, IOACT_INPUT},
 };
 
 int
-ble_sm_lgcy_passkey_action(struct ble_sm_proc *proc)
+ble_sm_lgcy_io_action(struct ble_sm_proc *proc)
 {
     int action;
 
     if (proc->pair_req.oob_data_flag && proc->pair_rsp.oob_data_flag) {
-        action = BLE_SM_PKACT_OOB;
+        action = BLE_SM_IOACT_OOB;
     } else if (!(proc->pair_req.authreq & BLE_SM_PAIR_AUTHREQ_MITM) &&
                !(proc->pair_rsp.authreq & BLE_SM_PAIR_AUTHREQ_MITM)) {
 
-        action = BLE_SM_PKACT_NONE;
+        action = BLE_SM_IOACT_NONE;
     } else if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         action = ble_sm_lgcy_init_pka[proc->pair_rsp.io_cap]
                                      [proc->pair_req.io_cap];
@@ -78,17 +78,17 @@ ble_sm_lgcy_passkey_action(struct ble_sm_proc *proc)
     }
 
     switch (action) {
-    case BLE_SM_PKACT_NONE:
+    case BLE_SM_IOACT_NONE:
         proc->pair_alg = BLE_SM_PAIR_ALG_JW;
         break;
 
-    case BLE_SM_PKACT_OOB:
+    case BLE_SM_IOACT_OOB:
         proc->pair_alg = BLE_SM_PAIR_ALG_OOB;
         proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
         break;
 
-    case BLE_SM_PKACT_INPUT:
-    case BLE_SM_PKACT_DISP:
+    case BLE_SM_IOACT_INPUT:
+    case BLE_SM_IOACT_DISP:
         proc->pair_alg = BLE_SM_PAIR_ALG_PASSKEY;
         proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
         break;
@@ -128,7 +128,7 @@ ble_sm_lgcy_confirm_prepare_args(struct ble_sm_proc *proc,
 }
 
 void
-ble_sm_lgcy_confirm_go(struct ble_sm_proc *proc, struct ble_sm_result *res)
+ble_sm_lgcy_confirm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res)
 {
     struct ble_sm_pair_confirm cmd;
     uint8_t preq[BLE_SM_HDR_SZ + BLE_SM_PAIR_CMD_SZ];
@@ -186,8 +186,7 @@ ble_sm_gen_stk(struct ble_sm_proc *proc)
 }
 
 void
-ble_sm_lgcy_random_go(struct ble_sm_proc *proc,
-                      struct ble_sm_result *res)
+ble_sm_lgcy_random_exec(struct ble_sm_proc *proc, struct ble_sm_result *res)
 {
     struct ble_sm_pair_random cmd;
     int rc;
@@ -208,7 +207,7 @@ ble_sm_lgcy_random_go(struct ble_sm_proc *proc,
 }
 
 void
-ble_sm_lgcy_rx_pair_random(struct ble_sm_proc *proc, struct ble_sm_result *res)
+ble_sm_lgcy_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
 {
     uint8_t preq[BLE_SM_HDR_SZ + BLE_SM_PAIR_CMD_SZ];
     uint8_t pres[BLE_SM_HDR_SZ + BLE_SM_PAIR_CMD_SZ];
@@ -229,7 +228,7 @@ ble_sm_lgcy_rx_pair_random(struct ble_sm_proc *proc, struct ble_sm_result *res)
         return;
     }
 
-    rc = ble_sm_alg_c1(k, ble_sm_their_pair_rand(proc), preq, pres,
+    rc = ble_sm_alg_c1(k, ble_sm_peer_pair_rand(proc), preq, pres,
                              iat, rat, ia, ra, confirm_val);
     if (rc != 0) {
         res->app_status = rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/ble_sm_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_priv.h b/net/nimble/host/src/ble_sm_priv.h
index 9362e29..e7961e2 100644
--- a/net/nimble/host/src/ble_sm_priv.h
+++ b/net/nimble/host/src/ble_sm_priv.h
@@ -377,41 +377,42 @@ int ble_sm_dhkey_check_write(void *payload, int len,
 int ble_sm_dhkey_check_tx(uint16_t conn_handle,
                           struct ble_sm_dhkey_check *cmd);
 
-void ble_sm_rx_encryption_change(struct hci_encrypt_change *evt);
-int ble_sm_rx_lt_key_req(struct hci_le_lt_key_req *evt);
+void ble_sm_enc_change_rx(struct hci_encrypt_change *evt);
+int ble_sm_ltk_req_rx(struct hci_le_lt_key_req *evt);
 
-int ble_sm_lgcy_passkey_action(struct ble_sm_proc *proc);
-void ble_sm_lgcy_confirm_go(struct ble_sm_proc *proc,
-                            struct ble_sm_result *res);
-void ble_sm_lgcy_random_go(struct ble_sm_proc *proc,
-                           struct ble_sm_result *res);
-void ble_sm_lgcy_rx_pair_random(struct ble_sm_proc *proc,
+int ble_sm_lgcy_io_action(struct ble_sm_proc *proc);
+void ble_sm_lgcy_confirm_exec(struct ble_sm_proc *proc,
+                              struct ble_sm_result *res);
+void ble_sm_lgcy_random_exec(struct ble_sm_proc *proc,
+                             struct ble_sm_result *res);
+void ble_sm_lgcy_random_rx(struct ble_sm_proc *proc,
                                struct ble_sm_result *res);
 
 #if NIMBLE_OPT(SM_SC)
-int ble_sm_sc_passkey_action(struct ble_sm_proc *proc);
-void ble_sm_sc_confirm_go(struct ble_sm_proc *proc, struct ble_sm_result *res);
-void ble_sm_sc_random_go(struct ble_sm_proc *proc, struct ble_sm_result *res);
-void ble_sm_sc_random_rx(struct ble_sm_proc *proc,
-                             struct ble_sm_result *res);
-void ble_sm_sc_public_key_go(struct ble_sm_proc *proc,
-                             struct ble_sm_result *res,
-                             void *arg);
+int ble_sm_sc_io_action(struct ble_sm_proc *proc);
+void ble_sm_sc_confirm_exec(struct ble_sm_proc *proc,
+                            struct ble_sm_result *res);
+void ble_sm_sc_random_exec(struct ble_sm_proc *proc,
+                           struct ble_sm_result *res);
+void ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res);
+void ble_sm_sc_public_key_exec(struct ble_sm_proc *proc,
+                               struct ble_sm_result *res,
+                               void *arg);
 void ble_sm_sc_public_key_rx(uint16_t conn_handle, uint8_t op,
                              struct os_mbuf **om, struct ble_sm_result *res);
-void ble_sm_sc_dhkey_check_go(struct ble_sm_proc *proc,
-                              struct ble_sm_result *res, void *arg);
+void ble_sm_sc_dhkey_check_exec(struct ble_sm_proc *proc,
+                                struct ble_sm_result *res, void *arg);
 void ble_sm_sc_dhkey_check_rx(uint16_t conn_handle, uint8_t op,
                               struct os_mbuf **om, struct ble_sm_result *res);
 void ble_sm_sc_init(void);
 #else
-#define ble_sm_sc_passkey_action(proc) (BLE_SM_PKACT_NONE)
-#define ble_sm_sc_confirm_go(proc, res)
-#define ble_sm_sc_random_go(proc, res)
+#define ble_sm_sc_io_action(proc) (BLE_SM_IOACT_NONE)
+#define ble_sm_sc_confirm_exec(proc, res)
+#define ble_sm_sc_random_exec(proc, res)
 #define ble_sm_sc_random_rx(proc, res)
-#define ble_sm_sc_public_key_go(proc, res, arg)
+#define ble_sm_sc_public_key_exec(proc, res, arg)
 #define ble_sm_sc_public_key_rx(conn_handle, op, om, res)
-#define ble_sm_sc_dhkey_check_go(proc, res, arg)
+#define ble_sm_sc_dhkey_check_exec(proc, res, arg)
 #define ble_sm_sc_dhkey_check_rx(conn_handle, op, om, res)
 #define ble_sm_sc_init()
 
@@ -423,8 +424,8 @@ struct ble_sm_proc *ble_sm_proc_find(uint16_t conn_handle, uint8_t state,
 int ble_sm_gen_pair_rand(uint8_t *pair_rand);
 int ble_sm_gen_pub_priv(void *pub, uint32_t *priv);
 uint8_t *ble_sm_our_pair_rand(struct ble_sm_proc *proc);
-uint8_t *ble_sm_their_pair_rand(struct ble_sm_proc *proc);
-int ble_sm_pkact_state(uint8_t action);
+uint8_t *ble_sm_peer_pair_rand(struct ble_sm_proc *proc);
+int ble_sm_ioact_state(uint8_t action);
 int ble_sm_proc_can_advance(struct ble_sm_proc *proc);
 void ble_sm_process_result(uint16_t conn_handle, struct ble_sm_result *res);
 void ble_sm_confirm_advance(struct ble_sm_proc *proc);
@@ -450,8 +451,8 @@ int ble_sm_init(void);
 
 #define ble_sm_create_chan() NULL
 
-#define ble_sm_rx_encryption_change(evt) ((void)(evt))
-#define ble_sm_rx_lt_key_req(evt) ((void)(evt))
+#define ble_sm_enc_change_rx(evt) ((void)(evt))
+#define ble_sm_ltk_req_rx(evt) ((void)(evt))
 
 #define ble_sm_heartbeat()
 #define ble_sm_connection_broken(conn_handle)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/ble_sm_sc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_sc.c b/net/nimble/host/src/ble_sm_sc.c
index c1a9686..32c362c 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -31,7 +31,8 @@
 
 /**
  * The public and private keys are stored in unions.  Some crypto functions
- * accept pointers to uint32_t; others accept pointers to uint8_t.
+ * accept pointers to uint32_t; others accept pointers to uint8_t.  The use of
+ * unions ensures the keys are properly aligned for pointers to uint32_t.
  */
 static union {
     uint32_t u32[16];
@@ -52,74 +53,74 @@ static uint8_t ble_sm_sc_keys_generated;
  * Create some shortened names for the passkey actions so that the table is
  * easier to read.
  */
-#define PKACT_NONE      BLE_SM_PKACT_NONE
-#define PKACT_OOB       BLE_SM_PKACT_OOB
-#define PKACT_INPUT     BLE_SM_PKACT_INPUT
-#define PKACT_DISP      BLE_SM_PKACT_DISP
-#define PKACT_NUMCMP    BLE_SM_PKACT_NUMCMP
+#define IOACT_NONE      BLE_SM_IOACT_NONE
+#define IOACT_OOB       BLE_SM_IOACT_OOB
+#define IOACT_INPUT     BLE_SM_IOACT_INPUT
+#define IOACT_DISP      BLE_SM_IOACT_DISP
+#define IOACT_NUMCMP    BLE_SM_IOACT_NUMCMP
 
 /**
  * This is the initiator passkey action action dpeneding on the io
  * capabilties of both parties
  */
-static const uint8_t ble_sm_sc_init_pka[5 /*resp*/ ][5 /*init */] =
+static const uint8_t ble_sm_sc_init_ioa[5 /*resp*/ ][5 /*init */] =
 {
-    {PKACT_NONE,    PKACT_NONE,   PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_NONE,    PKACT_NUMCMP, PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_DISP,    PKACT_DISP,   PKACT_INPUT, PKACT_NONE, PKACT_DISP},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_NONE,  PKACT_NONE, PKACT_NONE},
-    {PKACT_DISP,    PKACT_NUMCMP, PKACT_INPUT, PKACT_NONE, PKACT_NUMCMP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_NONE,    IOACT_NUMCMP, IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_DISP,    IOACT_DISP,   IOACT_INPUT, IOACT_NONE, IOACT_DISP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_NONE,  IOACT_NONE, IOACT_NONE},
+    {IOACT_DISP,    IOACT_NUMCMP, IOACT_INPUT, IOACT_NONE, IOACT_NUMCMP},
 };
 
 /**
  * This is the responder passkey action action depending on the io
  * capabilities of both parties
  */
-static const uint8_t ble_sm_sc_resp_pka[5 /*init*/ ][5 /*resp */] =
+static const uint8_t ble_sm_sc_resp_ioa[5 /*init*/ ][5 /*resp */] =
 {
-    {PKACT_NONE,    PKACT_NONE,   PKACT_DISP,  PKACT_NONE, PKACT_DISP},
-    {PKACT_NONE,    PKACT_NUMCMP, PKACT_DISP,  PKACT_NONE, PKACT_NUMCMP},
-    {PKACT_INPUT,   PKACT_INPUT,  PKACT_INPUT, PKACT_NONE, PKACT_INPUT},
-    {PKACT_NONE,    PKACT_NONE,   PKACT_NONE,  PKACT_NONE, PKACT_NONE},
-    {PKACT_INPUT,   PKACT_NUMCMP, PKACT_DISP,  PKACT_NONE, PKACT_NUMCMP},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_DISP,  IOACT_NONE, IOACT_DISP},
+    {IOACT_NONE,    IOACT_NUMCMP, IOACT_DISP,  IOACT_NONE, IOACT_NUMCMP},
+    {IOACT_INPUT,   IOACT_INPUT,  IOACT_INPUT, IOACT_NONE, IOACT_INPUT},
+    {IOACT_NONE,    IOACT_NONE,   IOACT_NONE,  IOACT_NONE, IOACT_NONE},
+    {IOACT_INPUT,   IOACT_NUMCMP, IOACT_DISP,  IOACT_NONE, IOACT_NUMCMP},
 };
 
 int
-ble_sm_sc_passkey_action(struct ble_sm_proc *proc)
+ble_sm_sc_io_action(struct ble_sm_proc *proc)
 {
     int action;
 
     if (proc->pair_req.oob_data_flag || proc->pair_rsp.oob_data_flag) {
-        action = BLE_SM_PKACT_OOB;
+        action = BLE_SM_IOACT_OOB;
     } else if (!(proc->pair_req.authreq & BLE_SM_PAIR_AUTHREQ_MITM) &&
                !(proc->pair_rsp.authreq & BLE_SM_PAIR_AUTHREQ_MITM)) {
 
-        action = BLE_SM_PKACT_NONE;
+        action = BLE_SM_IOACT_NONE;
     } else if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
-        action = ble_sm_sc_init_pka[proc->pair_rsp.io_cap]
+        action = ble_sm_sc_init_ioa[proc->pair_rsp.io_cap]
                                    [proc->pair_req.io_cap];
     } else {
-        action = ble_sm_sc_resp_pka[proc->pair_rsp.io_cap]
+        action = ble_sm_sc_resp_ioa[proc->pair_rsp.io_cap]
                                    [proc->pair_req.io_cap];
     }
 
     switch (action) {
-    case BLE_SM_PKACT_NONE:
+    case BLE_SM_IOACT_NONE:
         proc->pair_alg = BLE_SM_PAIR_ALG_JW;
         break;
 
-    case BLE_SM_PKACT_OOB:
+    case BLE_SM_IOACT_OOB:
         proc->pair_alg = BLE_SM_PAIR_ALG_OOB;
         proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
         break;
 
-    case BLE_SM_PKACT_INPUT:
-    case BLE_SM_PKACT_DISP:
+    case BLE_SM_IOACT_INPUT:
+    case BLE_SM_IOACT_DISP:
         proc->pair_alg = BLE_SM_PAIR_ALG_PASSKEY;
         proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
         break;
 
-    case BLE_SM_PKACT_NUMCMP:
+    case BLE_SM_IOACT_NUMCMP:
         proc->pair_alg = BLE_SM_PAIR_ALG_NUMCMP;
         proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
         break;
@@ -219,7 +220,7 @@ ble_sm_sc_gen_ri(struct ble_sm_proc *proc)
 }
 
 void
-ble_sm_sc_confirm_go(struct ble_sm_proc *proc, struct ble_sm_result *res)
+ble_sm_sc_confirm_exec(struct ble_sm_proc *proc, struct ble_sm_result *res)
 {
     struct ble_sm_pair_confirm cmd;
     int rc;
@@ -276,7 +277,7 @@ ble_sm_sc_gen_numcmp(struct ble_sm_proc *proc, struct ble_sm_result *res)
 }
 
 /**
- * Advances the supplied procedure object to the next state after it is
+ * Advances the supplied procedure object to the next state after it has
  * completed the random state.
  */
 static int
@@ -300,10 +301,10 @@ ble_sm_sc_random_advance(struct ble_sm_proc *proc)
 }
 
 void
-ble_sm_sc_random_go(struct ble_sm_proc *proc, struct ble_sm_result *res)
+ble_sm_sc_random_exec(struct ble_sm_proc *proc, struct ble_sm_result *res)
 {
     struct ble_sm_pair_random cmd;
-    uint8_t pkact;
+    uint8_t ioact;
     int rc;
 
     memcpy(cmd.value, ble_sm_our_pair_rand(proc), 16);
@@ -325,12 +326,12 @@ ble_sm_sc_random_go(struct ble_sm_proc *proc, struct ble_sm_result *res)
             return;
         }
 
-        pkact = ble_sm_sc_passkey_action(proc);
-        if (ble_sm_pkact_state(pkact) == proc->state &&
+        ioact = ble_sm_sc_io_action(proc);
+        if (ble_sm_ioact_state(ioact) == proc->state &&
             !(proc->flags & BLE_SM_PROC_F_IO_INJECTED)) {
 
-            res->passkey_action.action = pkact;
-            BLE_HS_DBG_ASSERT(pkact == BLE_SM_PKACT_NUMCMP);
+            res->passkey_action.action = ioact;
+            BLE_HS_DBG_ASSERT(ioact == BLE_SM_IOACT_NUMCMP);
             ble_sm_sc_gen_numcmp(proc, res);
         }
     }
@@ -342,7 +343,7 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
     uint8_t confirm_val[16];
     uint8_t ia[6];
     uint8_t ra[6];
-    uint8_t pkact;
+    uint8_t ioact;
     uint8_t iat;
     uint8_t rat;
     int rc;
@@ -355,7 +356,7 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
         BLE_HS_LOG(DEBUG, "\n");
 
         rc = ble_sm_alg_f4(proc->pub_key_peer.x, ble_sm_sc_pub_key.u8,
-                           ble_sm_their_pair_rand(proc), proc->ri,
+                           ble_sm_peer_pair_rand(proc), proc->ri,
                            confirm_val);
         if (rc != 0) {
             res->app_status = rc;
@@ -407,12 +408,12 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
     if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         ble_sm_sc_random_advance(proc);
 
-        pkact = ble_sm_sc_passkey_action(proc);
-        if (ble_sm_pkact_state(pkact) == proc->state &&
+        ioact = ble_sm_sc_io_action(proc);
+        if (ble_sm_ioact_state(ioact) == proc->state &&
             !(proc->flags & BLE_SM_PROC_F_IO_INJECTED)) {
 
-            res->passkey_action.action = pkact;
-            BLE_HS_DBG_ASSERT(pkact == BLE_SM_PKACT_NUMCMP);
+            res->passkey_action.action = ioact;
+            BLE_HS_DBG_ASSERT(ioact == BLE_SM_IOACT_NUMCMP);
             ble_sm_sc_gen_numcmp(proc, res);
         } else {
             res->execute = 1;
@@ -423,11 +424,11 @@ ble_sm_sc_random_rx(struct ble_sm_proc *proc, struct ble_sm_result *res)
 }
 
 void
-ble_sm_sc_public_key_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                        void *arg)
+ble_sm_sc_public_key_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                          void *arg)
 {
     struct ble_sm_public_key cmd;
-    uint8_t pkact;
+    uint8_t ioact;
 
     res->app_status = ble_sm_sc_ensure_keys_generated();
     if (res->app_status != 0) {
@@ -445,9 +446,9 @@ ble_sm_sc_public_key_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
         return;
     }
 
-    pkact = ble_sm_sc_passkey_action(proc);
-    if (ble_sm_pkact_state(pkact) == BLE_SM_PROC_STATE_CONFIRM) {
-        res->passkey_action.action = pkact;
+    ioact = ble_sm_sc_io_action(proc);
+    if (ble_sm_ioact_state(ioact) == BLE_SM_PROC_STATE_CONFIRM) {
+        res->passkey_action.action = ioact;
     }
 
     if (!(proc->flags & BLE_SM_PROC_F_INITIATOR)) {
@@ -530,8 +531,8 @@ ble_sm_sc_dhkey_check_iocap(struct ble_sm_pair_cmd *pair_cmd,
 }
 
 void
-ble_sm_sc_dhkey_check_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
-                         void *arg)
+ble_sm_sc_dhkey_check_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
+                           void *arg)
 {
     struct ble_sm_dhkey_check cmd;
     uint8_t our_addr[6];
@@ -555,7 +556,7 @@ ble_sm_sc_dhkey_check_go(struct ble_sm_proc *proc, struct ble_sm_result *res,
     }
 
     rc = ble_sm_alg_f6(proc->mackey, ble_sm_our_pair_rand(proc),
-                       ble_sm_their_pair_rand(proc), proc->tk, iocap,
+                       ble_sm_peer_pair_rand(proc), proc->tk, iocap,
                        our_addr_type, our_addr, peer_addr_type, peer_addr,
                        cmd.value);
     if (rc != 0) {
@@ -590,7 +591,7 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
     uint8_t *peer_addr;
     uint8_t peer_addr_type;
     uint8_t our_addr_type;
-    uint8_t pkact;
+    uint8_t ioact;
 
     if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         ble_sm_sc_dhkey_check_iocap(&proc->pair_rsp, iocap);
@@ -612,7 +613,7 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
     BLE_HS_LOG(DEBUG, "\n");
 
     res->app_status = ble_sm_alg_f6(proc->mackey,
-                                    ble_sm_their_pair_rand(proc),
+                                    ble_sm_peer_pair_rand(proc),
                                     ble_sm_our_pair_rand(proc), proc->tk,
                                     iocap, peer_addr_type, peer_addr,
                                     our_addr_type, our_addr, exp_value);
@@ -631,8 +632,8 @@ ble_sm_dhkey_check_process(struct ble_sm_proc *proc,
     }
 
 
-    pkact = ble_sm_sc_passkey_action(proc);
-    if (ble_sm_pkact_state(pkact) == proc->state) {
+    ioact = ble_sm_sc_io_action(proc);
+    if (ble_sm_ioact_state(ioact) == proc->state) {
         proc->flags |= BLE_SM_PROC_F_ADVANCE_ON_IO;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index b16ddba..e75e22c 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -174,7 +174,7 @@ host_hci_rx_encrypt_change(uint8_t event_code, uint8_t *data, int len)
     evt.connection_handle = le16toh(data + 3);
     evt.encryption_enabled = data[5];
 
-    ble_sm_rx_encryption_change(&evt);
+    ble_sm_enc_change_rx(&evt);
 
     return 0;
 }
@@ -437,7 +437,7 @@ host_hci_rx_le_lt_key_req(uint8_t subevent, uint8_t *data, int len)
     evt.random_number = le64toh(data + 3);
     evt.encrypted_diversifier = le16toh(data + 11);
 
-    ble_sm_rx_lt_key_req(&evt);
+    ble_sm_ltk_req_rx(&evt);
 
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6c8d7bd3/net/nimble/host/src/test/ble_sm_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_sm_test.c b/net/nimble/host/src/test/ble_sm_test.c
index 470eddf..71a5fca 100644
--- a/net/nimble/host/src/test/ble_sm_test.c
+++ b/net/nimble/host/src/test/ble_sm_test.c
@@ -46,14 +46,14 @@ static ble_store_write_fn ble_sm_test_util_store_write;
  *****************************************************************************/
 
 struct ble_sm_test_passkey_info {
-    struct ble_sm_passkey passkey;
+    struct ble_sm_io passkey;
     uint32_t exp_numcmp;
     unsigned io_before_rx:1;
 };
 
 struct ble_sm_test_lgcy_params {
     uint8_t init_addr[6];
-    uint8_t rsp_addr[6];
+    uint8_t resp_addr[6];
     struct ble_sm_sec_req sec_req;
     struct ble_sm_pair_cmd pair_req;
     struct ble_sm_pair_cmd pair_rsp;
@@ -84,7 +84,7 @@ struct ble_sm_test_lgcy_params {
 
 struct ble_sm_test_sc_params {
     uint8_t init_addr[6];
-    uint8_t rsp_addr[6];
+    uint8_t resp_addr[6];
     struct ble_sm_sec_req sec_req;
     struct ble_sm_pair_cmd pair_req;
     struct ble_sm_pair_cmd pair_rsp;
@@ -157,7 +157,7 @@ struct ble_sm_test_ltk_info {
     unsigned authenticated:1;
 };
 
-struct ble_gap_passkey_action ble_sm_test_pkact;
+struct ble_gap_passkey_action ble_sm_test_ioact;
 
 static int
 ble_sm_test_util_conn_cb(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
@@ -172,7 +172,7 @@ ble_sm_test_util_conn_cb(int event, struct ble_gap_conn_ctxt *ctxt, void *arg)
         break;
 
     case BLE_GAP_EVENT_PASSKEY_ACTION:
-        ble_sm_test_pkact = ctxt->passkey_action;
+        ble_sm_test_ioact = ctxt->passkey_action;
         break;
 
     default:
@@ -225,9 +225,8 @@ ble_sm_test_util_rx_pair_req(uint16_t conn_handle,
 }
 
 static void
-ble_sm_test_util_rx_pair_rsp(uint16_t conn_handle,
-                                   struct ble_sm_pair_cmd *rsp,
-                                   int rx_status)
+ble_sm_test_util_rx_pair_rsp(uint16_t conn_handle, struct ble_sm_pair_cmd *rsp,
+                             int rx_status)
 {
     ble_sm_test_util_rx_pair_cmd(conn_handle, BLE_SM_OP_PAIR_RSP,
                                        rsp, rx_status);
@@ -235,7 +234,7 @@ ble_sm_test_util_rx_pair_rsp(uint16_t conn_handle,
 
 static void
 ble_sm_test_util_rx_confirm(uint16_t conn_handle,
-                                  struct ble_sm_pair_confirm *cmd)
+                            struct ble_sm_pair_confirm *cmd)
 {
     struct hci_data_hdr hci_hdr;
     struct os_mbuf *om;
@@ -264,8 +263,8 @@ ble_sm_test_util_rx_confirm(uint16_t conn_handle,
 
 static void
 ble_sm_test_util_rx_random(uint16_t conn_handle,
-                                 struct ble_sm_pair_random *cmd,
-                                 int exp_status)
+                           struct ble_sm_pair_random *cmd,
+                           int exp_status)
 {
     struct hci_data_hdr hci_hdr;
     struct os_mbuf *om;
@@ -293,8 +292,7 @@ ble_sm_test_util_rx_random(uint16_t conn_handle,
 }
 
 static void
-ble_sm_test_util_rx_sec_req(uint16_t conn_handle,
-                            struct ble_sm_sec_req *cmd,
+ble_sm_test_util_rx_sec_req(uint16_t conn_handle, struct ble_sm_sec_req *cmd,
                             int exp_status)
 {
     struct hci_data_hdr hci_hdr;
@@ -324,7 +322,7 @@ ble_sm_test_util_rx_sec_req(uint16_t conn_handle,
 
 static void
 ble_sm_test_util_rx_public_key(uint16_t conn_handle,
-                                     struct ble_sm_public_key *cmd)
+                               struct ble_sm_public_key *cmd)
 {
     struct hci_data_hdr hci_hdr;
     struct os_mbuf *om;
@@ -353,8 +351,8 @@ ble_sm_test_util_rx_public_key(uint16_t conn_handle,
 
 static void
 ble_sm_test_util_rx_dhkey_check(uint16_t conn_handle,
-                                      struct ble_sm_dhkey_check *cmd,
-                                      int exp_status)
+                                struct ble_sm_dhkey_check *cmd,
+                                int exp_status)
 {
     struct hci_data_hdr hci_hdr;
     struct os_mbuf *om;
@@ -547,7 +545,7 @@ ble_sm_test_util_rx_lt_key_req(uint16_t conn_handle, uint64_t r,
     evt.random_number = r;
     evt.encrypted_diversifier = ediv;
 
-    rc = ble_sm_rx_lt_key_req(&evt);
+    rc = ble_sm_ltk_req_rx(&evt);
     TEST_ASSERT_FATAL(rc == 0);
 }
 
@@ -601,7 +599,7 @@ ble_sm_test_util_rx_enc_change(uint16_t conn_handle, uint8_t status,
     evt.encryption_enabled = encryption_enabled;
     evt.connection_handle = conn_handle;
 
-    ble_sm_rx_encryption_change(&evt);
+    ble_sm_enc_change_rx(&evt);
 }
 
 static void
@@ -630,16 +628,16 @@ ble_sm_test_util_io_inject(struct ble_sm_test_passkey_info *passkey_info,
     uint8_t io_sm_state;
     int rc;
 
-    io_sm_state = ble_sm_pkact_state(passkey_info->passkey.action);
+    io_sm_state = ble_sm_ioact_state(passkey_info->passkey.action);
     if (io_sm_state != cur_sm_state) {
         return;
     }
 
-    if (passkey_info->passkey.action == BLE_SM_PKACT_NUMCMP) {
-        TEST_ASSERT(ble_sm_test_pkact.numcmp == passkey_info->exp_numcmp);
+    if (passkey_info->passkey.action == BLE_SM_IOACT_NUMCMP) {
+        TEST_ASSERT(ble_sm_test_ioact.numcmp == passkey_info->exp_numcmp);
     }
 
-    rc = ble_sm_set_tk(2, &passkey_info->passkey);
+    rc = ble_sm_inject_io(2, &passkey_info->passkey);
     TEST_ASSERT(rc == 0);
 }
 
@@ -650,7 +648,7 @@ ble_sm_test_util_io_check_pre(struct ble_sm_test_passkey_info *passkey_info,
     uint8_t io_sm_state;
     int rc;
 
-    io_sm_state = ble_sm_pkact_state(passkey_info->passkey.action);
+    io_sm_state = ble_sm_ioact_state(passkey_info->passkey.action);
     if (io_sm_state != cur_sm_state) {
         return;
     }
@@ -659,11 +657,11 @@ ble_sm_test_util_io_check_pre(struct ble_sm_test_passkey_info *passkey_info,
         return;
     }
 
-    if (passkey_info->passkey.action == BLE_SM_PKACT_NUMCMP) {
-        TEST_ASSERT(ble_sm_test_pkact.numcmp == passkey_info->exp_numcmp);
+    if (passkey_info->passkey.action == BLE_SM_IOACT_NUMCMP) {
+        TEST_ASSERT(ble_sm_test_ioact.numcmp == passkey_info->exp_numcmp);
     }
 
-    rc = ble_sm_set_tk(2, &passkey_info->passkey);
+    rc = ble_sm_inject_io(2, &passkey_info->passkey);
     TEST_ASSERT(rc == 0);
 }
 
@@ -674,7 +672,7 @@ ble_sm_test_util_io_check_post(struct ble_sm_test_passkey_info *passkey_info,
     uint8_t io_sm_state;
     int rc;
 
-    io_sm_state = ble_sm_pkact_state(passkey_info->passkey.action);
+    io_sm_state = ble_sm_ioact_state(passkey_info->passkey.action);
     if (io_sm_state != cur_sm_state) {
         return;
     }
@@ -683,15 +681,15 @@ ble_sm_test_util_io_check_post(struct ble_sm_test_passkey_info *passkey_info,
         return;
     }
 
-    if (passkey_info->passkey.action == BLE_SM_PKACT_NUMCMP) {
-        TEST_ASSERT(ble_sm_test_pkact.numcmp == passkey_info->exp_numcmp);
+    if (passkey_info->passkey.action == BLE_SM_IOACT_NUMCMP) {
+        TEST_ASSERT(ble_sm_test_ioact.numcmp == passkey_info->exp_numcmp);
     }
 
     /* Ensure response not sent until user performs IO. */
     ble_hs_test_util_tx_all();
     TEST_ASSERT(ble_hs_test_util_prev_tx_queue_sz() == 0);
 
-    rc = ble_sm_set_tk(2, &passkey_info->passkey);
+    rc = ble_sm_inject_io(2, &passkey_info->passkey);
     TEST_ASSERT_FATAL(rc == 0);
 }
 
@@ -765,7 +763,7 @@ ble_sm_test_util_verify_sc_persist(struct ble_sm_test_sc_params *params,
 
     if (we_are_initiator) {
         peer_addr_type = 0;
-        peer_addr = params->rsp_addr;
+        peer_addr = params->resp_addr;
     } else {
         peer_addr_type = 0;
         peer_addr = params->init_addr;
@@ -823,7 +821,7 @@ ble_sm_test_util_us_lgcy_good(
         ble_sm_dbg_set_next_ltk(params->enc_info_req.ltk);
     }
 
-    ble_hs_test_util_create_conn(2, params->rsp_addr,
+    ble_hs_test_util_create_conn(2, params->resp_addr,
                                  ble_sm_test_util_conn_cb,
                                  NULL);
 
@@ -923,14 +921,14 @@ static void
 ble_sm_test_util_peer_fail_inval(
     int we_are_master,
     uint8_t *init_addr,
-    uint8_t *rsp_addr,
+    uint8_t *resp_addr,
     struct ble_sm_pair_cmd *pair_req,
     struct ble_sm_pair_fail *pair_fail)
 {
     struct ble_hs_conn *conn;
 
     ble_sm_test_util_init();
-    ble_hs_test_util_set_public_addr(rsp_addr);
+    ble_hs_test_util_set_public_addr(resp_addr);
 
     ble_hs_test_util_create_conn(2, init_addr, ble_sm_test_util_conn_cb,
                                  NULL);
@@ -975,7 +973,7 @@ ble_sm_test_util_peer_fail_inval(
 static void
 ble_sm_test_util_peer_lgcy_fail_confirm(
     uint8_t *init_addr,
-    uint8_t *rsp_addr,
+    uint8_t *resp_addr,
     struct ble_sm_pair_cmd *pair_req,
     struct ble_sm_pair_cmd *pair_rsp,
     struct ble_sm_pair_confirm *confirm_req,
@@ -987,7 +985,7 @@ ble_sm_test_util_peer_lgcy_fail_confirm(
     struct ble_hs_conn *conn;
 
     ble_sm_test_util_init();
-    ble_hs_test_util_set_public_addr(rsp_addr);
+    ble_hs_test_util_set_public_addr(resp_addr);
     ble_sm_dbg_set_next_pair_rand(random_rsp->value);
 
     ble_hs_test_util_create_conn(2, init_addr, ble_sm_test_util_conn_cb,
@@ -1074,7 +1072,7 @@ ble_sm_test_util_peer_lgcy_good_once(struct ble_sm_test_lgcy_params *params)
     ble_hs_cfg.sm_our_key_dist = params->pair_rsp.resp_key_dist;
     ble_hs_cfg.sm_their_key_dist = params->pair_rsp.init_key_dist;
 
-    ble_hs_test_util_set_public_addr(params->rsp_addr);
+    ble_hs_test_util_set_public_addr(params->resp_addr);
     ble_sm_dbg_set_next_pair_rand(params->random_rsp.value);
     ble_sm_dbg_set_next_ediv(params->ediv);
     ble_sm_dbg_set_next_start_rand(params->r);
@@ -1362,7 +1360,7 @@ ble_sm_test_util_peer_sc_good_once(struct ble_sm_test_sc_params *params)
     ble_hs_cfg.sm_our_key_dist = params->pair_rsp.resp_key_dist;
     ble_hs_cfg.sm_their_key_dist = params->pair_rsp.init_key_dist;
 
-    ble_hs_test_util_set_public_addr(params->rsp_addr);
+    ble_hs_test_util_set_public_addr(params->resp_addr);
     ble_sm_dbg_set_next_pair_rand(params->random_rsp[0].value);
 
     ble_sm_dbg_set_sc_keys(params->public_key_rsp.x, params->our_priv_key);
@@ -1560,7 +1558,7 @@ ble_sm_test_util_us_sc_good(struct ble_sm_test_sc_params *params)
 
     ble_sm_dbg_set_sc_keys(params->public_key_req.x, params->our_priv_key);
 
-    ble_hs_test_util_create_conn(2, params->rsp_addr,
+    ble_hs_test_util_create_conn(2, params->resp_addr,
                                  ble_sm_test_util_conn_cb,
                                  NULL);
 
@@ -1708,7 +1706,7 @@ ble_sm_test_util_us_fail_inval(
     int rc;
 
     ble_sm_test_util_init();
-    ble_hs_test_util_set_public_addr(params->rsp_addr);
+    ble_hs_test_util_set_public_addr(params->resp_addr);
 
     ble_sm_dbg_set_next_pair_rand(((uint8_t[16]){0}));
 
@@ -2202,7 +2200,7 @@ TEST_CASE(ble_sm_test_case_peer_lgcy_jw_good)
 
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x04,
             .oob_data_flag = 0,
@@ -2262,7 +2260,7 @@ TEST_CASE(ble_sm_test_case_peer_lgcy_passkey_good)
 
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07},
+        .resp_addr = {0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x04,
             .oob_data_flag = 0, .authreq = 0x05,
@@ -2317,7 +2315,7 @@ TEST_CASE(ble_sm_test_case_peer_lgcy_passkey_good)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_INPUT,
+                .action = BLE_SM_IOACT_INPUT,
                 .passkey = 884570,
             },
         },
@@ -2424,7 +2422,7 @@ TEST_CASE(ble_sm_test_case_peer_sec_req_pair)
 
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0x06, 0x05, 0x04, 0x03, 0x02, 0x01},
-        .rsp_addr = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a},
+        .resp_addr = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a},
         .sec_req = (struct ble_sm_sec_req) {
             .authreq = 0,
         },
@@ -2504,7 +2502,7 @@ TEST_CASE(ble_sm_test_case_peer_sc_jw_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x03,
             .oob_data_flag = 0x00,
@@ -2601,7 +2599,7 @@ TEST_CASE(ble_sm_test_case_peer_sc_numcmp_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x01,
             .oob_data_flag = 0x00,
@@ -2693,7 +2691,7 @@ TEST_CASE(ble_sm_test_case_peer_sc_numcmp_good)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_NUMCMP,
+                .action = BLE_SM_IOACT_NUMCMP,
                 .numcmp_accept = 1,
             },
 
@@ -2710,7 +2708,7 @@ TEST_CASE(ble_sm_test_case_peer_sc_passkey_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x04,
             .oob_data_flag = 0x00,
@@ -3262,7 +3260,7 @@ TEST_CASE(ble_sm_test_case_peer_sc_passkey_good)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_INPUT,
+                .action = BLE_SM_IOACT_INPUT,
                 .passkey = 873559,
             },
 
@@ -3283,7 +3281,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid IO capabiltiies. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3309,7 +3307,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid OOB flag. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3335,7 +3333,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid authreq - reserved bonding flag. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3361,7 +3359,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid authreq - reserved other flag. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3387,7 +3385,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid key size - too small. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3413,7 +3411,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid key size - too large. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3439,7 +3437,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid init key dist. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3465,7 +3463,7 @@ TEST_CASE(ble_sm_test_case_us_fail_inval)
     /* Invalid resp key dist. */
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
+        .resp_addr = {0x03, 0x02, 0x01, 0x50, 0x13, 0x00},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3495,7 +3493,7 @@ TEST_CASE(ble_sm_test_case_us_lgcy_jw_good)
 
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0x06, 0x05, 0x04, 0x03, 0x02, 0x01},
-        .rsp_addr = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a},
+        .resp_addr = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a},
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 3,
             .oob_data_flag = 0,
@@ -3560,7 +3558,7 @@ TEST_CASE(ble_sm_test_case_us_sec_req_pair)
 
     params = (struct ble_sm_test_lgcy_params) {
         .init_addr = {0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c},
-        .rsp_addr = {0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07},
+        .resp_addr = {0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07},
         .sec_req = (struct ble_sm_sec_req) {
             .authreq = 0x05,
         },
@@ -3620,7 +3618,7 @@ TEST_CASE(ble_sm_test_case_us_sec_req_pair)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_INPUT,
+                .action = BLE_SM_IOACT_INPUT,
                 .passkey = 884570,
             },
             .io_before_rx = 1,
@@ -3666,7 +3664,7 @@ TEST_CASE(ble_sm_test_case_us_sc_jw_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x03,
             .oob_data_flag = 0x00,
@@ -3768,7 +3766,7 @@ TEST_CASE(ble_sm_test_case_us_sc_numcmp_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x01,
             .oob_data_flag = 0x00,
@@ -3859,7 +3857,7 @@ TEST_CASE(ble_sm_test_case_us_sc_numcmp_good)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_NUMCMP,
+                .action = BLE_SM_IOACT_NUMCMP,
                 .numcmp_accept = 1,
             },
 
@@ -3881,7 +3879,7 @@ TEST_CASE(ble_sm_test_case_us_sc_passkey_good)
 
     params = (struct ble_sm_test_sc_params) {
         .init_addr = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 },
-        .rsp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
+        .resp_addr = { 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07 },
         .pair_req = (struct ble_sm_pair_cmd) {
             .io_cap = 0x04,
             .oob_data_flag = 0x00,
@@ -4434,7 +4432,7 @@ TEST_CASE(ble_sm_test_case_us_sc_passkey_good)
 
         .passkey_info = {
             .passkey = {
-                .action = BLE_SM_PKACT_DISP,
+                .action = BLE_SM_IOACT_DISP,
                 .passkey = 85212,
             },
         },