Skip to content

Commit 1be7576

Browse files
CodinGhouloverheadhunter
authored andcommitted
support vault format 8
update cryptofs update README.md update build.yml to java 17
1 parent d014c24 commit 1be7576

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v2
1818
- uses: actions/setup-java@v1
1919
with:
20-
java-version: 14
20+
java-version: 17
2121
- uses: actions/cache@v1
2222
with:
2323
path: ~/.m2/repository

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# Cryptomator CLI
55

6-
This is a minimal command-line program that unlocks vaults of vault format 7.
6+
This is a minimal command-line program that unlocks vaults of vault format 8.
77
After the unlock the vault content can then be accessed via an embedded WebDAV server.
8-
The minium required Java version is JDK 11.
8+
The minium required Java version is JDK 17.
99

1010
## Disclaimer
1111

@@ -15,7 +15,7 @@ This project is in an early stage and not ready for production use. We recommend
1515

1616
Download the jar file via [GitHub Releases](https://github.com/cryptomator/cli/releases).
1717

18-
Cryptomator CLI requires that at least JDK 11 is present on your system.
18+
Cryptomator CLI requires that at least JDK 17 is present on your system.
1919

2020
```sh
2121
java -jar cryptomator-cli-x.y.z.jar \

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<url>https://github.com/cryptomator/cli</url>
99

1010
<properties>
11-
<cryptofs.version>1.9.10</cryptofs.version>
11+
<cryptofs.version>2.3.0</cryptofs.version>
1212
<webdav-nio.version>1.0.11</webdav-nio.version>
1313
<commons.cli.version>1.4</commons.cli.version>
1414
<logback.version>1.2.3</logback.version>
1515
<fuse-nio.version>1.2.4</fuse-nio.version>
1616

17-
<java.version>11</java.version>
17+
<java.version>17</java.version>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
</properties>
2020

src/main/java/org/cryptomator/cli/CryptomatorCli.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@
1515
import java.nio.file.Files;
1616
import java.nio.file.Path;
1717
import java.nio.file.Paths;
18+
import java.security.NoSuchAlgorithmException;
19+
import java.security.SecureRandom;
1820
import java.util.ArrayList;
1921
import java.util.Optional;
2022
import java.util.Set;
2123

24+
import com.google.common.base.Preconditions;
2225
import org.apache.commons.cli.ParseException;
2326
import org.cryptomator.cryptofs.CryptoFileSystemProperties;
2427
import org.cryptomator.cryptofs.CryptoFileSystemProvider;
28+
import org.cryptomator.cryptolib.common.MasterkeyFileAccess;
2529
import org.slf4j.Logger;
2630
import org.slf4j.LoggerFactory;
2731

2832
public class CryptomatorCli {
2933

3034
private static final Logger LOG = LoggerFactory.getLogger(CryptomatorCli.class);
3135

36+
private static final byte[] PEPPER = new byte[0];
37+
private static final String SCHEME = "masterkeyfile";
38+
3239
public static void main(String[] rawArgs) throws IOException {
3340
try {
3441
Args args = Args.parse(rawArgs);
@@ -71,12 +78,26 @@ private static void startup(Args args) throws IOException {
7178
Optional<WebDav> server = initWebDavServer(args);
7279
ArrayList<FuseMount> mounts = new ArrayList<>();
7380

81+
SecureRandom secureRandom;
82+
try {
83+
secureRandom = SecureRandom.getInstanceStrong();
84+
} catch (NoSuchAlgorithmException e) {
85+
throw new IllegalStateException("A strong algorithm must exist in every Java platform.", e);
86+
}
87+
MasterkeyFileAccess masterkeyFileAccess = new MasterkeyFileAccess(PEPPER, secureRandom);
88+
7489
for (String vaultName : args.getVaultNames()) {
7590
Path vaultPath = Paths.get(args.getVaultPath(vaultName));
7691
LOG.info("Unlocking vault \"{}\" located at {}", vaultName, vaultPath);
7792
String vaultPassword = args.getPasswordStrategy(vaultName).password();
7893
CryptoFileSystemProperties properties = CryptoFileSystemProperties.cryptoFileSystemProperties()
79-
.withPassphrase(vaultPassword).build();
94+
.withKeyLoader(keyId -> {
95+
Preconditions.checkArgument(SCHEME.equalsIgnoreCase(keyId.getScheme()), "Only supports keys with scheme " + SCHEME);
96+
Path keyFilePath = vaultPath.resolve(keyId.getSchemeSpecificPart());
97+
return masterkeyFileAccess.load(keyFilePath, vaultPassword);
98+
})
99+
.build();
100+
80101
Path vaultRoot = CryptoFileSystemProvider.newFileSystem(vaultPath, properties).getPath("/");
81102

82103
Path fuseMountPoint = args.getFuseMountPoint(vaultName);

0 commit comments

Comments
 (0)