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

bpo-43279: Update code taken from Keccak Code Package #24601

Closed
wants to merge 1 commit into from

Conversation

illia-v
Copy link
Contributor

@illia-v illia-v commented Feb 20, 2021

There were some updates to the Keccak package since it was integrated in CPython initially.

History can be found in https://github.com/XKCP/XKCP.

XKCP's contributors did some refactoring. In particular, they replaced UINT64 and UINT8 with uint64_t and uint8_t.
Also, they added support for 64-bit big-endian platforms.
The changes are reflected in sha3module.c.

I replaced files in the kcp folder with ones generated with generic64lc/libXKCP.a.pack and generic32lc/libXKCP.a.pack targets.
And removed PlSnP-Fallback.inc because it is not used.

https://bugs.python.org/issue43279

There were some updates to the Keccak package since it was integrated in CPython initially.

History can be found in https://github.com/XKCP/XKCP.

XKCP's contributors did some refactoring. In particular, they replaced `UINT64` and `UINT8` with `uint64_t` and `uint8_t`.
Also, they added support for 64-bit big-endian platforms.
The changes are reflected in sha3module.c.

I replaced files in the kcp folder with ones generated with `generic64lc/libXKCP.a.pack` and `generic32lc/libXKCP.a.pack` targets.
And removed PlSnP-Fallback.inc because it is not used.
@tiran
Copy link
Member

tiran commented Feb 20, 2021

Thanks for your patch, but I'm going to remove the entire _sha3 code after PEP 644 has landed. With OpenSSL 1.1.1 we wont need a copy of Keccak any more.

@illia-v
Copy link
Contributor Author

illia-v commented Feb 21, 2021

Thanks for your patch, but I'm going to remove the entire _sha3 code after PEP 644 has landed. With OpenSSL 1.1.1 we wont need a copy of Keccak any more.

Nice.
Would you mind leaving this pull request open for merging it in case PEP 644 is postponed for some reason?

BTW, it looks like a title of the PEP misses one digit in the OpenSSL version, it is "1.1 or newer" instead of "1.1.1 or newer" as mentioned later in the proposal.

Also, I noticed a weird behavior related to SHA-3 in Python 3.8 that uses OpenSSL 1.1.1:

>>> import hashlib
>>> hashlib.new("sha3_224")
<_sha3.sha3_224 object at 0x7f5a57e2ca30>
>>> hashlib.new("sha3-224")
<sha3_224 HASH object @ 0x7f5a57dc6c10>

In the first case, it uses the built-in implementation. And in the second one, it uses an implementation from OpenSSL. I am not sure whether this is a feature or a bug that should be fixed 🙂.
Let me know if I should submit a patch.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 24, 2021
@illia-v
Copy link
Contributor Author

illia-v commented Apr 26, 2021

@tiran congrats on landing PEP 644! 🎉

I can see that the _sha3 module is still present in the source code.
Are you going to remove the code before the 3.10 feature freeze?
If not, could you please consider the updates?

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Apr 27, 2021
@tiran tiran requested a review from pablogsal May 2, 2021 08:16
@tiran
Copy link
Member

tiran commented May 2, 2021

@pablogsal What's your opinion on this patch? Ot updates the internal code base of _sha3 module. The code is only used when Python is compiled without OpenSSL support. I initially planned to remove the internal _sha3 module, but I won't have time to finish the task until tomorrow.

I'm a bit worried to land the change. It's a fairly large change. The current code works and as (AFAIK) no problems.

@pablogsal
Copy link
Member

@pablogsal What's your opinion on this patch? Ot updates the internal code base of _sha3 module. The code is only used when Python is compiled without OpenSSL support. I initially planned to remove the internal _sha3 module, but I won't have time to finish the task until tomorrow.

I'm a bit worried to land the change. It's a fairly large change. The current code works and as (AFAIK) no problems.

Unless is strictly necessary I would recommend to not do it, specially given the size of the diff (unless someone can review it thoroughly). We are still before beta so this could theoretically be merged but if you are going to remove the _sha3 module this is going to cause a bunch of merge conflicts.

Ultimately is up to you although my recommendation is to at least do it after you remove the _sha3 module.

@illia-v
Copy link
Contributor Author

illia-v commented May 2, 2021

but if you are going to remove the _sha3 module this is going to cause a bunch of merge conflicts.

Ultimately is up to you although my recommendation is to at least do it after you remove the _sha3 module.

The update won't be needed when the _sha3 module is removed :)

@illia-v
Copy link
Contributor Author

illia-v commented Jun 29, 2021

I initially planned to remove the internal _sha3 module, but I won't have time to finish the task until tomorrow.

Do you think the module can be removed at the current stage?

@tiran
Copy link
Member

tiran commented Mar 26, 2022

I have removed the KCP and replaced it with a much smaller fallback implementation. See bpo-47098 GH-32060

@tiran tiran closed this Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants