Skip to content

Commit 5136207

Browse files
committed
Directory id for root is derived from key material.
1 parent aca202b commit 5136207

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/UVFVault.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import ch.cyberduck.core.PathAttributes;
2121
import ch.cyberduck.core.Session;
2222
import ch.cyberduck.core.SimplePathPredicate;
23-
import ch.cyberduck.core.cryptomator.impl.CryptoDirectoryV7Provider;
23+
import ch.cyberduck.core.cryptomator.impl.CryptoDirectoryUVFProvider;
2424
import ch.cyberduck.core.cryptomator.impl.CryptoFilenameV7Provider;
2525
import ch.cyberduck.core.cryptomator.random.FastSecureRandomProvider;
2626
import ch.cyberduck.core.exception.BackgroundException;
@@ -84,7 +84,7 @@ public UVFVault load(final Session<?> session, final PasswordCallback prompt) th
8484
this.cryptor = provider.provide(masterKey, FastSecureRandomProvider.get().provide());
8585
this.fileNameCryptor = new CryptorCache(cryptor.fileNameCryptor(masterKey.firstRevision())); // TODO revision eventually depends on location - safe?
8686
this.filenameProvider = new CryptoFilenameV7Provider(Integer.MAX_VALUE); // TODO there is no shortening in UVF defined yet
87-
this.directoryProvider = new CryptoDirectoryV7Provider(vault, filenameProvider, fileNameCryptor);
87+
this.directoryProvider = new CryptoDirectoryUVFProvider(vault, filenameProvider, fileNameCryptor);
8888
this.nonceSize = 12;
8989
return this;
9090
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ch.cyberduck.core.cryptomator.impl;
2+
3+
/*
4+
* Copyright (c) 2002-2025 iterate GmbH. All rights reserved.
5+
* https://cyberduck.io/
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*/
17+
18+
import ch.cyberduck.core.Path;
19+
import ch.cyberduck.core.Session;
20+
import ch.cyberduck.core.SimplePathPredicate;
21+
import ch.cyberduck.core.cryptomator.CryptoFilename;
22+
import ch.cyberduck.core.cryptomator.CryptorCache;
23+
import ch.cyberduck.core.exception.BackgroundException;
24+
25+
public class CryptoDirectoryUVFProvider extends CryptoDirectoryV7Provider {
26+
27+
private final Path home;
28+
29+
public CryptoDirectoryUVFProvider(final Path vault, final CryptoFilename filenameProvider, final CryptorCache filenameCryptor) {
30+
super(vault, filenameProvider, filenameCryptor);
31+
this.home = vault;
32+
}
33+
34+
@Override
35+
protected byte[] toDirectoryId(final Session<?> session, final Path directory, final byte[] directoryId) throws BackgroundException {
36+
if(new SimplePathPredicate(home).test(directory)) {
37+
return directoryId;
38+
}
39+
return super.toDirectoryId(session, directory, directoryId);
40+
}
41+
}

cryptomator/src/main/java/ch/cyberduck/core/cryptomator/impl/CryptoDirectoryV6Provider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Path toEncrypted(final Session<?> session, final byte[] directoryId, fina
103103
throw new NotfoundException(directory.getAbsolute());
104104
}
105105

106-
private byte[] toDirectoryId(final Session<?> session, final Path directory, final byte[] directoryId) throws BackgroundException {
106+
protected byte[] toDirectoryId(final Session<?> session, final Path directory, final byte[] directoryId) throws BackgroundException {
107107
if(new SimplePathPredicate(home).test(directory)) {
108108
return ROOT_DIR_ID;
109109
}

0 commit comments

Comments
 (0)