mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-29 05:04:54 +01:00
Unify our Base64 utilities.
This commit is contained in:
committed by
Cody Henthorne
parent
e636e38ba1
commit
4fe6d79fff
@@ -30,7 +30,7 @@ import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||
|
||||
@@ -9,7 +9,7 @@ import androidx.annotation.Nullable;
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.InvalidMessageStructureException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
@@ -108,7 +108,7 @@ public class PointerAttachment extends Attachment {
|
||||
String encodedKey = null;
|
||||
|
||||
if (pointer.get().asPointer().getKey() != null) {
|
||||
encodedKey = Base64.encodeBytes(pointer.get().asPointer().getKey());
|
||||
encodedKey = Base64.encodeWithPadding(pointer.get().asPointer().getKey());
|
||||
}
|
||||
|
||||
return Optional.of(new PointerAttachment(pointer.get().getContentType(),
|
||||
@@ -144,7 +144,7 @@ public class PointerAttachment extends Attachment {
|
||||
pointer.getFileName(),
|
||||
thumbnail != null ? thumbnail.asPointer().getCdnNumber() : 0,
|
||||
thumbnail != null ? thumbnail.asPointer().getRemoteId().toString() : "0",
|
||||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeBytes(thumbnail.asPointer().getKey()) : null,
|
||||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeWithPadding(thumbnail.asPointer().getKey()) : null,
|
||||
null,
|
||||
thumbnail != null ? thumbnail.asPointer().getDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getIncrementalDigest().orElse(null) : null,
|
||||
@@ -175,7 +175,7 @@ public class PointerAttachment extends Attachment {
|
||||
quotedAttachment.fileName,
|
||||
thumbnail != null ? thumbnail.asPointer().getCdnNumber() : 0,
|
||||
thumbnail != null ? thumbnail.asPointer().getRemoteId().toString() : "0",
|
||||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeBytes(thumbnail.asPointer().getKey()) : null,
|
||||
thumbnail != null && thumbnail.asPointer().getKey() != null ? Base64.encodeWithPadding(thumbnail.asPointer().getKey()) : null,
|
||||
null,
|
||||
thumbnail != null ? thumbnail.asPointer().getDigest().orElse(null) : null,
|
||||
thumbnail != null ? thumbnail.asPointer().getIncrementalDigest().orElse(null) : null,
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.AudioWaveFormData;
|
||||
import org.thoughtcrime.securesms.util.ParcelUtil;
|
||||
import org.whispersystems.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
@@ -27,7 +27,7 @@ public final class AudioHash implements Parcelable {
|
||||
}
|
||||
|
||||
public AudioHash(@NonNull AudioWaveFormData audioWaveForm) {
|
||||
this(Base64.encodeBytes(audioWaveForm.encode()), audioWaveForm);
|
||||
this(Base64.encodeWithPadding(audioWaveForm.encode()), audioWaveForm);
|
||||
}
|
||||
|
||||
protected AudioHash(Parcel in) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.thoughtcrime.securesms.badges.gifts
|
||||
|
||||
import android.content.Context
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException
|
||||
import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialPresentation
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GiftBadge
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import java.lang.Integer.min
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -32,7 +32,7 @@ object Gifts {
|
||||
): OutgoingMessage {
|
||||
return OutgoingMessage(
|
||||
threadRecipient = recipient,
|
||||
body = Base64.encodeBytes(giftBadge.encode()),
|
||||
body = Base64.encodeWithPadding(giftBadge.encode()),
|
||||
isSecure = true,
|
||||
sentTimeMillis = sentTimestamp,
|
||||
expiresIn = expiresIn,
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Hex
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.core.util.isAbsent
|
||||
@@ -27,7 +28,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.subscription.Subscriber
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.SpanUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
@@ -110,7 +110,7 @@ class InternalConversationSettingsFragment : DSLSettingsFragment(
|
||||
summary = DSLSettingsText.from("[${recipient.profileName.givenName}] [${state.recipient.profileName.familyName}]")
|
||||
)
|
||||
|
||||
val profileKeyBase64 = recipient.profileKey?.let(Base64::encodeBytes) ?: "None"
|
||||
val profileKeyBase64 = recipient.profileKey?.let(Base64::encodeWithPadding) ?: "None"
|
||||
longClickPref(
|
||||
title = DSLSettingsText.from("Profile Key (Base64)"),
|
||||
summary = DSLSettingsText.from(profileKeyBase64),
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.StreamUtil
|
||||
import org.signal.core.util.concurrent.MaybeCompat
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
@@ -41,7 +42,6 @@ import org.thoughtcrime.securesms.mms.SlideFactory
|
||||
import org.thoughtcrime.securesms.mms.StickerSlide
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor
|
||||
import org.thoughtcrime.securesms.util.hasTextSlide
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import io.reactivex.rxjava3.core.Maybe
|
||||
import org.signal.core.util.Base64
|
||||
import org.thoughtcrime.securesms.components.location.SignalPlace
|
||||
import org.thoughtcrime.securesms.database.DraftTable.Draft
|
||||
import org.thoughtcrime.securesms.database.MentionUtil
|
||||
@@ -12,7 +13,6 @@ import org.thoughtcrime.securesms.database.model.MessageId
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.mms.QuoteId
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
|
||||
/**
|
||||
@@ -148,5 +148,5 @@ private fun String.toTextDraft(): Draft? {
|
||||
}
|
||||
|
||||
private fun BodyRangeList.toDraft(): Draft {
|
||||
return Draft(Draft.BODY_RANGES, Base64.encodeBytes(encode()))
|
||||
return Draft(Draft.BODY_RANGES, Base64.encodeWithPadding(encode()))
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.signal.libsignal.protocol.ecc.Curve;
|
||||
import org.signal.libsignal.protocol.ecc.ECKeyPair;
|
||||
import org.signal.libsignal.protocol.ecc.ECPrivateKey;
|
||||
import org.signal.libsignal.protocol.ecc.ECPublicKey;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -99,7 +99,7 @@ public class AsymmetricMasterCipher {
|
||||
}
|
||||
|
||||
public String encryptBody(String body) {
|
||||
return Base64.encodeBytes(encryptBytes(body.getBytes()));
|
||||
return Base64.encodeWithPadding(encryptBytes(body.getBytes()));
|
||||
}
|
||||
|
||||
private MasterCipher getMasterCipherForSecret(byte[] secretBytes) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.protocol.InvalidMessageException;
|
||||
import org.signal.libsignal.protocol.ecc.Curve;
|
||||
import org.signal.libsignal.protocol.ecc.ECPrivateKey;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.Hex;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -153,7 +153,7 @@ public class MasterCipher {
|
||||
|
||||
private String encryptAndEncodeBytes(@NonNull byte[] bytes) {
|
||||
byte[] encryptedAndMacBody = encryptBytes(bytes);
|
||||
return Base64.encodeBytes(encryptedAndMacBody);
|
||||
return Base64.encodeWithPadding(encryptedAndMacBody);
|
||||
}
|
||||
|
||||
private byte[] verifyMacBody(@NonNull Mac hmac, @NonNull byte[] encryptedAndMac) throws InvalidMessageException {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.signal.libsignal.protocol.ecc.Curve;
|
||||
import org.signal.libsignal.protocol.ecc.ECKeyPair;
|
||||
import org.signal.libsignal.protocol.ecc.ECPrivateKey;
|
||||
import org.signal.libsignal.protocol.ecc.ECPublicKey;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -216,7 +216,7 @@ public class MasterSecretUtil {
|
||||
private static void save(Context context, String key, byte[] value) {
|
||||
if (!getSharedPreferences(context)
|
||||
.edit()
|
||||
.putString(key, Base64.encodeBytes(value))
|
||||
.putString(key, Base64.encodeWithPadding(value))
|
||||
.commit())
|
||||
{
|
||||
throw new AssertionError("failed to save a shared pref in MasterSecretUtil");
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.thoughtcrime.securesms.keyvalue.PhoneNumberPrivacyValues;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.CursorExtensionsKt;
|
||||
import org.signal.core.util.CursorUtil;
|
||||
import org.signal.core.util.SQLiteDatabaseExtensionsKt;
|
||||
@@ -60,7 +61,6 @@ import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.mms.SentMediaQuality;
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.FileUtils;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@@ -1189,7 +1189,7 @@ public class AttachmentTable extends DatabaseTable {
|
||||
DigestInputStream digestInputStream = new DigestInputStream(in, messageDigest);
|
||||
Pair<byte[], OutputStream> out = ModernEncryptingPartOutputStream.createFor(attachmentSecret, tempFile, false);
|
||||
long length = StreamUtil.copy(digestInputStream, out.second);
|
||||
String hash = Base64.encodeBytes(digestInputStream.getMessageDigest().digest());
|
||||
String hash = Base64.encodeWithPadding(digestInputStream.getMessageDigest().digest());
|
||||
|
||||
if (!tempFile.renameTo(destination)) {
|
||||
Log.w(TAG, "Couldn't rename " + tempFile.getPath() + " to " + destination.getPath());
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.delete
|
||||
@@ -23,7 +24,6 @@ import org.thoughtcrime.securesms.database.model.StoryType
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.storage.StorageRecordUpdate
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.push.DistributionId
|
||||
import org.whispersystems.signalservice.api.storage.SignalStoryDistributionListRecord
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil
|
||||
@@ -55,7 +55,7 @@ class DistributionListTables constructor(context: Context?, databaseHelper: Sign
|
||||
contentValuesOf(
|
||||
RecipientTable.TYPE to RecipientTable.RecipientType.DISTRIBUTION_LIST.id,
|
||||
RecipientTable.DISTRIBUTION_LIST_ID to DistributionListId.MY_STORY_ID,
|
||||
RecipientTable.STORAGE_SERVICE_ID to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
RecipientTable.STORAGE_SERVICE_ID to Base64.encodeWithPadding(StorageSyncHelper.generateKey()),
|
||||
RecipientTable.PROFILE_SHARING to 1
|
||||
)
|
||||
)
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.thoughtcrime.securesms.database
|
||||
import android.content.Context
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.delete
|
||||
import org.signal.core.util.exists
|
||||
import org.signal.core.util.firstOrNull
|
||||
@@ -38,7 +39,6 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil
|
||||
@@ -146,7 +146,7 @@ class IdentityTable internal constructor(context: Context?, databaseHelper: Sign
|
||||
val updated = writableDatabase
|
||||
.update(TABLE_NAME)
|
||||
.values(VERIFIED to verifiedStatus.toInt())
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ?", addressName, Base64.encodeBytes(identityKey.serialize()))
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ?", addressName, Base64.encodeWithPadding(identityKey.serialize()))
|
||||
.run()
|
||||
|
||||
if (updated > 0) {
|
||||
@@ -211,14 +211,14 @@ class IdentityTable internal constructor(context: Context?, databaseHelper: Sign
|
||||
private fun hasMatchingKey(addressName: String, identityKey: IdentityKey): Boolean {
|
||||
return readableDatabase
|
||||
.exists(TABLE_NAME)
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ?", addressName, Base64.encodeBytes(identityKey.serialize()))
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ?", addressName, Base64.encodeWithPadding(identityKey.serialize()))
|
||||
.run()
|
||||
}
|
||||
|
||||
private fun hasMatchingStatus(addressName: String, identityKey: IdentityKey, verifiedStatus: VerifiedStatus): Boolean {
|
||||
return readableDatabase
|
||||
.exists(TABLE_NAME)
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ? AND $VERIFIED = ?", addressName, Base64.encodeBytes(identityKey.serialize()), verifiedStatus.toInt())
|
||||
.where("$ADDRESS = ? AND $IDENTITY_KEY = ? AND $VERIFIED = ?", addressName, Base64.encodeWithPadding(identityKey.serialize()), verifiedStatus.toInt())
|
||||
.run()
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class IdentityTable internal constructor(context: Context?, databaseHelper: Sign
|
||||
) {
|
||||
val contentValues = contentValuesOf(
|
||||
ADDRESS to addressName,
|
||||
IDENTITY_KEY to Base64.encodeBytes(identityKey.serialize()),
|
||||
IDENTITY_KEY to Base64.encodeWithPadding(identityKey.serialize()),
|
||||
TIMESTAMP to timestamp,
|
||||
VERIFIED to verifiedStatus.toInt(),
|
||||
NONBLOCKING_APPROVAL to if (nonBlockingApproval) 1 else 0,
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.android.mms.pdu_alt.PduHeaders
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.SqlUtil.appendArg
|
||||
@@ -131,7 +132,6 @@ import org.thoughtcrime.securesms.revealable.ViewOnceUtil
|
||||
import org.thoughtcrime.securesms.sms.IncomingGroupUpdateMessage
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage
|
||||
import org.thoughtcrime.securesms.stories.Stories.isFeatureEnabled
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.JsonUtils
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
@@ -861,7 +861,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
DATE_RECEIVED to timestamp,
|
||||
DATE_SENT to timestamp,
|
||||
READ to if (markRead) 1 else 0,
|
||||
BODY to Base64.encodeBytes(updateDetails),
|
||||
BODY to Base64.encodeWithPadding(updateDetails),
|
||||
TYPE to MessageTypes.GROUP_CALL_TYPE,
|
||||
THREAD_ID to threadId
|
||||
)
|
||||
@@ -891,7 +891,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
|
||||
val updateDetail = GroupCallUpdateDetailsUtil.parse(message.body)
|
||||
val contentValues = contentValuesOf(
|
||||
BODY to Base64.encodeBytes(updateDetail.newBuilder().startedCallTimestamp(timestamp).build().encode()),
|
||||
BODY to Base64.encodeWithPadding(updateDetail.newBuilder().startedCallTimestamp(timestamp).build().encode()),
|
||||
DATE_SENT to timestamp,
|
||||
DATE_RECEIVED to timestamp
|
||||
)
|
||||
@@ -1179,7 +1179,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
READ to 1,
|
||||
TYPE to MessageTypes.PROFILE_CHANGE_TYPE,
|
||||
THREAD_ID to threadId,
|
||||
BODY to Base64.encodeBytes(profileChangeDetails)
|
||||
BODY to Base64.encodeWithPadding(profileChangeDetails)
|
||||
)
|
||||
db.insert(TABLE_NAME, null, values)
|
||||
notifyConversationListeners(threadId)
|
||||
@@ -1286,7 +1286,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
READ to 1,
|
||||
TYPE to MessageTypes.THREAD_MERGE_TYPE,
|
||||
THREAD_ID to threadId,
|
||||
BODY to Base64.encodeBytes(event.encode())
|
||||
BODY to Base64.encodeWithPadding(event.encode())
|
||||
)
|
||||
.run()
|
||||
ApplicationDependencies.getDatabaseObserver().notifyConversationListeners(threadId)
|
||||
@@ -1305,7 +1305,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
READ to 1,
|
||||
TYPE to MessageTypes.SESSION_SWITCHOVER_TYPE,
|
||||
THREAD_ID to threadId,
|
||||
BODY to Base64.encodeBytes(event.encode())
|
||||
BODY to Base64.encodeWithPadding(event.encode())
|
||||
)
|
||||
.run()
|
||||
ApplicationDependencies.getDatabaseObserver().notifyConversationListeners(threadId)
|
||||
@@ -2914,7 +2914,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
|
||||
updated = db
|
||||
.update(TABLE_NAME)
|
||||
.values(BODY to Base64.encodeBytes(updatedBadge.encode()))
|
||||
.values(BODY to Base64.encodeWithPadding(updatedBadge.encode()))
|
||||
.where("$ID = ?", messageId)
|
||||
.run() > 0
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.delete
|
||||
import org.signal.core.util.logging.Log
|
||||
@@ -11,7 +12,6 @@ import org.signal.libsignal.protocol.InvalidKeyException
|
||||
import org.signal.libsignal.protocol.ecc.Curve
|
||||
import org.signal.libsignal.protocol.ecc.ECKeyPair
|
||||
import org.signal.libsignal.protocol.state.PreKeyRecord
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
import java.io.IOException
|
||||
|
||||
@@ -62,8 +62,8 @@ class OneTimePreKeyTable(context: Context, databaseHelper: SignalDatabase) : Dat
|
||||
val contentValues = contentValuesOf(
|
||||
ACCOUNT_ID to serviceId.toString(),
|
||||
KEY_ID to keyId,
|
||||
PUBLIC_KEY to Base64.encodeBytes(record.keyPair.publicKey.serialize()),
|
||||
PRIVATE_KEY to Base64.encodeBytes(record.keyPair.privateKey.serialize())
|
||||
PUBLIC_KEY to Base64.encodeWithPadding(record.keyPair.publicKey.serialize()),
|
||||
PRIVATE_KEY to Base64.encodeWithPadding(record.keyPair.privateKey.serialize())
|
||||
)
|
||||
|
||||
writableDatabase.replace(TABLE_NAME, null, contentValues)
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.thoughtcrime.securesms.payments.Payment;
|
||||
import org.thoughtcrime.securesms.payments.State;
|
||||
import org.thoughtcrime.securesms.payments.proto.PaymentMetaData;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
|
||||
import org.whispersystems.signalservice.api.payments.Money;
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||
@@ -239,7 +239,7 @@ public final class PaymentTable extends DatabaseTable implements RecipientIdData
|
||||
}
|
||||
if (receipt != null) {
|
||||
values.put(RECEIPT, receipt);
|
||||
values.put(PUBLIC_KEY, Base64.encodeBytes(PaymentMetaDataUtil.receiptPublic(PaymentMetaDataUtil.fromReceipt(receipt))));
|
||||
values.put(PUBLIC_KEY, Base64.encodeWithPadding(PaymentMetaDataUtil.receiptPublic(PaymentMetaDataUtil.fromReceipt(receipt))));
|
||||
} else {
|
||||
values.putNull(RECEIPT);
|
||||
values.putNull(PUBLIC_KEY);
|
||||
@@ -468,7 +468,7 @@ public final class PaymentTable extends DatabaseTable implements RecipientIdData
|
||||
values.put(TRANSACTION, transaction);
|
||||
values.put(RECEIPT, receipt);
|
||||
try {
|
||||
values.put(PUBLIC_KEY, Base64.encodeBytes(PaymentMetaDataUtil.receiptPublic(PaymentMetaDataUtil.fromReceipt(receipt))));
|
||||
values.put(PUBLIC_KEY, Base64.encodeWithPadding(PaymentMetaDataUtil.receiptPublic(PaymentMetaDataUtil.fromReceipt(receipt))));
|
||||
values.put(META_DATA, PaymentMetaDataUtil.fromReceiptAndTransaction(receipt, transaction).encode());
|
||||
} catch (SerializationException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.annotation.VisibleForTesting
|
||||
import androidx.core.content.contentValuesOf
|
||||
import app.cash.exhaustive.Exhaustive
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Bitmask
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.SqlUtil
|
||||
@@ -93,7 +94,6 @@ import org.thoughtcrime.securesms.service.webrtc.links.CallLinkRoomId
|
||||
import org.thoughtcrime.securesms.storage.StorageRecordUpdate
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncModels
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.thoughtcrime.securesms.util.GroupUtil
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil
|
||||
@@ -530,7 +530,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
ContentValues().apply {
|
||||
put(TYPE, RecipientType.DISTRIBUTION_LIST.id)
|
||||
put(DISTRIBUTION_LIST_ID, distributionListId.serialize())
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(storageId ?: StorageSyncHelper.generateKey()))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(storageId ?: StorageSyncHelper.generateKey()))
|
||||
put(PROFILE_SHARING, 1)
|
||||
}
|
||||
).recipientId
|
||||
@@ -596,7 +596,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
} else {
|
||||
put(TYPE, RecipientType.GV1.id)
|
||||
}
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
|
||||
fun getByStorageId(storageId: ByteArray): RecipientRecord? {
|
||||
val result = getRecordForSync("$TABLE_NAME.$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(storageId)))
|
||||
val result = getRecordForSync("$TABLE_NAME.$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeWithPadding(storageId)))
|
||||
|
||||
return if (result.isNotEmpty()) {
|
||||
result[0]
|
||||
@@ -774,7 +774,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val query = "$ID = ?"
|
||||
for ((key, value) in storageIds) {
|
||||
val values = ContentValues().apply {
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(value.raw))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(value.raw))
|
||||
}
|
||||
db.update(TABLE_NAME, values, query, arrayOf(key.serialize()))
|
||||
}
|
||||
@@ -826,13 +826,13 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val values = getValuesForStorageContact(update.new, false)
|
||||
|
||||
try {
|
||||
val updateCount = db.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
|
||||
val updateCount = db.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeWithPadding(update.old.id.raw)))
|
||||
if (updateCount < 1) {
|
||||
throw AssertionError("Had an update, but it didn't match any rows!")
|
||||
}
|
||||
} catch (e: SQLiteConstraintException) {
|
||||
Log.w(TAG, "[applyStorageSyncContactUpdate] Failed to update a user by storageId.")
|
||||
var recipientId = getByColumn(STORAGE_SERVICE_ID, Base64.encodeBytes(update.old.id.raw)).get()
|
||||
var recipientId = getByColumn(STORAGE_SERVICE_ID, Base64.encodeWithPadding(update.old.id.raw)).get()
|
||||
|
||||
Log.w(TAG, "[applyStorageSyncContactUpdate] Found user $recipientId. Possibly merging.")
|
||||
recipientId = getAndPossiblyMergePnpVerified(update.new.aci.orElse(null), update.new.pni.orElse(null), update.new.number.orElse(null))
|
||||
@@ -885,7 +885,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
fun applyStorageSyncGroupV1Update(update: StorageRecordUpdate<SignalGroupV1Record>) {
|
||||
val values = getValuesForStorageGroupV1(update.new, false)
|
||||
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, STORAGE_SERVICE_ID + " = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, STORAGE_SERVICE_ID + " = ?", arrayOf(Base64.encodeWithPadding(update.old.id.raw)))
|
||||
if (updateCount < 1) {
|
||||
throw AssertionError("Had an update, but it didn't match any rows!")
|
||||
}
|
||||
@@ -929,7 +929,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
fun applyStorageSyncGroupV2Update(update: StorageRecordUpdate<SignalGroupV2Record>) {
|
||||
val values = getValuesForStorageGroupV2(update.new, false)
|
||||
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeWithPadding(update.old.id.raw)))
|
||||
if (updateCount < 1) {
|
||||
throw AssertionError("Had an update, but it didn't match any rows!")
|
||||
}
|
||||
@@ -951,7 +951,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val profileName = ProfileName.fromParts(update.new.givenName.orElse(null), update.new.familyName.orElse(null))
|
||||
val localKey = ProfileKeyUtil.profileKeyOptional(update.old.profileKey.orElse(null))
|
||||
val remoteKey = ProfileKeyUtil.profileKeyOptional(update.new.profileKey.orElse(null))
|
||||
val profileKey: String? = remoteKey.or(localKey).map { obj: ProfileKey -> obj.serialize() }.map { source: ByteArray? -> Base64.encodeBytes(source!!) }.orElse(null)
|
||||
val profileKey: String? = remoteKey.or(localKey).map { obj: ProfileKey -> obj.serialize() }.map { source: ByteArray? -> Base64.encodeWithPadding(source!!) }.orElse(null)
|
||||
if (!remoteKey.isPresent) {
|
||||
Log.w(TAG, "Got an empty profile key while applying an account record update! The parsed local key is ${if (localKey.isPresent) "present" else "not present"}. The raw local key is ${if (update.old.profileKey.isPresent) "present" else "not present"}. The resulting key is ${if (profileKey != null) "present" else "not present"}.")
|
||||
}
|
||||
@@ -968,10 +968,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
|
||||
put(USERNAME, update.new.username)
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(update.new.id.raw))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(update.new.id.raw))
|
||||
|
||||
if (update.new.hasUnknownFields()) {
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeBytes(Objects.requireNonNull(update.new.serializeUnknownFields())))
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeWithPadding(Objects.requireNonNull(update.new.serializeUnknownFields())))
|
||||
} else {
|
||||
putNull(STORAGE_SERVICE_PROTO)
|
||||
}
|
||||
@@ -985,7 +985,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
.run()
|
||||
}
|
||||
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeBytes(update.old.id.raw)))
|
||||
val updateCount = writableDatabase.update(TABLE_NAME, values, "$STORAGE_SERVICE_ID = ?", arrayOf(Base64.encodeWithPadding(update.old.id.raw)))
|
||||
if (updateCount < 1) {
|
||||
throw AssertionError("Account update didn't match any rows!")
|
||||
}
|
||||
@@ -1019,7 +1019,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val values = contentValuesOf(STORAGE_SERVICE_ID to null)
|
||||
var updated = 0
|
||||
|
||||
SqlUtil.buildCollectionQuery(STORAGE_SERVICE_ID, storageIds.map { Base64.encodeBytes(it.raw) }, "$UNREGISTERED_TIMESTAMP > 0 AND")
|
||||
SqlUtil.buildCollectionQuery(STORAGE_SERVICE_ID, storageIds.map { Base64.encodeWithPadding(it.raw) }, "$UNREGISTERED_TIMESTAMP > 0 AND")
|
||||
.forEach {
|
||||
updated += writableDatabase.update(TABLE_NAME, values, it.where, it.whereArgs)
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
private fun getByStorageKeyOrThrow(storageKey: ByteArray): RecipientId {
|
||||
val query = "$STORAGE_SERVICE_ID = ?"
|
||||
val args = arrayOf(Base64.encodeBytes(storageKey))
|
||||
val args = arrayOf(Base64.encodeWithPadding(storageKey))
|
||||
|
||||
readableDatabase.query(TABLE_NAME, ID_PROJECTION, query, args, null, null, null).use { cursor ->
|
||||
return if (cursor != null && cursor.moveToFirst()) {
|
||||
@@ -1500,7 +1500,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
fun setProfileKey(id: RecipientId, profileKey: ProfileKey): Boolean {
|
||||
val selection = "$ID = ?"
|
||||
val args = arrayOf(id.serialize())
|
||||
val encodedProfileKey = Base64.encodeBytes(profileKey.serialize())
|
||||
val encodedProfileKey = Base64.encodeWithPadding(profileKey.serialize())
|
||||
val valuesToCompare = ContentValues(1).apply {
|
||||
put(PROFILE_KEY, encodedProfileKey)
|
||||
}
|
||||
@@ -1537,7 +1537,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val selection = "$ID = ? AND $PROFILE_KEY is NULL"
|
||||
val args = arrayOf(id.serialize())
|
||||
val valuesToSet = ContentValues(3).apply {
|
||||
put(PROFILE_KEY, Base64.encodeBytes(profileKey.serialize()))
|
||||
put(PROFILE_KEY, Base64.encodeWithPadding(profileKey.serialize()))
|
||||
putNull(EXPIRING_PROFILE_KEY_CREDENTIAL)
|
||||
put(SEALED_SENDER_MODE, UnidentifiedAccessMode.UNKNOWN.mode)
|
||||
}
|
||||
@@ -1560,13 +1560,13 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
expiringProfileKeyCredential: ExpiringProfileKeyCredential
|
||||
): Boolean {
|
||||
val selection = "$ID = ? AND $PROFILE_KEY = ?"
|
||||
val args = arrayOf(id.serialize(), Base64.encodeBytes(profileKey.serialize()))
|
||||
val args = arrayOf(id.serialize(), Base64.encodeWithPadding(profileKey.serialize()))
|
||||
val columnData = ExpiringProfileKeyCredentialColumnData.Builder()
|
||||
.profileKey(profileKey.serialize().toByteString())
|
||||
.expiringProfileKeyCredential(expiringProfileKeyCredential.serialize().toByteString())
|
||||
.build()
|
||||
val values = ContentValues(1).apply {
|
||||
put(EXPIRING_PROFILE_KEY_CREDENTIAL, Base64.encodeBytes(columnData.encode()))
|
||||
put(EXPIRING_PROFILE_KEY_CREDENTIAL, Base64.encodeWithPadding(columnData.encode()))
|
||||
}
|
||||
val updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values)
|
||||
|
||||
@@ -3492,7 +3492,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
try {
|
||||
for ((key, value) in ids) {
|
||||
val values = ContentValues().apply {
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(value!!))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(value!!))
|
||||
}
|
||||
db.update(TABLE_NAME, values, ID_WHERE, arrayOf(key.serialize()))
|
||||
}
|
||||
@@ -3639,7 +3639,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
*/
|
||||
fun rotateStorageId(recipientId: RecipientId) {
|
||||
val values = ContentValues(1).apply {
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
|
||||
val query = "$ID = ? AND ($TYPE IN (?, ?, ?) OR $REGISTERED = ?)"
|
||||
@@ -3652,7 +3652,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
*/
|
||||
fun setStorageIdIfNotSet(recipientId: RecipientId) {
|
||||
val values = ContentValues(1).apply {
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
|
||||
val query = "$ID = ? AND $STORAGE_SERVICE_ID IS NULL"
|
||||
@@ -3840,7 +3840,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
E164 to e164,
|
||||
ACI_COLUMN to aci?.toString(),
|
||||
PNI_COLUMN to pni?.toString(),
|
||||
STORAGE_SERVICE_ID to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
STORAGE_SERVICE_ID to Base64.encodeWithPadding(StorageSyncHelper.generateKey()),
|
||||
AVATAR_COLOR to AvatarColorHash.forAddress((aci ?: pni)?.toString(), e164).serialize()
|
||||
)
|
||||
|
||||
@@ -3868,16 +3868,16 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
put(SYSTEM_FAMILY_NAME, systemName.familyName)
|
||||
put(SYSTEM_JOINED_NAME, systemName.toString())
|
||||
put(SYSTEM_NICKNAME, contact.systemNickname.orElse(null))
|
||||
put(PROFILE_KEY, contact.profileKey.map { source -> Base64.encodeBytes(source) }.orElse(null))
|
||||
put(PROFILE_KEY, contact.profileKey.map { source -> Base64.encodeWithPadding(source) }.orElse(null))
|
||||
put(USERNAME, if (TextUtils.isEmpty(username)) null else username)
|
||||
put(PROFILE_SHARING, if (contact.isProfileSharingEnabled) "1" else "0")
|
||||
put(BLOCKED, if (contact.isBlocked) "1" else "0")
|
||||
put(MUTE_UNTIL, contact.muteUntil)
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(contact.id.raw))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(contact.id.raw))
|
||||
put(HIDDEN, contact.isHidden)
|
||||
|
||||
if (contact.hasUnknownFields()) {
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeBytes(Objects.requireNonNull(contact.serializeUnknownFields())))
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeWithPadding(Objects.requireNonNull(contact.serializeUnknownFields())))
|
||||
} else {
|
||||
putNull(STORAGE_SERVICE_PROTO)
|
||||
}
|
||||
@@ -3906,10 +3906,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
put(PROFILE_SHARING, if (groupV1.isProfileSharingEnabled) "1" else "0")
|
||||
put(BLOCKED, if (groupV1.isBlocked) "1" else "0")
|
||||
put(MUTE_UNTIL, groupV1.muteUntil)
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(groupV1.id.raw))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(groupV1.id.raw))
|
||||
|
||||
if (groupV1.hasUnknownFields()) {
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeBytes(groupV1.serializeUnknownFields()))
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeWithPadding(groupV1.serializeUnknownFields()))
|
||||
} else {
|
||||
putNull(STORAGE_SERVICE_PROTO)
|
||||
}
|
||||
@@ -3929,11 +3929,11 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
put(PROFILE_SHARING, if (groupV2.isProfileSharingEnabled) "1" else "0")
|
||||
put(BLOCKED, if (groupV2.isBlocked) "1" else "0")
|
||||
put(MUTE_UNTIL, groupV2.muteUntil)
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeBytes(groupV2.id.raw))
|
||||
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(groupV2.id.raw))
|
||||
put(MENTION_SETTING, if (groupV2.notifyForMentionsWhenMuted()) MentionSetting.ALWAYS_NOTIFY.id else MentionSetting.DO_NOT_NOTIFY.id)
|
||||
|
||||
if (groupV2.hasUnknownFields()) {
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeBytes(groupV2.serializeUnknownFields()))
|
||||
put(STORAGE_SERVICE_PROTO, Base64.encodeWithPadding(groupV2.serializeUnknownFields()))
|
||||
} else {
|
||||
putNull(STORAGE_SERVICE_PROTO)
|
||||
}
|
||||
@@ -4250,7 +4250,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
private fun updateProfileValuesForMerge(values: ContentValues, record: RecipientRecord) {
|
||||
values.apply {
|
||||
put(PROFILE_KEY, if (record.profileKey != null) Base64.encodeBytes(record.profileKey) else null)
|
||||
put(PROFILE_KEY, if (record.profileKey != null) Base64.encodeWithPadding(record.profileKey) else null)
|
||||
putNull(EXPIRING_PROFILE_KEY_CREDENTIAL)
|
||||
put(PROFILE_AVATAR, record.signalProfileAvatar)
|
||||
put(PROFILE_GIVEN_NAME, record.signalProfileName.givenName)
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.Context
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.core.util.requireInt
|
||||
@@ -11,7 +12,6 @@ import org.signal.libsignal.protocol.InvalidKeyException
|
||||
import org.signal.libsignal.protocol.ecc.Curve
|
||||
import org.signal.libsignal.protocol.ecc.ECKeyPair
|
||||
import org.signal.libsignal.protocol.state.SignedPreKeyRecord
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
import java.io.IOException
|
||||
import java.util.LinkedList
|
||||
@@ -88,9 +88,9 @@ class SignedPreKeyTable(context: Context, databaseHelper: SignalDatabase) : Data
|
||||
val contentValues = contentValuesOf(
|
||||
ACCOUNT_ID to serviceId.toString(),
|
||||
KEY_ID to keyId,
|
||||
PUBLIC_KEY to Base64.encodeBytes(record.keyPair.publicKey.serialize()),
|
||||
PRIVATE_KEY to Base64.encodeBytes(record.keyPair.privateKey.serialize()),
|
||||
SIGNATURE to Base64.encodeBytes(record.signature),
|
||||
PUBLIC_KEY to Base64.encodeWithPadding(record.keyPair.publicKey.serialize()),
|
||||
PRIVATE_KEY to Base64.encodeWithPadding(record.keyPair.privateKey.serialize()),
|
||||
SIGNATURE to Base64.encodeWithPadding(record.signature),
|
||||
TIMESTAMP to record.timestamp
|
||||
)
|
||||
writableDatabase.replace(TABLE_NAME, null, contentValues)
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.CursorUtil;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.SqlUtil;
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageRecord;
|
||||
import org.whispersystems.signalservice.api.storage.StorageId;
|
||||
@@ -84,7 +84,7 @@ public class UnknownStorageIdTable extends DatabaseTable {
|
||||
|
||||
public @Nullable SignalStorageRecord getById(@NonNull byte[] rawId) {
|
||||
String query = STORAGE_ID + " = ?";
|
||||
String[] args = new String[] { Base64.encodeBytes(rawId) };
|
||||
String[] args = new String[] { Base64.encodeWithPadding(rawId) };
|
||||
|
||||
try (Cursor cursor = databaseHelper.getSignalReadableDatabase().query(TABLE_NAME, null, query, args, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
@@ -104,7 +104,7 @@ public class UnknownStorageIdTable extends DatabaseTable {
|
||||
for (SignalStorageRecord insert : inserts) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(TYPE, insert.getType());
|
||||
values.put(STORAGE_ID, Base64.encodeBytes(insert.getId().getRaw()));
|
||||
values.put(STORAGE_ID, Base64.encodeWithPadding(insert.getId().getRaw()));
|
||||
|
||||
db.insert(TABLE_NAME, null, values);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class UnknownStorageIdTable extends DatabaseTable {
|
||||
Preconditions.checkArgument(db.inTransaction(), "Must be in a transaction!");
|
||||
|
||||
for (StorageId id : deletes) {
|
||||
String[] args = SqlUtil.buildArgs(Base64.encodeBytes(id.getRaw()));
|
||||
String[] args = SqlUtil.buildArgs(Base64.encodeWithPadding(id.getRaw()));
|
||||
db.delete(TABLE_NAME, deleteQuery, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.signal.libsignal.protocol.IdentityKey;
|
||||
import org.signal.libsignal.protocol.InvalidKeyException;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
@@ -83,7 +83,7 @@ public class IdentityKeyMismatch {
|
||||
public void serialize(IdentityKey value, JsonGenerator jsonGenerator, SerializerProvider serializers)
|
||||
throws IOException
|
||||
{
|
||||
jsonGenerator.writeString(Base64.encodeBytes(value.serialize()));
|
||||
jsonGenerator.writeString(Base64.encodeWithPadding(value.serialize()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.phonenumbers.NumberUtil;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.DelimiterUtil;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@@ -379,8 +379,8 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
if (identityKey != null) {
|
||||
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
||||
String identityKeyString = Base64.encodeBytes(identityKey.serialize());
|
||||
String macString = Base64.encodeBytes(masterCipher.getMacFor(recipientId +
|
||||
String identityKeyString = Base64.encodeWithPadding(identityKey.serialize());
|
||||
String macString = Base64.encodeWithPadding(masterCipher.getMacFor(recipientId +
|
||||
identityKeyString));
|
||||
|
||||
db.execSQL("REPLACE INTO identities (recipient, key, mac) VALUES (?, ?, ?)",
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.signal.libsignal.protocol.state.SignedPreKeyRecord;
|
||||
import org.thoughtcrime.securesms.database.OneTimePreKeyTable;
|
||||
import org.thoughtcrime.securesms.database.SignedPreKeyTable;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -49,8 +49,8 @@ public final class PreKeyMigrationHelper {
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(OneTimePreKeyTable.KEY_ID, preKey.getId());
|
||||
contentValues.put(OneTimePreKeyTable.PUBLIC_KEY, Base64.encodeBytes(preKey.getKeyPair().getPublicKey().serialize()));
|
||||
contentValues.put(OneTimePreKeyTable.PRIVATE_KEY, Base64.encodeBytes(preKey.getKeyPair().getPrivateKey().serialize()));
|
||||
contentValues.put(OneTimePreKeyTable.PUBLIC_KEY, Base64.encodeWithPadding(preKey.getKeyPair().getPublicKey().serialize()));
|
||||
contentValues.put(OneTimePreKeyTable.PRIVATE_KEY, Base64.encodeWithPadding(preKey.getKeyPair().getPrivateKey().serialize()));
|
||||
database.insert(OneTimePreKeyTable.TABLE_NAME, null, contentValues);
|
||||
Log.i(TAG, "Migrated one-time prekey: " + preKey.getId());
|
||||
} catch (IOException | InvalidMessageException | InvalidKeyException e) {
|
||||
@@ -71,9 +71,9 @@ public final class PreKeyMigrationHelper {
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(SignedPreKeyTable.KEY_ID, signedPreKey.getId());
|
||||
contentValues.put(SignedPreKeyTable.PUBLIC_KEY, Base64.encodeBytes(signedPreKey.getKeyPair().getPublicKey().serialize()));
|
||||
contentValues.put(SignedPreKeyTable.PRIVATE_KEY, Base64.encodeBytes(signedPreKey.getKeyPair().getPrivateKey().serialize()));
|
||||
contentValues.put(SignedPreKeyTable.SIGNATURE, Base64.encodeBytes(signedPreKey.getSignature()));
|
||||
contentValues.put(SignedPreKeyTable.PUBLIC_KEY, Base64.encodeWithPadding(signedPreKey.getKeyPair().getPublicKey().serialize()));
|
||||
contentValues.put(SignedPreKeyTable.PRIVATE_KEY, Base64.encodeWithPadding(signedPreKey.getKeyPair().getPrivateKey().serialize()));
|
||||
contentValues.put(SignedPreKeyTable.SIGNATURE, Base64.encodeWithPadding(signedPreKey.getSignature()));
|
||||
contentValues.put(SignedPreKeyTable.TIMESTAMP, signedPreKey.getTimestamp());
|
||||
database.insert(SignedPreKeyTable.TABLE_NAME, null, contentValues);
|
||||
Log.i(TAG, "Migrated signed prekey: " + signedPreKey.getId());
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.jobs.UnableToStartException;
|
||||
import org.thoughtcrime.securesms.migrations.LegacyMigrationJob;
|
||||
import org.thoughtcrime.securesms.service.GenericForegroundService;
|
||||
import org.thoughtcrime.securesms.service.NotificationController;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -125,7 +125,7 @@ public class SQLCipherMigrationHelper {
|
||||
plaintext = legacyCipher.decryptBytes(Base64.decode(mediaKey));
|
||||
}
|
||||
|
||||
row.put("cd", Base64.encodeBytes(plaintext));
|
||||
row.put("cd", Base64.encodeWithPadding(plaintext));
|
||||
}
|
||||
} catch (IOException | InvalidMessageException e) {
|
||||
Log.w(TAG, e);
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.text.TextUtils
|
||||
import androidx.core.content.contentValuesOf
|
||||
import com.annimon.stream.Stream
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.Hex
|
||||
import org.signal.core.util.SqlUtil
|
||||
@@ -41,7 +42,6 @@ import org.thoughtcrime.securesms.notifications.NotificationChannels
|
||||
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FileUtils
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||
import org.thoughtcrime.securesms.util.Triple
|
||||
@@ -825,7 +825,7 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
val encodedProfileKey = PreferenceManager.getDefaultSharedPreferences(context).getString("pref_profile_key", null)
|
||||
val profileKey = if (encodedProfileKey != null) Base64.decodeOrThrow(encodedProfileKey) else Util.getSecretBytes(32)
|
||||
val values = ContentValues(1).apply {
|
||||
put("profile_key", Base64.encodeBytes(profileKey))
|
||||
put("profile_key", Base64.encodeWithPadding(profileKey))
|
||||
}
|
||||
if (db.update("recipient", values, "phone = ?", arrayOf(localNumber)) == 0) {
|
||||
throw AssertionError("No rows updated!")
|
||||
@@ -851,7 +851,7 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
val id: String = cursor.getString(cursor.getColumnIndexOrThrow("_id"))
|
||||
val values = ContentValues(2).apply {
|
||||
put("dirty", 2)
|
||||
put("storage_service_key", Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put("storage_service_key", Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
db.update("recipient", values, "_id = ?", arrayOf(id))
|
||||
}
|
||||
@@ -1434,7 +1434,7 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
insertCount = cursor.count
|
||||
while (cursor.moveToNext()) {
|
||||
val insertValues = ContentValues().apply {
|
||||
put("storage_service_key", Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put("storage_service_key", Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
val id: Long = cursor.getLong(cursor.getColumnIndexOrThrow("_id"))
|
||||
db.update("recipient", insertValues, "_id = ?", SqlUtil.buildArgs(id))
|
||||
@@ -1445,7 +1445,7 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
updateCount = cursor.count
|
||||
while (cursor.moveToNext()) {
|
||||
val updateValues = ContentValues().apply {
|
||||
put("storage_service_key", Base64.encodeBytes(StorageSyncHelper.generateKey()))
|
||||
put("storage_service_key", Base64.encodeWithPadding(StorageSyncHelper.generateKey()))
|
||||
}
|
||||
val id: Long = cursor.getLong(cursor.getColumnIndexOrThrow("_id"))
|
||||
db.update("recipient", updateValues, "_id = ?", SqlUtil.buildArgs(id))
|
||||
@@ -2445,7 +2445,7 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
null,
|
||||
contentValuesOf(
|
||||
"distribution_list_id" to 1L,
|
||||
"storage_service_key" to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
"storage_service_key" to Base64.encodeWithPadding(StorageSyncHelper.generateKey()),
|
||||
"profile_sharing" to 1
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,11 +4,11 @@ import android.app.Application
|
||||
import android.database.Cursor
|
||||
import androidx.core.content.contentValuesOf
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
/**
|
||||
* Performs a check and ensures that MyStory exists at the correct distribution list id and correct distribution id.
|
||||
@@ -87,7 +87,7 @@ object V151_MyStoryMigration : SignalDatabaseMigration {
|
||||
contentValuesOf(
|
||||
"group_type" to 4,
|
||||
"distribution_list_id" to MY_STORY_DISTRIBUTION_LIST_ID,
|
||||
"storage_service_key" to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
"storage_service_key" to Base64.encodeWithPadding(StorageSyncHelper.generateKey()),
|
||||
"profile_sharing" to 1
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,11 +4,11 @@ import android.app.Application
|
||||
import android.database.Cursor
|
||||
import androidx.core.content.contentValuesOf
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.CursorUtil
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
/**
|
||||
* Performs a check and ensures that MyStory exists at the correct distribution list id and correct distribution id.
|
||||
@@ -87,7 +87,7 @@ object V153_MyStoryMigration : SignalDatabaseMigration {
|
||||
contentValuesOf(
|
||||
"group_type" to 4,
|
||||
"distribution_list_id" to MY_STORY_DISTRIBUTION_LIST_ID,
|
||||
"storage_service_key" to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
"storage_service_key" to Base64.encodeWithPadding(StorageSyncHelper.generateKey()),
|
||||
"profile_sharing" to 1
|
||||
)
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.signal.libsignal.protocol.util.ByteUtil;
|
||||
import org.thoughtcrime.securesms.devicelist.Device;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.DeviceInfo;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.thoughtcrime.securesms.database.model
|
||||
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.StringSerializer
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
object BodyRangeListSerializer : StringSerializer<BodyRangeList> {
|
||||
override fun serialize(data: BodyRangeList): String = Base64.encodeBytes(data.encode())
|
||||
override fun serialize(data: BodyRangeList): String = Base64.encodeWithPadding(data.encode())
|
||||
override fun deserialize(data: String): BodyRangeList = BodyRangeList.ADAPTER.decode(Base64.decode(data))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.GroupCallUpdateDetails;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -38,6 +38,6 @@ public final class GroupCallUpdateDetailsUtil {
|
||||
.isCallFull(isCallFull)
|
||||
.inCallUuids(inCallUuids);
|
||||
|
||||
return Base64.encodeBytes(builder.build().encode());
|
||||
return Base64.encodeWithPadding(builder.build().encode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
@@ -508,7 +508,7 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
List<ByteString> deleteRequestingMembers = new ArrayList<>(change.deleteRequestingMembers);
|
||||
deleteRequestingMembers.add(id);
|
||||
|
||||
return Base64.encodeBytes(decryptedGroupV2Context.newBuilder()
|
||||
return Base64.encodeWithPadding(decryptedGroupV2Context.newBuilder()
|
||||
.change(change.newBuilder()
|
||||
.revision(revision)
|
||||
.deleteRequestingMembers(deleteRequestingMembers)
|
||||
|
||||
@@ -3,11 +3,11 @@ package org.thoughtcrime.securesms.groups.v2;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.groups.GroupMasterKey;
|
||||
import org.signal.storageservice.protos.groups.GroupInviteLink;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.whispersystems.util.Base64UrlSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -58,7 +58,7 @@ public final class GroupInviteLinkUrl {
|
||||
throw new InvalidGroupLinkException("No reference was in the uri");
|
||||
}
|
||||
|
||||
byte[] bytes = Base64UrlSafe.decodePaddingAgnostic(encoding);
|
||||
byte[] bytes = Base64.decode(encoding);
|
||||
GroupInviteLink groupInviteLink = GroupInviteLink.ADAPTER.decode(bytes);
|
||||
|
||||
//noinspection SwitchStatementWithTooFewBranches
|
||||
@@ -112,7 +112,7 @@ public final class GroupInviteLinkUrl {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
String encoding = Base64UrlSafe.encodeBytesWithoutPadding(groupInviteLink.encode());
|
||||
String encoding = Base64.encodeUrlSafeWithoutPadding(groupInviteLink.encode());
|
||||
|
||||
return GROUP_URL_PREFIX + encoding;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import androidx.annotation.Nullable;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -427,7 +427,7 @@ public class JsonJobData {
|
||||
}
|
||||
|
||||
public Builder putBlobAsString(@NonNull String key, @Nullable byte[] value) {
|
||||
String serialized = value != null ? Base64.encodeBytes(value) : null;
|
||||
String serialized = value != null ? Base64.encodeWithPadding(value) : null;
|
||||
strings.put(key, serialized);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations
|
||||
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData
|
||||
import org.thoughtcrime.securesms.jobs.FailingJob
|
||||
import org.thoughtcrime.securesms.jobs.PushProcessMessageErrorJob
|
||||
import org.thoughtcrime.securesms.messages.MessageState
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.crypto.protos.CompleteMessage
|
||||
import org.whispersystems.signalservice.api.crypto.protos.EnvelopeMetadata
|
||||
import org.whispersystems.signalservice.api.push.ServiceId
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.serialize.protos.SignalServiceContentProto;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.thoughtcrime.securesms.jobs
|
||||
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.ProfileUtil
|
||||
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile
|
||||
import java.io.IOException
|
||||
@@ -57,7 +57,7 @@ class AccountConsistencyWorkerJob private constructor(parameters: Parameters) :
|
||||
}
|
||||
|
||||
val profile: SignalServiceProfile = ProfileUtil.retrieveProfileSync(context, Recipient.self(), SignalServiceProfile.RequestType.PROFILE, false).profile
|
||||
val encodedPublicKey = Base64.encodeBytes(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
||||
val encodedPublicKey = Base64.encodeWithPadding(SignalStore.account().aciIdentityKey.publicKey.serialize())
|
||||
|
||||
if (profile.identityKey != encodedPublicKey) {
|
||||
Log.w(TAG, "Identity key on profile differed from the one we have locally! Marking ourselves unregistered.")
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.thoughtcrime.securesms.releasechannel.ReleaseChannel;
|
||||
import org.thoughtcrime.securesms.s3.S3;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.AttachmentUtil;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -46,7 +46,7 @@ public class MmsReceiveJob extends BaseJob {
|
||||
|
||||
@Override
|
||||
public @Nullable byte[] serialize() {
|
||||
return new JsonJobData.Builder().putString(KEY_DATA, Base64.encodeBytes(data))
|
||||
return new JsonJobData.Builder().putString(KEY_DATA, Base64.encodeWithPadding(data))
|
||||
.putInt(KEY_SUBSCRIPTION_ID, subscriptionId)
|
||||
.serialize();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
@@ -76,7 +76,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob {
|
||||
@Override
|
||||
public @Nullable byte[] serialize() {
|
||||
return new JsonJobData.Builder().putString(KEY_DESTINATION, destination.serialize())
|
||||
.putString(KEY_IDENTITY_KEY, Base64.encodeBytes(identityKey))
|
||||
.putString(KEY_IDENTITY_KEY, Base64.encodeWithPadding(identityKey))
|
||||
.putInt(KEY_VERIFIED_STATUS, verifiedStatus.toInt())
|
||||
.putLong(KEY_TIMESTAMP, timestamp)
|
||||
.serialize();
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.thoughtcrime.securesms.net.NotPushRegisteredException;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.whispersystems.signalservice.api.crypto.ContentHint;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
@@ -120,7 +120,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
|
||||
return new JsonJobData.Builder().putString(KEY_RECIPIENTS, RecipientId.toSerializedList(recipients))
|
||||
.putInt(KEY_INITIAL_RECIPIENT_COUNT, initialRecipientCount)
|
||||
.putLong(KEY_TIMESTAMP, timestamp)
|
||||
.putString(KEY_GROUP_CONTEXT_V2, Base64.encodeBytes(groupContextV2.encode()))
|
||||
.putString(KEY_GROUP_CONTEXT_V2, Base64.encodeWithPadding(groupContextV2.encode()))
|
||||
.serialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.ImageCompressionUtil;
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.account.AccountAttributes;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
|
||||
import org.whispersystems.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -118,7 +118,7 @@ public class RefreshAttributesJob extends BaseJob {
|
||||
universalUnidentifiedAccess,
|
||||
capabilities,
|
||||
phoneNumberDiscoverable,
|
||||
(encryptedDeviceName == null) ? null : Base64.encodeBytes(encryptedDeviceName),
|
||||
(encryptedDeviceName == null) ? null : Base64.encodeWithPadding(encryptedDeviceName),
|
||||
pniRegistrationId,
|
||||
recoveryPassword
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.text.TextUtils;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.usernames.BaseUsernameException;
|
||||
import org.signal.libsignal.usernames.Username;
|
||||
@@ -23,7 +24,6 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.subscription.Subscriber;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.ProfileUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@@ -38,7 +38,6 @@ import org.whispersystems.signalservice.api.util.ExpiringProfileCredentialUtil;
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||
import org.whispersystems.signalservice.internal.push.ReserveUsernameResponse;
|
||||
import org.whispersystems.signalservice.internal.push.WhoAmIResponse;
|
||||
import org.whispersystems.util.Base64UrlSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@@ -273,7 +272,7 @@ public class RefreshOwnProfileJob extends BaseJob {
|
||||
WhoAmIResponse whoAmIResponse = ApplicationDependencies.getSignalServiceAccountManager().getWhoAmI();
|
||||
boolean hasServerUsername = !TextUtils.isEmpty(whoAmIResponse.getUsernameHash());
|
||||
String serverUsernameHash = whoAmIResponse.getUsernameHash();
|
||||
String localUsernameHash = Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(localUsername));
|
||||
String localUsernameHash = Base64.encodeUrlSafeWithoutPadding(Username.hash(localUsername));
|
||||
|
||||
if (!hasServerUsername) {
|
||||
Log.w(TAG, "No remote username is set.");
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
@@ -86,7 +86,7 @@ public class ReportSpamJob extends BaseJob {
|
||||
|
||||
byte[] reportingTokenBytes = SignalDatabase.recipients().getReportingToken(recipientId);
|
||||
if (reportingTokenBytes != null) {
|
||||
reportingTokenEncoded = Base64.encodeBytes(reportingTokenBytes);
|
||||
reportingTokenEncoded = Base64.encodeWithPadding(reportingTokenBytes);
|
||||
}
|
||||
|
||||
signalServiceAccountManager.reportSpam(serviceId.get(), data.getServerGuid(), reportingTokenEncoded);
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||
import org.thoughtcrime.securesms.util.ProfileUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.VerificationCodeParser;
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class SmsReceiveJob extends BaseJob {
|
||||
public @Nullable byte[] serialize() {
|
||||
String[] encoded = new String[pdus.length];
|
||||
for (int i = 0; i < pdus.length; i++) {
|
||||
encoded[i] = Base64.encodeBytes((byte[]) pdus[i]);
|
||||
encoded[i] = Base64.encodeWithPadding((byte[]) pdus[i]);
|
||||
}
|
||||
|
||||
return new JsonJobData.Builder().putStringArray(KEY_PDUS, encoded)
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.subscription.Subscriber;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.subscriptions.ActiveSubscription;
|
||||
import org.whispersystems.signalservice.api.subscriptions.SubscriberId;
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.libsignal.protocol.IdentityKey
|
||||
import org.signal.libsignal.protocol.IdentityKeyPair
|
||||
@@ -19,7 +20,6 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobs.PreKeysSyncJob
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.os.Build;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.KeyStoreHelper;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -49,7 +49,7 @@ public class LogSecretProvider {
|
||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(secret);
|
||||
TextSecurePreferences.setLogEncryptedSecret(context, encryptedSecret.serialize());
|
||||
} else {
|
||||
TextSecurePreferences.setLogUnencryptedSecret(context, Base64.encodeBytes(secret));
|
||||
TextSecurePreferences.setLogUnencryptedSecret(context, Base64.encodeWithPadding(secret));
|
||||
}
|
||||
|
||||
return secret;
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.ThreadUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||
@@ -20,7 +21,6 @@ import org.thoughtcrime.securesms.mms.OutgoingMessage
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
private val TAG = Log.tag(TextStoryPostSendRepository::class.java)
|
||||
@@ -110,6 +110,6 @@ class TextStoryPostSendRepository {
|
||||
builder.textBackgroundColor = textStoryPostCreationState.textBackgroundColor
|
||||
builder.textForegroundColor = textStoryPostCreationState.textForegroundColor
|
||||
|
||||
return Base64.encodeBytes(builder.build().encode())
|
||||
return Base64.encodeWithPadding(builder.build().encode())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.mobilecoin.lib.exceptions.SerializationException
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Hex
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.core.util.logging.Log
|
||||
@@ -88,7 +89,6 @@ import org.thoughtcrime.securesms.sms.IncomingEndSessionMessage
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.EarlyMessageCacheEntry
|
||||
import org.thoughtcrime.securesms.util.LinkUtil
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
@@ -825,7 +825,7 @@ object DataMessageProcessor {
|
||||
receivedTimeMillis = receivedTime,
|
||||
expiresIn = message.expireTimerDuration.inWholeMilliseconds,
|
||||
isUnidentified = metadata.sealedSender,
|
||||
body = Base64.encodeBytes(dbGiftBadge.encode()),
|
||||
body = Base64.encodeWithPadding(dbGiftBadge.encode()),
|
||||
serverGuid = envelope.serverGuid,
|
||||
giftBadge = dbGiftBadge
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.messages
|
||||
|
||||
import android.graphics.Color
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.orNull
|
||||
import org.thoughtcrime.securesms.database.MessageTable.InsertResult
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
@@ -17,7 +18,6 @@ import org.thoughtcrime.securesms.mms.IncomingMediaMessage
|
||||
import org.thoughtcrime.securesms.mms.MmsException
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||
import org.whispersystems.signalservice.api.crypto.EnvelopeMetadata
|
||||
import org.whispersystems.signalservice.internal.push.Content
|
||||
@@ -147,6 +147,6 @@ object StoryMessageProcessor {
|
||||
}
|
||||
builder.background(chatColorBuilder.build())
|
||||
|
||||
return Base64.encodeBytes(builder.build().encode())
|
||||
return Base64.encodeWithPadding(builder.build().encode())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.thoughtcrime.securesms.messages
|
||||
|
||||
import org.signal.core.util.Base64
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.messages.SignalServicePreview
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceTextAttachment
|
||||
import java.io.IOException
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
@@ -51,14 +51,14 @@ public final class MessageGroupContext {
|
||||
}
|
||||
|
||||
public MessageGroupContext(@NonNull GroupContext group) {
|
||||
this.encodedGroupContext = Base64.encodeBytes(group.encode());
|
||||
this.encodedGroupContext = Base64.encodeWithPadding(group.encode());
|
||||
this.groupV1 = new GroupV1Properties(group);
|
||||
this.groupV2 = null;
|
||||
this.group = groupV1;
|
||||
}
|
||||
|
||||
public MessageGroupContext(@NonNull DecryptedGroupV2Context group) {
|
||||
this.encodedGroupContext = Base64.encodeBytes(group.encode());
|
||||
this.encodedGroupContext = Base64.encodeWithPadding(group.encode());
|
||||
this.groupV1 = null;
|
||||
this.groupV2 = new GroupV2Properties(group);
|
||||
this.group = groupV2;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.mobilecoin.lib.Verifier;
|
||||
import com.mobilecoin.lib.exceptions.AttestationException;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.internal.push.AuthCredentials;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.mobilecoin.lib.ClientConfig;
|
||||
import com.mobilecoin.lib.exceptions.AttestationException;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.internal.push.AuthCredentials;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.profiles.manage
|
||||
import androidx.annotation.WorkerThread
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Result
|
||||
import org.signal.core.util.Result.Companion.failure
|
||||
import org.signal.core.util.Result.Companion.success
|
||||
@@ -24,7 +25,6 @@ import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulRespons
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UsernameIsNotReservedException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UsernameMalformedException
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UsernameTakenException
|
||||
import org.whispersystems.util.Base64UrlSafe
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ class UsernameRepository {
|
||||
val candidates: List<Username> = Username.candidatesFrom(nickname, UsernameUtil.MIN_LENGTH, UsernameUtil.MAX_LENGTH)
|
||||
|
||||
val hashes: List<String> = candidates
|
||||
.map { Base64UrlSafe.encodeBytesWithoutPadding(it.hash) }
|
||||
.map { Base64.encodeUrlSafeWithoutPadding(it.hash) }
|
||||
|
||||
val response = accountManager.reserveUsername(hashes)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.core.app.ShareCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable
|
||||
import org.signal.libsignal.usernames.Username
|
||||
@@ -20,7 +21,6 @@ import org.thoughtcrime.securesms.components.settings.configure
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.FragmentResultContract
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.whispersystems.util.Base64UrlSafe
|
||||
|
||||
/**
|
||||
* Allows the user to either share their username directly or to copy it to their clipboard.
|
||||
@@ -71,7 +71,7 @@ class UsernameShareBottomSheet : DSLSettingsBottomSheetFragment() {
|
||||
|
||||
customPref(
|
||||
CopyButton.Model(
|
||||
text = getString(R.string.signal_me_username_url, Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(username))),
|
||||
text = getString(R.string.signal_me_username_url, Base64.encodeUrlSafeWithoutPadding(Username.hash(username))),
|
||||
onClick = {
|
||||
copyToClipboard(it)
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class UsernameShareBottomSheet : DSLSettingsBottomSheetFragment() {
|
||||
|
||||
customPref(
|
||||
ShareButton.Model(
|
||||
text = getString(R.string.signal_me_username_url, Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(username))),
|
||||
text = getString(R.string.signal_me_username_url, Base64.encodeUrlSafeWithoutPadding(Username.hash(username))),
|
||||
onClick = {
|
||||
openShareSheet(it.text)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -7,6 +7,7 @@ import okhttp3.ConnectionSpec
|
||||
import okhttp3.Dns
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.TlsVersion
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.BuildConfig
|
||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues
|
||||
@@ -18,7 +19,6 @@ import org.thoughtcrime.securesms.net.RemoteDeprecationDetectorInterceptor
|
||||
import org.thoughtcrime.securesms.net.SequentialDns
|
||||
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor
|
||||
import org.thoughtcrime.securesms.net.StaticDns
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.push.TrustStore
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalCdnUrl
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalCdsiUrl
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.whispersystems.signalservice.api.push.exceptions.IncorrectCodeExcepti
|
||||
import org.whispersystems.signalservice.api.push.exceptions.IncorrectRegistrationRecoveryPasswordException;
|
||||
import org.whispersystems.signalservice.internal.ServiceResponse;
|
||||
import org.whispersystems.signalservice.internal.push.RegistrationSessionMetadataResponse;
|
||||
import org.whispersystems.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -9,9 +9,9 @@ import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import okio.ByteString
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Serializer
|
||||
import org.signal.ringrtc.CallLinkRootKey
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
@Parcelize
|
||||
class CallLinkRoomId private constructor(private val roomId: ByteArray) : Parcelable {
|
||||
@@ -40,7 +40,7 @@ class CallLinkRoomId private constructor(private val roomId: ByteArray) : Parcel
|
||||
|
||||
object DatabaseSerializer : Serializer<CallLinkRoomId, String> {
|
||||
override fun serialize(data: CallLinkRoomId): String {
|
||||
return Base64.encodeBytes(data.roomId)
|
||||
return Base64.encodeWithPadding(data.roomId)
|
||||
}
|
||||
|
||||
override fun deserialize(data: String): CallLinkRoomId {
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender.SendType;
|
||||
import org.thoughtcrime.securesms.stories.Stories;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.MessageUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -390,7 +390,7 @@ public final class MultiShareSender {
|
||||
{
|
||||
return OutgoingMessage.textStoryMessage(
|
||||
recipient,
|
||||
Base64.encodeBytes(new StoryTextPost.Builder()
|
||||
Base64.encodeWithPadding(new StoryTextPost.Builder()
|
||||
.body(getBodyForTextStory(multiShareArgs.getDraftText(), multiShareArgs.getLinkPreview()))
|
||||
.style(StoryTextPost.Style.DEFAULT)
|
||||
.background(background.serialize())
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.payments.Entropy;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.subscription.Subscriber;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.api.push.UsernameLinkComponents;
|
||||
@@ -69,8 +69,8 @@ public final class StorageSyncHelper {
|
||||
public static @NonNull IdDifferenceResult findIdDifference(@NonNull Collection<StorageId> remoteIds,
|
||||
@NonNull Collection<StorageId> localIds)
|
||||
{
|
||||
Map<String, StorageId> remoteByRawId = Stream.of(remoteIds).collect(Collectors.toMap(id -> Base64.encodeBytes(id.getRaw()), id -> id));
|
||||
Map<String, StorageId> localByRawId = Stream.of(localIds).collect(Collectors.toMap(id -> Base64.encodeBytes(id.getRaw()), id -> id));
|
||||
Map<String, StorageId> remoteByRawId = Stream.of(remoteIds).collect(Collectors.toMap(id -> Base64.encodeWithPadding(id.getRaw()), id -> id));
|
||||
Map<String, StorageId> localByRawId = Stream.of(localIds).collect(Collectors.toMap(id -> Base64.encodeWithPadding(id.getRaw()), id -> id));
|
||||
|
||||
boolean hasTypeMismatch = remoteByRawId.size() != remoteIds.size() || localByRawId.size() != localIds.size();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.SetUtil;
|
||||
import org.whispersystems.signalservice.api.storage.SignalContactRecord;
|
||||
import org.whispersystems.signalservice.api.storage.SignalStorageManifest;
|
||||
@@ -34,10 +34,10 @@ public final class StorageSyncValidations {
|
||||
validateManifestAndInserts(result.getManifest(), result.getInserts(), self);
|
||||
|
||||
if (result.getDeletes().size() > 0) {
|
||||
Set<String> allSetEncoded = Stream.of(result.getManifest().getStorageIds()).map(StorageId::getRaw).map(Base64::encodeBytes).collect(Collectors.toSet());
|
||||
Set<String> allSetEncoded = Stream.of(result.getManifest().getStorageIds()).map(StorageId::getRaw).map(Base64::encodeWithPadding).collect(Collectors.toSet());
|
||||
|
||||
for (byte[] delete : result.getDeletes()) {
|
||||
String encoded = Base64.encodeBytes(delete);
|
||||
String encoded = Base64.encodeWithPadding(delete);
|
||||
if (allSetEncoded.contains(encoded)) {
|
||||
throw new DeletePresentInFullIdSetError();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.bumptech.glide.load.Options
|
||||
import com.bumptech.glide.load.ResourceDecoder
|
||||
import com.bumptech.glide.load.engine.Resource
|
||||
import com.bumptech.glide.load.resource.SimpleResource
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.concurrent.safeBlockingGet
|
||||
import org.signal.core.util.readParcelableCompat
|
||||
import org.thoughtcrime.securesms.R
|
||||
@@ -32,7 +33,6 @@ import org.thoughtcrime.securesms.fonts.TypefaceCache
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.ParcelUtil
|
||||
import java.io.IOException
|
||||
import java.security.MessageDigest
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.core.app.ShareCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.bumptech.glide.load.Options
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.signal.core.util.concurrent.SimpleTask
|
||||
import org.signal.core.util.logging.Log
|
||||
@@ -27,7 +28,6 @@ import org.thoughtcrime.securesms.stories.StoryTextPostModel
|
||||
import org.thoughtcrime.securesms.stories.landing.StoriesLandingItem
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryPost
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryViewerPageState
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil
|
||||
import org.thoughtcrime.securesms.util.DeleteDialog
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.CheckResult
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.BreakIteratorCompat
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.core.util.logging.Log
|
||||
@@ -26,7 +27,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
/**
|
||||
* Open for testing.
|
||||
|
||||
@@ -8,10 +8,10 @@ import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryPost
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.microseconds
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.stories.viewer.post
|
||||
import android.graphics.Typeface
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.Base64
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost
|
||||
@@ -10,7 +11,6 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.fonts.TextFont
|
||||
import org.thoughtcrime.securesms.fonts.TextToScript
|
||||
import org.thoughtcrime.securesms.fonts.TypefaceCache
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
|
||||
class StoryTextPostRepository {
|
||||
fun getRecord(recordId: Long): Single<MmsMessageRecord> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.content.pm.Signature;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.logging.Log;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -56,7 +57,7 @@ public final class AppSignatureUtil {
|
||||
byte[] hashSignature = messageDigest.digest();
|
||||
hashSignature = Arrays.copyOfRange(hashSignature, 0, HASH_LENGTH_BYTES);
|
||||
|
||||
String base64Hash = Base64.encodeBytes(hashSignature);
|
||||
String base64Hash = Base64.encodeWithPadding(hashSignature);
|
||||
base64Hash = base64Hash.substring(0, HASH_LENGTH_CHARS);
|
||||
|
||||
return base64Hash;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class Base64 {
|
||||
|
||||
private Base64() {
|
||||
}
|
||||
|
||||
public static @NonNull byte[] decode(@NonNull String s) throws IOException {
|
||||
return org.whispersystems.util.Base64.decode(s);
|
||||
}
|
||||
|
||||
public static @NonNull byte[] decodeWithoutPadding(@NonNull String s) throws IOException {
|
||||
return org.whispersystems.util.Base64.decodeWithoutPadding(s);
|
||||
}
|
||||
|
||||
public static @NonNull String encodeBytes(@NonNull byte[] source) {
|
||||
return org.whispersystems.util.Base64.encodeBytes(source);
|
||||
}
|
||||
|
||||
public static @NonNull String encodeBytesWithoutPadding(@NonNull byte[] source) {
|
||||
return org.whispersystems.util.Base64.encodeBytesWithoutPadding(source);
|
||||
}
|
||||
|
||||
public static @NonNull byte[] decodeOrThrow(@NonNull String s) {
|
||||
try {
|
||||
return org.whispersystems.util.Base64.decode(s);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable byte[] decodeNullableOrThrow(@Nullable String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return org.whispersystems.util.Base64.decode(s);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
import org.signal.libsignal.protocol.IdentityKeyPair;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.libsignal.usernames.BaseUsernameException
|
||||
import org.signal.libsignal.usernames.Username
|
||||
@@ -11,7 +12,6 @@ import org.whispersystems.signalservice.api.push.ServiceId
|
||||
import org.whispersystems.signalservice.api.push.UsernameLinkComponents
|
||||
import org.whispersystems.signalservice.api.util.UuidUtil
|
||||
import org.whispersystems.signalservice.api.util.toByteArray
|
||||
import org.whispersystems.util.Base64UrlSafe
|
||||
import java.io.IOException
|
||||
import java.util.Locale
|
||||
import java.util.Optional
|
||||
@@ -85,7 +85,7 @@ object UsernameUtil {
|
||||
Log.d(TAG, "No local user with this username. Searching remotely.")
|
||||
|
||||
return try {
|
||||
fetchAciForUsernameHash(Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(username)))
|
||||
fetchAciForUsernameHash(Base64.encodeUrlSafeWithoutPadding(Username.hash(username)))
|
||||
} catch (e: BaseUsernameException) {
|
||||
Optional.empty()
|
||||
}
|
||||
@@ -97,7 +97,7 @@ object UsernameUtil {
|
||||
*/
|
||||
@Throws(BaseUsernameException::class)
|
||||
fun hashUsernameToBase64(username: String?): String {
|
||||
return Base64UrlSafe.encodeBytesWithoutPadding(Username.hash(username))
|
||||
return Base64.encodeUrlSafeWithoutPadding(Username.hash(username))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -117,7 +117,7 @@ object UsernameUtil {
|
||||
*/
|
||||
fun generateLink(components: UsernameLinkComponents): String {
|
||||
val combined: ByteArray = components.entropy + components.serverId.toByteArray()
|
||||
val base64 = Base64UrlSafe.encodeBytesWithoutPadding(combined)
|
||||
val base64 = Base64.encodeUrlSafeWithoutPadding(combined)
|
||||
return BASE_URL + base64
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ object UsernameUtil {
|
||||
fun parseLink(url: String): UsernameLinkComponents? {
|
||||
val match: MatchResult = URL_PATTERN.find(url) ?: return null
|
||||
val path: String = match.groups[2]?.value ?: return null
|
||||
val allBytes: ByteArray = Base64UrlSafe.decodePaddingAgnostic(path)
|
||||
val allBytes: ByteArray = Base64.decode(path)
|
||||
|
||||
if (allBytes.size != 48) {
|
||||
return null
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -359,7 +360,7 @@ public class Util {
|
||||
|
||||
public static String getSecret(int size) {
|
||||
byte[] secret = getSecretBytes(size);
|
||||
return Base64.encodeBytes(secret);
|
||||
return Base64.encodeWithPadding(secret);
|
||||
}
|
||||
|
||||
public static byte[] getSecretBytes(int size) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.mms.PartUriParser;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.whispersystems.signalservice.api.crypto.AttachmentCipherInputStream;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user