@@ -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 } ,
@@ -2295,7 +2297,6 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2295
2297
await bootstrapPromise ;
2296
2298
// Finally ensure backup is working
2297
2299
await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ;
2298
-
2299
2300
await backupStatusUpdate ;
2300
2301
}
2301
2302
@@ -2346,7 +2347,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2346
2347
} ,
2347
2348
) ;
2348
2349
2349
- newBackendOnly ( "should create a new key" , async ( ) => {
2350
+ it ( "should create a new key" , async ( ) => {
2350
2351
const bootstrapPromise = aliceClient
2351
2352
. getCrypto ( ) !
2352
2353
. bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
@@ -2389,46 +2390,43 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2389
2390
} ,
2390
2391
) ;
2391
2392
2392
- newBackendOnly (
2393
- "should create a new key if setupNewSecretStorage is at true even if an AES key is already in the secret storage" ,
2394
- async ( ) => {
2395
- let bootstrapPromise = aliceClient
2396
- . getCrypto ( ) !
2397
- . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2393
+ it ( "should create a new key if setupNewSecretStorage is at true even if an AES key is already in the secret storage" , async ( ) => {
2394
+ let bootstrapPromise = aliceClient
2395
+ . getCrypto ( ) !
2396
+ . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2398
2397
2399
- // Wait for the key to be uploaded in the account data
2400
- let secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2398
+ // Wait for the key to be uploaded in the account data
2399
+ let secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2401
2400
2402
- // Return the newly created key in the sync response
2403
- sendSyncResponse ( secretStorageKey ) ;
2401
+ // Return the newly created key in the sync response
2402
+ sendSyncResponse ( secretStorageKey ) ;
2404
2403
2405
- // Wait for bootstrapSecretStorage to finished
2406
- await bootstrapPromise ;
2404
+ // Wait for bootstrapSecretStorage to finished
2405
+ await bootstrapPromise ;
2407
2406
2408
- // Call again bootstrapSecretStorage
2409
- bootstrapPromise = aliceClient
2410
- . getCrypto ( ) !
2411
- . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2407
+ // Call again bootstrapSecretStorage
2408
+ bootstrapPromise = aliceClient
2409
+ . getCrypto ( ) !
2410
+ . bootstrapSecretStorage ( { setupNewSecretStorage : true , createSecretStorageKey } ) ;
2412
2411
2413
- // Wait for the key to be uploaded in the account data
2414
- secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2412
+ // Wait for the key to be uploaded in the account data
2413
+ secretStorageKey = await awaitSecretStorageKeyStoredInAccountData ( ) ;
2415
2414
2416
- // Return the newly created key in the sync response
2417
- sendSyncResponse ( secretStorageKey ) ;
2415
+ // Return the newly created key in the sync response
2416
+ sendSyncResponse ( secretStorageKey ) ;
2418
2417
2419
- // Wait for bootstrapSecretStorage to finished
2420
- await bootstrapPromise ;
2418
+ // Wait for bootstrapSecretStorage to finished
2419
+ await bootstrapPromise ;
2421
2420
2422
- // createSecretStorageKey should have been called twice, one time every bootstrapSecretStorage call
2423
- expect ( createSecretStorageKey ) . toHaveBeenCalledTimes ( 2 ) ;
2424
- } ,
2425
- ) ;
2421
+ // createSecretStorageKey should have been called twice, one time every bootstrapSecretStorage call
2422
+ expect ( createSecretStorageKey ) . toHaveBeenCalledTimes ( 2 ) ;
2423
+ } ) ;
2426
2424
2427
- newBackendOnly ( "should upload cross signing keys" , async ( ) => {
2425
+ it ( "should upload cross signing keys" , async ( ) => {
2428
2426
mockSetupCrossSigningRequests ( ) ;
2429
2427
2430
2428
// Before setting up secret-storage, bootstrap cross-signing, so that the client has cross-signing keys.
2431
- await aliceClient . getCrypto ( ) ? .bootstrapCrossSigning ( { } ) ;
2429
+ await aliceClient . getCrypto ( ) ! . bootstrapCrossSigning ( { } ) ;
2432
2430
2433
2431
// Now, when we bootstrap secret-storage, the cross-signing keys should be uploaded.
2434
2432
const bootstrapPromise = aliceClient
@@ -2457,17 +2455,25 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("crypto (%s)", (backend: string,
2457
2455
expect ( selfSigningKey [ secretStorageKey ] ) . toBeDefined ( ) ;
2458
2456
} ) ;
2459
2457
2460
- oldBackendOnly ( "should create a new megolm backup" , async ( ) => {
2458
+ it ( "should create a new megolm backup" , async ( ) => {
2461
2459
const backupVersion = "abc" ;
2462
2460
await bootstrapSecurity ( backupVersion ) ;
2463
2461
2464
2462
// Expect a backup to be available and used
2465
2463
const activeBackup = await aliceClient . getCrypto ( ) ! . getActiveSessionBackupVersion ( ) ;
2466
2464
expect ( activeBackup ) . toStrictEqual ( backupVersion ) ;
2465
+
2466
+ // check that there is a MSK signature
2467
+ const signatures = ( await aliceClient . getCrypto ( ) ! . checkKeyBackupAndEnable ( ) ) ! . backupInfo . auth_data !
2468
+ . signatures ;
2469
+ expect ( signatures ) . toBeDefined ( ) ;
2470
+ expect ( signatures ! [ aliceClient . getUserId ( ) ! ] ) . toBeDefined ( ) ;
2471
+ const mskId = await aliceClient . getCrypto ( ) ! . getCrossSigningKeyId ( CrossSigningKey . Master ) ! ;
2472
+ expect ( signatures ! [ aliceClient . getUserId ( ) ! ] [ `ed25519:${ mskId } ` ] ) . toBeDefined ( ) ;
2467
2473
} ) ;
2468
2474
2469
- oldBackendOnly ( "Reset key backup should create a new backup and update 4S" , async ( ) => {
2470
- // First set up 4S and key backup
2475
+ it ( "Reset key backup should create a new backup and update 4S" , async ( ) => {
2476
+ // First set up recovery
2471
2477
const backupVersion = "1" ;
2472
2478
await bootstrapSecurity ( backupVersion ) ;
2473
2479
0 commit comments