tiny-AES-c wrapper in Cython
Project description
tiny-AES-c Cython wrapper
tinyaes
is a few lines Cython
wrapper for the tiny-AES-c
library, a
Small portable AES128/192/256 in C.
The library offers a few modes, CTR and CBC modes are the only ones currently wrapped. Given the C API works modifying a buffer in-place, the wrapper offers:
CTR_xcrypt_buffer(..)
that works on all bytes convertible types, and encrypting a copy of the buffer,CTR_xcrypt_buffer_inplace(..)
that works onbytearray
s only, modifying the buffer in-place.CBC_encrypt_buffer_inplace_raw(..)
that works onbytearray
s only, modifying the buffer in-place (manual padding).CBC_decrypt_buffer_inplace_raw(..)
that works onbytearray
s only, modifying the buffer in-place (manual unpadding).
CBC usage Example:
import tinyaes
import binascii
def pad(m):
return m + bytes([16 - len(m) % 16] * (16 - len(m) % 16))
def unpad(ct):
return ct[:-ct[-1]]
# assign key and IV
aes_enc = tinyaes.AES(bytes.fromhex('11223344556677889900AABBCCDDEEFF'),
bytes.fromhex('FFEEDDCCBBAA00998877665544332211'))
aes_dec = tinyaes.AES(bytes.fromhex('11223344556677889900AABBCCDDEEFF'),
bytes.fromhex('FFEEDDCCBBAA00998877665544332211'))
text = b"hello"
print(text) # b'hello'
# padding plaintext to a multiple of block size
text = pad(text)
print(binascii.hexlify(bytearray(text))) # b'68656c6c6f0b0b0b0b0b0b0b0b0b0b0b' hex representation of added text
aes_enc.CBC_encrypt_buffer_inplace_raw(text) # b'5adc04828f9421c34210b05fe5c92bfd' hex representation of encrypted text
print(binascii.hexlify(bytearray(text)))
aes_dec.CBC_decrypt_buffer_inplace_raw(text)
print(unpad(text)) # b'hello' decrypted, original text
Release notes
- 1.1.0 (Dec 5, 2023)
- Final release with Python 3.12
- 1.1.0rc1 (Oct 2, 2023)
- Add Python 3.12 final to the matrix
- Expose raw functions for CBC mode, with manual padding and unpadding
- 1.1.0rc0 (13 Feb 2023)
- Drop support for Python 2.7 (CI tests and builds are disabled, code may still work)
- Add support for CBC mode (unstable API, inplace only, manual padding)
- 1.0.4 (Nov 3, 2022)
- Final release with Python 3.11
- 1.0.4rc1 (Oct 24, 2022)
- add Python 3.11 to the matrix, remove Python 2.7 and 3.6
- 1.0.3 (Feb 22, 2022)
- Final release with Python 3.10
- 1.0.3rc1 (Nov 4, 2021):
- add Python 3.10 to the matrix
- 1.0.2 (Nov 4, 2021):
- version bump from 1.0.2rc1
- bump to
manylinux2010
because of tlsv1 errors and drop Python 2.7 missing in the new image
- 1.0.2rc1 (Apr 7, 2021):
- added release Python 3.9 on Windows, Linux (
manylinux1
) and OSX - updated upstream
tiny-AES-c
with some cleanups and small optimizations
- added release Python 3.9 on Windows, Linux (
- 1.0.1 (Jun 8, 2020):
- release Python 3.6 OSX and Windows wheels
- updated upstream
tiny-AES-c
with some code changes
- 1.0.0 (Feb 20, 2020): updated readme (no code changes)
- 1.0.0a3 (Feb 7, 2020): fix bytes in-place mutation error
- 1.0.0a2 (Jan 29, 2020): first public release
Like to help?
The CI is up and running, but on Linux only, running a minimal test suite that uses hypothesis, and that allowed me to find a first bug, a missed variable replacement that had nefarious consequences.
The source package released on PyPI should be usable on Windows and MacOS too,
just pip install tinyaes
.
The development instead is Linux centered, without any guide yet, but the CI script can be a guide.
TL;DR
- Download Just and put it in your
PATH
. just test
should install the library and the dependencies and run the tests using your default Python version.- Inspect the
justfile
for some hints about what happens.
Thanks
The library is very minimal, but nonetheless, it uses a lot of existing software. I'd like to thank:
-
Cython developer for their wonderful "product", both the library and the documentation.
-
Kudos to
kokke
for their tiny-AES-c library, very minimal and easy to build and wrap for any usage that needs only the few AES modes it exposes. -
Just developers for their automation tool, I use in most of my projects.
-
A huge thank to all the hypothesis authors to their fantastic library, that helped me to find an miss-named variable bug that I worked very hard to add in a 6 lines of code wrapper! And to this Data-driven testing with Python article that had left me with the desire to try the library.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for tinyaes-1.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 876f33903b835bf3a307b288351e4ca988150582ca71471698252320137af35d |
|
MD5 | 327909d253cdeaeccc1b51ce8d5a20c0 |
|
BLAKE2b-256 | b1cddde171d1d33df282bb66612f1fd3bc2f3291d8d8775176510670c57aa4c8 |
Hashes for tinyaes-1.1.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0bad6e283b33376cf4e214c5b1582768deef606ed41f09220469764640dea18 |
|
MD5 | 0a17740e84865047bc006bee2c451c11 |
|
BLAKE2b-256 | da3b93613359e7c7e323bb5dc7a1c84f65fa5d97d0a065467d6f1d1f23daa52b |
Hashes for tinyaes-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f733eae946da475f37c4c68e8ae4b9deded0212e399680b58e87c97fd34ac956 |
|
MD5 | 58d9ab184758674cc243f7453bca958d |
|
BLAKE2b-256 | 761ceccc3c95fdcc048a2332c4e0c80aef83d16f3736a0cdc6a74d007292acb1 |
Hashes for tinyaes-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f33298097674331f39930ba8681cca4d949b46866317940acdd2b21da3240a5 |
|
MD5 | edfef85d543f8f453967fa1fa1097267 |
|
BLAKE2b-256 | 69ca6de32807d29ac5e1254ef34e4a429991806145c52b38d89a3741634b085e |
Hashes for tinyaes-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10ab5921cd113dd825d2af0ae49e5943e56c04562958b8d09fedd5212ee29d45 |
|
MD5 | bf3a49adcaa0a73fc8cc5e6a7f037e70 |
|
BLAKE2b-256 | c781c3e279099de26dc27fff1ffd088af8ac690b2c74ce3445ff3c32ac75d89c |
Hashes for tinyaes-1.1.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c732376af4bf5c86aa327bec1bf42cdc4cc8e48e1032a94129a91e3941a0301 |
|
MD5 | 3060fe8f888fc06977dbfcdaba254ade |
|
BLAKE2b-256 | 2fa1d12d957a3189511779a7a5bdd345c56281c40621ca9fb696b7a309c8dc62 |
Hashes for tinyaes-1.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ece6f78b5fa85a8d6d345f1df2a85fcdc765f42ff046a96ecb67d96afad23330 |
|
MD5 | e6d585b2f9be15806ccae8eddce5cca1 |
|
BLAKE2b-256 | e2637c4c24c07e2a5cbd50675d1e3309f87a94c0917a4d3a594a8d6439e937d9 |
Hashes for tinyaes-1.1.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e5d8c95de7decb43105c5a092939209304cca48b31e747fad51f9c80b7380fe |
|
MD5 | 80b362374bc29070ab318533b6158e00 |
|
BLAKE2b-256 | e1e1fbed022a11db9724d6d1bbe4689869b51eeef25c06bb1bbc32d7f39d1770 |
Hashes for tinyaes-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 069815f48b2ce91f4334c61473b855f2a76883aef13f25f2b2ca2fe776abd9e6 |
|
MD5 | a08d5c2834fd4b16361f1e8f8d5c80fe |
|
BLAKE2b-256 | 1edc09b5cba63011a76254971c0b875304b2e4189e4820bcbf37cea0c4879a72 |
Hashes for tinyaes-1.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5507897134855b59dd2f4e5267746d20487379a3a7b4df4421e5eba3248a826 |
|
MD5 | 595585e7d4279c78b2d6d684e5685159 |
|
BLAKE2b-256 | 8ef2bd2efc7edeb64a57e34ffcdc9ae3933885b7ec2080609d5ce5dc875e7dc8 |
Hashes for tinyaes-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d923960ae2049304d006ddef57b57f02e5c1cd0fd3ab9d90aeda985357bdd6a |
|
MD5 | 4a15906c0e25fda4f6b2ca0f0039bd8b |
|
BLAKE2b-256 | cf036c229d3b2e908c907ed9f099626b0ef42f1ef83c3876e0d28e8520846b6a |
Hashes for tinyaes-1.1.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f4c2a4b1292df22123363d5861df6f6e9e44462960f4590093427dab577ba4d |
|
MD5 | f5c296282b6249349e97a336f2e4adc6 |
|
BLAKE2b-256 | c5966264c591db11d30dc62e9fecd73545c4b80ca5922a50c2a85c4f502b0357 |
Hashes for tinyaes-1.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3efd48cd98e2c21d28fb2b8a84683c8bf26f1a86a9dc8da9a9de94f9583168de |
|
MD5 | 292a91f461191e4385354cfc738969cc |
|
BLAKE2b-256 | 22635b3ea48831516c520ecfd0cce06143f380d94b035cd7d6d0b218ae598610 |
Hashes for tinyaes-1.1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfc353536554e0a0dee5a3eed0fd4006bdc97e52b811ac937023b09b74c2bea0 |
|
MD5 | 5af1332d79370c99440aaf072f4107aa |
|
BLAKE2b-256 | 21b0e86877b369b0a5b6c0d9ac32b46fb4601b47b66dec130f7e18811d5753a1 |
Hashes for tinyaes-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0164695cbe6821f5e754f004e7fadb3ddbf063762cda1356fa744079d597a967 |
|
MD5 | 93e57848c48afbedbb2650c15c913b4f |
|
BLAKE2b-256 | d862bd78127f21a6129c3b6520781a17fae34ddc5d88d5442eaff45adf563776 |
Hashes for tinyaes-1.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4e82a1e903c83ab677feddaec41c89a260026812c391fdb06269e57dbdb5abb |
|
MD5 | c292ebe484b3fb67114b49f7f6aa7ab1 |
|
BLAKE2b-256 | 223e7e2f8f4435160278a8c717a6c3cc8be61fe9cfc4eaf4da6204d61e020821 |
Hashes for tinyaes-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 356d95134a4b6766e2d83cec050108e8e12230c8e197d95bfbd30f2734eac3e9 |
|
MD5 | 64dee9946863828689555932971f2ba4 |
|
BLAKE2b-256 | 03b67762f46695c5166035c78437ab1fc792b7609f6e34209b57d0264c8d8c9d |
Hashes for tinyaes-1.1.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9431cbf3993d4e43c270c79795c8e46c1dffa543fb43cc7546ad1a860fab2672 |
|
MD5 | b19a523b2552e88da5c24f0297ed5414 |
|
BLAKE2b-256 | d10c6c4cce84166fdbc3c20b74c5de4ecbce3b218abb16e9adffacc705ca5556 |
Hashes for tinyaes-1.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024adae289543b3c587fb17ac993076041395ac8442907c5d8d3837ef8ee3c4a |
|
MD5 | b68b576e3250f281740739f7dcebc779 |
|
BLAKE2b-256 | 1f96ba99df309ed81ca881c4a135cabea6780c847036137c8f46ef468f528e26 |
Hashes for tinyaes-1.1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 591af2c0fdcd0e86392d6b04c1c496c7c4c704a246ce40a4e9dfaf8951649ae5 |
|
MD5 | 531efb8c6c61e4e3156bcd53db1e708c |
|
BLAKE2b-256 | 71b6b31c78c530965e431bcf70ade3979da0db22934bf563eeb90b2cdb4e73ff |
Hashes for tinyaes-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c336f7244c05d286f29eeaad94210b402b306fb4c064f3b8fe3f3809b2cd432 |
|
MD5 | b853a95a383a988a6332587b4d77edf8 |
|
BLAKE2b-256 | 85dcc01b44049513600195a4f3d9160116db27f0ca05f64900682f67e0bd51c2 |
Hashes for tinyaes-1.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c5fdce6418f5efa3023d2ea8f959d2c22d1f95db57ca78d5e3ca5623e823ab9 |
|
MD5 | 8b40e8f0148e97d47af167e3acf44b9f |
|
BLAKE2b-256 | e191b7dbb8f01023b542ef7e3669fd90873368cfe3a898eddb572585b34c6cca |
Hashes for tinyaes-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6d750ac1b8fc2bd63e8535ee6a1c9dabc3d88e56f8e31cca0b48b31a79ddc1f |
|
MD5 | 3f0642d71a8c0420765201512e6aae1e |
|
BLAKE2b-256 | 515ee4b42f7fbb2a1e4999285a0faf8d3469b8c593c00da8170a98adbbdc675c |
Hashes for tinyaes-1.1.0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a39a34d01d4d29fd661cad66d7439812db064e7a71d0a638173400cabcfe99ad |
|
MD5 | 344d1b9cc3684425319868e7ca687627 |
|
BLAKE2b-256 | bcbcd5a57825f139b1ec1ff8bc87802e0221b69b3c6411509064be8b92e797bc |
Hashes for tinyaes-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a315522ade4900e7a59e25fb17041671fe48d894037b5aa7d2bfcf11f07f5d53 |
|
MD5 | 062de08201d72c3d0bd8524dd601ba10 |
|
BLAKE2b-256 | 17f1763f006d5e6b561e160ecebf7bb23b40fa240c760d61d860d2ef86a49bee |
Hashes for tinyaes-1.1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58148f6fca9c60efd318e3738989a54ba354f5cc52250a6814e1390e7869c5b7 |
|
MD5 | f843fcf7508a124cbb8c5161a16f451f |
|
BLAKE2b-256 | 31cc411e96aeae618feb252b2e93a2e1d4ef9d2687ca7d38e9d3178962710ace |
Hashes for tinyaes-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0a6bd418823cde8c8a751b40ee88182637fff9723811db25b8cc5bbb25eb979 |
|
MD5 | df6e3db16c897aee4f43fe7b9f0fb192 |
|
BLAKE2b-256 | 4818a4c45bf7e4e6082d25dc80f565f56449d05a8780887f31bf6a10bdfe77f4 |
Hashes for tinyaes-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d73ddd6db3d37e16c570324b4ddc633d775caf81681542221a8be2a8bb69de2 |
|
MD5 | 445c9fe2beb7a85cb465c2f609fbfbb5 |
|
BLAKE2b-256 | 3bde5e202c769303247a643db0a45545b8adc2020357591ad8bf8dfbd6f99d49 |