Skip to content

Commit 358362b

Browse files
committed
Merge branch 'release/2.6.6'
2 parents 6f462dd + 56fb7e0 commit 358362b

File tree

5 files changed

+86
-8
lines changed

5 files changed

+86
-8
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
### Security Architecture
1717

18-
For more information on the security details, visit [cryptomator.org](https://cryptomator.org/architecture/).
18+
For more information on the security details, visit [docs.cryptomator.org](https://docs.cryptomator.org/en/latest/security/architecture/).
1919

2020
## Audits
2121

@@ -33,9 +33,14 @@ For more information on the security details, visit [cryptomator.org](https://cr
3333
```java
3434
Path storageLocation = Paths.get("/home/cryptobot/vault");
3535
Files.createDirectories(storageLocation);
36-
CryptoFileSystemProvider.initialize(storageLocation, "masterkey.cryptomator", "password");
36+
Masterkey masterkey = Masterkey.generate(csprng));
37+
MasterkeyLoader loader = ignoredUri -> masterkey.copy(); //create a copy because the key handed over to init() method will be destroyed
38+
CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties().withKeyLoader(loader).build();
39+
CryptoFileSystemProvider.initialize(storageLocation, fsProps, "myKeyId");
3740
```
3841

42+
The key material used for initialization and later de- & encryption is given by the [org.cryptomator.cryptolib.api.Masterkeyloader](https://github.com/cryptomator/cryptolib/blob/2.1.2/src/main/java/org/cryptomator/cryptolib/api/MasterkeyLoader.java) interface.
43+
3944
### Obtaining a FileSystem Instance
4045

4146
You have the option to use the convenience method `CryptoFileSystemProvider#newFileSystem` as follows:
@@ -44,7 +49,7 @@ You have the option to use the convenience method `CryptoFileSystemProvider#newF
4449
FileSystem fileSystem = CryptoFileSystemProvider.newFileSystem(
4550
storageLocation,
4651
CryptoFileSystemProperties.cryptoFileSystemProperties()
47-
.withPassphrase("password")
52+
.withKeyLoader(ignoredUri -> masterkey.copy())
4853
.withFlags(FileSystemFlags.READONLY) // readonly flag is optional of course
4954
.build());
5055
```
@@ -56,7 +61,7 @@ URI uri = CryptoFileSystemUri.create(storageLocation);
5661
FileSystem fileSystem = FileSystems.newFileSystem(
5762
uri,
5863
CryptoFileSystemProperties.cryptoFileSystemProperties()
59-
.withPassphrase("password")
64+
.withKeyLoader(ignoredUri -> masterkey.copy())
6065
.withFlags(FileSystemFlags.READONLY) // readonly flag is optional of course
6166
.build());
6267
```

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.cryptomator</groupId>
44
<artifactId>cryptofs</artifactId>
5-
<version>2.6.5</version>
5+
<version>2.6.6</version>
66
<name>Cryptomator Crypto Filesystem</name>
77
<description>This library provides the Java filesystem provider used by Cryptomator.</description>
88
<url>https://github.com/cryptomator/cryptofs</url>
@@ -19,7 +19,7 @@
1919

2020
<!-- dependencies -->
2121
<cryptolib.version>2.1.2</cryptolib.version>
22-
<jwt.version>4.3.0</jwt.version>
22+
<jwt.version>4.4.0</jwt.version>
2323
<dagger.version>2.44.2</dagger.version>
2424
<guava.version>32.0.0-jre</guava.version>
2525
<caffeine.version>3.1.4</caffeine.version>

src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ private void moveFile(CryptoPath cleartextSource, CryptoPath cleartextTarget, Co
599599
CiphertextFilePath ciphertextTarget = cryptoPathMapper.getCiphertextFilePath(cleartextTarget);
600600
try (OpenCryptoFiles.TwoPhaseMove twoPhaseMove = openCryptoFiles.prepareMove(ciphertextSource.getRawPath(), ciphertextTarget.getRawPath())) {
601601
if (ciphertextTarget.isShortened()) {
602-
Files.createDirectory(ciphertextTarget.getRawPath());
602+
Files.createDirectories(ciphertextTarget.getRawPath());
603603
ciphertextTarget.persistLongFileName();
604604
}
605605
Files.move(ciphertextSource.getFilePath(), ciphertextTarget.getFilePath(), options);

src/test/java/org/cryptomator/cryptofs/CryptoFileSystemProviderIntegrationTest.java

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
import java.nio.file.attribute.BasicFileAttributes;
6363
import java.nio.file.attribute.DosFileAttributeView;
6464
import java.util.Arrays;
65+
import java.util.Comparator;
6566
import java.util.EnumSet;
67+
import java.util.Set;
6668

6769
import static java.nio.file.Files.readAllBytes;
6870
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
@@ -170,7 +172,7 @@ public void testCopyExceedingPathLengthLimit(String path) {
170172
@Nested
171173
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
172174
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
173-
public class InMemory {
175+
public class InMemoryOrdered {
174176

175177
private FileSystem tmpFs;
176178
private MasterkeyLoader keyLoader1;
@@ -587,6 +589,68 @@ public void testMoveFileFromOneCryptoFileSystemToAnother() throws IOException {
587589

588590
}
589591

592+
593+
@Nested
594+
public class InMemory {
595+
596+
private static FileSystem tmpFs;
597+
private static Path pathToVault;
598+
599+
@BeforeAll
600+
public static void beforeAll() {
601+
tmpFs = Jimfs.newFileSystem(Configuration.unix());
602+
pathToVault = tmpFs.getPath("/vault");
603+
}
604+
605+
@BeforeEach
606+
public void beforeEach() throws IOException {
607+
Files.createDirectory(pathToVault);
608+
}
609+
610+
@AfterEach
611+
public void afterEach() throws IOException {
612+
try (var paths = Files.walk(pathToVault)) {
613+
var nodes = paths.sorted(Comparator.reverseOrder()).toList();
614+
for (var node : nodes) {
615+
Files.delete(node);
616+
}
617+
}
618+
}
619+
620+
@AfterAll
621+
public static void afterAll() throws IOException {
622+
tmpFs.close();
623+
}
624+
625+
@Test
626+
@DisplayName("Replace an existing, shortened file")
627+
public void testReplaceExistingShortenedFile() throws IOException {
628+
try (var fs = setupCryptoFs(50, 100, false)) {
629+
var fiftyCharName2 = "/50char2_50char2_50char2_50char2_50char2_50char.txt"; //since filename encryption increases filename length, 50 cleartext chars are sufficient
630+
var source = fs.getPath("/source.txt");
631+
var target = fs.getPath(fiftyCharName2);
632+
Files.createFile(source);
633+
Files.createFile(target);
634+
635+
Assertions.assertDoesNotThrow(() -> Files.move(source, target, REPLACE_EXISTING));
636+
Assertions.assertTrue(Files.notExists(source));
637+
Assertions.assertTrue(Files.exists(target));
638+
}
639+
}
640+
641+
private FileSystem setupCryptoFs(int ciphertextShorteningThreshold, int maxCleartextFilename, boolean readonly) throws IOException {
642+
byte[] key = new byte[64];
643+
Arrays.fill(key, (byte) 0x55);
644+
var keyLoader = Mockito.mock(MasterkeyLoader.class);
645+
Mockito.when(keyLoader.loadKey(Mockito.any())).thenAnswer(ignored -> new Masterkey(key));
646+
var properties = CryptoFileSystemProperties.cryptoFileSystemProperties().withKeyLoader(keyLoader).withShorteningThreshold(ciphertextShorteningThreshold).withMaxCleartextNameLength(maxCleartextFilename).withFlags(readonly ? Set.of(CryptoFileSystemProperties.FileSystemFlags.READONLY) : Set.of()).build();
647+
CryptoFileSystemProvider.initialize(pathToVault, properties, URI.create("test:key"));
648+
URI fsUri = CryptoFileSystemUri.create(pathToVault);
649+
return FileSystems.newFileSystem(fsUri, cryptoFileSystemProperties().withKeyLoader(keyLoader).build());
650+
}
651+
652+
}
653+
590654
@Nested
591655
@EnabledOnOs({OS.MAC, OS.LINUX})
592656
@TestInstance(TestInstance.Lifecycle.PER_CLASS)

suppression.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,13 @@
99
<cpe>cpe:/a:cryptomator:cryptomator</cpe>
1010
<cve>CVE-2022-25366</cve>
1111
</suppress>
12+
<suppress>
13+
<notes>
14+
<![CDATA[
15+
file name: jackson-databind-2.14.2.jar
16+
]]>
17+
</notes>
18+
<packageUrl regex="true">^pkg:maven/com\.fasterxml\.jackson\.core/jackson\-databind@.*$</packageUrl>
19+
<cve>CVE-2023-35116</cve>
20+
</suppress>
1221
</suppressions>

0 commit comments

Comments
 (0)