mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:25:20 +00:00
feat: enhance password-protected rooms with key commitments and management
- Add key commitment scheme for immediate password verification - Implement ownership transfer with /transfer command - Add password change functionality with /pass command - Include room metadata in initialization messages - Remove /help command and rename /changepass to /pass - Make room names tappable to show sidebar - Remove spaces in person/room counter display - Update UI to show lock icons and orange colors for protected rooms - Fix password verification to work with empty rooms - Add comprehensive tests for new functionality This update significantly improves the security and usability of password-protected rooms by allowing immediate verification without waiting for encrypted messages.
This commit is contained in:
@@ -107,7 +107,9 @@ struct BinaryProtocol {
|
||||
var offset = 0
|
||||
|
||||
// Header
|
||||
_ = data[offset]; offset += 1 // version
|
||||
let version = data[offset]; offset += 1
|
||||
// Only support version 1
|
||||
guard version == 1 else { return nil }
|
||||
let type = data[offset]; offset += 1
|
||||
let ttl = data[offset]; offset += 1
|
||||
|
||||
|
||||
@@ -18,15 +18,18 @@ struct MessagePadding {
|
||||
static func pad(_ data: Data, toSize targetSize: Int) -> Data {
|
||||
guard data.count < targetSize else { return data }
|
||||
|
||||
var padded = data
|
||||
let paddingNeeded = targetSize - data.count
|
||||
|
||||
// Add random padding bytes (more secure than zeros)
|
||||
// PKCS#7 only supports padding up to 255 bytes
|
||||
// If we need more padding than that, don't pad - return original data
|
||||
guard paddingNeeded <= 255 else { return data }
|
||||
|
||||
var padded = data
|
||||
|
||||
// Standard PKCS#7 padding
|
||||
var randomBytes = [UInt8](repeating: 0, count: paddingNeeded - 1)
|
||||
_ = SecRandomCopyBytes(kSecRandomDefault, paddingNeeded - 1, &randomBytes)
|
||||
padded.append(contentsOf: randomBytes)
|
||||
|
||||
// Last byte indicates padding length (PKCS#7 style)
|
||||
padded.append(UInt8(paddingNeeded))
|
||||
|
||||
return padded
|
||||
@@ -161,7 +164,7 @@ protocol BitchatDelegate: AnyObject {
|
||||
func didDisconnectFromPeer(_ peerID: String)
|
||||
func didUpdatePeerList(_ peers: [String])
|
||||
func didReceiveRoomLeave(_ room: String, from peerID: String)
|
||||
func didReceivePasswordProtectedRoomAnnouncement(_ room: String, isProtected: Bool, creatorID: String?)
|
||||
func didReceivePasswordProtectedRoomAnnouncement(_ room: String, isProtected: Bool, creatorID: String?, keyCommitment: String?)
|
||||
func decryptRoomMessage(_ encryptedContent: Data, room: String) -> String?
|
||||
|
||||
// Optional method to check if a fingerprint belongs to a favorite peer
|
||||
@@ -178,7 +181,7 @@ extension BitchatDelegate {
|
||||
// Default empty implementation
|
||||
}
|
||||
|
||||
func didReceivePasswordProtectedRoomAnnouncement(_ room: String, isProtected: Bool, creatorID: String?) {
|
||||
func didReceivePasswordProtectedRoomAnnouncement(_ room: String, isProtected: Bool, creatorID: String?, keyCommitment: String?) {
|
||||
// Default empty implementation
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user