Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 414aeb1

Browse files
renamed JWT claims according to Cryptomator's vault config specification
1 parent ddcf4c8 commit 414aeb1

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/main/java/org/cryptomator/cloudaccess/CloudAccess.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ private static void verifyVaultFormat8GCMConfig(CloudProvider cloudProvider, Clo
7373
var vaultConfigPath = pathToVault.resolve("vaultconfig.jwt");
7474
var algorithm = Algorithm.HMAC256(rawKey);
7575
var verifier = JWT.require(algorithm)
76-
.withClaim("version", 8)
77-
.withClaim("ciphermode", "SIV_GCM")
76+
.withClaim("format", 8)
77+
.withClaim("cipherCombo", "SIV_GCM")
7878
.build();
7979

8080
var read = cloudProvider.read(vaultConfigPath, ProgressListener.NO_PROGRESS_AWARE);
@@ -85,7 +85,7 @@ private static void verifyVaultFormat8GCMConfig(CloudProvider cloudProvider, Clo
8585
} catch (SignatureVerificationException e) {
8686
throw new VaultKeyVerificationFailedException(e);
8787
} catch (JWTVerificationException e) {
88-
if (e.getMessage().equals("The Claim 'version' value doesn't match the required one.")) {
88+
if (e.getMessage().equals("The Claim 'format' value doesn't match the required one.")) {
8989
throw new VaultVersionVerificationFailedException(e);
9090
} else {
9191
throw new VaultVerificationFailedException(e);

src/test/java/org/cryptomator/cloudaccess/vaultformat8/VaultFormat8IntegrationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongVaultVersion() {
7676
Algorithm algorithm = Algorithm.HMAC256(masterkey);
7777
var token = JWT.create()
7878
.withJWTId(UUID.randomUUID().toString())
79-
.withClaim("version", 9)
80-
.withClaim("ciphermode", "SIV_GCM")
79+
.withClaim("format", 9)
80+
.withClaim("cipherCombo", "SIV_GCM")
8181
.sign(algorithm);
8282
var in = new ByteArrayInputStream(token.getBytes(StandardCharsets.US_ASCII));
8383
localProvider.write(CloudPath.of("/vaultconfig.jwt"), false, in, in.available(), Optional.empty(), ProgressListener.NO_PROGRESS_AWARE).toCompletableFuture().join();
@@ -92,8 +92,8 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongCiphermode() {
9292
Algorithm algorithm = Algorithm.HMAC256(masterkey);
9393
var token = JWT.create()
9494
.withJWTId(UUID.randomUUID().toString())
95-
.withClaim("version", 8)
96-
.withClaim("ciphermode", "FOO")
95+
.withClaim("format", 8)
96+
.withClaim("cipherCombo", "FOO")
9797
.sign(algorithm);
9898
var in = new ByteArrayInputStream(token.getBytes(StandardCharsets.US_ASCII));
9999
localProvider.write(CloudPath.of("/vaultconfig.jwt"), false, in, in.available(), Optional.empty(), ProgressListener.NO_PROGRESS_AWARE).toCompletableFuture().join();
@@ -109,8 +109,8 @@ public void testInstantiateFormat8GCMCloudAccessWithWrongKey() {
109109
Algorithm algorithm = Algorithm.HMAC256(masterkey);
110110
var token = JWT.create()
111111
.withJWTId(UUID.randomUUID().toString())
112-
.withClaim("version", 8)
113-
.withClaim("ciphermode", "FOO")
112+
.withClaim("format", 8)
113+
.withClaim("cipherCombo", "FOO")
114114
.sign(algorithm);
115115
var in = new ByteArrayInputStream(token.getBytes(StandardCharsets.US_ASCII));
116116
localProvider.write(CloudPath.of("/vaultconfig.jwt"), false, in, in.available(), Optional.empty(), ProgressListener.NO_PROGRESS_AWARE).toCompletableFuture().join();

src/test/resources/vaultconfig.jwt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjaXBoZXJtb2RlIjoiU0lWX0dDTSIsInZlcnNpb24iOjgsImp0aSI6IjQwNDJiMTk5LTg5ZmItNDA1NC05NDJlLTc0MjEyODBjOTY1OSJ9.b_5phqmQogpsnVeU4tAcug2zuvh37XcYxieBK-L6ZTE
1+
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjaXBoZXJDb21ibyI6IlNJVl9HQ00iLCJmb3JtYXQiOjgsImp0aSI6IjExMTExMTExLTIyMjItMzMzMy00NDQ0LTU1NTU1NTU1NTU1NSJ9.3vSf-eTUoJU8AppBc_sn1TEiGhnUn3Ds_4qT9L0sQ6o

0 commit comments

Comments
 (0)