@@ -111,47 +111,6 @@ - (void)doTestWithAliceWithCrossSigningAndKeyBackup:(XCTestCase*)testCase
111111 }];
112112}
113113
114- // Test privateKeyFromRecoveryKey & privateKeyFromPassphrase
115- //
116- // - Have Alice with cross-signing bootstrapped
117- // - Create a recovery with a passphrase
118- // -> privateKeyFromRecoveryKey must return the same private key
119- // -> privateKeyFromPassphrase must return the same private key
120- - (void )testPrivateKeyTools
121- {
122- // - Have Alice with cross-signing bootstrapped
123- [self doTestWithAliceWithCrossSigning: self readyToTest: ^(MXSession *aliceSession, NSString *roomId, XCTestExpectation *expectation) {
124-
125- MXRecoveryService *recoveryService = aliceSession.crypto .recoveryService ;
126-
127- // - Create a recovery with a passphrase
128- NSString *passphrase = @" A passphrase" ;
129- [recoveryService createRecoveryForSecrets: nil withPassphrase: passphrase createServicesBackups: NO success: ^(MXSecretStorageKeyCreationInfo * _Nonnull keyCreationInfo) {
130-
131- // -> privateKeyFromRecoveryKey must return the same private key
132- NSError *error;
133- NSData *privateKeyFromRecoveryKey = [recoveryService privateKeyFromRecoveryKey: keyCreationInfo.recoveryKey error: &error];
134- XCTAssertNil (error);
135- XCTAssertEqualObjects (privateKeyFromRecoveryKey, keyCreationInfo.privateKey );
136-
137- // -> privateKeyFromPassphrase must return the same private key
138- [recoveryService privateKeyFromPassphrase: passphrase success: ^(NSData * _Nonnull privateKey) {
139-
140- XCTAssertEqualObjects (privateKey, keyCreationInfo.privateKey );
141-
142- [expectation fulfill ];
143- } failure: ^(NSError * _Nonnull error) {
144- XCTFail (@" The operation should not fail - NSError: %@ " , error);
145- [expectation fulfill ];
146- }];
147-
148- } failure: ^(NSError * _Nonnull error) {
149- XCTFail (@" The operation should not fail - NSError: %@ " , error);
150- [expectation fulfill ];
151- }];
152- }];
153- }
154-
155114
156115// Test bad recovery key string format
157116//
@@ -179,55 +138,6 @@ - (void)testBadRecoveryKeyFormat
179138 }];
180139}
181140
182- // Test wrong private key
183- //
184- // - Have Alice with cross-signing bootstrapped
185- // - Create a recovery with a passphrase
186- // - Build a bad recovery key from a bad passphrase
187- // - Try to recover with this bad key
188- // -> It must error with expected NSError domain and code
189- - (void )testWrongRecoveryKey
190- {
191- // - Have Alice with cross-signing bootstrapped
192- [self doTestWithAliceWithCrossSigning: self readyToTest: ^(MXSession *aliceSession, NSString *roomId, XCTestExpectation *expectation) {
193-
194- MXRecoveryService *recoveryService = aliceSession.crypto .recoveryService ;
195-
196- // - Create a recovery with a passphrase
197- [recoveryService createRecoveryForSecrets: nil withPassphrase: @" A passphrase" createServicesBackups: NO success: ^(MXSecretStorageKeyCreationInfo * _Nonnull keyCreationInfo) {
198-
199- // - Build a bad recovery key from a bad passphrase
200- [recoveryService privateKeyFromPassphrase: @" A bad passphrase" success: ^(NSData * _Nonnull badPrivateKey) {
201-
202- // - Try to recover with this bad key
203- [recoveryService recoverSecrets: nil withPrivateKey: badPrivateKey recoverServices: NO success: ^(MXSecretRecoveryResult * _Nonnull recoveryResult) {
204-
205- XCTFail (@" The operation should not succeed" );
206- [expectation fulfill ];
207-
208- } failure: ^(NSError * _Nonnull error) {
209-
210- // -> It must error with expected NSError domain and code
211- XCTAssertNotNil (error);
212- XCTAssertEqualObjects (error.domain , MXRecoveryServiceErrorDomain);
213- XCTAssertEqual (error.code , MXRecoveryServiceBadRecoveryKeyErrorCode);
214-
215- [expectation fulfill ];
216- }];
217-
218- } failure: ^(NSError * _Nonnull error) {
219- XCTFail (@" The operation should not fail - NSError: %@ " , error);
220- [expectation fulfill ];
221- }];
222-
223- } failure: ^(NSError * _Nonnull error) {
224- XCTFail (@" The operation should not fail - NSError: %@ " , error);
225- [expectation fulfill ];
226- }];
227- }];
228- }
229-
230-
231141// Test createRecoveryForSecrets when there is already a key backup with the private key stored locally
232142//
233143// - Have Alice with cross-signing and key backup bootstrapped
0 commit comments