Skip to content

Commit ec97c8e

Browse files
embediverleongross
authored andcommitted
Fix challenge parsing for version <= v1.2
1 parent 9f82ddc commit ec97c8e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/commands/challenge/request.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,19 @@ pub(crate) fn handle_challenge_auth_response<'a>(
161161
.map_err(|e| (true, CommandError::Codec(e)))?;
162162
}
163163

164-
// This field shall be identical to the Context field of the corresponding request message.
165-
// TODO: compare it to the context we sent.
166-
// See: src/protocol/common.rs [RequesterContext]
167-
let _requester_context = resp_payload
168-
.data(8)
169-
.map_err(|e| (true, CommandError::Codec(e)))?;
164+
// In v1.3 a 8-byte request context was added before the signature field
165+
if ctx.connection_info().version_number() >= SpdmVersion::V13 {
166+
// This field shall be identical to the Context field of the corresponding request message.
167+
// TODO: compare it to the context we sent.
168+
// See: src/protocol/common.rs [RequesterContext]
169+
let _requester_context = resp_payload
170+
.data(8)
171+
.map_err(|e| (true, CommandError::Codec(e)))?;
170172

171-
resp_payload
172-
.pull_data(8)
173-
.map_err(|e| (true, CommandError::Codec(e)))?;
173+
resp_payload
174+
.pull_data(8)
175+
.map_err(|e| (true, CommandError::Codec(e)))?;
176+
}
174177

175178
// We have to use this ugly hack to bring the message buffer into the right form to exclude the signature.
176179
// This message buffer thing is totally fucked up...

0 commit comments

Comments
 (0)