Class SecretStorage
Secret storage (4S): secrets encrypted in account data with a key the user keeps as a recovery key.
Inheritance
SecretStorage
Namespace: Uniform.Matrix.Protocol.Crypto
Assembly: Uniform.Matrix.Protocol.Crypto.dll
public sealed class SecretStorage
SecretStorage storage = new(new MatrixKeyTransport(client));
(string keyId, SecretStorageKeyDescription description) = (await storage.GetDefaultKeyAsync())!.Value;
byte[] key = SecretStorage.Unlock(description, "EsTc 5rr1 ...");
string? master = await storage.GetSecretAsync(SecretNames.CrossSigningMaster, keyId, key);
Constructors
|
Edit this page
View Source
Use transport for account data.
Declaration
public SecretStorage(IKeyTransport transport)
Parameters
Fields
|
Edit this page
View Source
Account data type naming the default key.
Declaration
public const string DefaultKeyType = "m.secret_storage.default_key"
Field Value
|
Edit this page
View Source
Account data type prefix of key descriptions.
Declaration
public const string KeyTypePrefix = "m.secret_storage.key."
Field Value
Methods
|
Edit this page
View Source
Create a random key, publishes its description and make it the default; return its ID and the key, to show as a recovery key.
Declaration
public Task<(string KeyId, byte[] Key)> CreateKeyAsync(string? name = null, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return the default key's ID and description, or null when secret storage is not set up.
Declaration
public Task<(string KeyId, SecretStorageKeyDescription Description)?> GetDefaultKeyAsync(CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return secret name decrypted with key, or null when it is not stored for that key.
Declaration
public Task<string?> GetSecretAsync(string name, string keyId, byte[] key, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Store secret name encrypted with key, replacing copies for other keys.
Declaration
public Task StoreSecretAsync(string name, string secret, string keyId, byte[] key, CancellationToken cancellationToken = default)
Parameters
Returns
|
Edit this page
View Source
Return the key from a recovery key, or from a passphrase when the key has one; throw CryptographicException when it does not match.
Declaration
public static byte[] Unlock(SecretStorageKeyDescription description, string recoveryKeyOrPassphrase)
Parameters
Returns