mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-18 05:15:06 +00:00
Add E2EE recovery and device rotation
Add signed, encrypted recovery archives with revision checks, account-certified device enrollment and key rotation, and historical signer lookup. Include the database migration, API endpoints, tests, and updated E2EE documentation.
This commit is contained in:
+1407
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Govor.Domain.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class E2eeRecoveryAndRotation : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AccountIdentityKey",
|
||||
table: "UserCryptoSessions",
|
||||
type: "character varying(200)",
|
||||
maxLength: 200,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AccountSignature",
|
||||
table: "UserCryptoSessions",
|
||||
type: "character varying(100)",
|
||||
maxLength: 100,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "Generation",
|
||||
table: "UserCryptoSessions",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "PreviousFingerprint",
|
||||
table: "UserCryptoSessions",
|
||||
type: "character varying(64)",
|
||||
maxLength: 64,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "E2eeRecoveryVaults",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Revision = table.Column<long>(type: "bigint", nullable: false),
|
||||
IdentityKey = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
|
||||
Ciphertext = table.Column<string>(type: "character varying(4000000)", maxLength: 4000000, nullable: false),
|
||||
Signature = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_E2eeRecoveryVaults", x => x.UserId);
|
||||
table.ForeignKey(
|
||||
name: "FK_E2eeRecoveryVaults_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "E2eeRecoveryVaults");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AccountIdentityKey",
|
||||
table: "UserCryptoSessions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AccountSignature",
|
||||
table: "UserCryptoSessions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Generation",
|
||||
table: "UserCryptoSessions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PreviousFingerprint",
|
||||
table: "UserCryptoSessions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -797,6 +797,35 @@ namespace Govor.Domain.Migrations
|
||||
b.ToTable("Admins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Domain.Models.Users.Crypto.E2eeRecoveryVault", b =>
|
||||
{
|
||||
b.Property<Guid>("UserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Ciphertext")
|
||||
.IsRequired()
|
||||
.HasMaxLength(4000000)
|
||||
.HasColumnType("character varying(4000000)");
|
||||
|
||||
b.Property<string>("IdentityKey")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<long>("Revision")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Signature")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.HasKey("UserId");
|
||||
|
||||
b.ToTable("E2eeRecoveryVaults");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Domain.Models.Users.Crypto.OneTimePreKey", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -858,6 +887,22 @@ namespace Govor.Domain.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AccountIdentityKey")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)");
|
||||
|
||||
b.Property<string>("AccountSignature")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<long>("Generation")
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("PreviousFingerprint")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<byte[]>("PublicIdentityKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("bytea");
|
||||
@@ -1234,6 +1279,15 @@ namespace Govor.Domain.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Domain.Models.Users.Crypto.E2eeRecoveryVault", b =>
|
||||
{
|
||||
b.HasOne("Govor.Domain.Models.Users.User", null)
|
||||
.WithOne()
|
||||
.HasForeignKey("Govor.Domain.Models.Users.Crypto.E2eeRecoveryVault", "UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Govor.Domain.Models.Users.Crypto.OneTimePreKey", b =>
|
||||
{
|
||||
b.HasOne("Govor.Domain.Models.Users.Crypto.UserCryptoSession", "UserCryptoSession")
|
||||
|
||||
Reference in New Issue
Block a user