Skip to main content

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.

Release files for pyaradi 0.1.3

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

Source distribution (sdist)

Source distribution for pyaradi 0.1.3
File Size Uploaded
pyaradi-0.1.3.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyaradi 0.1.3
File Interpreter ABI Platform
pyaradi-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.5 kB

Release files / pyaradi-0.1.3.tar.gz

Download URL pyaradi-0.1.3.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5215ad4f3db7ee51f904215b787997addbcdf730cc19c3370f3c7aca799e280d
BLAKE2b-256 checksum
How to use checksums
288314afadc0889bdaa12681e197e633877659d67576e07ca4bfe688703080ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / pyaradi-0.1.3-py3-none-any.whl

Download URL pyaradi-0.1.3-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74b9fcc6f090e60512d75b8fbfa25eb7664d748c32656cba5a69b24e0d371a7f
BLAKE2b-256 checksum
How to use checksums
84f19ce7e6e60cb0a26a2db77b32c3282255ac06a7f100aeee6c27dd885116dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

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