pub struct PairSetupClient { /* private fields */ }Expand description
Implementations§
Source§impl PairSetupClient
impl PairSetupClient
Sourcepub fn new(setup_code: &str, controller: ControllerKeypair) -> Result<Self>
pub fn new(setup_code: &str, controller: ControllerKeypair) -> Result<Self>
Create a Pair Setup client for setup_code, signing with controller.
setup_code is the accessory’s 8-digit setup code. It is accepted either
already hyphenated ("123-45-678") or as bare digits ("12345678"); the
digits are re-grouped into the canonical XXX-XX-XXX form HAP hashes as
the SRP password. Any other input is used verbatim (the accessory will
then reject the proof, which surfaces as a setup-code error in M4).
The SRP client ephemeral a is drawn from the OS CSPRNG; use
new_with_private for a
deterministic exchange in tests.
§Errors
Returns CryptoError::SrpBadParameters if the freshly generated SRP
public ephemeral A is zero mod N (vanishingly unlikely).
Sourcepub fn new_with_private(
setup_code: &str,
controller: ControllerKeypair,
a: &[u8],
) -> Result<Self>
pub fn new_with_private( setup_code: &str, controller: ControllerKeypair, a: &[u8], ) -> Result<Self>
Create a Pair Setup client with a caller-supplied SRP private ephemeral
a (the deterministic test seam).
Mirrors the crate-internal srp module’s with_private so a replay
harness can reproduce an exchange exactly. a is the big-endian bytes of
the SRP exponent.
§Errors
Returns CryptoError::SrpBadParameters if the resulting SRP public
ephemeral A is zero mod N.
Sourcepub fn start(&mut self) -> Vec<u8> ⓘ
pub fn start(&mut self) -> Vec<u8> ⓘ
Produce the M1 request that starts Pair Setup.
The body is State=1, Method=PairSetup. Calling start advances the
machine to await M2; calling it again re-emits M1 but does not reset any
state already established by Self::handle.
Sourcepub fn handle(&mut self, response: &[u8]) -> Result<PairSetupStep>
pub fn handle(&mut self, response: &[u8]) -> Result<PairSetupStep>
Consume an accessory response and advance the exchange.
Feed M2, then M4, then M6 in order; the return value is the next message
to send (PairSetupStep::Send) until the final
PairSetupStep::Done yields the AccessoryPairing.
§Errors
Returns a CryptoError if the response is malformed, omits a required
field, carries an accessory Error TLV, fails SRP proof verification,
fails AEAD authentication, or carries an accessory signature that does
not verify. The machine then refuses further input.