feat: Add direct encrypted key testing for password in decryptAttachmentBlob function
This commit is contained in:
@@ -194,10 +194,16 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
scope.launch {
|
||||
try {
|
||||
// Шифрование
|
||||
val (encryptedContent, encryptedKey) = MessageCrypto.encryptForSending(
|
||||
val encryptResult = MessageCrypto.encryptForSending(
|
||||
text.trim(),
|
||||
toPublicKey
|
||||
)
|
||||
val encryptedContent = encryptResult.ciphertext
|
||||
val encryptedKey = encryptResult.encryptedKey
|
||||
|
||||
// 🔑 КРИТИЧНО: Сохраняем ЗАШИФРОВАННЫЙ chacha_key (как в Desktop!)
|
||||
// Desktop хранит зашифрованный ключ, расшифровывает только при использовании
|
||||
android.util.Log.d("MessageRepository", "🔑 Outgoing chacha_key (encrypted): ${encryptedKey.length} chars")
|
||||
|
||||
// Сериализуем attachments в JSON
|
||||
val attachmentsJson = serializeAttachments(attachments)
|
||||
@@ -306,6 +312,11 @@ class MessageRepository private constructor(private val context: Context) {
|
||||
val dialogKey = getDialogKey(packet.fromPublicKey)
|
||||
|
||||
try {
|
||||
// 🔑 КРИТИЧНО: Сохраняем ЗАШИФРОВАННЫЙ chacha_key (как в Desktop!)
|
||||
// Desktop: хранит зашифрованный ключ, расшифровывает только при использовании
|
||||
// Buffer.from(await decrypt(message.chacha_key, privatePlain), "binary").toString('utf-8')
|
||||
android.util.Log.d("MessageRepository", "🔑 Incoming chacha_key (encrypted): ${packet.chachaKey.length} chars")
|
||||
|
||||
// Расшифровываем
|
||||
val plainText = MessageCrypto.decryptIncoming(
|
||||
packet.content,
|
||||
|
||||
Reference in New Issue
Block a user