Skip to content

Conversation

@Ryanmtate
Copy link
Contributor

@Ryanmtate Ryanmtate commented Aug 21, 2025

This pull request introduces a static NFC handover implementation, adds BLE advertisement parsing, and refactors the device engagement module to better organize NFC-related functionality. The most significant changes are the addition of new modules for NFC APDU and BLE handling, the implementation of an APDU handover driver, and dependency updates.

NFC Handover and APDU Handling:

  • Added a complete implementation for parsing and handling NFC APDU commands, including support for file selection, binary read/update, and response code management in src/definitions/device_engagement/nfc/apdu.rs.
  • Implemented the APDU handover driver, which manages NFC handover state, processes APDU commands, and supports static BLE handover. Includes error handling and state reset logic in src/definitions/device_engagement/nfc/apdu_handover.rs.

BLE Advertisement Parsing:

  • Added BLE advertisement packet parsing and support for known/unknown packet types in src/definitions/device_engagement/nfc/ble.rs.

Module Organization and Refactoring:

  • Refactored the device engagement module to split NFC-related logic into new submodules: error, nfc, and nfc_options in src/definitions/device_engagement.rs, and reorganized imports accordingly. [1] [2]
  • Introduced the NFC module with APDU, BLE, NDEF handover, parser, and utility submodules in src/definitions/device_engagement/nfc/mod.rs. Also re-exported key types for external usage.

Dependency Updates:

  • Updated the time crate from version 0.3.20 to 0.3.35 and added the ndef-rs crate as a new dependency in Cargo.toml. [1] [2]

Minor Improvements:

  • Made the BleOptions struct Default to simplify instantiation in src/definitions/device_engagement.rs.

Ryanmtate and others added 15 commits April 4, 2025 08:05
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
…ession

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
(instead of negotiated handover)
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
presentation is broken - at some point, we broke the presentation flow
in isomdl, even for QR.
@alichay alichay force-pushed the feat/isomdl-device-engagement-refactor branch from 6cb8344 to 826bac1 Compare September 4, 2025 02:35
alichay and others added 3 commits September 3, 2025 19:37
I accidentally wiped over this commit, my bad!

Co-authored-by: Tiago Nascimento <tiago.nascimento@spruceid.com>
Handover gets serialized to CBOR and used in shared secret derivation per 18013-5.
Now, you hit a todo!() if you try to use negotiated handover.
Not perfect, but nicer than having a broken implementation.
@alichay alichay changed the title Feat/isomdl device engagement refactor NFC presentment support Oct 1, 2025
Comment on lines +54 to +61
// Stub out the real NdefUpdateDriver until we have negotiated handover finished.
#[derive(Debug, Clone)]
struct NdefUpdateDriver;
impl NdefUpdateDriver {
pub fn new() -> Self {
Self
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to leave the bones for adding back negotiated handover, because it was almost finished before the pivot to static handover for simplicity. We want to support negotiated handover in the future, so it's nice to have the main structure for when we bring it back.

Comment on lines +122 to +134
pub fn get_carrier_info(&mut self) -> Option<Box<NegotiatedCarrierInfo>> {
if matches!(&self.state, ndef_handover::HandoverState::Done(_)) {
let mut state = ndef_handover::HandoverState::Init;
std::mem::swap(&mut self.state, &mut state);
let ndef_handover::HandoverState::Done(carrier_info) = state else {
// Guaranteed unreachable
return None;
};
Some(carrier_info)
} else {
None
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is written awkwardly to support the negotiated handover state machine, once that gets brought back.

@alichay alichay marked this pull request as ready for review October 30, 2025 02:37
@alichay alichay requested a review from sbihel November 11, 2025 23:12
@Ryanmtate Ryanmtate requested a review from cobward November 12, 2025 22:05
@Ryanmtate Ryanmtate changed the title NFC presentment support NFC Device Engagement support Nov 12, 2025
@alichay alichay merged commit a5f04e0 into main Nov 13, 2025
1 check passed
@alichay alichay deleted the feat/isomdl-device-engagement-refactor branch November 13, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants