mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 06:05: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:
@@ -39,9 +39,17 @@ class MessagePaddingTests: XCTestCase {
|
||||
XCTAssertTrue(MessagePadding.blockSizes.contains(blockSize) || blockSize == data.count)
|
||||
|
||||
let padded = MessagePadding.pad(data, toSize: blockSize)
|
||||
let unpadded = MessagePadding.unpad(padded)
|
||||
|
||||
XCTAssertEqual(unpadded, data)
|
||||
// Check if padding was applied (only if needed padding <= 255)
|
||||
let paddingNeeded = blockSize - data.count
|
||||
if paddingNeeded <= 255 {
|
||||
XCTAssertEqual(padded.count, blockSize)
|
||||
let unpadded = MessagePadding.unpad(padded)
|
||||
XCTAssertEqual(unpadded, data)
|
||||
} else {
|
||||
// No padding applied if more than 255 bytes needed
|
||||
XCTAssertEqual(padded, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +61,18 @@ class MessagePaddingTests: XCTestCase {
|
||||
XCTAssertEqual(blockSize, 2048)
|
||||
|
||||
let padded = MessagePadding.pad(largeData, toSize: blockSize)
|
||||
XCTAssertEqual(padded.count, blockSize)
|
||||
// Since padding needed (548 bytes) > 255, no padding is applied
|
||||
XCTAssertEqual(padded.count, largeData.count)
|
||||
XCTAssertEqual(padded, largeData)
|
||||
|
||||
let unpadded = MessagePadding.unpad(padded)
|
||||
XCTAssertEqual(unpadded, largeData)
|
||||
// Test with data that fits within PKCS#7 limits
|
||||
let smallerData = Data(repeating: 0xAA, count: 1800)
|
||||
let paddedSmaller = MessagePadding.pad(smallerData, toSize: 2048)
|
||||
// Padding needed is 248 bytes, which is < 255, so padding should work
|
||||
XCTAssertEqual(paddedSmaller.count, 2048)
|
||||
|
||||
let unpaddedSmaller = MessagePadding.unpad(paddedSmaller)
|
||||
XCTAssertEqual(unpaddedSmaller, smallerData)
|
||||
}
|
||||
|
||||
func testInvalidPadding() {
|
||||
|
||||
Reference in New Issue
Block a user