Require that unidentified access keys be exactly 16 bytes
This commit is contained in:
parent
966d4e29d4
commit
e6237480f8
|
@ -544,6 +544,7 @@ public class AccountController {
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/attributes/")
|
@Path("/attributes/")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@ChangesDeviceEnabledState
|
@ChangesDeviceEnabledState
|
||||||
public void setAccountAttributes(@Auth DisabledPermittedAuthenticatedAccount disabledPermittedAuth,
|
public void setAccountAttributes(@Auth DisabledPermittedAuthenticatedAccount disabledPermittedAuth,
|
||||||
@HeaderParam("X-Signal-Agent") String userAgent,
|
@HeaderParam("X-Signal-Agent") String userAgent,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import org.whispersystems.textsecuregcm.storage.Device.DeviceCapabilities;
|
import org.whispersystems.textsecuregcm.storage.Device.DeviceCapabilities;
|
||||||
|
import org.whispersystems.textsecuregcm.util.ExactlySize;
|
||||||
|
|
||||||
public class AccountAttributes {
|
public class AccountAttributes {
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ public class AccountAttributes {
|
||||||
private String registrationLock;
|
private String registrationLock;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ExactlySize({0, 16})
|
||||||
private byte[] unidentifiedAccessKey;
|
private byte[] unidentifiedAccessKey;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -80,4 +82,9 @@ public class AccountAttributes {
|
||||||
public boolean isDiscoverableByPhoneNumber() {
|
public boolean isDiscoverableByPhoneNumber() {
|
||||||
return discoverableByPhoneNumber;
|
return discoverableByPhoneNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public void setUnidentifiedAccessKey(final byte[] unidentifiedAccessKey) {
|
||||||
|
this.unidentifiedAccessKey = unidentifiedAccessKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1673,6 +1673,21 @@ class AccountControllerTest {
|
||||||
assertThat(response.getStatus()).isEqualTo(204);
|
assertThat(response.getStatus()).isEqualTo(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSetAccountAttributesBadUnidentifiedKeyLength() {
|
||||||
|
final AccountAttributes attributes = new AccountAttributes(false, 2222, null, null, false, null);
|
||||||
|
attributes.setUnidentifiedAccessKey(new byte[7]);
|
||||||
|
|
||||||
|
Response response =
|
||||||
|
resources.getJerseyTest()
|
||||||
|
.target("/v1/accounts/attributes/")
|
||||||
|
.request()
|
||||||
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||||
|
.put(Entity.json(attributes));
|
||||||
|
|
||||||
|
assertThat(response.getStatus()).isEqualTo(422);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDeleteAccount() throws InterruptedException {
|
void testDeleteAccount() throws InterruptedException {
|
||||||
Response response =
|
Response response =
|
||||||
|
|
Loading…
Reference in New Issue