ClientMessageSecurity
Message-level (object) security between the request/response layer and the messaging layer, where RFC 8613 Figure 1 places OSCORE. Block-wise transfer and Observe sit above it, so they work on protected exchanges unchanged; retransmission and deduplication sit below it and handle the protected bytes.
kcoap-oscore implements these interfaces. EDHOC + OSCORE (RFC 9668) decorates them.
The CoAP stack assigns the token and Message ID before protecting a request, and keeps them: OSCORE does not protect either, and responses are matched by token.
Concurrency and cancellation. The stack calls every method here and on ProtectedRequest, ServerMessageSecurity and UnprotectedRequest from many coroutines at once, on any dispatcher: one per request, one per notification, and the receive loops. Implementations must be safe for that, as kcoap-oscore is with a Mutex for the sender and one for the recipient state of each security context. Any call may be cancelled, when its request is cancelled, its server stops or its endpoint closes, and a cancelled call must leave replay and sequence-number state consistent: a sequence number it took stays used and is never handed out again (RFC 8613 §7.2.1), and a replay window either accepted the message or is unchanged.
Errors. The four operations list MessageSecurityException and CancellationException in @Throws: the overrides, kcoap-oscore's OSCORE protection and verification among them, inherit that list, which Kotlin/Native requires to stay the same down the hierarchy. MessageSecurityException is a signal between the layers, not a KcoapException: the CoAP stack translates it at its boundary, into CoapException.Reason.SECURITY on the client and an error response on the server.