Skip to main content

ARADI encryption implementation with CTR modes

Project description

ARADI and LLAMA Encryption Implementations

Overview

This repository includes many implementations of the the ARADI and LLAMA cryptographic algorithms as described in the NSA publication ARADI and LLAMA. This library is designed for encrypting and decrypting messages and files securely using ARADI. The following lines will present each implementation:

License: This project is licensed under the MIT License.

Contributions: All suggestions and corrections are welcome. Please feel free to submit issues or pull requests.

To-do:

  • Implement LLAMA
  • Optimize the Python and C code
  • Create unit tests to verify integrity
  • Benchmark performance across different systems
  • Implement in an eletronic hardware system

Acknowledgements: Thanks to the authors of the original ARADI and LLAMA paper for their contributions to cryptography; to Bill Buchanan and Odzhan for their C implementations (for benchmark comparisons, check the C implementation); and to Professor Julio César López Hernández (IC-UNICAMP) for introducing us to this algorithm.

Python Library: pyaradi

pyaradi is the implementation of these functions in Python, which include the following features (so far):

  • ARADI encryption in CTR mode
  • Encrypt and decrypt strings and files
  • Automatic nonce generation
  • Padding support with PKCS7
  • Easy-to-use API

To install the pyaradi library, use pip:

pip install pyaradi

Use

Encryption

You can encrypt a message using the encrypt function. Here's an example:

from pyaradi import aradi_utils, aradi_core, encrypt

# Define your key (list of 8 32-bit words)
key = [
    0x01234567,
    0x89ABCDEF,
    0xFEDCBA98,
    0x76543210,
    0x00112233,
    0x44556677,
    0x8899AABB,
    0xCCDDEEFF,
]

message = "Hello, World!"
encrypted_message = encrypt(message, key)
print("Encrypted message (hex):", encrypted_message.hex())

Decrypting a Message

To decrypt a message, use the decrypt function:

from pyaradi import decrypt

# Assuming you have the encrypted message and the key
reconstructed_message = decrypt(encrypted_message, key)
print("Reconstructed message:", reconstructed_message)

Encrypting and Decrypting Files

You can also process files with the aradi_process_file function:

from pyaradi import aradi_process_file

input_file = 'input.txt'
output_file = 'output.txt'
nonce = aradi_utils.generate_nonce(size=8)

aradi_process_file(input_file, output_file, key, nonce)
print(f"File '{input_file}' has been encrypted to '{output_file}'.")

Testing the Implementation

You can run a test to verify the encryption and decryption:

from pyaradi import aradi_test

key = [
    0x01234567,
    0x89ABCDEF,
    0xFEDCBA98,
    0x76543210,
    0x00112233,
    0x44556677,
    0x8899AABB,
    0xCCDDEEFF,
]

message = "Test message for encryption."
encrypted_hex, reconstructed_message = aradi_test(message, key)

print("Encrypted message (hex):", encrypted_hex)
print("Reconstructed message:", reconstructed_message)

Contributing and Formatting

Feel free to make contributions. In order to automate the boring parts, the file pybash.sh should have all necessary functions to format, create the releases and upload the code to pip (although I'd prefer you left that to the admins). The functions are:

chmod +x pybash.sh to make it executable.

./pybash format to format using black and flake8.

./pybash create_dist to create the dist packages.

./pybash test_upload to test the upload to test.pypi.org

For the test uploads, create/configure the $HOME/.pypirc as:

[distutils]
index-servers=
pypi
testpypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = <username>
password = <api-key starting with pypi-...>

[testpypi]
repository = https://test.pypi.org/legacy/
username = <username>
password = <api-key starting with pypi-...>

Be aware that your test.pypi and pypi are different "organizations" with different usernames and api-keys. You need to create an account on both.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaradi-0.1.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaradi-0.1.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyaradi-0.1.3.tar.gz.

File metadata

  • Download URL: pyaradi-0.1.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pyaradi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5215ad4f3db7ee51f904215b787997addbcdf730cc19c3370f3c7aca799e280d
MD5 7b15f80c642ffac91fb6ca169da0ce5f
BLAKE2b-256 288314afadc0889bdaa12681e197e633877659d67576e07ca4bfe688703080ca

See more details on using hashes here.

File details

Details for the file pyaradi-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyaradi-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for pyaradi-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 74b9fcc6f090e60512d75b8fbfa25eb7664d748c32656cba5a69b24e0d371a7f
MD5 5d19f025a39e9b2f9de2263b36096507
BLAKE2b-256 84f19ce7e6e60cb0a26a2db77b32c3282255ac06a7f100aeee6c27dd885116dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page