[GitHub] [mynewt-nimble] prasad-alatkar commented on a change in pull request #540: nimble/host: Add support to accept or reject pairing request through GAP event
prasad-alatkar commented on a change in pull request #540: nimble/host: Add support to accept or reject pairing request through GAP event URL: https://github.com/apache/mynewt-nimble/pull/540#discussion_r375678248 ## File path: nimble/host/src/ble_gap.c ## @@ -5309,6 +5309,29 @@ ble_gap_identity_event(uint16_t conn_handle) ble_gap_call_conn_event_cb(, conn_handle); } +int +ble_gap_pairing_req_event(const struct ble_gap_pairing_req *req) +{ +#if !NIMBLE_BLE_SM +return 0; +#endif + +struct ble_gap_event event; +int rc; + +memset(, 0, sizeof event); +event.type = BLE_GAP_EVENT_PAIRING_REQUEST; +event.pairing_req.io_cap = req->io_cap; +event.pairing_req.oob_data_flag = req->oob_data_flag; +event.pairing_req.authreq = req->authreq; +event.pairing_req.max_enc_key_size = req->max_enc_key_size; +event.pairing_req.init_key_dist = req->init_key_dist; +event.pairing_req.resp_key_dist = req->resp_key_dist; + +rc = ble_gap_call_conn_event_cb(, req->conn_handle); Review comment: Hi @andrzej-kaczmarek , apologies for not actively working on this PR. If I understand correctly, the application should accept/reject the pairing request using API `ble_sm_inject_io`, I have made changes to this PR according to this assumptions. Please take a look. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-imgmod] ccollins476ad merged pull request #6: Update to latest mynewt-artifact (0.0.15)
ccollins476ad merged pull request #6: Update to latest mynewt-artifact (0.0.15) URL: https://github.com/apache/mynewt-imgmod/pull/6 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-imgmod] branch master updated: Update to latest mynewt-artifact (0.0.15)
This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git The following commit(s) were added to refs/heads/master by this push: new 9e273ae Update to latest mynewt-artifact (0.0.15) 9e273ae is described below commit 9e273aeca4cb3636c4b28fa6cb77c3a56b722059 Author: Christopher Collins AuthorDate: Tue Feb 4 16:36:01 2020 -0800 Update to latest mynewt-artifact (0.0.15) This pulls in a fix for verifying images with header padding. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index cc2ca2f..4b623b9 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module mynewt.apache.org/imgmod require ( - github.com/apache/mynewt-artifact v0.0.9 + github.com/apache/mynewt-artifact v0.0.15 github.com/otiai10/copy v1.0.1 github.com/pkg/errors v0.8.1 github.com/sirupsen/logrus v1.4.2 diff --git a/go.sum b/go.sum index a828f50..03e1893 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/apache/mynewt-artifact v0.0.2/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29O github.com/apache/mynewt-artifact v0.0.3 h1:760wpGruGSOPjslEo0fgs9PYJ58IAvyjuJqno1t4iOc= github.com/apache/mynewt-artifact v0.0.3/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/apache/mynewt-artifact v0.0.9/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= +github.com/apache/mynewt-artifact v0.0.15 h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavkvwJiTbhI= +github.com/apache/mynewt-artifact v0.0.15/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
[GitHub] [mynewt-imgmod] ccollins476ad opened a new pull request #6: Update to latest mynewt-artifact (0.0.15)
ccollins476ad opened a new pull request #6: Update to latest mynewt-artifact (0.0.15) URL: https://github.com/apache/mynewt-imgmod/pull/6 This pulls in a fix for verifying images with header padding. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375423796 ## File path: apps/btshell/src/main.c ## @@ -2253,10 +2280,42 @@ btshell_l2cap_event(struct ble_l2cap_event *event, void *arg) case BLE_L2CAP_EVENT_COC_DATA_RECEIVED: btshell_l2cap_coc_recv(event->receive.chan, event->receive.sdu_rx); +return 0; +case BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED: + +if (ble_l2cap_get_chan_info(event->reconfigured.chan, _info)) { +assert(0); +} + +console_printf("LE CoC reconfigure completed status %0x02x," \ +"chan: 0x%08lx\n", +event->reconfigured.status, +(uint32_t) event->reconfigured.chan); + +if (event->reconfigured.status == 0) { +console_printf("\t our_mps: %d our_mtu %d\n", chan_info.our_mps, chan_info.our_mtu); +} +return 0; +case BLE_L2CAP_EVENT_COC_PEER_RECONFIGURED: + +if (ble_l2cap_get_chan_info(event->reconfigured.chan, _info)) { +assert(0); +} + +console_printf("LE CoC peer reconfigured status %0x02x," \ Review comment: %0x02x -> 0x%02x This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375404384 ## File path: nimble/host/src/ble_l2cap_sig.c ## @@ -609,30 +640,391 @@ ble_l2cap_sig_coc_connect_cb(struct ble_l2cap_sig_proc *proc, int status) { struct ble_hs_conn *conn; struct ble_l2cap_chan *chan; +int i; if (!proc) { return; } -chan = proc->connect.chan; -if (!chan || !chan->cb) { +i = 0; +chan = proc->connect.chan[i]; +while (chan) { +if (!chan || !chan->cb) { +return; +} + +ble_l2cap_event_coc_connected(chan, status); + +if (status) { +/* Normally in channel free we send disconnected event to application. + * However in case on error during creation connection we send connected + * event with error status. To avoid additional disconnected event lets + * clear callbacks since we don't needed it anymore.*/ +chan->cb = NULL; +ble_hs_lock(); +conn = ble_hs_conn_find(chan->conn_handle); +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +} +chan = proc->connect.chan[++i]; +}; +} + +#if MYNEWT_VAL(BLE_VERSION) >= 52 +static void +ble_l2cap_event_coc_reconfigured(uint16_t conn_handle, uint16_t status, + struct ble_l2cap_chan *chan, bool peer) +{ +struct ble_l2cap_event event = { }; + +if (peer) { +event.type = BLE_L2CAP_EVENT_COC_PEER_RECONFIGURED; +} else { +event.type = BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED; +} +event.reconfigured.conn_handle = conn_handle; +event.reconfigured.chan = chan; +event.reconfigured.status = status; + +chan->cb(, chan->cb_arg); +} + +static int +ble_l2cap_sig_credit_base_config_req_rx(uint16_t conn_handle, + struct ble_l2cap_sig_hdr *hdr, + struct os_mbuf **om) +{ +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_l2cap_sig_credit_base_config_req *req; +struct ble_l2cap_sig_credit_base_config_rsp *rsp; +struct ble_hs_conn *conn; +struct os_mbuf *txom; +int i; +int rc; +uint8_t cid_cnt; +uint8_t reduction_mps = 0; + +rc = ble_hs_mbuf_pullup_base(om, hdr->length); +if (rc != 0) { +return rc; +} + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); +if (!conn) { +ble_hs_unlock(); +return 0; +} + +rsp = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONFIG_RSP, +hdr->identifier, sizeof(*rsp) , ); +if (!rsp) { +/* TODO: Reuse req bufor for the response. For now is such a case. + * remote will timeout. + */ +return 0; +} + +/* Assume request will succeed. If not, result will be updated */ +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_SUCCEED); + +req = (struct ble_l2cap_sig_credit_base_config_req *)(*om)->om_data; + +cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t); +assert(cid_cnt <= BLE_L2CAP_MAX_CIDS_IN_PACKET); + +for (i = 0; i < cid_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]); +if (!chan[i]) { + rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID); + ble_hs_unlock(); + goto done; +} + +if (chan[i]->peer_mtu > req->mps) { +reduction_mps++; +if (reduction_mps > 1) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +if (chan[i]->coc_tx.mtu > req->mtu) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +for (i = 0; i < cid_cnt; i++) { +chan[i]->coc_tx.mtu = req->mtu; +chan[i]->peer_mtu = req->mps; +ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true); +} + +ble_hs_unlock(); +done: +ble_l2cap_sig_tx(conn_handle, txom); +return 0; +} + +static void +ble_l2cap_sig_coc_reconfig_cb(struct ble_l2cap_sig_proc *proc, int status) +{ +int i; +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_hs_conn *conn; + +ble_hs_lock(); + +conn = ble_hs_conn_find(proc->conn_handle); +if (!conn) { +ble_hs_unlock(); return; } -ble_l2cap_event_coc_connected(chan, status); +for (i = 0; i< proc->reconfig.cids_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, proc->reconfig.cids[i]); +if (status == 0) { +
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375406287 ## File path: nimble/host/src/ble_l2cap_sig.c ## @@ -609,30 +640,391 @@ ble_l2cap_sig_coc_connect_cb(struct ble_l2cap_sig_proc *proc, int status) { struct ble_hs_conn *conn; struct ble_l2cap_chan *chan; +int i; if (!proc) { return; } -chan = proc->connect.chan; -if (!chan || !chan->cb) { +i = 0; +chan = proc->connect.chan[i]; +while (chan) { +if (!chan || !chan->cb) { +return; +} + +ble_l2cap_event_coc_connected(chan, status); + +if (status) { +/* Normally in channel free we send disconnected event to application. + * However in case on error during creation connection we send connected + * event with error status. To avoid additional disconnected event lets + * clear callbacks since we don't needed it anymore.*/ +chan->cb = NULL; +ble_hs_lock(); +conn = ble_hs_conn_find(chan->conn_handle); +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +} +chan = proc->connect.chan[++i]; +}; +} + +#if MYNEWT_VAL(BLE_VERSION) >= 52 +static void +ble_l2cap_event_coc_reconfigured(uint16_t conn_handle, uint16_t status, + struct ble_l2cap_chan *chan, bool peer) +{ +struct ble_l2cap_event event = { }; + +if (peer) { +event.type = BLE_L2CAP_EVENT_COC_PEER_RECONFIGURED; +} else { +event.type = BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED; +} +event.reconfigured.conn_handle = conn_handle; +event.reconfigured.chan = chan; +event.reconfigured.status = status; + +chan->cb(, chan->cb_arg); +} + +static int +ble_l2cap_sig_credit_base_config_req_rx(uint16_t conn_handle, + struct ble_l2cap_sig_hdr *hdr, + struct os_mbuf **om) +{ +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_l2cap_sig_credit_base_config_req *req; +struct ble_l2cap_sig_credit_base_config_rsp *rsp; +struct ble_hs_conn *conn; +struct os_mbuf *txom; +int i; +int rc; +uint8_t cid_cnt; +uint8_t reduction_mps = 0; + +rc = ble_hs_mbuf_pullup_base(om, hdr->length); +if (rc != 0) { +return rc; +} + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); +if (!conn) { +ble_hs_unlock(); +return 0; +} + +rsp = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONFIG_RSP, +hdr->identifier, sizeof(*rsp) , ); +if (!rsp) { +/* TODO: Reuse req bufor for the response. For now is such a case. + * remote will timeout. + */ +return 0; +} + +/* Assume request will succeed. If not, result will be updated */ +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_SUCCEED); + +req = (struct ble_l2cap_sig_credit_base_config_req *)(*om)->om_data; + +cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t); +assert(cid_cnt <= BLE_L2CAP_MAX_CIDS_IN_PACKET); + +for (i = 0; i < cid_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]); +if (!chan[i]) { + rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID); + ble_hs_unlock(); + goto done; +} + +if (chan[i]->peer_mtu > req->mps) { +reduction_mps++; +if (reduction_mps > 1) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +if (chan[i]->coc_tx.mtu > req->mtu) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +for (i = 0; i < cid_cnt; i++) { +chan[i]->coc_tx.mtu = req->mtu; +chan[i]->peer_mtu = req->mps; +ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true); +} + +ble_hs_unlock(); +done: +ble_l2cap_sig_tx(conn_handle, txom); +return 0; +} + +static void +ble_l2cap_sig_coc_reconfig_cb(struct ble_l2cap_sig_proc *proc, int status) +{ +int i; +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_hs_conn *conn; + +ble_hs_lock(); + +conn = ble_hs_conn_find(proc->conn_handle); +if (!conn) { +ble_hs_unlock(); return; } -ble_l2cap_event_coc_connected(chan, status); +for (i = 0; i< proc->reconfig.cids_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, proc->reconfig.cids[i]); +if (status == 0) { +
[GitHub] [mynewt-nimble] andrzej-kaczmarek opened a new pull request #750: nimble/ll: Fix PHY change on slave request
andrzej-kaczmarek opened a new pull request #750: nimble/ll: Fix PHY change on slave request URL: https://github.com/apache/mynewt-nimble/pull/750 This fixes PHY switch in case slave tries to change from asymmetric to symmetric PHY and the target PHY is one of currently used PHYs. The issue is because we first calculate PHY change in both directions and only then check if slave requested symmetric PHY. However, since either m_to_s or s_to_m are already set to 0 (due to no change required), the subseqent checks assume we should not change PHY in either direction. The current behavior is technically correct, since master is always allowed to leave PHY in both directions unchanged, but it's just dumb since we should make a change assuming our PHY preference allows it. To fix this we basically skip PHY calculation if we determined that slave requested symmetric PHY and we can apply it in both directions. If requested symmetric PHY cannot be applied in at least one direction, we leave both directions unchanged. If there was no request for symmetric PHY from slave, we calculated PHYs as usual. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375404384 ## File path: nimble/host/src/ble_l2cap_sig.c ## @@ -609,30 +640,391 @@ ble_l2cap_sig_coc_connect_cb(struct ble_l2cap_sig_proc *proc, int status) { struct ble_hs_conn *conn; struct ble_l2cap_chan *chan; +int i; if (!proc) { return; } -chan = proc->connect.chan; -if (!chan || !chan->cb) { +i = 0; +chan = proc->connect.chan[i]; +while (chan) { +if (!chan || !chan->cb) { +return; +} + +ble_l2cap_event_coc_connected(chan, status); + +if (status) { +/* Normally in channel free we send disconnected event to application. + * However in case on error during creation connection we send connected + * event with error status. To avoid additional disconnected event lets + * clear callbacks since we don't needed it anymore.*/ +chan->cb = NULL; +ble_hs_lock(); +conn = ble_hs_conn_find(chan->conn_handle); +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +} +chan = proc->connect.chan[++i]; +}; +} + +#if MYNEWT_VAL(BLE_VERSION) >= 52 +static void +ble_l2cap_event_coc_reconfigured(uint16_t conn_handle, uint16_t status, + struct ble_l2cap_chan *chan, bool peer) +{ +struct ble_l2cap_event event = { }; + +if (peer) { +event.type = BLE_L2CAP_EVENT_COC_PEER_RECONFIGURED; +} else { +event.type = BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED; +} +event.reconfigured.conn_handle = conn_handle; +event.reconfigured.chan = chan; +event.reconfigured.status = status; + +chan->cb(, chan->cb_arg); +} + +static int +ble_l2cap_sig_credit_base_config_req_rx(uint16_t conn_handle, + struct ble_l2cap_sig_hdr *hdr, + struct os_mbuf **om) +{ +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_l2cap_sig_credit_base_config_req *req; +struct ble_l2cap_sig_credit_base_config_rsp *rsp; +struct ble_hs_conn *conn; +struct os_mbuf *txom; +int i; +int rc; +uint8_t cid_cnt; +uint8_t reduction_mps = 0; + +rc = ble_hs_mbuf_pullup_base(om, hdr->length); +if (rc != 0) { +return rc; +} + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); +if (!conn) { +ble_hs_unlock(); +return 0; +} + +rsp = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONFIG_RSP, +hdr->identifier, sizeof(*rsp) , ); +if (!rsp) { +/* TODO: Reuse req bufor for the response. For now is such a case. + * remote will timeout. + */ +return 0; +} + +/* Assume request will succeed. If not, result will be updated */ +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_SUCCEED); + +req = (struct ble_l2cap_sig_credit_base_config_req *)(*om)->om_data; + +cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t); +assert(cid_cnt <= BLE_L2CAP_MAX_CIDS_IN_PACKET); + +for (i = 0; i < cid_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]); +if (!chan[i]) { + rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID); + ble_hs_unlock(); + goto done; +} + +if (chan[i]->peer_mtu > req->mps) { +reduction_mps++; +if (reduction_mps > 1) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +if (chan[i]->coc_tx.mtu > req->mtu) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +for (i = 0; i < cid_cnt; i++) { +chan[i]->coc_tx.mtu = req->mtu; +chan[i]->peer_mtu = req->mps; +ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true); +} + +ble_hs_unlock(); +done: +ble_l2cap_sig_tx(conn_handle, txom); +return 0; +} + +static void +ble_l2cap_sig_coc_reconfig_cb(struct ble_l2cap_sig_proc *proc, int status) +{ +int i; +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_hs_conn *conn; + +ble_hs_lock(); + +conn = ble_hs_conn_find(proc->conn_handle); +if (!conn) { +ble_hs_unlock(); return; } -ble_l2cap_event_coc_connected(chan, status); +for (i = 0; i< proc->reconfig.cids_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, proc->reconfig.cids[i]); +if (status == 0) { +
[GitHub] [mynewt-core] utzig commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples.
utzig commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples. URL: https://github.com/apache/mynewt-core/pull/2176#discussion_r375393468 ## File path: hw/drivers/flash/enc_flash/ef_da1469x/src/hw_enc_flash.c ## @@ -139,12 +139,15 @@ enc_flash_crypt_arch(struct enc_flash_dev *edev, uint32_t blk_addr, struct eflash_da1469x_dev *dev = EDEV_TO_DA1469X(edev); const struct hal_flash *h_dev = edev->efd_hwdev; uint32_t ctr[4] = {0}; +uint8_t blk[ENC_FLASH_BLK] = {0}; ctr[0] = (uint32_t) ((blk_addr - h_dev->hf_base_addr) / ENC_FLASH_BLK); Review comment: Btw, it would be interesting to find out if the endianness of the `uint32_t` written to `CRYPTO_MREGx_REG` is correct by just writing the value or if we need to do `os_bswap_32` here (or in the register writing above!). The security is still OK, but the values would be different from the expected ones and the counter would increment in a weird way (instead of +1). A way to test it would be to write one block of a vector to address 0 of flash and read using JTAG/SWD and check that it matches the encrypted vector. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375386729 ## File path: apps/btshell/src/main.c ## @@ -2253,10 +2280,42 @@ btshell_l2cap_event(struct ble_l2cap_event *event, void *arg) case BLE_L2CAP_EVENT_COC_DATA_RECEIVED: btshell_l2cap_coc_recv(event->receive.chan, event->receive.sdu_rx); +return 0; +case BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED: + +if (ble_l2cap_get_chan_info(event->reconfigured.chan, _info)) { +assert(0); +} + +console_printf("LE CoC reconfigure completed status %0x02x," \ Review comment: %0x02x -> 0x%02x This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375387077 ## File path: apps/btshell/src/main.c ## @@ -2265,35 +2324,53 @@ btshell_l2cap_event(struct ble_l2cap_event *event, void *arg) #endif int -btshell_l2cap_create_srv(uint16_t psm, int accept_response) +btshell_l2cap_create_srv(uint16_t psm, uint16_t mtu, int accept_response) { #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) == 0 console_printf("BLE L2CAP LE COC not supported."); console_printf(" Configure nimble host to enable it\n"); return 0; #else -return ble_l2cap_create_server(psm, BTSHELL_COC_MTU, btshell_l2cap_event, +if (mtu == 0 || mtu > BTSHELL_COC_MTU) { +mtu = BTSHELL_COC_MTU; +} + +return ble_l2cap_create_server(psm, mtu, btshell_l2cap_event, INT_TO_PTR(accept_response)); #endif } int -btshell_l2cap_connect(uint16_t conn_handle, uint16_t psm) +btshell_l2cap_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, uint8_t num) { #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) == 0 console_printf("BLE L2CAP LE COC not supported."); console_printf(" Configure nimble host to enable it\n"); return 0; #else -struct os_mbuf *sdu_rx; +struct os_mbuf *sdu_rx[num]; +int i; -sdu_rx = os_mbuf_get_pkthdr(_os_mbuf_pool, 0); -assert(sdu_rx != NULL); +if (mtu == 0 || mtu > BTSHELL_COC_MTU) { +mtu = BTSHELL_COC_MTU; +} + +console_printf("L2CAP CoC MTU: %d, max available %d", mtu, BTSHELL_COC_MTU); Review comment: Missing newline This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375388111 ## File path: nimble/host/src/ble_l2cap_sig.c ## @@ -609,30 +640,391 @@ ble_l2cap_sig_coc_connect_cb(struct ble_l2cap_sig_proc *proc, int status) { struct ble_hs_conn *conn; struct ble_l2cap_chan *chan; +int i; if (!proc) { return; } -chan = proc->connect.chan; -if (!chan || !chan->cb) { +i = 0; +chan = proc->connect.chan[i]; +while (chan) { +if (!chan || !chan->cb) { +return; +} + +ble_l2cap_event_coc_connected(chan, status); + +if (status) { +/* Normally in channel free we send disconnected event to application. + * However in case on error during creation connection we send connected + * event with error status. To avoid additional disconnected event lets + * clear callbacks since we don't needed it anymore.*/ +chan->cb = NULL; +ble_hs_lock(); +conn = ble_hs_conn_find(chan->conn_handle); +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +} +chan = proc->connect.chan[++i]; +}; +} + +#if MYNEWT_VAL(BLE_VERSION) >= 52 +static void +ble_l2cap_event_coc_reconfigured(uint16_t conn_handle, uint16_t status, + struct ble_l2cap_chan *chan, bool peer) +{ +struct ble_l2cap_event event = { }; + +if (peer) { +event.type = BLE_L2CAP_EVENT_COC_PEER_RECONFIGURED; +} else { +event.type = BLE_L2CAP_EVENT_COC_RECONFIGURE_COMPLETED; +} +event.reconfigured.conn_handle = conn_handle; +event.reconfigured.chan = chan; +event.reconfigured.status = status; + +chan->cb(, chan->cb_arg); +} + +static int +ble_l2cap_sig_credit_base_config_req_rx(uint16_t conn_handle, + struct ble_l2cap_sig_hdr *hdr, + struct os_mbuf **om) +{ +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_l2cap_sig_credit_base_config_req *req; +struct ble_l2cap_sig_credit_base_config_rsp *rsp; +struct ble_hs_conn *conn; +struct os_mbuf *txom; +int i; +int rc; +uint8_t cid_cnt; +uint8_t reduction_mps = 0; + +rc = ble_hs_mbuf_pullup_base(om, hdr->length); +if (rc != 0) { +return rc; +} + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); +if (!conn) { +ble_hs_unlock(); +return 0; +} + +rsp = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONFIG_RSP, +hdr->identifier, sizeof(*rsp) , ); +if (!rsp) { +/* TODO: Reuse req bufor for the response. For now is such a case. + * remote will timeout. + */ +return 0; +} + +/* Assume request will succeed. If not, result will be updated */ +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_SUCCEED); + +req = (struct ble_l2cap_sig_credit_base_config_req *)(*om)->om_data; + +cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t); +assert(cid_cnt <= BLE_L2CAP_MAX_CIDS_IN_PACKET); + +for (i = 0; i < cid_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]); +if (!chan[i]) { + rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID); + ble_hs_unlock(); + goto done; +} + +if (chan[i]->peer_mtu > req->mps) { +reduction_mps++; +if (reduction_mps > 1) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +if (chan[i]->coc_tx.mtu > req->mtu) { +rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED); +ble_hs_unlock(); +goto done; +} +} + +for (i = 0; i < cid_cnt; i++) { +chan[i]->coc_tx.mtu = req->mtu; +chan[i]->peer_mtu = req->mps; +ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true); +} + +ble_hs_unlock(); +done: +ble_l2cap_sig_tx(conn_handle, txom); +return 0; +} + +static void +ble_l2cap_sig_coc_reconfig_cb(struct ble_l2cap_sig_proc *proc, int status) +{ +int i; +struct ble_l2cap_chan *chan[BLE_L2CAP_MAX_CIDS_IN_PACKET] = {0}; +struct ble_hs_conn *conn; + +ble_hs_lock(); + +conn = ble_hs_conn_find(proc->conn_handle); +if (!conn) { +ble_hs_unlock(); return; } -ble_l2cap_event_coc_connected(chan, status); +for (i = 0; i< proc->reconfig.cids_cnt; i++) { +chan[i] = ble_hs_conn_chan_find_by_dcid(conn, proc->reconfig.cids[i]); Review comment: find_by_scid
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375388388 ## File path: nimble/host/src/ble_l2cap_sig.c ## @@ -869,6 +1261,170 @@ ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t psm, uint16_t mtu, return rc; } +int +ble_l2cap_sig_coc_connect_multiple(uint16_t conn_handle, + uint16_t psm, uint16_t mtu, + uint8_t num, struct os_mbuf *sdu_rx[num], + ble_l2cap_event_fn *cb, void *cb_arg) +{ +#if MYNEWT_VAL(BLE_VERSION) >= 52 +struct ble_hs_conn *conn; +struct ble_l2cap_sig_proc *proc; +struct ble_l2cap_chan *chan = NULL; +struct os_mbuf *txom; +struct ble_l2cap_sig_credit_base_connect_req *req; +int rc; +int i; +int j; + +if (!sdu_rx || !cb) { +return BLE_HS_EINVAL; +} + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); + +if (!conn) { +ble_hs_unlock(); +return BLE_HS_ENOTCONN; +} + +proc = ble_l2cap_sig_proc_alloc(); +if (!proc) { +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +return BLE_HS_ENOMEM; +} + +for (i = 0; i < num; i++) { +chan = ble_l2cap_coc_chan_alloc(conn, psm, mtu, sdu_rx[i], cb, cb_arg); +if (!chan) { +for (j = 0; j < i; j++) { +chan[j].cb = NULL; +ble_l2cap_chan_free(conn, proc->connect.chan[j]); +} +ble_hs_unlock(); +rc = BLE_HS_ENOMEM; +goto done; +} +proc->connect.chan[i] = chan; +} + +proc->op = BLE_L2CAP_SIG_PROC_OP_CONNECT; +proc->id = ble_l2cap_sig_next_id(); +proc->conn_handle = conn_handle; + +req = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONNECT_REQ, proc->id, +sizeof(*req) + num * sizeof(uint16_t), ); +if (!req) { +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +return BLE_HS_ENOMEM; +} + +req->psm = htole16(psm); +req->mtu = htole16(chan->coc_rx.mtu); +req->mps = htole16(chan->my_mtu); +req->credits = htole16(chan->coc_rx.credits); +for (i = 0; i < num; i++) { +req->scids[i] = htole16(proc->connect.chan[i]->scid); +} + +ble_hs_unlock(); + +rc = ble_l2cap_sig_tx(proc->conn_handle, txom); +if (rc != 0) { +ble_hs_lock(); +conn = ble_hs_conn_find_assert(conn_handle); +ble_l2cap_chan_free(conn, chan); +ble_hs_unlock(); +} + +done: +ble_l2cap_sig_process_status(proc, rc); + +return rc; +#else +return BLE_HS_ENOTSUP; +#endif +} + +int +ble_l2cap_sig_coc_reconfig(uint16_t conn_handle, uint16_t new_mtu, + uint8_t cnt, struct ble_l2cap_chan *chans[]) +{ +#if MYNEWT_VAL(BLE_VERSION) >= 52 +struct ble_hs_conn *conn; +struct ble_l2cap_sig_proc *proc; +struct os_mbuf *txom; +struct ble_l2cap_sig_credit_base_config_req *req; +int rc; +int i; + +ble_hs_lock(); +conn = ble_hs_conn_find(conn_handle); + +if (!conn) { +ble_hs_unlock(); +return BLE_HS_ENOTCONN; +} + +proc = ble_l2cap_sig_proc_alloc(); +if (!proc) { +ble_hs_unlock(); +return BLE_HS_ENOMEM; +} + +for (i = 0; i < cnt; i++) { +if (ble_hs_conn_chan_exist(conn, chans[i])) { +proc->reconfig.cids[i] = chans[i]->dcid; Review comment: chans[i]->scid; This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375386467 ## File path: apps/btshell/src/main.c ## @@ -2221,14 +2247,15 @@ btshell_l2cap_event(struct ble_l2cap_event *event, void *arg) return 0; } -console_printf("LE COC connected, conn: %d, chan: 0x%08lx, scid: 0x%04x, " - "dcid: 0x%04x, our_mtu: 0x%04x, peer_mtu: 0x%04x\n", - event->connect.conn_handle, - (uint32_t) event->connect.chan, - ble_l2cap_get_scid(event->connect.chan), - ble_l2cap_get_dcid(event->connect.chan), - ble_l2cap_get_our_mtu(event->connect.chan), - ble_l2cap_get_peer_mtu(event->connect.chan)); +if (ble_l2cap_get_chan_info(event->connect.chan, _info)) { +assert(0); +} + +console_printf("LE COC connected, conn: %d, chan: 0x%08lx, psm: 0x%02x, scid: 0x%04x, " + "dcid: 0x%04x, our_mps: %d, our_mtu: %d, peer_mps: 0x%d, peer_mtu: %d\n", Review comment: peer_mps: 0x%d should be peer_mps: %d This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[mynewt-newt] branch master updated: Update mynewt-artifact dep to v0.0.15
This is an automated email from the ASF dual-hosted git repository. utzig pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git The following commit(s) were added to refs/heads/master by this push: new df8f3d7 Update mynewt-artifact dep to v0.0.15 df8f3d7 is described below commit df8f3d7b2ed897a2404ef36c51330f47926bf166 Author: Fabio Utzig AuthorDate: Wed Feb 5 09:19:47 2020 -0300 Update mynewt-artifact dep to v0.0.15 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e991a53..64e5afd 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5 - github.com/apache/mynewt-artifact v0.0.9 + github.com/apache/mynewt-artifact v0.0.15 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/sirupsen/logrus v1.4.2 diff --git a/go.sum b/go.sum index 8543079..03ac25a 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/apache/mynewt-artifact v0.0.8 h1:as5qSDTT5httEM1IclQM4XgoF9Wn/lTqeoJx github.com/apache/mynewt-artifact v0.0.8/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/apache/mynewt-artifact v0.0.9 h1:Pv/nAD50Zvom6YJ5gzQG7M4jsItPA3txSV/5eelt3Cc= github.com/apache/mynewt-artifact v0.0.9/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= +github.com/apache/mynewt-artifact v0.0.15 h1:NOAdYAMjVBGVm/4iOs70+oQnb4StlD2tavkvwJiTbhI= +github.com/apache/mynewt-artifact v0.0.15/go.mod h1:vFUd47t74KPQMzSBhQ2qp5Hc7D29OU/Tl3xHtFwN3k8= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
[GitHub] [mynewt-newt] utzig merged pull request #375: Update mynewt-artifact dep to v0.0.15
utzig merged pull request #375: Update mynewt-artifact dep to v0.0.15 URL: https://github.com/apache/mynewt-newt/pull/375 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-nimble] michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2
michal-narajowski commented on a change in pull request #744: [WIP] Add support for Enhanced LE CoC as per BT 5.2 URL: https://github.com/apache/mynewt-nimble/pull/744#discussion_r375385729 ## File path: apps/btshell/src/cmd.c ## @@ -3540,6 +3543,24 @@ static const struct shell_cmd_help l2cap_disconnect_help = { .params = l2cap_disconnect_params, }; +/* + * $l2cap-reconfig * + */ + +static const struct shell_param l2cap_reconfig_params[] = { +{"conn", "connection handle, usage: ="}, +{"mtu", "new mtu, usage: =, default: 0 (no change)"}, +{"mps", "new mps, usage: =, default: 0 (no change)"}, +{"idxs", "list of channel indexes, usage: idx_1:idx_2:...:idx_5"}, Review comment: It wasn't clear for me at first how to use this parameter, maybe it could be improved. Example usage: idxs=00:11 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples.
apache-mynewt-bot removed a comment on issue #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples. URL: https://github.com/apache/mynewt-core/pull/2176#issuecomment-581721136 ## Style check summary No suggestions at this time! This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples.
apache-mynewt-bot commented on issue #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples. URL: https://github.com/apache/mynewt-core/pull/2176#issuecomment-582491048 ## Style check summary No suggestions at this time! This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] nkaje commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples.
nkaje commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples. URL: https://github.com/apache/mynewt-core/pull/2176#discussion_r375353656 ## File path: hw/drivers/flash/enc_flash/ef_da1469x/src/hw_enc_flash.c ## @@ -132,18 +133,34 @@ do_encrypt(const struct hal_flash *h_dev, uint32_t *ctr, const uint8_t *src, uin da1469x_clock_amba_disable(CRG_TOP_CLK_AMBA_REG_AES_CLK_ENABLE_Msk); } +static void +ef_da_get_block(const struct hal_flash *h_dev, uint32_t *ctr, uint32_t addr, uint8_t *blk) +{ +memcpy(blk, ENC_FLASH_NONCE, 12); +memcpy(blk + 12, , sizeof(addr)); + +do_encrypt(h_dev, ctr, blk, blk); +} + void enc_flash_crypt_arch(struct enc_flash_dev *edev, uint32_t blk_addr, const uint8_t *src, uint8_t *tgt, int off, int cnt) { struct eflash_da1469x_dev *dev = EDEV_TO_DA1469X(edev); const struct hal_flash *h_dev = edev->efd_hwdev; uint32_t ctr[4] = {0}; +uint8_t blk[ENC_FLASH_BLK]; +uint8_t *b; +int i; ctr[0] = (uint32_t) ((blk_addr - h_dev->hf_base_addr) / ENC_FLASH_BLK); os_sem_pend(>ef_sem, OS_TIMEOUT_NEVER); -do_encrypt(h_dev, ctr, src, tgt, off, cnt); +ef_da_get_block(h_dev, ctr, blk_addr, blk); +b = [off]; +for (i = 0; i < cnt; i++) { +*tgt++ = *b++ ^ *src++; +} Review comment: Modified by removing the` XOR` operations and using `memcpy` instead. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-core] utzig commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples.
utzig commented on a change in pull request #2176: da1469x: support blocks that are not ENC_FLASH_BLK multiples. URL: https://github.com/apache/mynewt-core/pull/2176#discussion_r375261015 ## File path: hw/drivers/flash/enc_flash/ef_da1469x/src/hw_enc_flash.c ## @@ -132,18 +133,34 @@ do_encrypt(const struct hal_flash *h_dev, uint32_t *ctr, const uint8_t *src, uin da1469x_clock_amba_disable(CRG_TOP_CLK_AMBA_REG_AES_CLK_ENABLE_Msk); } +static void +ef_da_get_block(const struct hal_flash *h_dev, uint32_t *ctr, uint32_t addr, uint8_t *blk) +{ +memcpy(blk, ENC_FLASH_NONCE, 12); +memcpy(blk + 12, , sizeof(addr)); + +do_encrypt(h_dev, ctr, blk, blk); +} + void enc_flash_crypt_arch(struct enc_flash_dev *edev, uint32_t blk_addr, const uint8_t *src, uint8_t *tgt, int off, int cnt) { struct eflash_da1469x_dev *dev = EDEV_TO_DA1469X(edev); const struct hal_flash *h_dev = edev->efd_hwdev; uint32_t ctr[4] = {0}; +uint8_t blk[ENC_FLASH_BLK]; +uint8_t *b; +int i; ctr[0] = (uint32_t) ((blk_addr - h_dev->hf_base_addr) / ENC_FLASH_BLK); os_sem_pend(>ef_sem, OS_TIMEOUT_NEVER); -do_encrypt(h_dev, ctr, src, tgt, off, cnt); +ef_da_get_block(h_dev, ctr, blk_addr, blk); +b = [off]; +for (i = 0; i < cnt; i++) { +*tgt++ = *b++ ^ *src++; +} Review comment: The code is doing CTR-mode in SW, and the HW seems to be configured to do CTR-mode in HW as well, so the results won't be what you would expect; it still garbles data but not in a standard way. I think this can either be changed to use the HW in ECB mode and leave the code above as is, or adapt the code to send the same `src` received by `enc_flash_crypt_arch` to `do_encrypt` and remove this block of XOR operations above, changing for a simple `memcpy` of `cnt` amount... This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [mynewt-newt] utzig opened a new pull request #375: Update mynewt-artifact dep to v0.0.15
utzig opened a new pull request #375: Update mynewt-artifact dep to v0.0.15 URL: https://github.com/apache/mynewt-newt/pull/375 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services