Skip to content

Commit 7633e6b

Browse files
committed
cp: Remove unused flag PD_FLAG_HAS_SCBK
PD_FLAG_HAS_SCBK was used to decide if the SCBK must be preserved when secure channel is initialized. This was from an era where we had master key based key derivation where the SCBK was derived. Since master-key has long been depreciated and subsequently removed, we can get rid of that flag too. Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
1 parent dad97d7 commit 7633e6b

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

src/osdp_common.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,9 @@ union osdp_ephemeral_data {
270270
#define PD_FLAG_CHN_SHARED BIT(9) /* PD's channel is shared */
271271
#define PD_FLAG_PKT_SKIP_MARK BIT(10) /* OPT_OSDP_SKIP_MARK_BYTE */
272272
#define PD_FLAG_PKT_HAS_MARK BIT(11) /* Packet has mark byte */
273-
#define PD_FLAG_HAS_SCBK BIT(12) /* PD has a dedicated SCBK */
274-
#define PD_FLAG_SC_DISABLED BIT(13) /* master_key=NULL && scbk=NULL */
275-
#define PD_FLAG_PKT_BROADCAST BIT(14) /* this packet was addressed to 0x7F */
276-
#define PD_FLAG_CP_USE_CRC BIT(15) /* CP uses CRC-16 instead of checksum */
273+
#define PD_FLAG_SC_DISABLED BIT(12) /* master_key=NULL && scbk=NULL */
274+
#define PD_FLAG_PKT_BROADCAST BIT(13) /* this packet was addressed to 0x7F */
275+
#define PD_FLAG_CP_USE_CRC BIT(14) /* CP uses CRC-16 instead of checksum */
277276

278277
/* PD Init flags */
279278
#define PD_FLAG_ENFORCE_SECURE BIT(24) /* See: OSDP_FLAG_ENFORCE_SECURE */

src/osdp_cp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,6 @@ static int cp_add_pd(struct osdp *ctx, int num_pd, const osdp_pd_info_t *info_li
15581558
memcpy(&pd->channel, &info->channel, sizeof(struct osdp_channel));
15591559
if (info->scbk != NULL) {
15601560
memcpy(pd->sc.scbk, info->scbk, 16);
1561-
SET_FLAG(pd, PD_FLAG_HAS_SCBK);
15621561
CLEAR_FLAG(pd, PD_FLAG_SC_DISABLED);
15631562
} else if (is_enforce_secure(pd)) {
15641563
LOG_PRINT("SCBK must be passed for each PD when"

src/osdp_sc.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,13 @@ int osdp_compute_mac(struct osdp_pd *pd, int is_cmd,
219219
void osdp_sc_setup(struct osdp_pd *pd)
220220
{
221221
uint8_t scbk[16];
222-
bool preserve_scbk = is_pd_mode(pd) || ISSET_FLAG(pd, PD_FLAG_HAS_SCBK);
223222

224223
osdp_crypt_setup();
225224

226-
if (preserve_scbk) {
227-
memcpy(scbk, pd->sc.scbk, 16);
228-
}
225+
memcpy(scbk, pd->sc.scbk, 16);
229226
memset(&pd->sc, 0, sizeof(struct osdp_secure_channel));
230-
if (preserve_scbk) {
231-
memcpy(pd->sc.scbk, scbk, 16);
232-
}
227+
memcpy(pd->sc.scbk, scbk, 16);
228+
233229
if (is_pd_mode(pd)) {
234230
pd->sc.pd_client_uid[0] = BYTE_0(pd->id.vendor_code);
235231
pd->sc.pd_client_uid[1] = BYTE_1(pd->id.vendor_code);

0 commit comments

Comments
 (0)