Harden private media migration compatibility

This commit is contained in:
jack
2026-07-25 23:00:27 +02:00
committed by jack
parent a17f4abb02
commit 30215de295
31 changed files with 2703 additions and 120 deletions
@@ -746,7 +746,7 @@ final class NoiseEncryptionService {
/// the bounded `BitchatFilePacket` envelope and refuses every other typed
/// payload so the larger allocation budget cannot become a generic bypass.
func encryptPrivateFilePayload(_ data: Data, for peerID: PeerID) throws -> Data {
guard data.first == NoisePayloadType.privateFile.rawValue,
guard NoisePayloadType.isPrivateFile(rawValue: data.first),
NoiseSecurityValidator.validatePrivateFileMessageSize(data) else {
throw NoiseSecurityError.messageTooLarge
}
@@ -787,7 +787,7 @@ final class NoiseEncryptionService {
let decrypted = try sessionManager.decrypt(data, from: peerID)
if !isStandardCiphertext {
guard decrypted.first == NoisePayloadType.privateFile.rawValue,
guard NoisePayloadType.isPrivateFile(rawValue: decrypted.first),
NoiseSecurityValidator.validatePrivateFileMessageSize(decrypted) else {
throw NoiseSecurityError.messageTooLarge
}