NAME

Protocol::HAP::Pairing - HAP pairing protocol implementation

SYNOPSIS

use Protocol::HAP::Pairing;

my $pairing = Protocol::HAP::Pairing->new(
    pin => '9876-5432',
    store => $store,
    accessory_ltsk => $ltsk,
    accessory_ltpk => $ltpk,
);

my $response = $pairing->handle_pair_setup($body, $session);
my $response = $pairing->handle_pair_verify($body, $session);

DESCRIPTION

This module implements the HAP pairing protocol. The protocol has the pair-setup (SRP) flow and the pair-verify (X25519) flow.

The store argument is required: any object that satisfies the contract of Protocol/HAP/Store.pod. The attempt counter of pair-setup needs persistence, so the limit of 100 failed attempts survives restarts; a silent in-memory fallback would fail open. The instance restores the counter from the store at construction and persists every change.

The pairing lock and the attempt counter are instance state. Two Pairing objects in one process never share a lock or a counter.

The constructor also takes an optional logger argument, defaulting to the null logger of Protocol::HAP.

SEE ALSO

Protocol::HAP, Protocol::HAP::SRP, Protocol::HAP::Crypto, Protocol/HAP/Store.pod, spec/HAP-Pairing.md