Add swiftlint configuration and fix issues

This commit is contained in:
Jordan Rose 2020-10-06 10:56:43 -07:00
parent 9e3682db86
commit c7a33f4d6e
10 changed files with 72 additions and 79 deletions

9
.swiftlint.yml Normal file
View File

@ -0,0 +1,9 @@
disabled_rules:
- cyclomatic_complexity
- force_try
- function_body_length
- function_parameter_count
- identifier_name
- line_length
- trailing_comma
- type_body_length

View File

@ -62,7 +62,7 @@ class ClonableHandleOwner {
switch handle {
case nil:
return
case .borrowed(_)?:
case .borrowed?:
preconditionFailure("borrowed handle may have escaped")
case .owned(let handle)?:
Self.destroyNativeHandle(handle)

View File

@ -1,12 +1,11 @@
class InMemorySignalProtocolStore : IdentityKeyStore, PreKeyStore, SignedPreKeyStore, SessionStore, SenderKeyStore {
private var publicKeys : [ProtocolAddress : IdentityKey] = [:]
private var privateKey : IdentityKeyPair;
private var deviceId : UInt32;
private var prekeyMap : [UInt32 : PreKeyRecord] = [:]
private var signedPrekeyMap : [UInt32 : SignedPreKeyRecord] = [:]
private var sessionMap : [ProtocolAddress: SessionRecord] = [:]
private var senderKeyMap : [SenderKeyName : SenderKeyRecord] = [:]
class InMemorySignalProtocolStore: IdentityKeyStore, PreKeyStore, SignedPreKeyStore, SessionStore, SenderKeyStore {
private var publicKeys: [ProtocolAddress: IdentityKey] = [:]
private var privateKey: IdentityKeyPair
private var deviceId: UInt32
private var prekeyMap: [UInt32: PreKeyRecord] = [:]
private var signedPrekeyMap: [UInt32: SignedPreKeyRecord] = [:]
private var sessionMap: [ProtocolAddress: SessionRecord] = [:]
private var senderKeyMap: [SenderKeyName: SenderKeyRecord] = [:]
init() throws {
privateKey = try IdentityKeyPair.generate()
@ -25,7 +24,7 @@ class InMemorySignalProtocolStore : IdentityKeyStore, PreKeyStore, SignedPreKeyS
if publicKeys.updateValue(identity, forKey: address) == nil {
return false; // newly created
} else {
return true;
return true
}
}
@ -43,14 +42,14 @@ class InMemorySignalProtocolStore : IdentityKeyStore, PreKeyStore, SignedPreKeyS
func loadPreKey(id: UInt32, context: UnsafeMutableRawPointer?) throws -> PreKeyRecord {
if let record = prekeyMap[id] {
return record;
return record
} else {
throw SignalError.invalidKeyIdentifier("no prekey with this identifier")
}
}
func storePreKey(_ record: PreKeyRecord, id: UInt32, context: UnsafeMutableRawPointer?) throws {
prekeyMap[id] = record;
prekeyMap[id] = record
}
func removePreKey(id: UInt32, context: UnsafeMutableRawPointer?) throws {
@ -59,22 +58,22 @@ class InMemorySignalProtocolStore : IdentityKeyStore, PreKeyStore, SignedPreKeyS
func loadSignedPreKey(id: UInt32, context: UnsafeMutableRawPointer?) throws -> SignedPreKeyRecord {
if let record = signedPrekeyMap[id] {
return record;
return record
} else {
throw SignalError.invalidKeyIdentifier("no signed prekey with this identifier")
}
}
func storeSignedPreKey(_ record: SignedPreKeyRecord, id: UInt32, context: UnsafeMutableRawPointer?) throws {
signedPrekeyMap[id] = record;
signedPrekeyMap[id] = record
}
func loadSession(for address: ProtocolAddress, context: UnsafeMutableRawPointer?) throws -> SessionRecord? {
return sessionMap[address];
return sessionMap[address]
}
func storeSession(_ record: SessionRecord, for address: ProtocolAddress, context: UnsafeMutableRawPointer?) throws {
sessionMap[address] = record;
sessionMap[address] = record
}
func storeSenderKey(name: SenderKeyName, record: SenderKeyRecord, context: UnsafeMutableRawPointer?) throws {

View File

@ -1,6 +1,6 @@
import SignalFfi
public enum SignalError : Error {
public enum SignalError: Error {
case invalidState(String)
case internalError(String)
case nullParameter(String)

View File

@ -24,7 +24,7 @@ struct ScannableFingerprint {
}
struct Fingerprint {
let scannable : ScannableFingerprint
let scannable: ScannableFingerprint
let displayable: DisplayableFingerprint
internal init(displayable: DisplayableFingerprint, scannable: ScannableFingerprint) {
@ -46,7 +46,7 @@ struct NumericFingerprintGenerator {
remoteIdentifier: [UInt8],
remoteKey: PublicKey) throws -> Fingerprint {
var obj : OpaquePointer?
var obj: OpaquePointer?
try checkError(signal_fingerprint_new(&obj, UInt32(iterations), UInt32(version),
localIdentifier, localIdentifier.count,
localKey.nativeHandle,

View File

@ -16,13 +16,12 @@ struct IdentityKey: Equatable {
}
}
struct IdentityKeyPair {
let publicKey: PublicKey
let privateKey: PrivateKey
private init() throws {
privateKey = try PrivateKey.generate();
privateKey = try PrivateKey.generate()
publicKey = try privateKey.publicKey()
}

View File

@ -36,7 +36,7 @@ class PublicKey: ClonableHandleOwner {
}
func compare(_ other: PublicKey) -> Int32 {
var result : Int32 = 0
var result: Int32 = 0
try! checkError(signal_publickey_compare(&result, nativeHandle, other.nativeHandle))
return result
}

View File

@ -1,7 +1,7 @@
import SignalFfi
func invokeFnReturningString(fn: (UnsafeMutablePointer<UnsafePointer<CChar>?>?) -> SignalFfiErrorRef?) throws -> String {
var output : UnsafePointer<Int8>? = nil
var output: UnsafePointer<Int8>?
try checkError(fn(&output))
let result = String(cString: output!)
signal_free_string(output)
@ -9,7 +9,7 @@ func invokeFnReturningString(fn: (UnsafeMutablePointer<UnsafePointer<CChar>?>?)
}
func invokeFnReturningArray(fn: (UnsafeMutablePointer<UnsafePointer<UInt8>?>?, UnsafeMutablePointer<Int>?) -> SignalFfiErrorRef?) throws -> [UInt8] {
var output : UnsafePointer<UInt8>? = nil
var output: UnsafePointer<UInt8>?
var output_len = 0
try checkError(fn(&output, &output_len))
let result = Array(UnsafeBufferPointer(start: output, count: output_len))
@ -18,31 +18,31 @@ func invokeFnReturningArray(fn: (UnsafeMutablePointer<UnsafePointer<UInt8>?>?, U
}
func invokeFnReturningInteger<Result: FixedWidthInteger>(fn: (UnsafeMutablePointer<Result>?) -> SignalFfiErrorRef?) throws -> Result {
var output : Result = 0
var output: Result = 0
try checkError(fn(&output))
return output
}
func invokeFnReturningPublicKey(fn: (UnsafeMutablePointer<OpaquePointer?>?) -> SignalFfiErrorRef?) throws -> PublicKey {
var pk_handle : OpaquePointer?
var pk_handle: OpaquePointer?
try checkError(fn(&pk_handle))
return PublicKey(owned: pk_handle!)
}
func invokeFnReturningPrivateKey(fn: (UnsafeMutablePointer<OpaquePointer?>?) -> SignalFfiErrorRef?) throws -> PrivateKey {
var pk_handle : OpaquePointer?
var pk_handle: OpaquePointer?
try checkError(fn(&pk_handle))
return PrivateKey(owned: pk_handle!)
}
func invokeFnReturningOptionalPublicKey(fn: (UnsafeMutablePointer<OpaquePointer?>?) -> SignalFfiErrorRef?) throws -> PublicKey? {
var pk_handle : OpaquePointer?
var pk_handle: OpaquePointer?
try checkError(fn(&pk_handle))
return pk_handle.map { PublicKey(owned: $0) }
}
func invokeFnReturningCiphertextMessage(fn: (UnsafeMutablePointer<OpaquePointer?>?) -> SignalFfiErrorRef?) throws -> CiphertextMessage {
var handle : OpaquePointer?
var handle: OpaquePointer?
try checkError(fn(&handle))
return CiphertextMessage(owned: handle)
}
@ -56,8 +56,7 @@ func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePoin
var privateKey = try store.identityKeyPair(context: ctx).privateKey
keyp!.pointee = try cloneOrTakeHandle(from: &privateKey)
return 0
}
catch {
} catch {
return -1
}
}
@ -68,10 +67,9 @@ func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePoin
do {
let store = store_ctx!.assumingMemoryBound(to: IdentityKeyStore.self).pointee
let id = try store.localRegistrationId(context: ctx)
idp!.pointee = id;
idp!.pointee = id
return 0
}
catch {
} catch {
return -1
}
}
@ -93,8 +91,7 @@ func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePoin
} else {
return 0
}
}
catch {
} catch {
return -1
}
}
@ -114,8 +111,7 @@ func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePoin
public_key!.pointee = nil
}
return 0
}
catch {
} catch {
return -1
}
}
@ -144,8 +140,7 @@ func withIdentityKeyStore<Result>(_ store: IdentityKeyStore, _ body: (UnsafePoin
let identity = IdentityKey(publicKey: public_key)
let trusted = try store.isTrustedIdentity(identity, for: address, direction: direction, context: ctx)
return trusted ? 1 : 0
}
catch {
} catch {
return -1
}
}
@ -175,8 +170,7 @@ func withPreKeyStore<Result>(_ store: PreKeyStore, _ body: (UnsafePointer<Signal
defer { cloneOrForgetAsNeeded(&record) }
try store.storePreKey(record, id: id, context: ctx)
return 0
}
catch {
} catch {
return -1
}
}
@ -190,8 +184,7 @@ func withPreKeyStore<Result>(_ store: PreKeyStore, _ body: (UnsafePointer<Signal
var record = try store.loadPreKey(id: id, context: ctx)
recordp!.pointee = try cloneOrTakeHandle(from: &record)
return 0
}
catch {
} catch {
return -1
}
}
@ -203,8 +196,7 @@ func withPreKeyStore<Result>(_ store: PreKeyStore, _ body: (UnsafePointer<Signal
let store = store_ctx!.assumingMemoryBound(to: PreKeyStore.self).pointee
try store.removePreKey(id: id, context: ctx)
return 0
}
catch {
} catch {
return -1
}
}
@ -232,8 +224,7 @@ func withSignedPreKeyStore<Result>(_ store: SignedPreKeyStore, _ body: (UnsafePo
defer { cloneOrForgetAsNeeded(&record) }
try store.storeSignedPreKey(record, id: id, context: ctx)
return 0
}
catch {
} catch {
return -1
}
}
@ -247,8 +238,7 @@ func withSignedPreKeyStore<Result>(_ store: SignedPreKeyStore, _ body: (UnsafePo
var record = try store.loadSignedPreKey(id: id, context: ctx)
recordp!.pointee = try cloneOrTakeHandle(from: &record)
return 0
}
catch {
} catch {
return -1
}
}
@ -277,8 +267,7 @@ func withSessionStore<Result>(_ store: SessionStore, _ body: (UnsafePointer<Sign
defer { cloneOrForgetAsNeeded(&record) }
try store.storeSession(record, for: address, context: ctx)
return 0
}
catch {
} catch {
return -1
}
}
@ -297,8 +286,7 @@ func withSessionStore<Result>(_ store: SessionStore, _ body: (UnsafePointer<Sign
recordp!.pointee = nil
}
return 0
}
catch {
} catch {
return -1
}
}
@ -327,8 +315,7 @@ func withSenderKeyStore<Result>(_ store: SenderKeyStore, _ body: (UnsafePointer<
defer { cloneOrForgetAsNeeded(&record) }
try store.storeSenderKey(name: sender_name, record: record, context: ctx)
return 0
}
catch {
} catch {
return -1
}
}
@ -347,8 +334,7 @@ func withSenderKeyStore<Result>(_ store: SenderKeyStore, _ body: (UnsafePointer<
recordp!.pointee = nil
}
return 0
}
catch {
} catch {
return -1
}
}

View File

@ -23,7 +23,7 @@ class SignedPreKeyRecord: ClonableHandleOwner {
var handle: OpaquePointer?
try checkError(signal_signed_pre_key_record_new(&handle, id, timestamp,
publicKey.nativeHandle, privateKey.nativeHandle,
signature, signature.count));
signature, signature.count))
super.init(owned: handle!)
}

View File

@ -4,13 +4,13 @@ import XCTest
class SignalProtocolTests: XCTestCase {
func testHkdf() {
let ikm : [UInt8] = [
let ikm: [UInt8] = [
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
]
let info : [UInt8] = []
let salt : [UInt8] = []
let okm : [UInt8] = [0x8d, 0xa4, 0xe7, 0x75]
let info: [UInt8] = []
let salt: [UInt8] = []
let okm: [UInt8] = [0x8d, 0xa4, 0xe7, 0x75]
let version = UInt32(3)
let derived = try! hkdf(outputLength: okm.count,
@ -46,7 +46,7 @@ class SignalProtocolTests: XCTestCase {
XCTAssertEqual(try! pk.serialize(), try! pk_reloaded.serialize())
var message : [UInt8] = [1, 2, 3]
var message: [UInt8] = [1, 2, 3]
var signature = try! sk.generateSignature(message: message)
XCTAssertEqual(try! pk.verifySignature(message: message, signature: signature), true)
@ -70,22 +70,22 @@ class SignalProtocolTests: XCTestCase {
func testFingerprint() {
let ALICE_IDENTITY : [UInt8] = [0x05, 0x06, 0x86, 0x3b, 0xc6, 0x6d, 0x02, 0xb4, 0x0d, 0x27, 0xb8, 0xd4, 0x9c, 0xa7, 0xc0, 0x9e, 0x92, 0x39, 0x23, 0x6f, 0x9d, 0x7d, 0x25, 0xd6, 0xfc, 0xca, 0x5c, 0xe1, 0x3c, 0x70, 0x64, 0xd8, 0x68]
let BOB_IDENTITY : [UInt8] = [0x05, 0xf7, 0x81, 0xb6, 0xfb, 0x32, 0xfe, 0xd9, 0xba, 0x1c, 0xf2, 0xde, 0x97, 0x8d, 0x4d, 0x5d, 0xa2, 0x8d, 0xc3, 0x40, 0x46, 0xae, 0x81, 0x44, 0x02, 0xb5, 0xc0, 0xdb, 0xd9, 0x6f, 0xda, 0x90, 0x7b]
let ALICE_IDENTITY: [UInt8] = [0x05, 0x06, 0x86, 0x3b, 0xc6, 0x6d, 0x02, 0xb4, 0x0d, 0x27, 0xb8, 0xd4, 0x9c, 0xa7, 0xc0, 0x9e, 0x92, 0x39, 0x23, 0x6f, 0x9d, 0x7d, 0x25, 0xd6, 0xfc, 0xca, 0x5c, 0xe1, 0x3c, 0x70, 0x64, 0xd8, 0x68]
let BOB_IDENTITY: [UInt8] = [0x05, 0xf7, 0x81, 0xb6, 0xfb, 0x32, 0xfe, 0xd9, 0xba, 0x1c, 0xf2, 0xde, 0x97, 0x8d, 0x4d, 0x5d, 0xa2, 0x8d, 0xc3, 0x40, 0x46, 0xae, 0x81, 0x44, 0x02, 0xb5, 0xc0, 0xdb, 0xd9, 0x6f, 0xda, 0x90, 0x7b]
let VERSION_1 = 1
let DISPLAYABLE_FINGERPRINT_V1 = "300354477692869396892869876765458257569162576843440918079131"
let ALICE_SCANNABLE_FINGERPRINT_V1 : [UInt8] = [0x08, 0x01, 0x12, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf, 0x1a, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d]
let BOB_SCANNABLE_FINGERPRINT_V1 : [UInt8] = [0x08, 0x01, 0x12, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d, 0x1a, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf]
let ALICE_SCANNABLE_FINGERPRINT_V1: [UInt8] = [0x08, 0x01, 0x12, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf, 0x1a, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d]
let BOB_SCANNABLE_FINGERPRINT_V1: [UInt8] = [0x08, 0x01, 0x12, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d, 0x1a, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf]
let VERSION_2 = 2
let DISPLAYABLE_FINGERPRINT_V2 = DISPLAYABLE_FINGERPRINT_V1
let ALICE_SCANNABLE_FINGERPRINT_V2: [UInt8] = [0x08, 0x02, 0x12, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf, 0x1a, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d]
let BOB_SCANNABLE_FINGERPRINT_V2 : [UInt8] = [0x08, 0x02, 0x12, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d, 0x1a, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf]
let BOB_SCANNABLE_FINGERPRINT_V2: [UInt8] = [0x08, 0x02, 0x12, 0x22, 0x0a, 0x20, 0xd6, 0x2c, 0xbf, 0x73, 0xa1, 0x15, 0x92, 0x01, 0x5b, 0x6b, 0x9f, 0x16, 0x82, 0xac, 0x30, 0x6f, 0xea, 0x3a, 0xaf, 0x38, 0x85, 0xb8, 0x4d, 0x12, 0xbc, 0xa6, 0x31, 0xe9, 0xd4, 0xfb, 0x3a, 0x4d, 0x1a, 0x22, 0x0a, 0x20, 0x1e, 0x30, 0x1a, 0x03, 0x53, 0xdc, 0xe3, 0xdb, 0xe7, 0x68, 0x4c, 0xb8, 0x33, 0x6e, 0x85, 0x13, 0x6c, 0xdc, 0x0e, 0xe9, 0x62, 0x19, 0x49, 0x4a, 0xda, 0x30, 0x5d, 0x62, 0xa7, 0xbd, 0x61, 0xdf]
// testVectorsVersion1
let aliceStableId : [UInt8] = [UInt8]("+14152222222".utf8)
let bobStableId : [UInt8] = [UInt8]("+14153333333".utf8)
let aliceStableId: [UInt8] = [UInt8]("+14152222222".utf8)
let bobStableId: [UInt8] = [UInt8]("+14153333333".utf8)
let aliceIdentityKey = try! PublicKey(ALICE_IDENTITY)
let bobIdentityKey = try! PublicKey(BOB_IDENTITY)
@ -156,7 +156,7 @@ class SignalProtocolTests: XCTestCase {
// testMismatchingIdentifiers
let badBobStableId : [UInt8] = [UInt8]("+14153333334".utf8)
let badBobStableId: [UInt8] = [UInt8]("+14153333334".utf8)
let aliceFingerprintI = try! generator.create(version: VERSION_1,
localIdentifier: aliceStableId,
@ -190,7 +190,7 @@ class SignalProtocolTests: XCTestCase {
let skdm_r = try! SenderKeyDistributionMessage(bytes: skdm_bits)
let a_ctext = try! groupEncrypt(groupId: group_id, message: [1,2,3], store: a_store, context: nil)
let a_ctext = try! groupEncrypt(groupId: group_id, message: [1, 2, 3], store: a_store, context: nil)
let b_store = try! InMemorySignalProtocolStore()
try! processSenderKeyDistributionMessage(sender: group_id,
@ -199,7 +199,7 @@ class SignalProtocolTests: XCTestCase {
context: nil)
let b_ptext = try! groupDecrypt(groupId: group_id, message: a_ctext, store: b_store, context: nil)
XCTAssertEqual(b_ptext, [1,2,3])
XCTAssertEqual(b_ptext, [1, 2, 3])
}
func testSessionCipher() {
@ -217,8 +217,8 @@ class SignalProtocolTests: XCTestCase {
let bob_identity_key = try! bob_store.identityKeyPair(context: nil).identityKey
let bob_signed_pre_key_signature = try! bob_store.identityKeyPair(context: nil).privateKey.generateSignature(message: bob_signed_pre_key_public)
let prekey_id : UInt32 = 4570;
let signed_prekey_id : UInt32 = 3006;
let prekey_id: UInt32 = 4570
let signed_prekey_id: UInt32 = 3006
let bob_bundle = try! PreKeyBundle(registrationId: try! bob_store.localRegistrationId(context: nil),
deviceId: 9,
@ -251,7 +251,7 @@ class SignalProtocolTests: XCTestCase {
context: nil)
// Alice sends a message:
let ptext_a : [UInt8] = [8,6,7,5,3,0,9];
let ptext_a: [UInt8] = [8, 6, 7, 5, 3, 0, 9]
let ctext_a = try! signalEncrypt(message: ptext_a,
for: bob_address,
@ -274,7 +274,7 @@ class SignalProtocolTests: XCTestCase {
XCTAssertEqual(ptext_a, ptext_b)
// Bob replies
let ptext2_b : [UInt8] = [23];
let ptext2_b: [UInt8] = [23]
let ctext2_b = try! signalEncrypt(message: ptext2_b,
for: alice_address,