Class SecretStorageCrypto
Inheritance
SecretStorageCrypto
Namespace: Uniform.Matrix.Protocol.Crypto
Assembly: Uniform.Matrix.Protocol.Crypto.dll
public static class SecretStorageCrypto
Fields
|
Edit this page
View Source
Algorithm name of the secret storage keys this class handles.
Declaration
public const string Algorithm = "m.secret_storage.v1.aes-hmac-sha2"
Field Value
Methods
|
Edit this page
View Source
Return whether key matches a key description's iv and mac.
Declaration
public static bool CheckKey(ReadOnlySpan<byte> key, string iv, string mac)
Parameters
Returns
|
Edit this page
View Source
Return the iv and mac that prove knowledge of key: 32 zero bytes encrypted under the empty name.
Declaration
public static (string Iv, string Mac) CreateKeyCheck(ReadOnlySpan<byte> key)
Parameters
Returns
|
Edit this page
View Source
Parse a recovery key, ignoring spaces; throw FormatException when the prefix, length or parity is wrong.
Declaration
public static byte[] DecodeRecoveryKey(string recoveryKey)
Parameters
| Type |
Name |
Description |
| string |
recoveryKey |
|
Returns
|
Edit this page
View Source
Declaration
public static string Decrypt(ReadOnlySpan<byte> key, string name, EncryptedSecret secret)
Parameters
Returns
|
Edit this page
View Source
Declaration
public static byte[] DecryptBytes(ReadOnlySpan<byte> key, string name, EncryptedSecret secret)
Parameters
Returns
|
Edit this page
View Source
Format a 32-byte key as a recovery key: prefix, key and parity in base58, in groups of four.
Declaration
public static string EncodeRecoveryKey(ReadOnlySpan<byte> key)
Parameters
Returns
string shown = SecretStorageCrypto.EncodeRecoveryKey(key); // "EsTc 5rr1 4mpm ..."
|
Edit this page
View Source
Encrypt plaintext under name, e.g. m.cross_signing.master.
Declaration
public static EncryptedSecret Encrypt(ReadOnlySpan<byte> key, string name, ReadOnlySpan<byte> plaintext)
Parameters
Returns
|
Edit this page
View Source
Encrypt a text secret, such as a base64 private key.
Declaration
public static EncryptedSecret Encrypt(ReadOnlySpan<byte> key, string name, string secret)
Parameters
Returns
|
Edit this page
View Source
Derive a key from a passphrase with PBKDF2-SHA-512, as in m.pbkdf2 passphrase settings.
Declaration
public static byte[] KeyFromPassphrase(string passphrase, string salt, int iterations, int bits = 256)
Parameters
Returns