Skip to content

Commit 07435a3

Browse files
committed
spdm: Add support for mutual authentication
Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Lukas Wunner <[email protected]>
1 parent 8c40588 commit 07435a3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/spdm/req-authenticate.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ static int spdm_negotiate_algs(struct spdm_state *spdm_state)
251251
spdm_state->rsp_caps & SPDM_KEY_EX_CAP)
252252
req->other_params_support = SPDM_OPAQUE_DATA_FMT_GENERAL;
253253

254+
/* ReqAlgStruct order shall be by AlgType (SPDM 1.1.0 margin no 186) */
254255
req_alg_struct = (struct spdm_req_alg_struct *)(req + 1);
255256
if (spdm_state->rsp_caps & SPDM_KEY_EX_CAP) {
256257
req_alg_struct[i++] = (struct spdm_req_alg_struct) {
@@ -263,12 +264,19 @@ static int spdm_negotiate_algs(struct spdm_state *spdm_state)
263264
.alg_count = 0x20,
264265
.alg_supported = cpu_to_le16(SPDM_AEAD_ALGOS),
265266
};
267+
}
268+
if (spdm_state->rsp_caps & SPDM_MUT_AUTH_CAP)
269+
req_alg_struct[i++] = (struct spdm_req_alg_struct) {
270+
.alg_type = SPDM_REQ_ALG_STRUCT_REQ_BASE_ASYM_ALG,
271+
.alg_count = 0x20,
272+
.alg_supported = cpu_to_le16(SPDM_ASYM_ALGOS),
273+
};
274+
if (spdm_state->rsp_caps & SPDM_KEY_EX_CAP)
266275
req_alg_struct[i++] = (struct spdm_req_alg_struct) {
267276
.alg_type = SPDM_REQ_ALG_STRUCT_KEY_SCHEDULE,
268277
.alg_count = 0x20,
269278
.alg_supported = cpu_to_le16(SPDM_KEY_SCHEDULE_SPDM),
270279
};
271-
}
272280
WARN_ON(i > SPDM_MAX_REQ_ALG_STRUCT);
273281
req_sz = sizeof(*req) + i * sizeof(*req_alg_struct);
274282
rsp_sz = sizeof(*rsp) + i * sizeof(*req_alg_struct);

lib/spdm/spdm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
#define SPDM_AEAD_CHACHA20_POLY1305 BIT(2) /* 1.1 */
134134
#define SPDM_AEAD_SM4_GCM BIT(3) /* 1.2 */
135135

136+
/* SPDM asymmetric key signature algorithms (SPDM 1.1.0 margin no 191) */
137+
#define SPDM_REQ_ALG_STRUCT_REQ_BASE_ASYM_ALG 4 /* 1.1 */
138+
136139
/* SPDM key schedule algorithms (SPDM 1.1.0 margin no 192) */
137140
#define SPDM_REQ_ALG_STRUCT_KEY_SCHEDULE 5 /* 1.1 */
138141
#define SPDM_KEY_SCHEDULE_SPDM BIT(0) /* 1.1 */
@@ -321,7 +324,7 @@ struct spdm_negotiate_algs_rsp {
321324
} __packed;
322325

323326
/* Maximum number of ReqAlgStructs sent by this implementation */
324-
#define SPDM_MAX_REQ_ALG_STRUCT 3
327+
#define SPDM_MAX_REQ_ALG_STRUCT 4
325328

326329
struct spdm_req_alg_struct {
327330
u8 alg_type;

0 commit comments

Comments
 (0)