mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 01:21:09 +00:00
Only use MasterSecret for local message encryption.
Not for the axolotl store. // FREEBIE
This commit is contained in:
@@ -2,8 +2,11 @@ package org.thoughtcrime.securesms.mms;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.AsymmetricMasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUnion;
|
||||
import org.thoughtcrime.securesms.crypto.MediaKey;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -34,7 +37,7 @@ public class IncomingMediaMessage {
|
||||
this.push = false;
|
||||
}
|
||||
|
||||
public IncomingMediaMessage(MasterSecret masterSecret,
|
||||
public IncomingMediaMessage(MasterSecretUnion masterSecret,
|
||||
String from,
|
||||
String to,
|
||||
long sentTimeMillis,
|
||||
@@ -70,11 +73,11 @@ public class IncomingMediaMessage {
|
||||
for (TextSecureAttachment attachment : attachments.get()) {
|
||||
if (attachment.isPointer()) {
|
||||
PduPart media = new PduPart();
|
||||
byte[] encryptedKey = new MasterCipher(masterSecret).encryptBytes(attachment.asPointer().getKey());
|
||||
String encryptedKey = MediaKey.getEncrypted(masterSecret, attachment.asPointer().getKey());
|
||||
|
||||
media.setContentType(Util.toIsoBytes(attachment.getContentType()));
|
||||
media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.asPointer().getId())));
|
||||
media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));
|
||||
media.setContentDisposition(Util.toIsoBytes(encryptedKey));
|
||||
|
||||
if (relay.isPresent()) {
|
||||
media.setName(Util.toIsoBytes(relay.get()));
|
||||
|
||||
@@ -3,11 +3,10 @@ package org.thoughtcrime.securesms.mms;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUnion;
|
||||
import org.thoughtcrime.securesms.crypto.MediaKey;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.textsecure.api.messages.TextSecureAttachment;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class OutgoingMediaMessage {
|
||||
this(context, recipients, slideDeck.toPduBody(), message, distributionType);
|
||||
}
|
||||
|
||||
public OutgoingMediaMessage(Context context, MasterSecret masterSecret,
|
||||
public OutgoingMediaMessage(Context context, MasterSecretUnion masterSecret,
|
||||
Recipients recipients, List<TextSecureAttachment> attachments,
|
||||
String message)
|
||||
{
|
||||
@@ -74,17 +73,17 @@ public class OutgoingMediaMessage {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static PduBody pduBodyFor(MasterSecret masterSecret, List<TextSecureAttachment> attachments) {
|
||||
private static PduBody pduBodyFor(MasterSecretUnion masterSecret, List<TextSecureAttachment> attachments) {
|
||||
PduBody body = new PduBody();
|
||||
|
||||
for (TextSecureAttachment attachment : attachments) {
|
||||
if (attachment.isPointer()) {
|
||||
PduPart media = new PduPart();
|
||||
byte[] encryptedKey = new MasterCipher(masterSecret).encryptBytes(attachment.asPointer().getKey());
|
||||
String encryptedKey = MediaKey.getEncrypted(masterSecret, attachment.asPointer().getKey());
|
||||
|
||||
media.setContentType(Util.toIsoBytes(attachment.getContentType()));
|
||||
media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.asPointer().getId())));
|
||||
media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));
|
||||
media.setContentDisposition(Util.toIsoBytes(encryptedKey));
|
||||
|
||||
body.addPart(media);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user