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

Move away from openssl #274

Open
rbock44 opened this issue Oct 8, 2024 · 9 comments
Open

Move away from openssl #274

rbock44 opened this issue Oct 8, 2024 · 9 comments

Comments

@rbock44
Copy link

rbock44 commented Oct 8, 2024

I am using tauri to create a mobile android app using tapo as a depenendy.
Tapo has a depenency on openssl which gives me cross compile problems.
Is this a known issue?
Did you consider switching to rustls to avoid native openssl issues during compilation?

@mihai-dinculescu
Copy link
Owner

mihai-dinculescu commented Oct 8, 2024

Yes, OpenSSL is known for compatibility issues, even on the platforms on which it's supposed to be supported.
I'd definitely welcome switching away from it.
I think someone started doing it on a fork, but I'm not sure what happened to the effort or where it is exactly.

If someone wants to have a go at it, please shout in the next couple of days.
Otherwise, I'll try to find some time myself now that there's clear interest expressed.

@mihai-dinculescu mihai-dinculescu changed the title openssl build problem on android Switch from openssl to rustls Oct 8, 2024
@rbock44
Copy link
Author

rbock44 commented Oct 9, 2024

Hi Mihai,

I made local changes to tapo to remove openssl and replace it with sha1 and sha2 and I commented the rsa stuff out as it was to complicated for the moment.

Also Claude and ChatGpt were not really giving consistent solutions. But the dummy tapo was finally building with tauri and I could install the android native app with tapo.

Of course the requests were not working because of the commented out stuff.

I am a Rust Newbee. I have some experience with Golang and Python and I found a lot of crypto crates and I am not sure which to go for ... Also the question is how trustworthy they are. I figured that openssl is a pretty solid battle proofed solution. Not sure what the security requirements for your project are ...

But I will try again today evening to see if I can get the rsa stuff also working ...

@mihai-dinculescu mihai-dinculescu changed the title Switch from openssl to rustls Move away from openssl Oct 9, 2024
@mihai-dinculescu
Copy link
Owner

I've started having a quick look, and there seem to be three areas that openssl covers and could be replaced with lower-level crates.

  • hashing: sha1 and sha2 crates should cover this
  • asymmetric encryption (RSA): the rsa crate looks like a good choice
  • symmetric encryption (AES): I haven't had a chance to look into this yet

@rbock44
Copy link
Author

rbock44 commented Oct 9, 2024

Working :-)

I tried yesterdayh ChatGpt4 and Claude3.5 until my free tokens were over. I did not really succeed but got some inspirations.

The problem with the AI is that there are many crate versions of rsa and cipher and cbc and the guys are changing the API frequently. The AI gets confused und mixes different versions. So it becomes worse after some time.

I started today fresh and limited the changes and used an older crate version for rsa which is 0.7 instead of 0.9 and with some manual fixing now it works for me.

You can see it in the picture :-)

android-app

I am a big fan of your tapo library ... Only in case I did not mention this before.

I guess the refactoring would need a look from an expierienced guy and the upgrade to rsa 0.9 I would also think is necessary. But I am putting the stuff I have as a pull request so you can see where this is going and you can fine tune it. Or give me some comments and I try to fine tune it.

I am also not sure if you have some test cases which I can run and validate the changes ...

@rbock44
Copy link
Author

rbock44 commented Oct 9, 2024

I now also upgraded to crate version 0.9.6 for rsa so this should be fixed.

@mihai-dinculescu
Copy link
Owner

This is great! #275.
I need to understand what's going on and figure out how to test it, but this should serve as a very good starting point while also unblocking your use case.

@rbock44
Copy link
Author

rbock44 commented Oct 18, 2024

Yes. That is the scary part :-) I only understand half of it. Cryptography sucks and Cryptography with Rust sucks even more :-)
It works for me with Android and Linux Desktop so I am fine with the fork for now, but I can see a big plus for the tapo lib as you get rid of the native dependencies that are difficult to ensure that they work on all platforms.

But take your time. I can live with the fork for now :-) In case I find problems I let you know ...

@mihai-dinculescu
Copy link
Owner

Ok, I think I've got it. #281

Your PR has been a great source of inspiration, and I've ended up writing the same thing, which is just a tad more optimised (e.g., the padding is done through the library rather than manually).

Mind giving it a try?

@rbock44
Copy link
Author

rbock44 commented Oct 18, 2024 via email

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