@matter/protocol 0.16.0-alpha.0-20250812-285b75d83 → 0.16.0-alpha.0-20250815-ac9fd6eb0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/advertisement/ble/BleAdvertisement.js +1 -1
- package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts +2 -2
- package/dist/cjs/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
- package/dist/cjs/ble/Ble.d.ts +2 -2
- package/dist/cjs/ble/Ble.d.ts.map +1 -1
- package/dist/cjs/ble/Ble.js.map +1 -1
- package/dist/cjs/ble/BtpSessionHandler.d.ts +6 -6
- package/dist/cjs/ble/BtpSessionHandler.d.ts.map +1 -1
- package/dist/cjs/ble/BtpSessionHandler.js +9 -9
- package/dist/cjs/ble/BtpSessionHandler.js.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts +5 -5
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.js +2 -2
- package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +5 -5
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js +6 -3
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/ChipPAAuthorities.d.ts +8 -8
- package/dist/cjs/certificate/DeviceCertification.d.ts +9 -9
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +2 -3
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +4 -4
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/cjs/certificate/kinds/Icac.d.ts +3 -3
- package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Icac.js +2 -2
- package/dist/cjs/certificate/kinds/Icac.js.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.d.ts +3 -3
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Noc.js +2 -2
- package/dist/cjs/certificate/kinds/Noc.js.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts +2 -1
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/OperationalBase.js +2 -2
- package/dist/cjs/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.d.ts +3 -3
- package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/Rcac.js +2 -2
- package/dist/cjs/certificate/kinds/Rcac.js.map +1 -1
- package/dist/cjs/certificate/kinds/X509Base.d.ts +11 -11
- package/dist/cjs/certificate/kinds/X509Base.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/X509Base.js +1 -1
- package/dist/cjs/certificate/kinds/X509Base.js.map +1 -1
- package/dist/cjs/certificate/kinds/common.d.ts +2 -2
- package/dist/cjs/certificate/kinds/common.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/common.js +2 -2
- package/dist/cjs/certificate/kinds/common.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.d.ts +7 -6
- package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts +1 -1
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts +21 -21
- package/dist/cjs/codec/BtpCodec.d.ts +12 -11
- package/dist/cjs/codec/BtpCodec.d.ts.map +1 -1
- package/dist/cjs/codec/BtpCodec.js +1 -1
- package/dist/cjs/codec/BtpCodec.js.map +1 -1
- package/dist/cjs/codec/MessageCodec.d.ts +8 -8
- package/dist/cjs/codec/MessageCodec.d.ts.map +1 -1
- package/dist/cjs/codec/MessageCodec.js +2 -2
- package/dist/cjs/codec/MessageCodec.js.map +1 -1
- package/dist/cjs/common/FailsafeContext.d.ts +8 -8
- package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/common/OperationalCredentialsTypes.d.ts +8 -8
- package/dist/cjs/fabric/Fabric.d.ts +27 -27
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +3 -6
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +2 -2
- package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricManager.js.map +1 -1
- package/dist/cjs/groups/FabricGroups.d.ts +4 -4
- package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
- package/dist/cjs/groups/Groups.d.ts +1 -1
- package/dist/cjs/groups/KeySets.d.ts +12 -12
- package/dist/cjs/groups/KeySets.d.ts.map +1 -1
- package/dist/cjs/groups/KeySets.js.map +1 -1
- package/dist/cjs/groups/MessagingState.d.ts +4 -4
- package/dist/cjs/groups/MessagingState.d.ts.map +1 -1
- package/dist/cjs/groups/MessagingState.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +3 -2
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.js +9 -9
- package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
- package/dist/cjs/mdns/MdnsClient.d.ts +2 -2
- package/dist/cjs/mdns/MdnsClient.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsClient.js.map +1 -1
- package/dist/cjs/mdns/MdnsSocket.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsSocket.js +5 -5
- package/dist/cjs/mdns/MdnsSocket.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -2
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/protocol/ChannelManager.d.ts +2 -2
- package/dist/cjs/protocol/ChannelManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ChannelManager.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +4 -3
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/MessageChannel.d.ts +3 -3
- package/dist/cjs/protocol/MessageChannel.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageChannel.js +2 -2
- package/dist/cjs/protocol/MessageChannel.js.map +1 -1
- package/dist/cjs/protocol/MessageExchange.d.ts +2 -2
- package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageExchange.js.map +1 -1
- package/dist/cjs/protocol/ProtocolStatusMessage.d.ts +6 -5
- package/dist/cjs/protocol/ProtocolStatusMessage.d.ts.map +1 -1
- package/dist/cjs/protocol/ProtocolStatusMessage.js +1 -1
- package/dist/cjs/protocol/ProtocolStatusMessage.js.map +1 -1
- package/dist/cjs/securechannel/SecureChannelMessenger.d.ts +1 -1
- package/dist/cjs/session/GroupSession.d.ts +5 -4
- package/dist/cjs/session/GroupSession.d.ts.map +1 -1
- package/dist/cjs/session/GroupSession.js.map +1 -1
- package/dist/cjs/session/InsecureSession.d.ts +1 -1
- package/dist/cjs/session/InsecureSession.d.ts.map +1 -1
- package/dist/cjs/session/InsecureSession.js.map +1 -1
- package/dist/cjs/session/NodeSession.d.ts +8 -8
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +7 -5
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/Session.d.ts +4 -4
- package/dist/cjs/session/Session.d.ts.map +1 -1
- package/dist/cjs/session/Session.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +8 -8
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +1 -2
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/cjs/session/case/CaseMessages.d.ts +30 -30
- package/dist/cjs/session/case/CaseMessages.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseMessenger.d.ts +18 -18
- package/dist/cjs/session/pase/PaseClient.d.ts +1 -1
- package/dist/cjs/session/pase/PaseMessages.d.ts +8 -8
- package/dist/cjs/session/pase/PaseMessenger.d.ts +16 -16
- package/dist/cjs/session/pase/PaseMessenger.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseServer.d.ts +3 -3
- package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseServer.js +3 -2
- package/dist/cjs/session/pase/PaseServer.js.map +1 -1
- package/dist/esm/advertisement/ble/BleAdvertisement.js +1 -1
- package/dist/esm/advertisement/ble/BleAdvertiser.d.ts +2 -2
- package/dist/esm/advertisement/ble/BleAdvertiser.d.ts.map +1 -1
- package/dist/esm/ble/Ble.d.ts +2 -2
- package/dist/esm/ble/Ble.d.ts.map +1 -1
- package/dist/esm/ble/Ble.js.map +1 -1
- package/dist/esm/ble/BtpSessionHandler.d.ts +6 -6
- package/dist/esm/ble/BtpSessionHandler.d.ts.map +1 -1
- package/dist/esm/ble/BtpSessionHandler.js +9 -9
- package/dist/esm/ble/BtpSessionHandler.js.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.d.ts +5 -5
- package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.js +2 -2
- package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +5 -5
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js +6 -3
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/ChipPAAuthorities.d.ts +8 -8
- package/dist/esm/certificate/DeviceCertification.d.ts +9 -9
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +3 -4
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.js.map +1 -1
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +4 -4
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +1 -1
- package/dist/esm/certificate/kinds/Icac.d.ts +3 -3
- package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Icac.js +2 -2
- package/dist/esm/certificate/kinds/Icac.js.map +1 -1
- package/dist/esm/certificate/kinds/Noc.d.ts +3 -3
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Noc.js +2 -2
- package/dist/esm/certificate/kinds/Noc.js.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.d.ts +2 -1
- package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/OperationalBase.js +2 -2
- package/dist/esm/certificate/kinds/OperationalBase.js.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.d.ts +3 -3
- package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/Rcac.js +2 -2
- package/dist/esm/certificate/kinds/Rcac.js.map +1 -1
- package/dist/esm/certificate/kinds/X509Base.d.ts +11 -11
- package/dist/esm/certificate/kinds/X509Base.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/X509Base.js +1 -1
- package/dist/esm/certificate/kinds/X509Base.js.map +1 -1
- package/dist/esm/certificate/kinds/common.d.ts +2 -2
- package/dist/esm/certificate/kinds/common.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/common.js +2 -2
- package/dist/esm/certificate/kinds/common.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.d.ts +7 -6
- package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -1
- package/dist/esm/certificate/kinds/definitions/base.js.map +1 -1
- package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts +1 -1
- package/dist/esm/certificate/kinds/definitions/operational.d.ts +21 -21
- package/dist/esm/codec/BtpCodec.d.ts +12 -11
- package/dist/esm/codec/BtpCodec.d.ts.map +1 -1
- package/dist/esm/codec/BtpCodec.js +1 -1
- package/dist/esm/codec/BtpCodec.js.map +1 -1
- package/dist/esm/codec/MessageCodec.d.ts +8 -8
- package/dist/esm/codec/MessageCodec.d.ts.map +1 -1
- package/dist/esm/codec/MessageCodec.js +2 -2
- package/dist/esm/codec/MessageCodec.js.map +1 -1
- package/dist/esm/common/FailsafeContext.d.ts +8 -8
- package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/common/OperationalCredentialsTypes.d.ts +8 -8
- package/dist/esm/fabric/Fabric.d.ts +27 -27
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +3 -6
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +2 -2
- package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
- package/dist/esm/fabric/FabricManager.js.map +1 -1
- package/dist/esm/groups/FabricGroups.d.ts +4 -4
- package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
- package/dist/esm/groups/Groups.d.ts +1 -1
- package/dist/esm/groups/KeySets.d.ts +12 -12
- package/dist/esm/groups/KeySets.d.ts.map +1 -1
- package/dist/esm/groups/KeySets.js.map +1 -1
- package/dist/esm/groups/MessagingState.d.ts +4 -4
- package/dist/esm/groups/MessagingState.d.ts.map +1 -1
- package/dist/esm/groups/MessagingState.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +3 -2
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.js +9 -9
- package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
- package/dist/esm/mdns/MdnsClient.d.ts +2 -2
- package/dist/esm/mdns/MdnsClient.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsClient.js.map +1 -1
- package/dist/esm/mdns/MdnsSocket.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsSocket.js +5 -5
- package/dist/esm/mdns/MdnsSocket.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +2 -2
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/protocol/ChannelManager.d.ts +2 -2
- package/dist/esm/protocol/ChannelManager.d.ts.map +1 -1
- package/dist/esm/protocol/ChannelManager.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +5 -3
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/MessageChannel.d.ts +3 -3
- package/dist/esm/protocol/MessageChannel.d.ts.map +1 -1
- package/dist/esm/protocol/MessageChannel.js +2 -2
- package/dist/esm/protocol/MessageChannel.js.map +1 -1
- package/dist/esm/protocol/MessageExchange.d.ts +2 -2
- package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
- package/dist/esm/protocol/MessageExchange.js.map +1 -1
- package/dist/esm/protocol/ProtocolStatusMessage.d.ts +6 -5
- package/dist/esm/protocol/ProtocolStatusMessage.d.ts.map +1 -1
- package/dist/esm/protocol/ProtocolStatusMessage.js +1 -1
- package/dist/esm/protocol/ProtocolStatusMessage.js.map +1 -1
- package/dist/esm/securechannel/SecureChannelMessenger.d.ts +1 -1
- package/dist/esm/session/GroupSession.d.ts +5 -4
- package/dist/esm/session/GroupSession.d.ts.map +1 -1
- package/dist/esm/session/GroupSession.js.map +1 -1
- package/dist/esm/session/InsecureSession.d.ts +1 -1
- package/dist/esm/session/InsecureSession.d.ts.map +1 -1
- package/dist/esm/session/InsecureSession.js.map +1 -1
- package/dist/esm/session/NodeSession.d.ts +8 -8
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +7 -5
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/Session.d.ts +4 -4
- package/dist/esm/session/Session.d.ts.map +1 -1
- package/dist/esm/session/Session.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +8 -8
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +1 -2
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/dist/esm/session/case/CaseMessages.d.ts +30 -30
- package/dist/esm/session/case/CaseMessages.d.ts.map +1 -1
- package/dist/esm/session/case/CaseMessenger.d.ts +18 -18
- package/dist/esm/session/pase/PaseClient.d.ts +1 -1
- package/dist/esm/session/pase/PaseMessages.d.ts +8 -8
- package/dist/esm/session/pase/PaseMessenger.d.ts +16 -16
- package/dist/esm/session/pase/PaseMessenger.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseServer.d.ts +3 -3
- package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseServer.js +3 -2
- package/dist/esm/session/pase/PaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/advertisement/ble/BleAdvertisement.ts +1 -1
- package/src/advertisement/ble/BleAdvertiser.ts +1 -1
- package/src/ble/Ble.ts +2 -2
- package/src/ble/BtpSessionHandler.ts +20 -20
- package/src/certificate/AttestationCertificateManager.ts +5 -5
- package/src/certificate/CertificateAuthority.ts +14 -11
- package/src/certificate/DeviceCertification.ts +11 -13
- package/src/certificate/kinds/AttestationCertificates.ts +1 -1
- package/src/certificate/kinds/CertificationDeclaration.ts +3 -6
- package/src/certificate/kinds/Icac.ts +3 -3
- package/src/certificate/kinds/Noc.ts +3 -3
- package/src/certificate/kinds/OperationalBase.ts +4 -4
- package/src/certificate/kinds/Rcac.ts +3 -3
- package/src/certificate/kinds/X509Base.ts +7 -7
- package/src/certificate/kinds/common.ts +4 -4
- package/src/certificate/kinds/definitions/base.ts +7 -6
- package/src/codec/BtpCodec.ts +13 -13
- package/src/codec/MessageCodec.ts +10 -10
- package/src/common/FailsafeContext.ts +6 -5
- package/src/fabric/Fabric.ts +31 -34
- package/src/fabric/FabricManager.ts +1 -1
- package/src/groups/KeySets.ts +6 -6
- package/src/groups/MessagingState.ts +3 -3
- package/src/interaction/InteractionMessenger.ts +12 -11
- package/src/mdns/MdnsClient.ts +2 -2
- package/src/mdns/MdnsSocket.ts +7 -6
- package/src/peer/ControllerCommissioner.ts +2 -1
- package/src/peer/ControllerCommissioningFlow.ts +5 -5
- package/src/protocol/ChannelManager.ts +3 -3
- package/src/protocol/ExchangeManager.ts +7 -5
- package/src/protocol/MessageChannel.ts +4 -4
- package/src/protocol/MessageExchange.ts +2 -1
- package/src/protocol/ProtocolStatusMessage.ts +6 -6
- package/src/session/GroupSession.ts +7 -7
- package/src/session/InsecureSession.ts +1 -1
- package/src/session/NodeSession.ts +17 -15
- package/src/session/Session.ts +3 -3
- package/src/session/SessionManager.ts +9 -10
- package/src/session/case/CaseServer.ts +8 -8
- package/src/session/pase/PaseServer.ts +5 -4
|
@@ -26,7 +26,7 @@ const logger = Logger.get("BtpSessionHandler");
|
|
|
26
26
|
|
|
27
27
|
export class BtpSessionHandler {
|
|
28
28
|
private currentIncomingSegmentedMsgLength: number | undefined;
|
|
29
|
-
private currentIncomingSegmentedPayload:
|
|
29
|
+
private currentIncomingSegmentedPayload: Bytes | undefined;
|
|
30
30
|
private prevIncomingSequenceNumber = 255; // Incoming Sequence Number received. Set to 255 to start at 0
|
|
31
31
|
private prevIncomingAckNumber = -1; // Previous ackNumber received
|
|
32
32
|
private readonly ackReceiveTimer = Time.getTimer("BTP ack timeout", BTP_ACK_TIMEOUT_MS, () =>
|
|
@@ -49,10 +49,10 @@ export class BtpSessionHandler {
|
|
|
49
49
|
/** Factory method to create a new BTPSessionHandler from a received handshake request */
|
|
50
50
|
static async createFromHandshakeRequest(
|
|
51
51
|
maxDataSize: number | undefined,
|
|
52
|
-
handshakeRequestPayload:
|
|
53
|
-
writeBleCallback: (data:
|
|
52
|
+
handshakeRequestPayload: Bytes,
|
|
53
|
+
writeBleCallback: (data: Bytes) => Promise<void>,
|
|
54
54
|
disconnectBleCallback: () => Promise<void>,
|
|
55
|
-
handleMatterMessagePayload: (data:
|
|
55
|
+
handleMatterMessagePayload: (data: Bytes) => Promise<void>,
|
|
56
56
|
): Promise<BtpSessionHandler> {
|
|
57
57
|
// Decode handshake request
|
|
58
58
|
const handshakeRequest = BtpCodec.decodeBtpHandshakeRequest(handshakeRequestPayload);
|
|
@@ -117,10 +117,10 @@ export class BtpSessionHandler {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
static async createAsCentral(
|
|
120
|
-
handshakeResponsePayload:
|
|
121
|
-
writeBleCallback: (data:
|
|
120
|
+
handshakeResponsePayload: Bytes,
|
|
121
|
+
writeBleCallback: (data: Bytes) => Promise<void>,
|
|
122
122
|
disconnectBleCallback: () => Promise<void>,
|
|
123
|
-
handleMatterMessagePayload: (data:
|
|
123
|
+
handleMatterMessagePayload: (data: Bytes) => Promise<void>,
|
|
124
124
|
) {
|
|
125
125
|
const handshakeRequest = BtpCodec.decodeBtpHandshakeResponsePayload(handshakeResponsePayload);
|
|
126
126
|
|
|
@@ -156,9 +156,9 @@ export class BtpSessionHandler {
|
|
|
156
156
|
btpVersion: number,
|
|
157
157
|
private readonly fragmentSize: number,
|
|
158
158
|
private readonly clientWindowSize: number,
|
|
159
|
-
private readonly writeBleCallback: (data:
|
|
159
|
+
private readonly writeBleCallback: (data: Bytes) => Promise<void>,
|
|
160
160
|
private readonly disconnectBleCallback: () => Promise<void>,
|
|
161
|
-
private readonly handleMatterMessagePayload: (data:
|
|
161
|
+
private readonly handleMatterMessagePayload: (data: Bytes) => Promise<void>,
|
|
162
162
|
) {
|
|
163
163
|
if (btpVersion !== 4) {
|
|
164
164
|
throw new BtpProtocolError(`Unsupported BTP version ${btpVersion}`);
|
|
@@ -179,21 +179,21 @@ export class BtpSessionHandler {
|
|
|
179
179
|
*
|
|
180
180
|
* @param data ByteArray containing the data
|
|
181
181
|
*/
|
|
182
|
-
public async handleIncomingBleData(data:
|
|
182
|
+
public async handleIncomingBleData(data: Bytes) {
|
|
183
183
|
if (!this.isActive) {
|
|
184
184
|
logger.debug(`BTP session is not active, ignoring incoming BLE data`);
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
try {
|
|
188
|
-
if (data.
|
|
188
|
+
if (data.byteLength > this.fragmentSize) {
|
|
189
189
|
// Apple seems to interpret the ATT_MTU as the maximum size of a single ATT packet
|
|
190
|
-
if (data.
|
|
190
|
+
if (data.byteLength > this.fragmentSize + 3) {
|
|
191
191
|
throw new BtpProtocolError(
|
|
192
|
-
`Received data ${data.
|
|
192
|
+
`Received data ${data.byteLength} bytes exceeds fragment size of ${this.fragmentSize} bytes`,
|
|
193
193
|
);
|
|
194
194
|
} else {
|
|
195
195
|
logger.warn(
|
|
196
|
-
`Received data ${data.
|
|
196
|
+
`Received data ${data.byteLength} bytes exceeds fragment size of ${this.fragmentSize} bytes, still accepting`,
|
|
197
197
|
);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
@@ -214,7 +214,7 @@ export class BtpSessionHandler {
|
|
|
214
214
|
if (isHandshakeRequest || hasManagementOpcode) {
|
|
215
215
|
throw new BtpProtocolError("BTP packet must not be a handshake request or have a management opcode.");
|
|
216
216
|
}
|
|
217
|
-
if (segmentPayload.
|
|
217
|
+
if (segmentPayload.byteLength === 0 && !hasAckNumber) {
|
|
218
218
|
throw new BtpProtocolError("BTP packet must have a segment payload or an ack number.");
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -261,7 +261,7 @@ export class BtpSessionHandler {
|
|
|
261
261
|
if (this.currentIncomingSegmentedPayload === undefined) {
|
|
262
262
|
throw new BtpProtocolError(`BTP Continuing or ending packet received without beginning packet.`);
|
|
263
263
|
}
|
|
264
|
-
if (segmentPayload.
|
|
264
|
+
if (segmentPayload.byteLength === 0) {
|
|
265
265
|
throw new BtpProtocolError(`BTP Continuing or ending packet received without payload.`);
|
|
266
266
|
}
|
|
267
267
|
this.currentIncomingSegmentedPayload = Bytes.concat(
|
|
@@ -277,9 +277,9 @@ export class BtpSessionHandler {
|
|
|
277
277
|
) {
|
|
278
278
|
throw new BtpProtocolError("BTP beginning packet missing but ending packet received.");
|
|
279
279
|
}
|
|
280
|
-
if (this.currentIncomingSegmentedPayload.
|
|
280
|
+
if (this.currentIncomingSegmentedPayload.byteLength !== this.currentIncomingSegmentedMsgLength) {
|
|
281
281
|
throw new BtpProtocolError(
|
|
282
|
-
`BTP packet payload length does not match message length: ${this.currentIncomingSegmentedPayload.
|
|
282
|
+
`BTP packet payload length does not match message length: ${this.currentIncomingSegmentedPayload.byteLength} !== ${this.currentIncomingSegmentedMsgLength}`,
|
|
283
283
|
);
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -306,13 +306,13 @@ export class BtpSessionHandler {
|
|
|
306
306
|
*
|
|
307
307
|
* @param data ByteArray containing the Matter message
|
|
308
308
|
*/
|
|
309
|
-
public async sendMatterMessage(data:
|
|
309
|
+
public async sendMatterMessage(data: Bytes) {
|
|
310
310
|
if (!this.isActive) {
|
|
311
311
|
throw new BtpFlowError("BTP session is not active");
|
|
312
312
|
}
|
|
313
313
|
logger.debug(`Got Matter message to send via BLE transport: ${Bytes.toHex(data)}`);
|
|
314
314
|
|
|
315
|
-
if (data.
|
|
315
|
+
if (data.byteLength === 0) {
|
|
316
316
|
throw new BtpFlowError("BTP packet must not be empty");
|
|
317
317
|
}
|
|
318
318
|
const dataReader = new DataReader(data, Endian.Little);
|
|
@@ -40,13 +40,13 @@ export class AttestationCertificateManager {
|
|
|
40
40
|
readonly #crypto: Crypto;
|
|
41
41
|
readonly #vendorId: VendorId;
|
|
42
42
|
readonly #paiKeyPair: PrivateKey;
|
|
43
|
-
readonly #paiKeyIdentifier:
|
|
43
|
+
readonly #paiKeyIdentifier: Bytes;
|
|
44
44
|
readonly #paaKeyIdentifier = TestCert_PAA_NoVID_SKID;
|
|
45
45
|
readonly #paiCertId = BigInt(1);
|
|
46
46
|
readonly #paiCertBytes;
|
|
47
47
|
#nextCertificateId = 2;
|
|
48
48
|
|
|
49
|
-
constructor(crypto: Crypto, vendorId: VendorId, paiKeyPair: PrivateKey, paiKeyIdentifier:
|
|
49
|
+
constructor(crypto: Crypto, vendorId: VendorId, paiKeyPair: PrivateKey, paiKeyIdentifier: Bytes) {
|
|
50
50
|
this.#crypto = crypto;
|
|
51
51
|
this.#vendorId = vendorId;
|
|
52
52
|
this.#paiKeyPair = paiKeyPair;
|
|
@@ -56,7 +56,7 @@ export class AttestationCertificateManager {
|
|
|
56
56
|
|
|
57
57
|
static async create(crypto: Crypto, vendorId: VendorId) {
|
|
58
58
|
const key = await crypto.createKeyPair();
|
|
59
|
-
const identifier = await crypto.computeSha256(key.publicKey);
|
|
59
|
+
const identifier = Bytes.of(await crypto.computeSha256(key.publicKey));
|
|
60
60
|
return new AttestationCertificateManager(crypto, vendorId, key, identifier.slice(0, 20));
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -145,7 +145,7 @@ export class AttestationCertificateManager {
|
|
|
145
145
|
return cert.asSignedAsn1();
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
async generateDaCert(publicKey:
|
|
148
|
+
async generateDaCert(publicKey: Bytes, vendorId: VendorId, productId: number) {
|
|
149
149
|
const now = Time.get().now();
|
|
150
150
|
const certId = this.#nextCertificateId++;
|
|
151
151
|
const cert = new Dac({
|
|
@@ -172,7 +172,7 @@ export class AttestationCertificateManager {
|
|
|
172
172
|
keyUsage: {
|
|
173
173
|
digitalSignature: true,
|
|
174
174
|
},
|
|
175
|
-
subjectKeyIdentifier: (await this.#crypto.computeSha256(publicKey)).slice(0, 20),
|
|
175
|
+
subjectKeyIdentifier: Bytes.of(await this.#crypto.computeSha256(publicKey)).slice(0, 20),
|
|
176
176
|
authorityKeyIdentifier: this.#paiKeyIdentifier,
|
|
177
177
|
},
|
|
178
178
|
});
|
|
@@ -35,8 +35,8 @@ export class CertificateAuthority {
|
|
|
35
35
|
#crypto: Crypto;
|
|
36
36
|
#rootCertId = BigInt(0);
|
|
37
37
|
#rootKeyPair?: PrivateKey;
|
|
38
|
-
#rootKeyIdentifier?:
|
|
39
|
-
#rootCertBytes?:
|
|
38
|
+
#rootKeyIdentifier?: Bytes;
|
|
39
|
+
#rootCertBytes?: Bytes;
|
|
40
40
|
#nextCertificateId = BigInt(1);
|
|
41
41
|
#construction: Construction<CertificateAuthority>;
|
|
42
42
|
|
|
@@ -59,14 +59,17 @@ export class CertificateAuthority {
|
|
|
59
59
|
const certValues = options instanceof StorageContext ? await options.values() : (options ?? {});
|
|
60
60
|
|
|
61
61
|
this.#rootKeyPair = await this.#crypto.createKeyPair();
|
|
62
|
-
this.#rootKeyIdentifier = (await this.#crypto.computeSha256(this.#rootKeyPair.publicKey)).slice(
|
|
62
|
+
this.#rootKeyIdentifier = Bytes.of(await this.#crypto.computeSha256(this.#rootKeyPair.publicKey)).slice(
|
|
63
|
+
0,
|
|
64
|
+
20,
|
|
65
|
+
);
|
|
63
66
|
this.#rootCertBytes = await this.#generateRootCert();
|
|
64
67
|
|
|
65
68
|
if (
|
|
66
69
|
(typeof certValues.rootCertId === "number" || typeof certValues.rootCertId === "bigint") &&
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
(Bytes.isBytes(certValues.rootKeyPair) || typeof certValues.rootKeyPair === "object") &&
|
|
71
|
+
Bytes.isBytes(certValues.rootKeyIdentifier) &&
|
|
72
|
+
Bytes.isBytes(certValues.rootCertBytes) &&
|
|
70
73
|
(typeof certValues.nextCertificateId === "number" || typeof certValues.nextCertificateId === "bigint")
|
|
71
74
|
) {
|
|
72
75
|
this.#rootCertId = BigInt(certValues.rootCertId);
|
|
@@ -99,7 +102,7 @@ export class CertificateAuthority {
|
|
|
99
102
|
return instance;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
get rootCert() {
|
|
105
|
+
get rootCert(): Bytes {
|
|
103
106
|
return this.#construction.assert("root cert", this.#rootCertBytes);
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -140,7 +143,7 @@ export class CertificateAuthority {
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
async generateNoc(
|
|
143
|
-
publicKey:
|
|
146
|
+
publicKey: Bytes,
|
|
144
147
|
fabricId: FabricId,
|
|
145
148
|
nodeId: NodeId,
|
|
146
149
|
caseAuthenticatedTags?: CaseAuthenticatedTag[],
|
|
@@ -163,7 +166,7 @@ export class CertificateAuthority {
|
|
|
163
166
|
digitalSignature: true,
|
|
164
167
|
},
|
|
165
168
|
extendedKeyUsage: [2, 1],
|
|
166
|
-
subjectKeyIdentifier: (await this.#crypto.computeSha256(publicKey)).slice(0, 20),
|
|
169
|
+
subjectKeyIdentifier: Bytes.of(await this.#crypto.computeSha256(publicKey)).slice(0, 20),
|
|
167
170
|
authorityKeyIdentifier: this.#initializedRootKeyIdentifier,
|
|
168
171
|
},
|
|
169
172
|
});
|
|
@@ -190,8 +193,8 @@ export namespace CertificateAuthority {
|
|
|
190
193
|
export type Configuration = {
|
|
191
194
|
rootCertId: bigint;
|
|
192
195
|
rootKeyPair: BinaryKeyPair;
|
|
193
|
-
rootKeyIdentifier:
|
|
194
|
-
rootCertBytes:
|
|
196
|
+
rootKeyIdentifier: Bytes;
|
|
197
|
+
rootCertBytes: Bytes;
|
|
195
198
|
nextCertificateId: bigint;
|
|
196
199
|
};
|
|
197
200
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { CertificationDeclaration } from "#certificate/kinds/CertificationDeclaration.js";
|
|
8
|
-
import { Construction, Crypto, ImplementationError, InternalError, PrivateKey } from "#general";
|
|
8
|
+
import { Bytes, Construction, Crypto, ImplementationError, InternalError, PrivateKey } from "#general";
|
|
9
9
|
import { NodeSession } from "#session/NodeSession.js";
|
|
10
10
|
import { ProductDescription } from "#types";
|
|
11
11
|
import { AttestationCertificateManager } from "./AttestationCertificateManager.js";
|
|
@@ -16,9 +16,9 @@ import { AttestationCertificateManager } from "./AttestationCertificateManager.j
|
|
|
16
16
|
export class DeviceCertification {
|
|
17
17
|
#crypto: Crypto;
|
|
18
18
|
#privateKey?: PrivateKey;
|
|
19
|
-
#certificate?:
|
|
20
|
-
#intermediateCertificate?:
|
|
21
|
-
#declaration?:
|
|
19
|
+
#certificate?: Bytes;
|
|
20
|
+
#intermediateCertificate?: Bytes;
|
|
21
|
+
#declaration?: Bytes;
|
|
22
22
|
readonly #construction: Construction<DeviceCertification>;
|
|
23
23
|
|
|
24
24
|
get construction() {
|
|
@@ -65,18 +65,16 @@ export class DeviceCertification {
|
|
|
65
65
|
this.#construction = Construction(this, async () => {
|
|
66
66
|
const config = await configProvider();
|
|
67
67
|
|
|
68
|
-
this.#privateKey =
|
|
69
|
-
config.privateKey instanceof Uint8Array ? PrivateKey(config.privateKey) : config.privateKey;
|
|
68
|
+
this.#privateKey = Bytes.isBytes(config.privateKey) ? PrivateKey(config.privateKey) : config.privateKey;
|
|
70
69
|
this.#certificate = config.certificate;
|
|
71
70
|
this.#intermediateCertificate = config.intermediateCertificate;
|
|
72
71
|
this.#declaration = config.declaration;
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
async sign(session: NodeSession, data:
|
|
75
|
+
async sign(session: NodeSession, data: Bytes) {
|
|
77
76
|
const { privateKey } = this.#assertInitialized();
|
|
78
|
-
|
|
79
|
-
return signature;
|
|
77
|
+
return this.#crypto.signEcdsa(privateKey, [data, session.attestationChallengeKey]);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
/**
|
|
@@ -106,10 +104,10 @@ export class DeviceCertification {
|
|
|
106
104
|
|
|
107
105
|
export namespace DeviceCertification {
|
|
108
106
|
export interface Configuration {
|
|
109
|
-
privateKey: PrivateKey |
|
|
110
|
-
certificate:
|
|
111
|
-
intermediateCertificate:
|
|
112
|
-
declaration:
|
|
107
|
+
privateKey: PrivateKey | Bytes;
|
|
108
|
+
certificate: Bytes;
|
|
109
|
+
intermediateCertificate: Bytes;
|
|
110
|
+
declaration: Bytes;
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
export type Definition = Configuration | (() => Promise<Configuration>);
|
|
@@ -26,7 +26,7 @@ export abstract class AttestationBaseCertificate<CT extends X509Certificate> ext
|
|
|
26
26
|
* Returns the signed certificate in ASN.1 DER format.
|
|
27
27
|
* If the certificate is not signed, it throws a CertificateError.
|
|
28
28
|
*/
|
|
29
|
-
asSignedAsn1()
|
|
29
|
+
asSignedAsn1() {
|
|
30
30
|
const certificate = this.genericBuildAsn1Structure(this.cert);
|
|
31
31
|
const certBytes = DerCodec.encode({
|
|
32
32
|
certificate,
|
|
@@ -32,8 +32,8 @@ const TestCMS_SignerSubjectKeyIdentifier = Bytes.fromHex("62FA823359ACFAA9963E1C
|
|
|
32
32
|
|
|
33
33
|
/** A Matter Certification Declaration */
|
|
34
34
|
export class CertificationDeclaration {
|
|
35
|
-
#eContent:
|
|
36
|
-
#subjectKeyIdentifier:
|
|
35
|
+
#eContent: Bytes;
|
|
36
|
+
#subjectKeyIdentifier: Bytes;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Generator which is the main usage for the class from outside.
|
|
@@ -58,10 +58,7 @@ export class CertificationDeclaration {
|
|
|
58
58
|
return cd.asSignedAsn1(crypto, PrivateKey(TestCMS_SignerPrivateKey));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
constructor(
|
|
62
|
-
content: TypeFromBitmapSchema<typeof CertificationDeclarationDef.TlvDc>,
|
|
63
|
-
subjectKeyIdentifier: Uint8Array,
|
|
64
|
-
) {
|
|
61
|
+
constructor(content: TypeFromBitmapSchema<typeof CertificationDeclarationDef.TlvDc>, subjectKeyIdentifier: Bytes) {
|
|
65
62
|
this.#eContent = CertificationDeclarationDef.TlvDc.encode(content);
|
|
66
63
|
this.#subjectKeyIdentifier = subjectKeyIdentifier;
|
|
67
64
|
}
|
|
@@ -17,7 +17,7 @@ import { Rcac } from "./Rcac.js";
|
|
|
17
17
|
*/
|
|
18
18
|
export class Icac extends OperationalBase<OperationalCertificate.Icac> {
|
|
19
19
|
/** Construct the class from a Tlv version of the certificate */
|
|
20
|
-
static fromTlv(tlv:
|
|
20
|
+
static fromTlv(tlv: Bytes): Icac {
|
|
21
21
|
return new Icac(OperationalCertificate.TlvIcac.decode(tlv));
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -132,7 +132,7 @@ export class Icac extends OperationalBase<OperationalCertificate.Icac> {
|
|
|
132
132
|
if (subjectKeyIdentifier === undefined) {
|
|
133
133
|
throw new CertificateError(`Ica certificate must have subjectKeyIdentifier set.`);
|
|
134
134
|
}
|
|
135
|
-
if (subjectKeyIdentifier.
|
|
135
|
+
if (subjectKeyIdentifier.byteLength !== 20) {
|
|
136
136
|
throw new CertificateError(`Ica certificate subjectKeyIdentifier must be 160 bit.`);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -140,7 +140,7 @@ export class Icac extends OperationalBase<OperationalCertificate.Icac> {
|
|
|
140
140
|
if (authorityKeyIdentifier === undefined) {
|
|
141
141
|
throw new CertificateError(`Ica certificate must have authorityKeyIdentifier set.`);
|
|
142
142
|
}
|
|
143
|
-
if (authorityKeyIdentifier.
|
|
143
|
+
if (authorityKeyIdentifier.byteLength !== 20) {
|
|
144
144
|
throw new CertificateError(`Ica certificate authorityKeyIdentifier must be 160 bit.`);
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -14,7 +14,7 @@ import { Rcac } from "./Rcac.js";
|
|
|
14
14
|
|
|
15
15
|
export class Noc extends OperationalBase<OperationalCertificate.Noc> {
|
|
16
16
|
/** Construct the class from a Tlv version of the certificate */
|
|
17
|
-
static fromTlv(tlv:
|
|
17
|
+
static fromTlv(tlv: Bytes) {
|
|
18
18
|
return new Noc(OperationalCertificate.TlvNoc.decode(tlv));
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -136,7 +136,7 @@ export class Noc extends OperationalBase<OperationalCertificate.Noc> {
|
|
|
136
136
|
if (subjectKeyIdentifier === undefined) {
|
|
137
137
|
throw new CertificateError(`Noc certificate must have subjectKeyIdentifier set.`);
|
|
138
138
|
}
|
|
139
|
-
if (subjectKeyIdentifier.
|
|
139
|
+
if (subjectKeyIdentifier.byteLength !== 20) {
|
|
140
140
|
throw new CertificateError(`Noc certificate subjectKeyIdentifier must be 160 bit.`);
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -144,7 +144,7 @@ export class Noc extends OperationalBase<OperationalCertificate.Noc> {
|
|
|
144
144
|
if (authorityKeyIdentifier === undefined) {
|
|
145
145
|
throw new CertificateError(`Noc certificate must have authorityKeyIdentifier set.`);
|
|
146
146
|
}
|
|
147
|
-
if (authorityKeyIdentifier.
|
|
147
|
+
if (authorityKeyIdentifier.byteLength !== 20) {
|
|
148
148
|
throw new CertificateError(`Noc certificate authorityKeyIdentifier must be 160 bit.`);
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Logger, Time } from "#general";
|
|
7
|
+
import { Bytes, Logger, Time } from "#general";
|
|
8
8
|
import { X509Base } from "./X509Base.js";
|
|
9
9
|
import { CertificateError, Unsigned } from "./common.js";
|
|
10
10
|
import { X509Certificate } from "./definitions/base.js";
|
|
@@ -24,7 +24,7 @@ export abstract class OperationalBase<CT extends X509Certificate> extends X509Ba
|
|
|
24
24
|
protected abstract validateFields(): void;
|
|
25
25
|
|
|
26
26
|
/** Encodes the signed certificate into the Matter TLV format. */
|
|
27
|
-
abstract asSignedTlv(signature:
|
|
27
|
+
abstract asSignedTlv(signature: Bytes): Bytes;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Verifies general requirements a Matter certificate fields must fulfill.
|
|
@@ -32,9 +32,9 @@ export abstract class OperationalBase<CT extends X509Certificate> extends X509Ba
|
|
|
32
32
|
*/
|
|
33
33
|
generalVerify() {
|
|
34
34
|
const cert = this.cert;
|
|
35
|
-
if (cert.serialNumber.
|
|
35
|
+
if (cert.serialNumber.byteLength > 20)
|
|
36
36
|
throw new CertificateError(
|
|
37
|
-
`Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.
|
|
37
|
+
`Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.byteLength} octets.`,
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
if (cert.signatureAlgorithm !== 1) {
|
|
@@ -13,7 +13,7 @@ import { OperationalBase } from "./OperationalBase.js";
|
|
|
13
13
|
|
|
14
14
|
export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
|
|
15
15
|
/** Construct the class from a Tlv version of the certificate */
|
|
16
|
-
static fromTlv(tlv:
|
|
16
|
+
static fromTlv(tlv: Bytes): Rcac {
|
|
17
17
|
return new Rcac(OperationalCertificate.TlvRcac.decode(tlv));
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -102,7 +102,7 @@ export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
|
|
|
102
102
|
if (subjectKeyIdentifier === undefined) {
|
|
103
103
|
throw new CertificateError(`Root certificate must have subjectKeyIdentifier set.`);
|
|
104
104
|
}
|
|
105
|
-
if (subjectKeyIdentifier.
|
|
105
|
+
if (subjectKeyIdentifier.byteLength !== 20) {
|
|
106
106
|
throw new CertificateError(`Root certificate subjectKeyIdentifier must be 160 bit.`);
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -110,7 +110,7 @@ export class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
|
|
|
110
110
|
if (authorityKeyIdentifier === undefined) {
|
|
111
111
|
throw new CertificateError(`Root certificate must have authorityKeyIdentifier set.`);
|
|
112
112
|
}
|
|
113
|
-
if (authorityKeyIdentifier.
|
|
113
|
+
if (authorityKeyIdentifier.byteLength !== 20) {
|
|
114
114
|
throw new CertificateError(`Root certificate authorityKeyIdentifier must be 160 bit.`);
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -42,7 +42,7 @@ import { CertificateExtension } from "./definitions/operational.js";
|
|
|
42
42
|
* from a CSR.
|
|
43
43
|
*/
|
|
44
44
|
export abstract class X509Base<CT extends X509Certificate> {
|
|
45
|
-
#signature?:
|
|
45
|
+
#signature?: Bytes;
|
|
46
46
|
#cert: Unsigned<CT>;
|
|
47
47
|
|
|
48
48
|
constructor(cert: CT | Unsigned<CT>) {
|
|
@@ -75,7 +75,7 @@ export abstract class X509Base<CT extends X509Certificate> {
|
|
|
75
75
|
* Set the signature of the certificate.
|
|
76
76
|
* If the certificate is already signed, it throws a CertificateError.
|
|
77
77
|
*/
|
|
78
|
-
set signature(signature:
|
|
78
|
+
set signature(signature: Bytes) {
|
|
79
79
|
if (this.isSigned) {
|
|
80
80
|
throw new CertificateError("Certificate is already signed");
|
|
81
81
|
}
|
|
@@ -93,7 +93,7 @@ export abstract class X509Base<CT extends X509Certificate> {
|
|
|
93
93
|
/**
|
|
94
94
|
* Convert the certificate to ASN.1 DER format without signature.
|
|
95
95
|
*/
|
|
96
|
-
asUnsignedAsn1():
|
|
96
|
+
asUnsignedAsn1(): Bytes {
|
|
97
97
|
const certBytes = DerCodec.encode(this.genericBuildAsn1Structure(this.cert));
|
|
98
98
|
assertCertificateDerSize(certBytes);
|
|
99
99
|
return certBytes;
|
|
@@ -273,10 +273,10 @@ export abstract class X509Base<CT extends X509Certificate> {
|
|
|
273
273
|
asn.extendedKeyUsage = X509.ExtendedKeyUsage(value as number[] | undefined);
|
|
274
274
|
break;
|
|
275
275
|
case "subjectKeyIdentifier":
|
|
276
|
-
asn.subjectKeyIdentifier = X509.SubjectKeyIdentifier(value as
|
|
276
|
+
asn.subjectKeyIdentifier = X509.SubjectKeyIdentifier(value as Bytes);
|
|
277
277
|
break;
|
|
278
278
|
case "authorityKeyIdentifier":
|
|
279
|
-
asn.authorityKeyIdentifier = X509.AuthorityKeyIdentifier(value as
|
|
279
|
+
asn.authorityKeyIdentifier = X509.AuthorityKeyIdentifier(value as Bytes);
|
|
280
280
|
break;
|
|
281
281
|
case "futureExtension":
|
|
282
282
|
asn.futureExtension = RawBytes(Bytes.concat(...((value as Uint8Array[] | undefined) ?? [])));
|
|
@@ -340,7 +340,7 @@ export abstract class X509Base<CT extends X509Certificate> {
|
|
|
340
340
|
/**
|
|
341
341
|
* Extract the public key from a Certificate Signing Request (CSR) in ASN.1 DER format.
|
|
342
342
|
*/
|
|
343
|
-
static async getPublicKeyFromCsr(crypto: Crypto, encodedCsr:
|
|
343
|
+
static async getPublicKeyFromCsr(crypto: Crypto, encodedCsr: Bytes) {
|
|
344
344
|
const { [DerKey.Elements]: rootElements } = DerCodec.decode(encodedCsr);
|
|
345
345
|
if (rootElements?.length !== 3) {
|
|
346
346
|
throw new CertificateError("Invalid CSR data");
|
|
@@ -353,7 +353,7 @@ export abstract class X509Base<CT extends X509Certificate> {
|
|
|
353
353
|
throw new CertificateError("Invalid CSR data");
|
|
354
354
|
}
|
|
355
355
|
const [versionNode, subjectNode, publicKeyNode] = requestElements;
|
|
356
|
-
const requestVersionBytes = versionNode[DerKey.Bytes];
|
|
356
|
+
const requestVersionBytes = Bytes.of(versionNode[DerKey.Bytes]);
|
|
357
357
|
if (requestVersionBytes.length !== 1 || requestVersionBytes[0] !== 0) {
|
|
358
358
|
throw new CertificateError(`Unsupported CSR version ${requestVersionBytes[0]}`);
|
|
359
359
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2022-2025 Matter.js Authors
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { ImplementationError, MatterError } from "#general";
|
|
6
|
+
import { Bytes, ImplementationError, MatterError } from "#general";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Matter specific Certificate Sizes
|
|
@@ -15,10 +15,10 @@ export class CertificateError extends MatterError {}
|
|
|
15
15
|
|
|
16
16
|
export type Unsigned<Type> = { [Property in keyof Type as Exclude<Property, "signature">]: Type[Property] };
|
|
17
17
|
|
|
18
|
-
export function assertCertificateDerSize(certBytes:
|
|
19
|
-
if (certBytes.
|
|
18
|
+
export function assertCertificateDerSize(certBytes: Bytes) {
|
|
19
|
+
if (certBytes.byteLength > MAX_DER_CERTIFICATE_SIZE) {
|
|
20
20
|
throw new ImplementationError(
|
|
21
|
-
`Certificate to generate is too big: ${certBytes.
|
|
21
|
+
`Certificate to generate is too big: ${certBytes.byteLength} bytes instead of max ${MAX_DER_CERTIFICATE_SIZE} bytes`,
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { BitFlag, BitmapSchema, TypeFromPartialBitSchema } from "#types";
|
|
7
|
+
import { Bytes } from "@matter/general";
|
|
7
8
|
|
|
8
9
|
export const ExtensionKeyUsageBitmap = {
|
|
9
10
|
digitalSignature: BitFlag(0),
|
|
@@ -19,7 +20,7 @@ export const ExtensionKeyUsageBitmap = {
|
|
|
19
20
|
export const ExtensionKeyUsageSchema = BitmapSchema(ExtensionKeyUsageBitmap);
|
|
20
21
|
|
|
21
22
|
export interface X509Certificate {
|
|
22
|
-
serialNumber:
|
|
23
|
+
serialNumber: Bytes;
|
|
23
24
|
signatureAlgorithm: number;
|
|
24
25
|
issuer: {};
|
|
25
26
|
notBefore: number;
|
|
@@ -27,7 +28,7 @@ export interface X509Certificate {
|
|
|
27
28
|
subject: {};
|
|
28
29
|
publicKeyAlgorithm: number;
|
|
29
30
|
ellipticCurveIdentifier: number;
|
|
30
|
-
ellipticCurvePublicKey:
|
|
31
|
+
ellipticCurvePublicKey: Bytes;
|
|
31
32
|
extensions: {
|
|
32
33
|
basicConstraints: {
|
|
33
34
|
isCa: boolean;
|
|
@@ -35,9 +36,9 @@ export interface X509Certificate {
|
|
|
35
36
|
};
|
|
36
37
|
keyUsage: TypeFromPartialBitSchema<typeof ExtensionKeyUsageBitmap>;
|
|
37
38
|
extendedKeyUsage?: number[];
|
|
38
|
-
subjectKeyIdentifier:
|
|
39
|
-
authorityKeyIdentifier:
|
|
40
|
-
futureExtension?:
|
|
39
|
+
subjectKeyIdentifier: Bytes;
|
|
40
|
+
authorityKeyIdentifier: Bytes;
|
|
41
|
+
futureExtension?: Bytes[];
|
|
41
42
|
};
|
|
42
|
-
signature:
|
|
43
|
+
signature: Bytes;
|
|
43
44
|
}
|
package/src/codec/BtpCodec.ts
CHANGED
|
@@ -24,11 +24,11 @@ export interface BtpPacketPayload {
|
|
|
24
24
|
ackNumber?: number;
|
|
25
25
|
sequenceNumber: number;
|
|
26
26
|
messageLength?: number;
|
|
27
|
-
segmentPayload?:
|
|
27
|
+
segmentPayload?: Bytes;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface DecodedBtpPacketPayload extends BtpPacketPayload {
|
|
31
|
-
segmentPayload:
|
|
31
|
+
segmentPayload: Bytes;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface BtpHeader {
|
|
@@ -66,12 +66,12 @@ export enum BtpOpcode {
|
|
|
66
66
|
const HANDSHAKE_HEADER = 0b01100101;
|
|
67
67
|
|
|
68
68
|
export class BtpCodec {
|
|
69
|
-
static decodeBtpHandshakeRequest(data:
|
|
69
|
+
static decodeBtpHandshakeRequest(data: Bytes): BtpHandshakeRequest {
|
|
70
70
|
const reader = new DataReader(data, Endian.Little);
|
|
71
71
|
return this.decodeHandshakeRequestPayload(reader);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
static decodeBtpPacket(data:
|
|
74
|
+
static decodeBtpPacket(data: Bytes): DecodedBtpPacket {
|
|
75
75
|
const reader = new DataReader(data, Endian.Little);
|
|
76
76
|
|
|
77
77
|
const header = this.decodeBtpPacketHeader(reader);
|
|
@@ -82,11 +82,11 @@ export class BtpCodec {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
static encodeBtpPacket({ header, payload }: BtpPacket):
|
|
85
|
+
static encodeBtpPacket({ header, payload }: BtpPacket): Bytes {
|
|
86
86
|
return Bytes.concat(this.encodeBtpPacketHeader(header), this.encodeBtpPacketPayload(header, payload));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
static encodeBtpHandshakeRequest({ versions, attMtu, clientWindowSize }: BtpHandshakeRequest):
|
|
89
|
+
static encodeBtpHandshakeRequest({ versions, attMtu, clientWindowSize }: BtpHandshakeRequest): Bytes {
|
|
90
90
|
const writer = new DataWriter(Endian.Little);
|
|
91
91
|
writer.writeUInt8(HANDSHAKE_HEADER);
|
|
92
92
|
writer.writeUInt8(BtpOpcode.HandshakeManagementOpcode);
|
|
@@ -99,7 +99,7 @@ export class BtpCodec {
|
|
|
99
99
|
return writer.toByteArray();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
static encodeBtpHandshakeResponse({ version, attMtu, windowSize }: BtpHandshakeResponse):
|
|
102
|
+
static encodeBtpHandshakeResponse({ version, attMtu, windowSize }: BtpHandshakeResponse): Bytes {
|
|
103
103
|
const writer = new DataWriter(Endian.Little);
|
|
104
104
|
writer.writeUInt8(HANDSHAKE_HEADER);
|
|
105
105
|
writer.writeUInt8(BtpOpcode.HandshakeManagementOpcode);
|
|
@@ -125,7 +125,7 @@ export class BtpCodec {
|
|
|
125
125
|
private static encodeBtpPacketPayload(
|
|
126
126
|
{ hasAckNumber, isBeginningSegment, isContinuingSegment, isEndingSegment }: BtpHeader,
|
|
127
127
|
{ ackNumber, sequenceNumber, messageLength, segmentPayload }: BtpPacketPayload,
|
|
128
|
-
):
|
|
128
|
+
): Bytes {
|
|
129
129
|
const writer = new DataWriter(Endian.Little);
|
|
130
130
|
|
|
131
131
|
// Validate Header against Payload fields to make sure they match together
|
|
@@ -143,7 +143,7 @@ export class BtpCodec {
|
|
|
143
143
|
}
|
|
144
144
|
if (
|
|
145
145
|
(isBeginningSegment || isContinuingSegment) &&
|
|
146
|
-
(segmentPayload === undefined || segmentPayload.
|
|
146
|
+
(segmentPayload === undefined || segmentPayload.byteLength === 0)
|
|
147
147
|
) {
|
|
148
148
|
throw new BtpProtocolError("Payload needs to be set because header flag indicates a message with payload.");
|
|
149
149
|
}
|
|
@@ -211,7 +211,7 @@ export class BtpCodec {
|
|
|
211
211
|
return { versions, attMtu, clientWindowSize };
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
static decodeBtpHandshakeResponsePayload(data:
|
|
214
|
+
static decodeBtpHandshakeResponsePayload(data: Bytes): BtpHandshakeResponse {
|
|
215
215
|
const reader = new DataReader(data, Endian.Little);
|
|
216
216
|
const header = reader.readUInt8();
|
|
217
217
|
if (header !== HANDSHAKE_HEADER) {
|
|
@@ -259,7 +259,7 @@ export class BtpCodec {
|
|
|
259
259
|
isEndingSegment,
|
|
260
260
|
isContinuingSegment,
|
|
261
261
|
isBeginningSegment,
|
|
262
|
-
}: BtpHeader):
|
|
262
|
+
}: BtpHeader): Bytes {
|
|
263
263
|
const writer = new DataWriter(Endian.Little);
|
|
264
264
|
|
|
265
265
|
if (isHandshakeRequest || hasManagementOpcode) {
|
|
@@ -300,7 +300,7 @@ export class BtpCodec {
|
|
|
300
300
|
return writer.toByteArray();
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
static decodeBleAdvertisementData(data:
|
|
303
|
+
static decodeBleAdvertisementData(data: Bytes) {
|
|
304
304
|
const reader = new DataReader(data, Endian.Little);
|
|
305
305
|
if (
|
|
306
306
|
reader.readUInt8() !== 0x02 ||
|
|
@@ -320,7 +320,7 @@ export class BtpCodec {
|
|
|
320
320
|
return { discriminator, vendorId, productId, hasAdditionalAdvertisementData };
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
static decodeBleAdvertisementServiceData(data:
|
|
323
|
+
static decodeBleAdvertisementServiceData(data: Bytes) {
|
|
324
324
|
const reader = new DataReader(data, Endian.Little);
|
|
325
325
|
if (reader.readUInt8() !== 0x00) {
|
|
326
326
|
throw new BleError("Invalid BLE advertisement data");
|