mirror of
https://github.com/signalapp/libsignal.git
synced 2026-04-25 17:25:18 +02:00
- Java: org.whispersystems:signal-client-java ->
org.signal:libsignal-client
- Java: org.whispersystems:signal-client-android ->
org.signal:libsignal-android
- Java: org.whispersystems:libsignal-server ->
org.signal:libsignal-server
- Swift: SignalClient -> LibSignalClient
- NPM: @signalapp/signal-client -> @signalapp/libsignal-client
- Repository: github.com/signalapp/libsignal-client ->
github.com/signalapp/libsignal
460 lines
28 KiB
Swift
460 lines
28 KiB
Swift
//
|
|
// Copyright 2020-2021 Signal Messenger, LLC.
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import XCTest
|
|
import LibSignalClient
|
|
|
|
class ZKGroupTests: TestCaseBase {
|
|
|
|
let TEST_ARRAY_16: UUID = UUID(uuid: (0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f))
|
|
|
|
let TEST_ARRAY_16_1: UUID = UUID(uuid: (0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73))
|
|
|
|
let TEST_ARRAY_32: Randomness = Randomness((0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f))
|
|
|
|
let TEST_ARRAY_32_1: [UInt8] = [0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
|
|
0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83]
|
|
|
|
let TEST_ARRAY_32_2: Randomness = Randomness((0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
|
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
|
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7))
|
|
|
|
let TEST_ARRAY_32_3: Randomness = Randomness((
|
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
|
28, 29, 30, 31, 32))
|
|
|
|
let TEST_ARRAY_32_4: Randomness = Randomness((
|
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
|
|
28, 29, 30, 31, 32, 33))
|
|
|
|
let TEST_ARRAY_32_5: Randomness = Randomness((0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
|
|
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
|
|
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
|
|
0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22))
|
|
|
|
let authPresentationResult: [UInt8] = [ 0x00, 0x0c, 0xde, 0x97, 0x97, 0x37,
|
|
0xed, 0x30, 0xbb, 0xeb, 0x16, 0x36, 0x2e, 0x4e, 0x07, 0x69, 0x45, 0xce, 0x02,
|
|
0x06, 0x9f, 0x72, 0x7b, 0x0e, 0xd4, 0xc3, 0xc3, 0x3c, 0x01, 0x1e, 0x82, 0x54,
|
|
0x6e, 0x1c, 0xdf, 0x08, 0x1f, 0xbd, 0xf3, 0x7c, 0x03, 0xa8, 0x51, 0xad,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 0x5f, 0x3f, 0x28, 0x42, 0x33, 0xbb, 0x07, 0x48, 0xc0, 0x3a, 0xb4, 0xaf, 0xbf, 0x6b,
|
|
0x8f, 0xb0, 0xe1, 0x26, 0xc0, 0x37, 0xa0, 0xad, 0x40, 0x94, 0x60, 0x0d, 0xd0, 0xe0, 0x63, 0x4d,
|
|
0x76, 0xf8, 0x8c, 0x21, 0x08, 0x7f, 0x3c, 0xfb, 0x48, 0x5a, 0x89, 0xbc, 0x1e, 0x3a, 0xbc, 0x4c,
|
|
0x95, 0x04, 0x1d, 0x1d, 0x17, 0x0e, 0xcc, 0xf0, 0x29, 0x33, 0xec, 0x53, 0x93, 0xd4, 0xbe, 0x1d,
|
|
0xc5, 0x73, 0xf8, 0x3c, 0x33, 0xd3, 0xb9, 0xa7, 0x46]
|
|
|
|
let serverSignatureResult: [UInt8] = [ 0x87, 0xd3, 0x54, 0x56, 0x4d, 0x35,
|
|
0xef, 0x91, 0xed, 0xba, 0x85, 0x1e, 0x08, 0x15, 0x61, 0x2e, 0x86, 0x4c, 0x22,
|
|
0x7a, 0x04, 0x71, 0xd5, 0x0c, 0x27, 0x06, 0x98, 0x60, 0x44, 0x06, 0xd0, 0x03,
|
|
0xa5, 0x54, 0x73, 0xf5, 0x76, 0xcf, 0x24, 0x1f, 0xc6, 0xb4, 0x1c, 0x6b, 0x16,
|
|
0xe5, 0xe6, 0x3b, 0x33, 0x3c, 0x02, 0xfe, 0x4a, 0x33, 0x85, 0x80, 0x22, 0xfd,
|
|
0xd7, 0xa4, 0xab, 0x36, 0x7b, 0x06]
|
|
|
|
func testAuthIntegration() throws {
|
|
let uuid: UUID = TEST_ARRAY_16
|
|
let redemptionTime: UInt32 = 123456
|
|
|
|
// Generate keys (client's are per-group, server's are not)
|
|
// ---
|
|
|
|
// SERVER
|
|
let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32)
|
|
let serverPublicParams = try serverSecretParams.getPublicParams()
|
|
let serverZkAuth = ServerZkAuthOperations(serverSecretParams: serverSecretParams)
|
|
|
|
// CLIENT
|
|
let masterKey = try GroupMasterKey(contents: TEST_ARRAY_32_1)
|
|
let groupSecretParams = try GroupSecretParams.deriveFromMasterKey(groupMasterKey: masterKey)
|
|
|
|
XCTAssertEqual((try groupSecretParams.getMasterKey()).serialize(), masterKey.serialize())
|
|
|
|
let groupPublicParams = try groupSecretParams.getPublicParams()
|
|
|
|
// SERVER
|
|
// Issue credential
|
|
let authCredentialResponse = try serverZkAuth.issueAuthCredential(randomness: TEST_ARRAY_32_2, uuid: uuid, redemptionTime: redemptionTime)
|
|
|
|
// CLIENT
|
|
// Receive credential
|
|
let clientZkAuthCipher = ClientZkAuthOperations(serverPublicParams: serverPublicParams)
|
|
let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams )
|
|
let authCredential = try clientZkAuthCipher.receiveAuthCredential(uuid: uuid, redemptionTime: redemptionTime, authCredentialResponse: authCredentialResponse)
|
|
|
|
// Create and decrypt user entry
|
|
let uuidCiphertext = try clientZkGroupCipher.encryptUuid(uuid: uuid)
|
|
let plaintext = try clientZkGroupCipher.decryptUuid(uuidCiphertext: uuidCiphertext)
|
|
XCTAssertEqual(uuid, plaintext)
|
|
|
|
// Create presentation
|
|
let presentation = try clientZkAuthCipher.createAuthCredentialPresentation(randomness: TEST_ARRAY_32_5, groupSecretParams: groupSecretParams, authCredential: authCredential)
|
|
|
|
// Verify presentation
|
|
let uuidCiphertextRecv = try presentation.getUuidCiphertext()
|
|
XCTAssertEqual(uuidCiphertext.serialize(), uuidCiphertextRecv.serialize())
|
|
XCTAssertEqual(try presentation.getRedemptionTime(), redemptionTime)
|
|
try serverZkAuth.verifyAuthCredentialPresentation(groupPublicParams: groupPublicParams, authCredentialPresentation: presentation)
|
|
|
|
XCTAssertEqual(presentation.serialize(), authPresentationResult)
|
|
}
|
|
|
|
func testProfileKeyIntegration() throws {
|
|
|
|
let uuid: UUID = TEST_ARRAY_16
|
|
// Generate keys (client's are per-group, server's are not)
|
|
// ---
|
|
|
|
// SERVER
|
|
let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32)
|
|
let serverPublicParams = try serverSecretParams.getPublicParams()
|
|
let serverZkProfile = ServerZkProfileOperations(serverSecretParams: serverSecretParams)
|
|
|
|
// CLIENT
|
|
let masterKey = try GroupMasterKey(contents: TEST_ARRAY_32_1)
|
|
let groupSecretParams = try GroupSecretParams.deriveFromMasterKey(groupMasterKey: masterKey)
|
|
|
|
XCTAssertEqual(try groupSecretParams.getMasterKey().serialize(), masterKey.serialize())
|
|
|
|
let groupPublicParams = try groupSecretParams.getPublicParams()
|
|
let clientZkProfileCipher = ClientZkProfileOperations(serverPublicParams: serverPublicParams)
|
|
|
|
let profileKey = try ProfileKey(contents: TEST_ARRAY_32_1)
|
|
let profileKeyCommitment = try profileKey.getCommitment(uuid: uuid)
|
|
|
|
// Create context and request
|
|
let context = try clientZkProfileCipher.createProfileKeyCredentialRequestContext(randomness: TEST_ARRAY_32_3, uuid: uuid, profileKey: profileKey)
|
|
let request = try context.getRequest()
|
|
|
|
// SERVER
|
|
let response = try serverZkProfile.issueProfileKeyCredential(randomness: TEST_ARRAY_32_4, profileKeyCredentialRequest: request, uuid: uuid, profileKeyCommitment: profileKeyCommitment)
|
|
|
|
// CLIENT
|
|
// Gets stored profile credential
|
|
let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams)
|
|
let profileKeyCredential = try clientZkProfileCipher.receiveProfileKeyCredential(profileKeyCredentialRequestContext: context, profileKeyCredentialResponse: response)
|
|
|
|
// Create encrypted UID and profile key
|
|
let uuidCiphertext = try clientZkGroupCipher.encryptUuid(uuid: uuid)
|
|
let plaintext = try clientZkGroupCipher.decryptUuid(uuidCiphertext: uuidCiphertext)
|
|
|
|
XCTAssertEqual(plaintext, uuid)
|
|
|
|
let profileKeyCiphertext = try clientZkGroupCipher.encryptProfileKey(profileKey: profileKey, uuid: uuid)
|
|
let decryptedProfileKey = try clientZkGroupCipher.decryptProfileKey(profileKeyCiphertext: profileKeyCiphertext, uuid: uuid)
|
|
XCTAssertEqual(profileKey.serialize(), decryptedProfileKey.serialize())
|
|
|
|
let presentation = try clientZkProfileCipher.createProfileKeyCredentialPresentation(randomness: TEST_ARRAY_32_5, groupSecretParams: groupSecretParams, profileKeyCredential: profileKeyCredential)
|
|
|
|
XCTAssertEqual(presentation.serialize(), profileKeyPresentationResult)
|
|
|
|
// Verify presentation
|
|
try serverZkProfile.verifyProfileKeyCredentialPresentation(groupPublicParams: groupPublicParams, profileKeyCredentialPresentation: presentation)
|
|
let uuidCiphertextRecv = try presentation.getUuidCiphertext()
|
|
XCTAssertEqual(uuidCiphertext.serialize(), uuidCiphertextRecv.serialize())
|
|
|
|
let pkvB = try profileKey.getProfileKeyVersion(uuid: uuid)
|
|
let pkvC = try ProfileKeyVersion(contents: pkvB.serialize())
|
|
XCTAssertEqual(pkvB.serialize(), pkvC.serialize())
|
|
}
|
|
|
|
func testPniIntegration() throws {
|
|
let aci: UUID = TEST_ARRAY_16
|
|
let pni: UUID = TEST_ARRAY_16_1
|
|
|
|
// Generate keys (client's are per-group, server's are not)
|
|
// ---
|
|
|
|
// SERVER
|
|
let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32)
|
|
let serverPublicParams = try serverSecretParams.getPublicParams()
|
|
let serverZkProfile = ServerZkProfileOperations(serverSecretParams: serverSecretParams)
|
|
|
|
// CLIENT
|
|
let masterKey = try GroupMasterKey(contents: TEST_ARRAY_32_1)
|
|
let groupSecretParams = try GroupSecretParams.deriveFromMasterKey(groupMasterKey: masterKey)
|
|
|
|
XCTAssertEqual(try groupSecretParams.getMasterKey().serialize(), masterKey.serialize())
|
|
|
|
let groupPublicParams = try groupSecretParams.getPublicParams()
|
|
let clientZkProfileCipher = ClientZkProfileOperations(serverPublicParams: serverPublicParams)
|
|
|
|
let profileKey = try ProfileKey(contents: TEST_ARRAY_32_1)
|
|
let profileKeyCommitment = try profileKey.getCommitment(uuid: aci)
|
|
|
|
// Create context and request
|
|
let context = try clientZkProfileCipher.createPniCredentialRequestContext(randomness: TEST_ARRAY_32_3, aci: aci, pni: pni, profileKey: profileKey)
|
|
let request = try context.getRequest()
|
|
|
|
// SERVER
|
|
let response = try serverZkProfile.issuePniCredential(randomness: TEST_ARRAY_32_4, profileKeyCredentialRequest: request, aci: aci, pni: pni, profileKeyCommitment: profileKeyCommitment)
|
|
|
|
// CLIENT
|
|
// Gets stored profile credential
|
|
let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams)
|
|
let pniCredential = try clientZkProfileCipher.receivePniCredential(requestContext: context, response: response)
|
|
|
|
let presentation = try clientZkProfileCipher.createPniCredentialPresentation(randomness: TEST_ARRAY_32_5, groupSecretParams: groupSecretParams, credential: pniCredential)
|
|
|
|
XCTAssertEqual(presentation.serialize(), pniPresentationResult)
|
|
|
|
// Verify presentation
|
|
try serverZkProfile.verifyPniCredentialPresentation(groupPublicParams: groupPublicParams, presentation: presentation)
|
|
let aciCiphertextRecv = try presentation.getAciCiphertext()
|
|
XCTAssertEqual(try clientZkGroupCipher.encryptUuid(uuid: aci).serialize(), aciCiphertextRecv.serialize())
|
|
let pniCiphertextRecv = try presentation.getPniCiphertext()
|
|
XCTAssertEqual(try clientZkGroupCipher.encryptUuid(uuid: pni).serialize(), pniCiphertextRecv.serialize())
|
|
}
|
|
|
|
func testServerSignatures() throws {
|
|
let serverSecretParams = try ServerSecretParams.generate(randomness: TEST_ARRAY_32)
|
|
let serverPublicParams = try serverSecretParams.getPublicParams()
|
|
|
|
let message = TEST_ARRAY_32_1
|
|
|
|
let signature = try serverSecretParams.sign(randomness: TEST_ARRAY_32_2, message: message)
|
|
try serverPublicParams.verifySignature(message: message, notarySignature: signature)
|
|
|
|
XCTAssertEqual(signature.serialize(), serverSignatureResult)
|
|
|
|
var alteredMessage = message
|
|
alteredMessage[0] ^= 1
|
|
do {
|
|
try serverPublicParams.verifySignature(message: alteredMessage, notarySignature: signature)
|
|
XCTAssert(false)
|
|
} catch SignalError.verificationFailed(_) {
|
|
// good
|
|
}
|
|
}
|
|
|
|
func testInvalidSerialized() throws {
|
|
let ckp: [UInt8] = Array(repeating: 255, count: 289)
|
|
do {
|
|
_ = try GroupSecretParams(contents: ckp)
|
|
XCTFail("should have thrown")
|
|
} catch SignalError.invalidType(_) {
|
|
// good
|
|
}
|
|
}
|
|
|
|
func testWrongSizeSerialized() throws {
|
|
let ckp: [UInt8] = Array(repeating: 255, count: 5)
|
|
do {
|
|
_ = try GroupSecretParams(contents: ckp)
|
|
XCTFail("should have thrown")
|
|
} catch SignalError.invalidType(_) {
|
|
// good
|
|
}
|
|
}
|
|
|
|
func testBlobEncryption() throws {
|
|
let groupSecretParams = try GroupSecretParams.generate()
|
|
let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams)
|
|
|
|
let plaintext: [UInt8] = [0, 1, 2, 3, 4]
|
|
let ciphertext = try clientZkGroupCipher.encryptBlob(plaintext: plaintext)
|
|
let plaintext2 = try clientZkGroupCipher.decryptBlob(blobCiphertext: ciphertext)
|
|
|
|
XCTAssertEqual(plaintext, plaintext2)
|
|
}
|
|
|
|
func testBlobEncryptionWithRandom() throws {
|
|
let masterKey = try GroupMasterKey(contents: TEST_ARRAY_32_1)
|
|
let groupSecretParams = try GroupSecretParams.deriveFromMasterKey(groupMasterKey: masterKey)
|
|
let clientZkGroupCipher = ClientZkGroupCipher(groupSecretParams: groupSecretParams)
|
|
|
|
let plaintext: [UInt8] = [
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
0x18, 0x19]
|
|
|
|
let ciphertext: [UInt8] = [ 0xdd, 0x4d, 0x03, 0x2c, 0xa9, 0xbb, 0x75, 0xa4,
|
|
0xa7, 0x85, 0x41, 0xb9, 0x0c, 0xb4, 0xe9, 0x57, 0x43, 0xf3, 0xb0, 0xda,
|
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.encryptBlob(randomness: TEST_ARRAY_32_2, plaintext: plaintext)
|
|
let plaintext2 = try clientZkGroupCipher.decryptBlob(blobCiphertext: ciphertext2)
|
|
|
|
XCTAssertEqual(plaintext, plaintext2)
|
|
XCTAssertEqual(ciphertext, ciphertext2)
|
|
|
|
let plaintext257 = try clientZkGroupCipher.decryptBlob(blobCiphertext: ciphertext257)
|
|
XCTAssertEqual(plaintext, plaintext257)
|
|
}
|
|
|
|
static var allTests: [(String, (ZKGroupTests) -> () throws -> Void)] {
|
|
return [
|
|
("testAuthIntegration", testAuthIntegration),
|
|
("testProfileKeyIntegration", testProfileKeyIntegration),
|
|
("testServerSignatures", testServerSignatures),
|
|
("testInvalidSerialized", testInvalidSerialized),
|
|
("testWrongSizeSerialized", testWrongSizeSerialized),
|
|
("testBlobEncryption", testBlobEncryption),
|
|
("testBlobEncryptionWithRandom", testBlobEncryptionWithRandom),
|
|
]
|
|
}
|
|
}
|