mv-experiment #1

Merged
fmodf merged 88 commits from mv-experiment into develop 2024-09-03 15:13:59 +00:00
Showing only changes of commit d950c4c907 - Show all commits

View file

@ -54,7 +54,13 @@ final class ClientMartinOMEMO {
String(format: "%02x", byte) String(format: "%02x", byte)
}.joined() }.joined()
guard !OMEMOIdentity.existsFor(account: credentials.bareJid, name: credentials.bareJid, fingerprint: fingerprint) else { return save(address: address, fingerprint: fingerprint, own: true, data: keyPair.serialized())
}
return true
}
private func save(address: SignalAddress, fingerprint: String, own: Bool, data: Data) -> Bool {
guard !OMEMOIdentity.existsFor(account: credentials.bareJid, name: address.name, fingerprint: fingerprint) else {
return false return false
} }
@ -65,8 +71,8 @@ final class ClientMartinOMEMO {
name: address.name, name: address.name,
deviceId: Int(address.deviceId), deviceId: Int(address.deviceId),
fingerprint: fingerprint, fingerprint: fingerprint,
key: keyPair.serialized(), key: data,
own: true, own: own,
status: MartinOMEMO.IdentityStatus.trustedActive.rawValue status: MartinOMEMO.IdentityStatus.trustedActive.rawValue
) )
.insert(db) .insert(db)
@ -77,8 +83,6 @@ final class ClientMartinOMEMO {
return false return false
} }
} }
return true
}
} }
// MARK: - Session // MARK: - Session
@ -197,14 +201,26 @@ extension ClientMartinOMEMO: SignalIdentityKeyStoreProtocol {
} }
func save(identity: MartinOMEMO.SignalAddress, key: (any MartinOMEMO.SignalIdentityKeyProtocol)?) -> Bool { func save(identity: MartinOMEMO.SignalAddress, key: (any MartinOMEMO.SignalIdentityKeyProtocol)?) -> Bool {
print(identity, key) guard let key = key as SignalIdentityKeyProtocol?, let publicKey = key.publicKey else {
return false return false
} }
let fingerprint = publicKey.map { byte -> String in
String(format: "%02x", byte)
}.joined()
return save(address: identity, fingerprint: fingerprint, own: true, data: key.serialized())
}
func save(identity: MartinOMEMO.SignalAddress, publicKeyData: Data?) -> Bool { func save(identity: MartinOMEMO.SignalAddress, publicKeyData: Data?) -> Bool {
print(identity, publicKeyData) guard let publicKeyData = publicKeyData else {
return false return false
} }
let fingerprint = publicKeyData.map { byte -> String in
String(format: "%02x", byte)
}.joined()
return save(address: identity, fingerprint: fingerprint, own: false, data: publicKeyData)
}
func isTrusted(identity _: MartinOMEMO.SignalAddress, key _: (any MartinOMEMO.SignalIdentityKeyProtocol)?) -> Bool { func isTrusted(identity _: MartinOMEMO.SignalAddress, key _: (any MartinOMEMO.SignalIdentityKeyProtocol)?) -> Bool {
true true