Skip to content

Refactor entropy.so.1 as C extension#150

Merged
EdwardLarson merged 5 commits into
redballoonsecurity:masterfrom
EdwardLarson:refactor/entropy_c_extension
Dec 28, 2022
Merged

Refactor entropy.so.1 as C extension#150
EdwardLarson merged 5 commits into
redballoonsecurity:masterfrom
EdwardLarson:refactor/entropy_c_extension

Conversation

@EdwardLarson
Copy link
Copy Markdown
Contributor

Link to Related Issue(s)

We used a Makefile to build a shared object and ctypes to import from it. The Makefile was not necessarily portable across systems and was an extra build step besides pip installing.

Please describe the changes in your request.

  • An explicit C extension is added to ofrak_core which makes setuptools build the C source when running e.g. pip install, so installation of this is a 1-liner
  • This extension is also optional, and if at runtime the C extension can't be imported, OFRAK falls back to a Python implementation (the existing one we used for tests)
  • As such, the external dependency on entropy.so.1 is removed

Anyone you think should look at this, specifically?
@rbs-jacob for sure!

Copy link
Copy Markdown
Member

@rbs-jacob rbs-jacob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the portability, and really like that it falls back on a pure-Python implementation.

See some comments about testing, and a couple of other minor things.

Comment thread ofrak_core/setup.py Outdated
Comment thread ofrak_core/ofrak/core/entropy/entropy.c
Comment thread ofrak_core/ofrak/core/entropy/entropy.c
Comment thread ofrak_core/ofrak/core/entropy/entropy.py Outdated
Comment thread ofrak_core/ofrak/core/entropy/reference_entropy.py
Comment thread ofrak_core/test_ofrak/components/test_entropy_component.py Outdated
Comment thread ofrak_core/setup.py
@EdwardLarson EdwardLarson merged commit bbdf952 into redballoonsecurity:master Dec 28, 2022
alchzh added a commit to alchzh/ofrak that referenced this pull request Jul 16, 2024
…edballoonsecurity#150)

Maintains current API and automatic builds with setuptools.
Extends setuptools build_ext command to add a `.1` to the end of
extensions marked with ctypes to match the old behavior. Not sure
if this modification is still needed.
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