pub struct SessionLayer { /* private fields */ }Expand description
The session table + session_nb allocator.
Implementations§
Source§impl SessionLayer
impl SessionLayer
Sourcepub fn resource_of(&self, session_nb: u16) -> Option<ResourceId>
pub fn resource_of(&self, session_nb: u16) -> Option<ResourceId>
Resource bound to session_nb, if open.
Sourcepub fn sessions(&self) -> Vec<(u16, ResourceId)>
pub fn sessions(&self) -> Vec<(u16, ResourceId)>
All open (session_nb, resource) pairs, ascending by session_nb.
Sourcepub fn create_session(&mut self, resource: ResourceId) -> Vec<u8> ⓘ
pub fn create_session(&mut self, resource: ResourceId) -> Vec<u8> ⓘ
Open a session to a module-provided resource (host-initiated):
returns the open_session_request SPDU to send. Sessions are opened the
same way in both directions (§8.4.1) — the host sends
open_session_request, and the module (the resource provider) assigns the
session_nb in its open_session_response. (create_session/0x93 is a
resource-manager-internal primitive; a real CAM rejects it with
status=0xF0 — verified live against an AlphaCrypt.) The session is
recorded once the module’s open_session_response(ok) arrives.
Sourcepub fn send_apdu(&self, session_nb: u16, apdu: &[u8]) -> Vec<u8> ⓘ
pub fn send_apdu(&self, session_nb: u16, apdu: &[u8]) -> Vec<u8> ⓘ
Wrap an APDU for sending on session_nb (session_number + body).
Sourcepub fn close(&mut self, session_nb: u16) -> Vec<u8> ⓘ
pub fn close(&mut self, session_nb: u16) -> Vec<u8> ⓘ
Begin closing session_nb: returns the close_session_request SPDU.
Sourcepub fn on_spdu(
&mut self,
spdu: &[u8],
provides: impl Fn(ResourceId) -> bool,
) -> SessionOut
pub fn on_spdu( &mut self, spdu: &[u8], provides: impl Fn(ResourceId) -> bool, ) -> SessionOut
Handle one inbound SPDU. provides answers “does the host provide this
resource?” for an incoming open_session_request.