InMemoryContextRepository

A MutableSecurityContextRepository in memory, keyed by Recipient ID and ID Context. It keeps every context until it is removed, without a bound: right for provisioned contexts and tests, while a server that runs EDHOC for many clients supplies a bounded repository instead (MutableSecurityContextRepository).

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open suspend override fun add(context: SecurityContext)

Adds context, replacing any context with the same Recipient ID and ID Context.

Link copied to clipboard
open suspend override fun addIfAbsent(context: SecurityContext): Boolean

Adds context unless a context with the same Recipient ID and ID Context is present, in one step that no other writer can interleave with, and returns whether it did. A writer that must never replace another's context uses this instead of add: EdhocServer adds every context it derives this way, and fails the handshake when the Recipient ID was taken meanwhile (RFC 9668 §4.1.2).

Link copied to clipboard
open suspend override fun find(recipientId: ByteArray, idContext: ByteArray?): SecurityContext?

Without a 'kid context' in the request, a context is found by Recipient ID alone when exactly one context has it (RFC 8613 §3.3 recommends unique Recipient IDs).

Link copied to clipboard
open suspend override fun remove(context: SecurityContext): Boolean

Removes context itself, in one step that no other writer can interleave with, and returns whether it did: only when context is the very context held under its Recipient ID and ID Context. A context that has been replaced or evicted already leaves the newer one in place, so a late removal, such as an expiry timer or a second revocation, never takes out another client's context that got the same Recipient ID since.