Create a new manage profile screen.

This commit is contained in:
Greyson Parrelli
2021-01-14 13:05:03 -05:00
parent 7e64d57ba8
commit 8ca54bcc7b
30 changed files with 1004 additions and 158 deletions

View File

@@ -7,9 +7,11 @@ import org.conscrypt.Conscrypt;
import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.profiles.ProfileKey;
import org.whispersystems.signalservice.internal.util.Util;
import org.whispersystems.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.security.Security;
public class ProfileCipherTest extends TestCase {
@@ -21,7 +23,7 @@ public class ProfileCipherTest extends TestCase {
public void testEncryptDecrypt() throws InvalidCiphertextException, InvalidInputException {
ProfileKey key = new ProfileKey(Util.getSecretBytes(32));
ProfileCipher cipher = new ProfileCipher(key);
byte[] name = cipher.encryptName("Clement\0Duval".getBytes(), ProfileCipher.NAME_PADDED_LENGTH);
byte[] name = cipher.encryptName("Clement\0Duval".getBytes(), 53);
byte[] plaintext = cipher.decryptName(name);
assertEquals(new String(plaintext), "Clement\0Duval");
}
@@ -59,4 +61,29 @@ public class ProfileCipherTest extends TestCase {
assertEquals(new String(result.toByteArray()), "This is an avatar");
}
public void testEncryptLengthBucket1() throws InvalidInputException {
ProfileKey key = new ProfileKey(Util.getSecretBytes(32));
ProfileCipher cipher = new ProfileCipher(key);
byte[] name = cipher.encryptName("Peter\0Parker".getBytes(), 53);
String encoded = Base64.encodeBytes(name);
assertEquals(108, encoded.length());
}
public void testEncryptLengthBucket2() throws InvalidInputException {
ProfileKey key = new ProfileKey(Util.getSecretBytes(32));
ProfileCipher cipher = new ProfileCipher(key);
byte[] name = cipher.encryptName("Peter\0Parker".getBytes(), 257);
String encoded = Base64.encodeBytes(name);
assertEquals(380, encoded.length());
}
public void testTargetNameLength() {
assertEquals(53, ProfileCipher.getTargetNameLength("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"));
assertEquals(53, ProfileCipher.getTargetNameLength("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1"));
assertEquals(257, ProfileCipher.getTargetNameLength("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12"));
}
}