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

Swift 5.2 Crash while calling TSGenerateSymmetricKey, encrypt and decrypt methods. #687

Closed
1 task done
ghost opened this issue Jul 28, 2020 · 6 comments
Closed
1 task done
Labels
bug O-iOS 📱 Operating system: iOS W-SwiftThemis 🔶 Wrapper: SwiftThemis, Swift API

Comments

@ghost
Copy link

ghost commented Jul 28, 2020

Describe the bug
iOS Application crashes after update to themis 0.13.0 and using new methods TSGenerateSymmetricKey, encrypt and decrypt.

To Reproduce
Steps to reproduce the behavior:
1a. Use let masterKeyData: Data = TSGenerateSymmetricKey()
1b. Use let decryptedData = try cellSeal.decrypt(data)
1c. Use let encryptedData = try cellSeal.encrypt(data)
2. App crashes without any error message poiting out to called themis method.

Expected behavior
1.a returns generated key
1.b returns decryptedData
1.c returns encryptedData

Environment (please complete the following information):

  • OS: iOS 13.6
  • Hardware: iPhone 11 Pro
  • Themis version: 0.13.0
  • Installation way:
    • via package manager - CocoaPods

Additional context
Xcode 11.6, Swift 5.2

@ilammy ilammy added bug O-iOS 📱 Operating system: iOS W-SwiftThemis 🔶 Wrapper: SwiftThemis, Swift API labels Jul 28, 2020
@ilammy
Copy link
Collaborator

ilammy commented Jul 28, 2020

Hm... That's weird. I just tried the following snippet with 0.13 and it works:

let key = TSGenerateSymmetricKey()!
let cellSeal = TSCellSeal(key: key)!
let inputData = "test message".data(using: .utf8)!
let encrypted = try! cellSeal.encrypt(Data())
let decrypted = try! cellSeal.decrypt(encrypted)
assert(decrypted == inputData)

Though, this might be some Swift 5.2 issue specifically. Unfortunately, I have only Swift 5 available at the moment 😞 @vixentael, your Xcode is newer, IIRC. Can you please check with Swift 5.2?

@hudzanton, just for context, is it something new for 0.13, or 0.12 breaks as well?

There is no TSGenerateSymmetricKey there, you will have to use the old API.

let key = "test key".data(using: .utf8)!
let cellSeal = TSCellSeal(key: key)!
let inputData = "test message".data(using: .utf8)!
let encrypted = try! cellSeal.wrap(inputData)
let decrypted = try! cellSeal.unwrapData(encrypted)

@ghost
Copy link
Author

ghost commented Jul 28, 2020

@ilammy It worked perfectly in 0.12.0 using wrap, unwrap and generating key on my side. I got this issue after updating to 0.13.0.

@ghost
Copy link
Author

ghost commented Jul 29, 2020

@ilammy sorry for trouble, I updated Xcode and now I don't have any crashes. I will close this issue.

@ghost ghost closed this as completed Jul 29, 2020
@vixentael
Copy link
Contributor

@hudzanton noooooooooooooo, i've already created a small test project, tested on numerous devices and OS versions, and was going to send you a test project and ask for details :D

Couldn't reproduce the crash, thought.

I tried using Xcode 11.6 and Xcode-12-beta2.

Which Xcode you've updated to?

@ghost
Copy link
Author

ghost commented Jul 29, 2020

@vixentael sorry for trouble =( I was using Xcode 11.6 when I had a crash, then I downloaded Xcode 12-beta3 and installed Xcode tools for Xcode12-beta 3. After that, it doesn't crash on both Xcode 11.6 and Xcode 12-beta3.

Thank you for the effort and all work you put in this project! I was really waiting for a 0.13.0 release to get TSGenerateSymmetricKey().

@vixentael
Copy link
Contributor

@hudzanton thank you for details, and thank you for opening the issue! It was useful for us, as we revisited our Swift/ObjC code base one more time. We'll update test suits and examples to showcase new APIs more.

Thank you for the effort and all work you put in this project! I was really waiting for a 0.13.0 release to get TSGenerateSymmetricKey().

Thank you! Let your data stay secure 🧡

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug O-iOS 📱 Operating system: iOS W-SwiftThemis 🔶 Wrapper: SwiftThemis, Swift API
Projects
None yet
Development

No branches or pull requests

2 participants