Class RoomKeyStore
Holds room content keys for end-to-end encrypted channels: in-memory for the active session, persisted per-server in the client config (like saved sessions) so users don't retype the passphrase every launch. Keys never leave this machine and are encrypted at rest by RoomKeyProtector. Also tracks which channels are known to be end-to-end encrypted, so senders can refuse to emit plaintext into a room whose key isn't cached yet.
public sealed class RoomKeyStore
- Inheritance
-
RoomKeyStore
- Inherited Members
Constructors
RoomKeyStore()
public RoomKeyStore()
RoomKeyStore(RoomKeyProtector)
public RoomKeyStore(RoomKeyProtector protector)
Parameters
protectorRoomKeyProtector
Methods
Clear()
public void Clear()
HasKey(string)
public bool HasKey(string channelName)
Parameters
channelNamestring
Returns
IsChannelEncrypted(string)
public bool IsChannelEncrypted(string channelName)
Parameters
channelNamestring
Returns
LoadForServer(string)
Binds the store to a server and loads that server's cached keys from config.
public void LoadForServer(string serverUrl)
Parameters
serverUrlstring
MarkChannelEncrypted(string, bool)
Records whether a channel is end-to-end encrypted (from channel listings, crypto metadata, or join outcomes). Senders consult this to block plaintext into rooms whose key isn't cached.
public void MarkChannelEncrypted(string channelName, bool isEncrypted)
Parameters
RemoveKey(string)
public void RemoveKey(string channelName)
Parameters
channelNamestring
StoreKey(string, byte[])
Stores a key for the session and persists it to the server's config entry.
public void StoreKey(string channelName, byte[] key)
Parameters
TryGetKey(string, out byte[])
public bool TryGetKey(string channelName, out byte[] key)
Parameters
Returns
TryStoreFromEnvelope(string, string, byte[])
Unwraps a fresh key envelope and caches the key, overwriting any stale cached key (e.g. the channel was deleted and recreated under the same name, so the old key would encrypt messages nobody else can read). Returns false when the KEK doesn't open the envelope — the cache is left untouched.
public bool TryStoreFromEnvelope(string channelName, string wrappedRoomKey, byte[] kek)