feat: Add direct encrypted key testing for password in decryptAttachmentBlob function
This commit is contained in:
@@ -192,11 +192,16 @@ fun ImageAttachment(
|
||||
downloadStatus = DownloadStatus.DECRYPTING
|
||||
Log.d(TAG, "🔓 Decrypting image...")
|
||||
|
||||
// Расшифровываем
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlob(
|
||||
// КРИТИЧНО: chachaKey ЗАШИФРОВАН в БД (как в Desktop)
|
||||
// Сначала расшифровываем его: Buffer.from(await decrypt(message.chacha_key, privatePlain), "binary").toString('utf-8')
|
||||
val decryptedKeyAndNonce = MessageCrypto.decryptKeyFromSender(chachaKey, myPrivateKey)
|
||||
val decryptKeyString = String(decryptedKeyAndNonce, Charsets.UTF_8)
|
||||
Log.d(TAG, "🔑 Decrypted chacha_key: ${decryptKeyString.length} chars")
|
||||
|
||||
// Теперь используем расшифрованный ключ как password для PBKDF2
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlobWithPassword(
|
||||
encryptedContent,
|
||||
chachaKey,
|
||||
privateKey
|
||||
decryptKeyString
|
||||
)
|
||||
downloadProgress = 0.8f
|
||||
|
||||
@@ -390,10 +395,14 @@ fun FileAttachment(
|
||||
|
||||
downloadStatus = DownloadStatus.DECRYPTING
|
||||
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlob(
|
||||
// КРИТИЧНО: chachaKey ЗАШИФРОВАН в БД (как в Desktop)
|
||||
// Сначала расшифровываем его
|
||||
val decryptedKeyAndNonce = MessageCrypto.decryptKeyFromSender(chachaKey, myPrivateKey)
|
||||
val decryptKeyString = String(decryptedKeyAndNonce, Charsets.UTF_8)
|
||||
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlobWithPassword(
|
||||
encryptedContent,
|
||||
chachaKey,
|
||||
privateKey
|
||||
decryptKeyString
|
||||
)
|
||||
downloadProgress = 0.9f
|
||||
|
||||
@@ -581,10 +590,14 @@ fun AvatarAttachment(
|
||||
val encryptedContent = TransportManager.downloadFile(attachment.id, downloadTag)
|
||||
downloadStatus = DownloadStatus.DECRYPTING
|
||||
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlob(
|
||||
// КРИТИЧНО: chachaKey ЗАШИФРОВАН в БД (как в Desktop)
|
||||
// Сначала расшифровываем его
|
||||
val decryptedKeyAndNonce = MessageCrypto.decryptKeyFromSender(chachaKey, myPrivateKey)
|
||||
val decryptKeyString = String(decryptedKeyAndNonce, Charsets.UTF_8)
|
||||
|
||||
val decrypted = MessageCrypto.decryptAttachmentBlobWithPassword(
|
||||
encryptedContent,
|
||||
chachaKey,
|
||||
privateKey
|
||||
decryptKeyString
|
||||
)
|
||||
|
||||
if (decrypted != null) {
|
||||
|
||||
Reference in New Issue
Block a user