pub struct LinkSession { /* private fields */ }Expand description
Linking session, one side (desktop or phone). Secrets never leave the core and are wiped on close, on any mismatch and when the object is dropped.
Implementations§
Source§impl LinkSession
impl LinkSession
Sourcepub fn desktop(
link_id: Vec<u8>,
relay_hint: String,
now_secs: u64,
) -> LR<Arc<Self>>
pub fn desktop( link_id: Vec<u8>, relay_hint: String, now_secs: u64, ) -> LR<Arc<Self>>
Desktop: new session with ephemeral keys. link_id is 16..32 bytes (issued by the server or
random), relay_hint is the relay address for the phone (part of the transcript),
now_secs is the desktop’s Unix time.
Sourcepub fn phone(qr_text: String, now_secs: u64) -> LR<Arc<Self>>
pub fn phone(qr_text: String, now_secs: u64) -> LR<Arc<Self>>
Phone: session from the QR text. Checks format, checksum and validity window (with clock tolerance).
pub fn role(&self) -> LinkRole
pub fn state(&self) -> LinkState
pub fn link_id(&self) -> Vec<u8> ⓘ
pub fn relay_hint(&self) -> String
pub fn issued_at(&self) -> u64
Sourcepub fn offer(&self) -> LR<LinkBlob>
pub fn offer(&self) -> LR<LinkBlob>
Desktop: OFFER blob (ML-KEM key). May be resent; it is always the same.
Sourcepub fn phone_accept(&self, offer: LinkBlob, now_secs: u64) -> LR<LinkBlob>
pub fn phone_accept(&self, offer: LinkBlob, now_secs: u64) -> LR<LinkBlob>
Phone: check OFFER against the QR, encapsulate, return ACCEPT.
Sourcepub fn desktop_accept(&self, accept: LinkBlob, now_secs: u64) -> LR<LinkBlob>
pub fn desktop_accept(&self, accept: LinkBlob, now_secs: u64) -> LR<LinkBlob>
Desktop: accept ACCEPT (no later than 60 s after the QR was shown), verify the phone’s confirmation, return CONFIRM. Any mismatch destroys the session.
Sourcepub fn phone_confirm(&self, confirm: LinkBlob, now_secs: u64) -> LR<()>
pub fn phone_confirm(&self, confirm: LinkBlob, now_secs: u64) -> LR<()>
Phone: verify the desktop’s CONFIRM.
Sourcepub fn confirm_sas(&self, now_secs: u64) -> LR<()>
pub fn confirm_sas(&self, now_secs: u64) -> LR<()>
The user saw matching codes and tapped “Link”.
Sourcepub fn seal(&self, kind: u8, plaintext: Vec<u8>) -> LR<LinkBlob>
pub fn seal(&self, kind: u8, plaintext: Vec<u8>) -> LR<LinkBlob>
Encrypt a blob of one’s own kind (see KIND_). The package goes only through package_.
Sourcepub fn open(&self, blob: LinkBlob) -> LR<Vec<u8>>
pub fn open(&self, blob: LinkBlob) -> LR<Vec<u8>>
Decrypt a peer blob (except package parts and the device request).
Sourcepub fn device_request(
&self,
device_seed: Vec<u8>,
device_type: u8,
label: String,
) -> LR<LinkBlob>
pub fn device_request( &self, device_seed: Vec<u8>, device_type: u8, label: String, ) -> LR<LinkBlob>
Desktop: “sign my keys” request: device public keys from device_seed and
proof of possession (Ed25519 + ML-DSA-65 signatures over the linking transcript).
Sourcepub fn open_device_request(&self, blob: LinkBlob) -> LR<DeviceRequest>
pub fn open_device_request(&self, blob: LinkBlob) -> LR<DeviceRequest>
Phone: open the desktop’s request and verify the proof of possession.
Sourcepub fn package_begin(&self, include_history: bool) -> LR<LinkBlob>
pub fn package_begin(&self, include_history: bool) -> LR<LinkBlob>
Phone: start a transfer package. include_history: the user chose “with history”.
Sourcepub fn package_add(
&self,
section: u8,
id: Vec<u8>,
body: Vec<u8>,
) -> LR<Vec<LinkBlob>>
pub fn package_add( &self, section: u8, id: Vec<u8>, body: Vec<u8>, ) -> LR<Vec<LinkBlob>>
Phone: add a record. Returns parts ready to send (may be empty).
Sourcepub fn package_finish(&self) -> LR<Vec<LinkBlob>>
pub fn package_finish(&self) -> LR<Vec<LinkBlob>>
Phone: finish the package: the last parts and END with the final checksum.
Sourcepub fn package_receive(&self, blob: LinkBlob) -> LR<PackageProgress>
pub fn package_receive(&self, blob: LinkBlob) -> LR<PackageProgress>
Desktop: accept HEADER/PART/END. Records are returned as they arrive; commit them to the database
only once done (the final checksum matched).
Sourcepub fn package_ack(&self) -> LR<LinkBlob>
pub fn package_ack(&self) -> LR<LinkBlob>
Desktop: “package received in full” acknowledgement (package checksum inside), after done.
Sourcepub fn package_check_ack(&self, blob: LinkBlob) -> LR<()>
pub fn package_check_ack(&self, blob: LinkBlob) -> LR<()>
Phone: verify the desktop’s acknowledgement: the package checksum must match the one sent.
Trait Implementations§
Source§impl Debug for LinkSession
No secrets: only the side and the state.
impl Debug for LinkSession
No secrets: only the side and the state.
Source§impl<UT> LiftRef<UT> for LinkSession
impl<UT> LiftRef<UT> for LinkSession
type LiftType = Arc<LinkSession>
Source§impl<UT> LowerError<UT> for LinkSession
impl<UT> LowerError<UT> for LinkSession
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for LinkSession
impl<UT> LowerReturn<UT> for LinkSession
Source§type ReturnType = <Arc<LinkSession> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<LinkSession> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Source§impl<UT> TypeId<UT> for LinkSession
impl<UT> TypeId<UT> for LinkSession
Auto Trait Implementations§
impl !Freeze for LinkSession
impl Forget for LinkSession
impl Move for LinkSession
impl RefUnwindSafe for LinkSession
impl Send for LinkSession
impl Sync for LinkSession
impl Unpin for LinkSession
impl UnsafeUnpin for LinkSession
impl UnwindSafe for LinkSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more