oscoreContext
Derives the OSCORE security context of this EDHOC session (RFC 9528 Appendix A.1).
The keys are new with every session, so no request under them can have been accepted before: the replay window is trusted from the start (FreshnessPolicy.ASSUME_FRESH), whatever sequenceStore is. Without that, a durable store would make FreshnessPolicy.AUTO challenge the first request, which breaks the combined EDHOC + OSCORE request of RFC 9668.
Call it once per session. EdhocServer and EdhocClientHandshake already do, with their sequenceStore, and return or register the result; deriving a second context from the same session gives two contexts with the same keys that both start at sequence number 0, so their nonces repeat. Only an application that drives dev.kcoap.edhoc.EdhocInitiator or dev.kcoap.edhoc.EdhocResponder itself derives the context here.
Sequence numbers live in memory (EphemeralSequenceNumberStore) unless sequenceStore says otherwise, and such a context ends with the process. To resume one after a restart, pass a durable store here, persist oscoreParameters, and derive again from both as oscoreParameters describes, with the SecurityContext.identity of this one, which the parameters do not hold.
The context's SecurityContext.identity is an EdhocIdentity: the peer's authenticated credential and the context's Recipient ID, which the requests it verifies carry to access policies and handlers (ADR 0008).
@Throws lists KcoapException and CancellationException, as for SecurityContext.derive, and as there the exceptions of sequenceStore and crypto pass unchanged and are not in that list, so from Swift they end the process. EdhocClientHandshake and EdhocServer, which call this, turn them into an dev.kcoap.edhoc.EdhocException with the failure as cause.