Class DeviceKeyService
The server's part of end-to-end encryption: device keys, one-time and fallback keys, cross-signing keys and signatures.
Inheritance
DeviceKeyService
Assembly: Uniform.Matrix.Server.dll
public sealed class DeviceKeyService
Constructors
|
Edit this page
View Source
DeviceKeyService(IDbContextFactory<ServerDbContext>, ServerStream)
Declaration
public DeviceKeyService(IDbContextFactory<ServerDbContext> contexts, ServerStream stream)
Parameters
Fields
|
Edit this page
View Source
Usage of the master cross-signing key.
Declaration
public const string Master = "master"
Field Value
|
Edit this page
View Source
Usage of the key that signs the user's own devices.
Declaration
public const string SelfSigning = "self_signing"
Field Value
|
Edit this page
View Source
Usage of the key that signs other users' master keys.
Declaration
public const string UserSigning = "user_signing"
Field Value
Methods
|
Edit this page
View Source
ClaimAsync(JsonObject, CancellationToken)
Claims one key per requested device: a one-time key, which is then removed, else the fallback key.
Declaration
public Task<JsonObject> ClaimAsync(JsonObject request, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
CountOneTimeKeysAsync(ServerDbContext, string, string, CancellationToken)
Return the counts of a device's unclaimed one-time keys by algorithm.
Declaration
public static Task<JsonObject> CountOneTimeKeysAsync(ServerDbContext dbContext, string userId, string deviceId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Remove the keys and signatures of deleted devices, and tell others.
Declaration
public Task DeleteDevicesAsync(string userId, IReadOnlyCollection<string> deviceIds, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
Record a change of the users' keys at a new stream position.
Declaration
public Task MarkChangedAsync(IEnumerable<string> userIds, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
QueryAsync(string, JsonObject, CancellationToken)
Return the device and cross-signing keys of queried users: all devices, or the listed ones.
Declaration
public Task<JsonObject> QueryAsync(string requesterId, JsonObject query, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
UnusedFallbackKeyTypesAsync(ServerDbContext, string, string, CancellationToken)
Return the algorithms of a device's fallback keys that were not claimed yet.
Declaration
public static Task<JsonArray> UnusedFallbackKeyTypesAsync(ServerDbContext dbContext, string userId, string deviceId, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
UploadAsync(Requester, JsonObject?, JsonObject?, JsonObject?, CancellationToken)
Store uploaded keys of the requester's device; return the counts of its unclaimed one-time keys by algorithm.
Declaration
public Task<JsonObject> UploadAsync(Requester requester, JsonObject? deviceKeys, JsonObject? oneTimeKeys, JsonObject? fallbackKeys, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
UploadCrossSigningKeysAsync(string, JsonObject?, JsonObject?, JsonObject?, Func<Task>, CancellationToken)
Declaration
public Task UploadCrossSigningKeysAsync(string userId, JsonObject? master, JsonObject? selfSigning, JsonObject? userSigning, Func<Task> authorize, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
UploadSignaturesAsync(string, JsonObject, CancellationToken)
Stores signatures of devices and master keys after checking them; returns the failures by user and key.
Declaration
public Task<JsonObject> UploadSignaturesAsync(string requesterId, JsonObject body, CancellationToken cancellationToken)
Parameters
Returns