feat: Replace ProtocolManager logging with Android Log for ECDH encryption process
This commit is contained in:
@@ -303,8 +303,8 @@ object MessageCrypto {
|
|||||||
secureRandom.nextBytes(iv)
|
secureRandom.nextBytes(iv)
|
||||||
val ivHex = iv.toHex()
|
val ivHex = iv.toHex()
|
||||||
|
|
||||||
// Шифруем keyAndNonce с AES-CBC используя sharedSecret как ключ
|
// Шифруем keyAndNonce напрямую с AES-CBC используя sharedSecret как ключ
|
||||||
// ВАЖНО: Используем сам sharedSecret напрямую (32 байта) без SHA-256!
|
// React Native теперь использует crypto.enc.Latin1 для binary data
|
||||||
val aesKey = SecretKeySpec(sharedSecret, "AES")
|
val aesKey = SecretKeySpec(sharedSecret, "AES")
|
||||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, aesKey, IvParameterSpec(iv))
|
cipher.init(Cipher.ENCRYPT_MODE, aesKey, IvParameterSpec(iv))
|
||||||
@@ -314,11 +314,11 @@ object MessageCrypto {
|
|||||||
// Формат как в RN: btoa(ivHex:encryptedHex:ephemeralPrivateHex)
|
// Формат как в RN: btoa(ivHex:encryptedHex:ephemeralPrivateHex)
|
||||||
val combined = "$ivHex:$encryptedKeyHex:$ephemeralPrivateKeyHex"
|
val combined = "$ivHex:$encryptedKeyHex:$ephemeralPrivateKeyHex"
|
||||||
|
|
||||||
ProtocolManager.addLog("🔐 ECDH Encrypt:")
|
android.util.Log.d("MessageCrypto", "🔐 ECDH Encrypt:")
|
||||||
ProtocolManager.addLog(" - Shared secret: ${sharedSecretHex.take(40)}...")
|
android.util.Log.d("MessageCrypto", " - Shared secret: ${sharedSecretHex.take(40)}...")
|
||||||
ProtocolManager.addLog(" - IV: ${ivHex.take(32)}...")
|
android.util.Log.d("MessageCrypto", " - IV: ${ivHex.take(32)}...")
|
||||||
ProtocolManager.addLog(" - Ephemeral private: ${ephemeralPrivateKeyHex.take(40)}...")
|
android.util.Log.d("MessageCrypto", " - Ephemeral private: ${ephemeralPrivateKeyHex.take(40)}...")
|
||||||
ProtocolManager.addLog(" - Recipient public: ${recipientPublicKeyHex.take(40)}...")
|
android.util.Log.d("MessageCrypto", " - Recipient public: ${recipientPublicKeyHex.take(40)}...")
|
||||||
|
|
||||||
return Base64.encodeToString(combined.toByteArray(), Base64.NO_WRAP)
|
return Base64.encodeToString(combined.toByteArray(), Base64.NO_WRAP)
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ object MessageCrypto {
|
|||||||
android.util.Log.d("MessageCrypto", "✅ Encrypted key length: ${encryptedKey.length}")
|
android.util.Log.d("MessageCrypto", "✅ Encrypted key length: ${encryptedKey.length}")
|
||||||
|
|
||||||
android.util.Log.d("MessageCrypto", "🔐 === ENCRYPTION COMPLETE ===")
|
android.util.Log.d("MessageCrypto", "🔐 === ENCRYPTION COMPLETE ===")
|
||||||
return Pair(encrypted.ciphertext, encryptedKey)
|
return kotlin.Pair(encrypted.ciphertext, encryptedKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user