circuitmatter.session ===================== .. py:module:: circuitmatter.session Attributes ---------- .. autoapisummary:: circuitmatter.session.MSG_COUNTER_WINDOW_SIZE circuitmatter.session.MSG_COUNTER_SYNC_REQ_JITTER_MS circuitmatter.session.MSG_COUNTER_SYNC_TIMEOUT_MS Classes ------- .. autoapisummary:: circuitmatter.session.SessionParameterStruct circuitmatter.session.GeneralCode circuitmatter.session.SecureChannelProtocolCode circuitmatter.session.StatusReport circuitmatter.session.SessionContext circuitmatter.session.UnsecuredSessionContext circuitmatter.session.SecureSessionContext circuitmatter.session.MessageReceptionState circuitmatter.session.MessageCounter circuitmatter.session.SessionManager Module Contents --------------- .. py:data:: MSG_COUNTER_WINDOW_SIZE :value: 32 .. py:data:: MSG_COUNTER_SYNC_REQ_JITTER_MS :value: 500 .. py:data:: MSG_COUNTER_SYNC_TIMEOUT_MS :value: 400 .. py:class:: SessionParameterStruct Bases: :py:obj:`circuitmatter.tlv.Structure` .. py:attribute:: session_idle_interval .. py:attribute:: session_active_interval .. py:attribute:: session_active_threshold .. py:attribute:: data_model_revision .. py:attribute:: interaction_model_revision .. py:attribute:: specification_version .. py:attribute:: max_paths_per_invoke .. py:method:: __str__() .. py:method:: encode() -> memoryview .. py:method:: encode_into(buffer: bytearray, offset: int = 0) -> int .. py:method:: decode(buffer: memoryview, offset=0) -> Structure :classmethod: .. py:method:: decode_member(control_octet, buffer, offset=0, depth=0) -> tuple[dict, int] :classmethod: .. py:method:: construct_containers() .. py:method:: from_value(value) :classmethod: .. py:attribute:: values .. py:method:: max_length() :classmethod: .. py:method:: set_value(tag, value) .. py:method:: delete_value(tag) .. py:class:: GeneralCode Bases: :py:obj:`enum.IntEnum` Enum where members are also (and must be) ints .. py:attribute:: SUCCESS :value: 0 Operation completed successfully. .. py:attribute:: FAILURE :value: 1 Generic failure, additional details may be included in the protocol specific status. .. py:attribute:: BAD_PRECONDITION :value: 2 Operation was rejected by the system because the system is in an invalid state. .. py:attribute:: OUT_OF_RANGE :value: 3 A value was out of a required range .. py:attribute:: BAD_REQUEST :value: 4 A request was unrecognized or malformed .. py:attribute:: UNSUPPORTED :value: 5 An unrecognized or unsupported request was received .. py:attribute:: UNEXPECTED :value: 6 A request was not expected at this time .. py:attribute:: RESOURCE_EXHAUSTED :value: 7 Insufficient resources to process the given request .. py:attribute:: BUSY :value: 8 Device is busy and cannot handle this request at this time .. py:attribute:: TIMEOUT :value: 9 A timeout occurred .. py:attribute:: CONTINUE :value: 10 Context-specific signal to proceed .. py:attribute:: ABORTED :value: 11 Failure, may be due to a concurrency error. .. py:attribute:: INVALID_ARGUMENT :value: 12 An invalid/unsupported argument was provided .. py:attribute:: NOT_FOUND :value: 13 Some requested entity was not found .. py:attribute:: ALREADY_EXISTS :value: 14 The sender attempted to create something that already exists .. py:attribute:: PERMISSION_DENIED :value: 15 The sender does not have sufficient permissions to execute the requested operations. .. py:attribute:: DATA_LOSS :value: 16 Unrecoverable data loss or corruption has occurred. .. py:attribute:: MESSAGE_TOO_LARGE :value: 17 Message size is larger than the recipient can handle. .. py:class:: SecureChannelProtocolCode Bases: :py:obj:`enum.IntEnum` Enum where members are also (and must be) ints .. py:attribute:: SESSION_ESTABLISHMENT_SUCCESS :value: 0 Indication that the last session establishment message was successfully processed. .. py:attribute:: NO_SHARED_TRUST_ROOTS :value: 1 Failure to find a common set of shared roots. .. py:attribute:: INVALID_PARAMETER :value: 2 Generic failure during session establishment. .. py:attribute:: CLOSE_SESSION :value: 3 Indication that the sender will close the current session. .. py:attribute:: BUSY :value: 4 Indication that the sender cannot currently fulfill the request. .. py:class:: StatusReport .. py:attribute:: PROTOCOL_ID .. py:attribute:: PROTOCOL_OPCODE .. py:method:: clear() .. py:method:: __len__() .. py:method:: encode_into(buffer, offset=0) -> int .. py:method:: decode(buffer) .. py:method:: __str__() .. py:class:: SessionContext(socket) .. py:attribute:: socket .. py:attribute:: responder_exchanges .. py:attribute:: initiator_exchanges .. py:attribute:: active_timestamp :value: None A timestamp indicating the time at which the last message was received. This timestamp SHALL be initialized with the time the session was created. .. py:attribute:: session_idle_interval :value: 0.5 .. py:attribute:: session_active_interval :value: 0.3 .. py:attribute:: session_active_threshold :value: 4 .. py:property:: peer_active .. py:method:: receive(message) .. py:class:: UnsecuredSessionContext(socket, message_counter, initiator, ephemeral_initiator_node_id, node_ipaddress) Bases: :py:obj:`SessionContext` .. py:attribute:: initiator .. py:attribute:: ephemeral_initiator_node_id .. py:attribute:: message_reception_state :value: None .. py:attribute:: message_counter .. py:attribute:: local_node_id :value: 0 .. py:attribute:: node_ipaddress .. py:method:: send(message) .. py:attribute:: socket .. py:attribute:: responder_exchanges .. py:attribute:: initiator_exchanges .. py:attribute:: active_timestamp :value: None A timestamp indicating the time at which the last message was received. This timestamp SHALL be initialized with the time the session was created. .. py:attribute:: session_idle_interval :value: 0.5 .. py:attribute:: session_active_interval :value: 0.3 .. py:attribute:: session_active_threshold :value: 4 .. py:property:: peer_active .. py:method:: receive(message) .. py:class:: SecureSessionContext(random_source, socket, local_session_id) Bases: :py:obj:`SessionContext` .. py:attribute:: session_type :value: None Records whether the session was established using CASE or PASE. .. py:attribute:: session_role_initiator :value: False Records whether the node is the session initiator or responder. .. py:attribute:: local_session_id Individually selected by each participant in secure unicast communication during session establishment and used as a unique identifier to recover encryption keys, authenticate incoming messages and associate them to existing sessions. .. py:attribute:: peer_session_id :value: None Assigned by the peer during session establishment .. py:attribute:: i2r_key :value: None Encrypts data in messages sent from the initiator of session establishment to the responder. .. py:attribute:: r2i_key :value: None Encrypts data in messages sent from the session establishment responder to the initiator. .. py:attribute:: shared_secret :value: None Computed during the CASE protocol execution and re-used when CASE session resumption is implemented. .. py:attribute:: local_message_counter Secure Session Message Counter for outbound messages. .. py:attribute:: message_reception_state :value: None Provides tracking for the Secure Session Message Counter of the remote .. py:attribute:: local_fabric_index :value: None Records the local Index for the session’s Fabric, which MAY be used to look up Fabric metadata related to the Fabric for which this session context applies. .. py:attribute:: peer_node_id :value: 0 Records the authenticated node ID of the remote peer, when available. .. py:attribute:: resumption_id :value: None The ID used when resuming a session between the local and remote peer. .. py:attribute:: session_timestamp :value: None A timestamp indicating the time at which the last message was sent or received. This timestamp SHALL be initialized with the time the session was created. .. py:attribute:: subscriptions .. py:attribute:: local_node_id :value: 0 .. py:attribute:: socket .. py:attribute:: node_ipaddress :value: None .. py:method:: __str__() .. py:property:: next_exchange_id .. py:method:: decrypt_and_verify(message) .. py:method:: send(message) .. py:attribute:: responder_exchanges .. py:attribute:: initiator_exchanges .. py:attribute:: active_timestamp :value: None A timestamp indicating the time at which the last message was received. This timestamp SHALL be initialized with the time the session was created. .. py:attribute:: session_idle_interval :value: 0.5 .. py:attribute:: session_active_interval :value: 0.3 .. py:attribute:: session_active_threshold :value: 4 .. py:property:: peer_active .. py:method:: receive(message) .. py:class:: MessageReceptionState(starting_value, rollover=True, encrypted=False) .. py:attribute:: message_counter .. py:attribute:: window_bitmap .. py:attribute:: mask .. py:attribute:: encrypted .. py:attribute:: rollover .. py:method:: process_counter(counter) -> bool Returns True if the counter number is a duplicate .. py:class:: MessageCounter(starting_value=None, random_source=None) .. py:attribute:: value .. py:method:: __next__() .. py:class:: SessionManager(random_source, socket, node_credentials) .. py:attribute:: nonvolatile .. py:attribute:: unencrypted_message_counter .. py:attribute:: group_encrypted_data_message_counter .. py:attribute:: group_encrypted_control_message_counter .. py:attribute:: check_in_counter .. py:attribute:: unsecured_session_context .. py:attribute:: secure_session_contexts :value: ['reserved'] .. py:attribute:: socket .. py:attribute:: random .. py:attribute:: node_credentials .. py:method:: get_session(message) .. py:method:: send_packets() .. py:method:: mark_duplicate(message) Implements 4.6.7 .. py:method:: next_message_counter(message) Implements 4.6.6 .. py:method:: new_context() .. py:method:: process_exchange(message) .. py:method:: reply_to_sigma1(exchange, sigma1) .. py:method:: reply_to_sigma3(exchange, sigma3) -> SecureChannelProtocolCode