From 1e2d27585a2ccb37bff10d0a23bec527c5ef1f39 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Tue, 14 Apr 2026 10:07:54 -0500 Subject: [PATCH] Add gRPC size annotations; allow non-empty UAK for unrestricted --- .../textsecuregcm/entities/AccountAttributes.java | 5 ++--- service/src/main/proto/org/signal/chat/account.proto | 2 +- .../textsecuregcm/controllers/AccountControllerTest.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java index f1550a2b6..96375f7b6 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountAttributes.java @@ -139,9 +139,8 @@ public class AccountAttributes { @Schema(hidden = true) public boolean isUnrestrictedUakValid() { - final boolean valid = - (unrestrictedUnidentifiedAccess && (unidentifiedAccessKey == null || unidentifiedAccessKey.length == 0)) - || (!unrestrictedUnidentifiedAccess && (unidentifiedAccessKey != null + final boolean valid = unrestrictedUnidentifiedAccess || + (!unrestrictedUnidentifiedAccess && (unidentifiedAccessKey != null && unidentifiedAccessKey.length == 16)); Metrics.counter(UAK_VALIDATION_COUNTER_NAME, diff --git a/service/src/main/proto/org/signal/chat/account.proto b/service/src/main/proto/org/signal/chat/account.proto index aa1a3aa31..55ce0737a 100644 --- a/service/src/main/proto/org/signal/chat/account.proto +++ b/service/src/main/proto/org/signal/chat/account.proto @@ -197,7 +197,7 @@ message ConfigureUnidentifiedAccessRequest { // anonymously (i.e. to retrieve keys or profiles or to send messages) unless // unrestricted unidentified access is permitted. Must be present if // unrestricted unidentified access is not allowed. - bytes unidentified_access_key = 1; + bytes unidentified_access_key = 1 [(require.exactlySize) = 0, (require.exactlySize) = 16]; // If `true`, any user may interact with this account anonymously without // providing an unidentified access key. Otherwise, users must provide the diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java index f239a3c99..592d315f3 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/AccountControllerTest.java @@ -802,7 +802,7 @@ class AccountControllerTest { Arguments.argumentSet("restricted, non-empty UAK", false, new byte[16], 204), Arguments.argumentSet("unrestricted, empty UAK", true, new byte[0], 204), Arguments.argumentSet("restricted, empty UAK", false, new byte[0], 422), - Arguments.argumentSet("unrestricted, non-empty UAK", true, new byte[16], 422) + Arguments.argumentSet("unrestricted, non-empty UAK", true, new byte[16], 204) ); }