Skip to content

Commit

Permalink
ignore company id from sign (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
buglloc committed Jun 27, 2024
1 parent 2bde234 commit b7da420
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ LOG_MODULE_REGISTER(pw_ble);
#define PW_BLE_EXT_ADV_OPTS 0
#endif

#define IDX_MFG_BATT_LVL 3
#define IDX_MFG_START (2)
#define IDX_MFG_VERSION (IDX_MFG_START)
#define IDX_MFG_BATT_LVL (IDX_MFG_VERSION + 1)
#define IDX_MFG_BTN_STATE (IDX_MFG_BATT_LVL + 1)
#define IDX_MFG_TS (IDX_MFG_BTN_STATE + 1)
#define IDX_MFG_SIGN (IDX_MFG_TS + 4)
#define MFG_SIGN_LEN (10)

static uint8_t mfg_data[] = {
/* company ID must be 0xffff by spec */
0xff, 0xff,
0x5D, 0x03,
/* version */
0x01,
0x37,
/* battery level */
0x00,
/* button state */
Expand Down Expand Up @@ -76,7 +78,8 @@ int pw_ble_update_mfg_sign()
return -1;
}

err = mbedtls_sha1_update(&mfg_hash_ctx, &mfg_data[0], IDX_MFG_SIGN);
/* ignore company id */
err = mbedtls_sha1_update(&mfg_hash_ctx, &mfg_data[IDX_MFG_START], IDX_MFG_SIGN - IDX_MFG_START);
if (err) {
LOG_ERR("failed to update hash (err %d)", err);
return -1;
Expand Down

0 comments on commit b7da420

Please sign in to comment.