mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-02 12:16:53 +00:00
Require UAKs to be non-zero length or null
This commit is contained in:
1 parent
2344d3d9b7
commit
b551e0cb34
7 files changed
+44
-19
No files matched your search
@@ -16,6 +16,9 @@ public class Anonymous {
|
||||
public Anonymous(String header) {
|
||||
try {
|
||||
this.unidentifiedSenderAccessKey = Base64.getDecoder().decode(header);
|
||||
if (unidentifiedSenderAccessKey.length != UnidentifiedAccessUtil.UNIDENTIFIED_ACCESS_KEY_LENGTH) {
|
||||
throw new WebApplicationException("access key length must be 16", Response.Status.UNAUTHORIZED);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WebApplicationException(e, Response.Status.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public class Account {
|
||||
private String registrationLockSalt;
|
||||
|
||||
@JsonProperty("uak")
|
||||
@Nullable
|
||||
private byte[] unidentifiedAccessKey;
|
||||
|
||||
@JsonProperty("uua")
|
||||
@@ -432,7 +433,9 @@ public class Account {
|
||||
public Optional<byte[]> getUnidentifiedAccessKey() {
|
||||
requireNotStale();
|
||||
|
||||
return Optional.ofNullable(unidentifiedAccessKey);
|
||||
return Optional.ofNullable((unidentifiedAccessKey == null || unidentifiedAccessKey.length == 0)
|
||||
? null
|
||||
: unidentifiedAccessKey);
|
||||
}
|
||||
|
||||
public void setUnidentifiedAccessKey(final byte[] unidentifiedAccessKey) {
|
||||
|
||||
Reference in new issue
Block a user