Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird issue with encryption + SignalAddress #2

Open
bxem44 opened this issue Apr 27, 2018 · 2 comments
Open

Weird issue with encryption + SignalAddress #2

bxem44 opened this issue Apr 27, 2018 · 2 comments

Comments

@bxem44
Copy link
Contributor

bxem44 commented Apr 27, 2018

When encrypting a message the framework invokes its delegate stores in order to do some processing. This is done when invoking encrypt(_:) on a SessionCipher. In order to create a SessionCipher a remoteAddress is needed. Lets say we create the remoteAddress with let remoteAddress = SignalAddress(name: userId.description, deviceId: 1). Now when checking the values the remoteAddress contains (name + deviceId) I get the following correct values: userId = "1" and deviceId = 1.

Then something weird happens when encrypt(_:) is invoked. The first method that is invoked by the framework is loadSession(for:) - SessionStore. The loadSession(for:) method gets the remoteAddress as a parameter.

Now checking the values of the remoteAddress the method did receive the deviceId equals 1, but the name does not equal. Instead of getting "1" I get this: "1\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}Hrkt\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}\u{ef}U\u{ef}\u{ef}\u{ef}ݺ\u{ef}i"

Every time when encrypt(_:) is invoked the name of the address changes. But the string always starts with the original name (here "1").

I wrote some unit tests and when running non of them show this issue. This only happens on actually running the application on device or on simulator.

Here a picture of the original address that was handed over to the session cipher object:

bildschirmfoto 2018-04-27 um 21 23 32

And here the same address, that was handed over to the store delegates:

bildschirmfoto 2018-04-27 um 21 23 54

@crossle
Copy link

crossle commented May 18, 2018

SignalAddress.swift use this self.namePointer = UnsafeMutablePointer<Int8>(mutating: (name as NSString).utf8String!) should work well

@bxem44
Copy link
Contributor Author

bxem44 commented Jun 14, 2018

Thanks I will try it. For now I did make it work by filtering every character from the string which is not an integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants