use core::future::Future;
use super::Unauthenticated;
use crate::{
CommMode, Configuration, File, FileSettingsUpdate, FileSettingsView, KeyNumber,
NonMasterKeyNumber, Session, SessionError, TagTamperStatusReadout, Transport, Version,
types::file_settings::CryptoMode,
};
pub trait AuthenticatedSession: Sized {
fn mode(&self) -> CryptoMode;
fn key_number(&self) -> KeyNumber;
fn get_version<T: Transport>(
self,
transport: &mut T,
) -> impl Future<Output = Result<(Version, Self), SessionError<T::Error>>>;
fn change_key<T: Transport>(
self,
transport: &mut T,
key_no: NonMasterKeyNumber,
new_key: &[u8; 16],
new_key_version: u8,
old_key: &[u8; 16],
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn change_master_key<T: Transport>(
self,
transport: &mut T,
new_key: &[u8; 16],
new_key_version: u8,
) -> impl Future<Output = Result<Session<Unauthenticated>, SessionError<T::Error>>>;
fn get_uid<T: Transport>(
self,
transport: &mut T,
) -> impl Future<Output = Result<([u8; 7], Self), SessionError<T::Error>>>;
fn get_key_version<T: Transport>(
self,
transport: &mut T,
key_no: KeyNumber,
) -> impl Future<Output = Result<(u8, Self), SessionError<T::Error>>>;
fn get_file_settings<T: Transport>(
self,
transport: &mut T,
file: File,
) -> impl Future<Output = Result<(FileSettingsView, Self), SessionError<T::Error>>>;
fn get_file_counters<T: Transport>(
self,
transport: &mut T,
file: File,
) -> impl Future<Output = Result<(u32, Self), SessionError<T::Error>>>;
fn get_tt_status<T: Transport>(
self,
transport: &mut T,
) -> impl Future<Output = Result<(TagTamperStatusReadout, Self), SessionError<T::Error>>>;
fn set_configuration<T: Transport>(
self,
transport: &mut T,
configuration: &Configuration,
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn change_file_settings<T: Transport>(
self,
transport: &mut T,
file: File,
settings: &FileSettingsUpdate,
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn verify_originality<T: Transport>(
self,
transport: &mut T,
uid: &[u8; 7],
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn read_file_plain<T: Transport>(
&mut self,
transport: &mut T,
file: File,
offset: u32,
length: u32,
buf: &mut [u8],
) -> impl Future<Output = Result<usize, SessionError<T::Error>>>;
fn read_file_with_mode<T: Transport>(
self,
transport: &mut T,
file: File,
offset: u32,
length: u32,
mode: CommMode,
buf: &mut [u8],
) -> impl Future<Output = Result<(usize, Self), SessionError<T::Error>>>;
fn write_file_plain<T: Transport>(
&mut self,
transport: &mut T,
file: File,
offset: u32,
data: &[u8],
) -> impl Future<Output = Result<(), SessionError<T::Error>>>;
fn write_file_with_mode<T: Transport>(
self,
transport: &mut T,
file: File,
offset: u32,
data: &[u8],
mode: CommMode,
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn write_file<T: Transport>(
self,
transport: &mut T,
file: File,
offset: u32,
data: &[u8],
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
fn read_file<T: Transport>(
self,
transport: &mut T,
file: File,
offset: u32,
length: u32,
buf: &mut [u8],
) -> impl Future<Output = Result<(usize, Self), SessionError<T::Error>>>;
#[doc(hidden)] fn ti(&self) -> &[u8; 4];
#[doc(hidden)]
fn pd_cap2(&self) -> &[u8; 6];
fn pcd_cap2(&self) -> &[u8; 6];
#[doc(hidden)] fn cmd_counter(&self) -> u16;
fn authenticate<T: Transport>(
self,
transport: &mut T,
key_no: KeyNumber,
key: &[u8; 16],
rnd_a: [u8; 16],
) -> impl Future<Output = Result<Self, SessionError<T::Error>>>;
}