Skip to main content

Blue Galaxy Energy

Hologram: Shut up! You do not know the power of the Blue Galaxy Energy! Also known as the "B.G.E" Mr. Whereabout: The Loss, Part III, Volume I

BlueGalaxyEnergy is a tool to perform the so-called BGE attack described in

  • Cryptanalysis of a White Box AES Implementation, Olivier Billet, Henri Gilbert, Charaf Ech-Chatbi

with the optimizations proposed in:

  • Improved cryptanalysis of an AES implementation, Ludo Tolhuizen
  • Revisiting the BGE Attack on a White-Box AES Implementation, Yoni De Mulder, Peter Roelse, Bart Preneel

Compile

To compile and install the project, install gmp and ntl libraries and development headers (available in your OS package manager), e.g.

$ sudo apt install libgmp-dev libntl-dev

or

$ sudo pacman -S gmp ntl

then compile and install the package locally:

$ pip install bluegalaxyenergy

Test

$ python3 -m bluegalaxyenergy --selftest

Run the attack

from bluegalaxyenergy import WhiteBoxedAES, BGE

class MyWhiteBoxedAES(WhiteBoxedAES):

    def __init__(self, ...):
        # TODO

    def isEncrypt(self):
        # return True if the whitebox is an encryption whitebox, False otherwise
        return True

    def getRoundNumber(self):
        # return the number of rounds of the whitebox (10 for AES128,
        #   12 for AES192 and 14 for AES256)
        return 10

    def applyRound(self, data, roundN):
        # Apply a round of the whitebox on a buffer
        # [param] data    a buffer of 16 bytes (type bytes)
        # [param] roundN  the round number to apply (int in the range [0, self.getRoundNumber()) )
        # return  16 bytes of the encrypted data by the round
        return ... # TODO

mywb = MyWhiteBoxedAES(...)

# run the attack
bge = BGE(mywb)
bge.run()

# extract the key from the available roundKey
key = bge.computeKey()
if key is not None:
    print("key:", key.hex())

By default, the method run extracts all rounds except for the last one, which lacks a MixColumns operation. You can restrict the rounds used for the attack using the roundList option: run(roundList = [4, 5, 6, 7, 8]). However, the attack requires a minimum of three consecutive rounds to extract a single round key.

  • AES128 necessitates a minimum of three consecutive rounds for key extraction.
  • AES192 and AES256 require a minimum of four consecutive rounds.

If the whitebox's intermediary state is shuffled, specify shuffle=True in the run method. When shuffled, the number of required rounds increases to four for AES128 and AES192, and five for AES256. Insufficient rounds will result in no key being found or a dictionary containing 16 possible keys.

The bge class can additionally extract the encoding of the intermediary round (with bge.getEncoding()) and the permutation of the intermediary round if the whitebox is shuffled (with bge.getShuffle()). For more information on these elements, refer to the test implemented in __main__.py.

About

Authors and Contributors

Initial Authors and Contributors:

  • Laurent Grémy
  • Nicolas Surbayrole
  • Philippe Teuwen

For subsequent contributions, see the git projet history.

Copyright

Quarkslab

License

BlueGalaxyEnergy is provided under the Apache 2.0 license.

Metadata

Release files for bluegalaxyenergy 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bluegalaxyenergy 2.0.1
File Size Uploaded Provenance
bluegalaxyenergy-2.0.1.tar.gz 158.9 kB Without provenance Details

Release files / bluegalaxyenergy-2.0.1.tar.gz

Download URL bluegalaxyenergy-2.0.1.tar.gz
Size 158.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dad67df2ea9534be302172b6b3ce621bbd89ba35481fcd04f9c6bae48f59bb27
BLAKE2b-256 checksum
How to use checksums
ab2a423b4d146c00f87dc5105edbe36aa4726ab0080a257369be9a3a9725af10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Security for bluegalaxyenergy 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page