@@ -40,7 +40,6 @@ import { logger } from "../../../src/logger";
40
40
import {
41
41
Category ,
42
42
createClient ,
43
- CryptoEvent ,
44
43
IClaimOTKsResult ,
45
44
IContent ,
46
45
IDownloadKeyResult ,
@@ -55,6 +54,7 @@ import {
55
54
Room ,
56
55
RoomMember ,
57
56
RoomStateEvent ,
57
+ CryptoEvent ,
58
58
} from "../../../src/matrix" ;
59
59
import { DeviceInfo } from "../../../src/crypto/deviceinfo" ;
60
60
import { E2EKeyReceiver , IE2EKeyReceiver } from "../../test-utils/E2EKeyReceiver" ;
@@ -68,7 +68,7 @@ import {
68
68
mockSetupMegolmBackupRequests ,
69
69
} from "../../test-utils/mockEndpoints" ;
70
70
import { AddSecretStorageKeyOpts , SECRET_STORAGE_ALGORITHM_V1_AES } from "../../../src/secret-storage" ;
71
- import { CryptoCallbacks , KeyBackupInfo } from "../../../src/crypto-api" ;
71
+ import { CrossSigningKey , CryptoCallbacks , KeyBackupInfo } from "../../../src/crypto-api" ;
72
72
import { E2EKeyResponder } from "../../test-utils/E2EKeyResponder" ;
73
73
74
74
afterEach ( ( ) => {
@@ -2202,9 +2202,11 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2202
2202
"express:/_matrix/client/v3/user/:userId/account_data/:type(m.secret_storage.*)" ,
2203
2203
( url : string , options : RequestInit ) => {
2204
2204
const content = JSON . parse ( options . body as string ) ;
2205
+
2205
2206
if ( content . key ) {
2206
2207
resolve ( content . key ) ;
2207
2208
}
2209
+
2208
2210
return { } ;
2209
2211
} ,
2210
2212
{ overwriteRoutes : true } ,
@@ -2289,7 +2291,6 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2289
2291
await bootstrapPromise ;
2290
2292
// Finally ensure backup is working
2291
2293
await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ;
2292
-
2293
2294
await backupStatusUpdate ;
2294
2295
}
2295
2296
@@ -2340,7 +2341,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2340
2341
} ,
2341
2342
) ;
2342
2343
2343
- newBackendOnly ( "should create a new key" , async ( ) => {
2344
+ it ( "should create a new key" , async ( ) => {
2344
2345
const bootstrapPromise = aliceClient
2345
2346
. getCrypto ( ) !
2346
2347
. bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
@@ -2383,46 +2384,43 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2383
2384
} ,
2384
2385
) ;
2385
2386
2386
- newBackendOnly (
2387
- "should create a new key if setupNewSecretStorage is at true even if an AES key is already in the secret storage" ,
2388
- async ( ) => {
2389
- let bootstrapPromise = aliceClient
2390
- . getCrypto ( ) !
2391
- . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2387
+ it ( "should create a new key if setupNewSecretStorage is at true even if an AES key is already in the secret storage" , async ( ) => {
2388
+ let bootstrapPromise = aliceClient
2389
+ . getCrypto ( ) !
2390
+ . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2392
2391
2393
- // Wait for the key to be uploaded in the account data
2394
- let secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2392
+ // Wait for the key to be uploaded in the account data
2393
+ let secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2395
2394
2396
- // Return the newly created key in the sync response
2397
- sendSyncResponse ( secretStorageKey ) ;
2395
+ // Return the newly created key in the sync response
2396
+ sendSyncResponse ( secretStorageKey ) ;
2398
2397
2399
- // Wait for bootstrapSecretStorage to finished
2400
- await bootstrapPromise ;
2398
+ // Wait for bootstrapSecretStorage to finished
2399
+ await bootstrapPromise ;
2401
2400
2402
- // Call again bootstrapSecretStorage
2403
- bootstrapPromise = aliceClient
2404
- . getCrypto ( ) !
2405
- . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2401
+ // Call again bootstrapSecretStorage
2402
+ bootstrapPromise = aliceClient
2403
+ . getCrypto ( ) !
2404
+ . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2406
2405
2407
- // Wait for the key to be uploaded in the account data
2408
- secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2406
+ // Wait for the key to be uploaded in the account data
2407
+ secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2409
2408
2410
- // Return the newly created key in the sync response
2411
- sendSyncResponse ( secretStorageKey ) ;
2409
+ // Return the newly created key in the sync response
2410
+ sendSyncResponse ( secretStorageKey ) ;
2412
2411
2413
- // Wait for bootstrapSecretStorage to finished
2414
- await bootstrapPromise ;
2412
+ // Wait for bootstrapSecretStorage to finished
2413
+ await bootstrapPromise ;
2415
2414
2416
- // createSecretStorageKey should have been called twice, one time every bootstrapSecretStorage call
2417
- expect ( createSecretStorageKey ) . toHaveBeenCalledTimes ( 2 ) ;
2418
- } ,
2419
- ) ;
2415
+ // createSecretStorageKey should have been called twice, one time every bootstrapSecretStorage call
2416
+ expect ( createSecretStorageKey ) . toHaveBeenCalledTimes ( 2 ) ;
2417
+ } ) ;
2420
2418
2421
- newBackendOnly ( "should upload cross signing keys" , async ( ) => {
2419
+ it ( "should upload cross signing keys" , async ( ) => {
2422
2420
mockSetupCrossSigningRequests ( ) ;
2423
2421
2424
2422
// Before setting up secret-storage, bootstrap cross-signing, so that the client has cross-signing keys.
2425
- await aliceClient . getCrypto ( ) ? .bootstrapCrossSigning ( { } ) ;
2423
+ await aliceClient . getCrypto ( ) ! . bootstrapCrossSigning ( { } ) ;
2426
2424
2427
2425
// Now, when we bootstrap secret-storage, the cross-signing keys should be uploaded.
2428
2426
const bootstrapPromise = aliceClient
@@ -2451,16 +2449,24 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2451
2449
expect ( selfSigningKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2452
2450
} ) ;
2453
2451
2454
- oldBackendOnly ( "should create a new megolm backup" , async ( ) => {
2452
+ it ( "should create a new megolm backup" , async ( ) => {
2455
2453
const backupVersion = "abc" ;
2456
2454
await bootstrapSecurity ( backupVersion ) ;
2457
2455
2458
2456
// Expect a backup to be available and used
2459
2457
const activeBackup = await aliceClient . getCrypto ( ) ! . getActiveSessionBackupVersion ( ) ;
2460
2458
expect ( activeBackup ) . toStrictEqual ( backupVersion ) ;
2459
+
2460
+ // check that there is a MSK signature
2461
+ const signatures = ( await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ) ! . backupInfo . auth_data !
2462
+ . signatures ;
2463
+ expect ( signatures ) . toBeDefined ( ) ;
2464
+ expect ( signatures ! [ aliceClient . getUserId ( ) ! ] ) . toBeDefined ( ) ;
2465
+ const mskId = await aliceClient . getCrypto ( ) ! . getCrossSigningKeyId ( CrossSigningKey . Master ) ! ;
2466
+ expect ( signatures ! [ aliceClient . getUserId ( ) ! ] [ `ed25519:${ mskId } ` ] ) . toBeDefined ( ) ;
2461
2467
} ) ;
2462
2468
2463
- oldBackendOnly ( "Reset key backup should create a new backup and update 4S" , async ( ) => {
2469
+ it ( "Reset key backup should create a new backup and update 4S" , async ( ) => {
2464
2470
// First set up recovery
2465
2471
const backupVersion = "1" ;
2466
2472
await bootstrapSecurity ( backupVersion ) ;
0 commit comments