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

Keep leading zero bytes in salt, based on gist by @Gdocal #61

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

magicus
Copy link
Contributor

@magicus magicus commented Nov 1, 2024

Apple iCloud login recently switched to using SRP. In an effort to get the Python-based iCloud wrappers (like https://github.com/picklepete/pyicloud and https://github.com/gcobb321/icloud3_v3), it was discovered that the SRP implementation between the Apple original JS login, and the pysrp Python library differed in some cases.

The difference was tracked down by @Gdocal in an heroic effort to be the handling of leading zeros in the salt, where Apple keep them but pysrp loses them, due to a conversion of the salt to a long value instead of keeping it byte-by-byte.

This PR is a cleaned-up version of the patch published by @Gdocal at https://gist.github.com/Gdocal/45c24f542ebd32a2256217bfd856d972. All credit for writing this patch goes to him; I just removed some debug comment and reverted spurious changes.

This is of course not the only way possible to solve the issue; feel free to ignore this PR and implement another solution yourself.

@magicus magicus changed the title Fix for srp python lib, salt has leading zero bytes, based on gist by @Gdocal Keep leading zero bytes in salt, based on gist by @Gdocal Nov 1, 2024
@magicus
Copy link
Contributor Author

magicus commented Nov 1, 2024

I checked the commit history of the project, and noticed that this is a partial reversal of 0931971. I hope the reintroduction of six is not controversial. I am open to any other possible solution that keeps the salt properly.

@cocagne cocagne merged commit 8c55b0a into cocagne:master Nov 1, 2024
@cocagne
Copy link
Owner

cocagne commented Nov 1, 2024

Thanks for the patch. At the time this was originally written, rfc5054 hadn't yet become the de-facto standard for SRP implementations it is to day so I had to wing it for parts of the implementation. Even with all the contributions over the years, it's no surprising that some lingering incompatibilities remain. Thanks for working with @Gdocal to patch this hole.

@magicus magicus deleted the fix-salt-leading-zero branch November 2, 2024 00:00
@a-detiste
Copy link
Contributor

@cocagne @magicus I don't mind re-playing the six changes again.

@cocagne
Copy link
Owner

cocagne commented Nov 5, 2024 via email

@magicus
Copy link
Contributor Author

magicus commented Nov 5, 2024

As I said, I'm just the messenger here. The patch was written by Gdocal, and I just submitted it upstream (i.e. here). Unfortunately my knowledge about six in Python is extremely limited, so I cannot be of any assistance. I do however strongly recommend that some kind of test for the leading zero issue (as suggested in #62) to make sure it does not regress.

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

Successfully merging this pull request may close these issues.

3 participants