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.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.0rc1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49dd8d7a5355a894c65176dfede628aa80033ba71b0234305e2024afc4ff0875 |
|
MD5 | 8b3d560ee7a9e9241bb3bababb910f10 |
|
BLAKE2b-256 | 35c9f66c0a40889fa4da5d63364466946afd21b012b5f23257fec004e377dc8c |
Hashes for tinyaes-1.1.0rc1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 165962d8592173e95a4f17d693bff41c17df3227b9b6b64bfde4b9ff12c2051f |
|
MD5 | 0043cd95ccaf6cbea6c6399f5047a51b |
|
BLAKE2b-256 | 4c8d2c4b53a5cba2de34bb41f877e5d7d5b02afe880f9bb5dab6f5242897f219 |
Hashes for tinyaes-1.1.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fb4040d718f5518a2e50ea87c79327fca227f6a4db6dd10287f498bca0fabf9 |
|
MD5 | cfbaec305beac0dd857a2970d4a678bc |
|
BLAKE2b-256 | 12f3ce4c3b9db0d58ac53c2a3224e42fd4b9157cfbaadab57b2646f16b02ce4a |
Hashes for tinyaes-1.1.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9103418189151c38d7a6d5af7a95007bf60f3686afeae425439d9f8ffd65a09 |
|
MD5 | 0867f80eb2664551c5585dab1130216b |
|
BLAKE2b-256 | 664f66a2e3e5d9705ccaff3e3b45370f9094d0e86fc82591ce98d69def9b4d0e |
Hashes for tinyaes-1.1.0rc1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b221489bbcd2edbbfce0220141501d86f63baa8106d7ed8ac3b73b4cf4e6dd5 |
|
MD5 | b513520ad8bebad6fc5f93cd102d915b |
|
BLAKE2b-256 | 3127bc2200237f721e23914dbd60a3e9862547604fd208a5608770715a0ee9a8 |
Hashes for tinyaes-1.1.0rc1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acdb046a5b17f9f955de3bf6d6ae2709a114454eccf19997a34691c07b67af78 |
|
MD5 | 95eaca5ee25c17477e38f4243b94cc56 |
|
BLAKE2b-256 | ba6ce35e7eb62546f5bca041c813739a0fd96350f10f36a0963f3d451d5dced0 |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dba0054eb174a8997e55f9ee26b9466b43172fca9935834589d17023a6f352c6 |
|
MD5 | 8dae71557ea8478c0bfdff37ece6ee0d |
|
BLAKE2b-256 | e1254cbfbd2f484b117b3f30d674cc93a3bfac344b2d1aa538d484d5316423d1 |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a685cc3793cbbfe9003f28eed9b902b9299db7162d28f3758469e34a6ccffbeb |
|
MD5 | cfa5c8a84e7018301461a43641f3c1cf |
|
BLAKE2b-256 | 6541d9f1432796cad8b29077203b3a272d519c4899490680f513bed7315d55dc |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b3578c5714a32f3cb3694624fca8f7c06ab50c26e1a7e534c7bfacd57d3fda5 |
|
MD5 | 5e461912e4a7958f3eeb1488959e8e86 |
|
BLAKE2b-256 | a88d0cfcaf16fa93fef699881c7f66d401f44da909086380ba606c82e01a31dd |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3d484820c6d2a4a598cb2012ec8c1ede7c46888be79ed14927e59c24dce09a4 |
|
MD5 | ddc34dc5aaa8c4a2eb82507fde24489e |
|
BLAKE2b-256 | 4becc12fe5709d267c8ee176371f84e365193c250488b6f0b6dde1242209a0b9 |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ca730400a9fa210565ca16a6b05f6fa2fa28956e9021c567df36096b70bf31d |
|
MD5 | 8c007968025c85c53578f843ace87471 |
|
BLAKE2b-256 | 6f72a758e72f8cd806dd1848d02f7a1fd924abe1d6c17576b8a69cd972397e87 |
Hashes for tinyaes-1.1.0rc1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b27ed14e3c15129c71b5aa17b09e37bbebe52f6ab3399af858b097108f202412 |
|
MD5 | 56928d1636f53675770984433473c612 |
|
BLAKE2b-256 | f5b89f337371f8fbe9e47e150d75a892a7181304316f46c012c6165b0cb9fbd1 |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77c3e964e2a7cf50eff9aed8be2de1bb567f8f84fa8f8927865f4da8db40c17d |
|
MD5 | 0a9b739cafae389dd566815425b1ec49 |
|
BLAKE2b-256 | 35109d285b2e266bf36036d7b2529e86aa3a39b2767b64a8b427642e5d64fa07 |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29ee1a873593788dba4462db51fa887595d46254dfe560031e9789e524bf4669 |
|
MD5 | 31ce3a656834ed87b029ec7c7ca3136f |
|
BLAKE2b-256 | 45c0f96f85ec6343a46991adfba8d712e34365cb85ca105af472605220a90ec6 |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7cb0b4bcbbdb96fbe2ede8a097f8b31d455276f3260d742e09c25e911b2a7d |
|
MD5 | 9856296d4d89b46497d3a9748afc9146 |
|
BLAKE2b-256 | 26ea983cca42573d20261ffc9a02f61f54d587b06d3f06cf1ee897cf50a80a88 |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13adbe891237b0f7d72cf770d228650542a231b52f6646ad0fbf412b49dd48bb |
|
MD5 | 866fec3d9b6d808287463a79348db0e9 |
|
BLAKE2b-256 | b86219a54efc6660c7db3935eeadd1de9c87945b2f9ae1c6b48871308b40bb3a |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40cd9f22cdf597d12ed2562d3005f3acd031cdc2dd26c853fef7dd01a5b36c1a |
|
MD5 | 532b8b23998819b2c8e99a00b26c36ba |
|
BLAKE2b-256 | a49c7a87516ff1c339e9c8effeecf2b720f42fa5a0c813f03471ab85df012d3e |
Hashes for tinyaes-1.1.0rc1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db2ce0331cf126ed89ffb3911ebcd7bdf7bdf783bf6d49557cc5a3840dc10c36 |
|
MD5 | 77bdf49f2c45955d91e708664861064a |
|
BLAKE2b-256 | 5915889934e170d454c6239ece5d336d01be660642b79d788f0f005f1c5210a5 |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35497b42a2b5706cf0d03c971b861ef53a5d47953ac57ab69f2bba46b12f26b9 |
|
MD5 | 8d710a7888f967e935e7fe042012dc74 |
|
BLAKE2b-256 | 155046513a4ca85ac164671625f98f55ddbe3bf6ab7bcc3402cfa0cd90e22816 |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f4b8e3db91b187342fcd06f548e9881be71ae990f323030fd0c860f4adfded0 |
|
MD5 | 3e02759335df796e6d94daaf678304c8 |
|
BLAKE2b-256 | 4e5762a177b83d57146986dbeb1ff2c1789e36ea88d206c84793e02cf3179525 |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f1c24eaf46d90320ccecefe1a4ddc5abbca798cc97fc268c1b5a5e2151c9236 |
|
MD5 | 8481d6a601f85fd9c047264fb7e99191 |
|
BLAKE2b-256 | 3eaf7c1fec4d6a236085f815f9f58b4840397efba8107f03a9d1745956c4e07c |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95365aa7faac7e7e3fea612403d85bf08e8e8a56f231fae6bd43f361a8174159 |
|
MD5 | a2d03868038582ff058e369e3f976e57 |
|
BLAKE2b-256 | bbd5e181ac22abe2df28fbbf79253eb4748198ff28b5ebff641769e2830b4d9a |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c9b6b0492d4f1b6e82400f5269897510128b4a6d66890c1303a30965e31aa8 |
|
MD5 | aaee1d4c4e913045993474239ef3e32e |
|
BLAKE2b-256 | 16de467517f438c14f4ca57da01a86edd3b0f767fdf7f5a7aa04b5efe718c81e |
Hashes for tinyaes-1.1.0rc1-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | baa1f219c38f3f434ff2ba26b7407b116e9cd0fca92a521bb63bb143da5375be |
|
MD5 | 2dfdf6735020970f7e1bfcbe2a0cdf3e |
|
BLAKE2b-256 | d54a6cc154e09ff7038add517baf192461507fde30848157e40cb853e85f9096 |
Hashes for tinyaes-1.1.0rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21e8a6c5421e7bc3706db97921f2abc5f35f66875cd0f21fbbcfdf88c25cb2fb |
|
MD5 | 6d907b04b08b29e40266e5fcb09e2caf |
|
BLAKE2b-256 | 2c65c1721231be76acaf98a52b4497e767287cd9431a8f4db18afd485550dbb1 |
Hashes for tinyaes-1.1.0rc1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d76b5b38abd5e600c647435cd8dae4368b3d9e21f586a6c007fc99bfdc9b441 |
|
MD5 | 804efe6003332164e51b4c61b252779c |
|
BLAKE2b-256 | 8ad860eb4f83bae7d40674e90b2f7b8f15ca491e80ba08ab112baee1342645aa |
Hashes for tinyaes-1.1.0rc1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b52bd12c26fa38f35f7933f14c4578c926ddfcda0fc701bf42764aafd0081e7 |
|
MD5 | 891299cc3902580290191c75c1f73792 |
|
BLAKE2b-256 | d59efdd011cc3d103ff52d82b65387a52353dc0a1d73f2f13b0a9162ef8113bf |
Hashes for tinyaes-1.1.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53d6a91fe6749a92492b51a7852bbc1cabe009909b08eb3b42fa7012b3b202c9 |
|
MD5 | ff9cdffbfe73c253e0cafd3f906f0f05 |
|
BLAKE2b-256 | 413b1e159cfd435f0495d21b10ac71ee8e63e9692e56a166d8c3e65eb7529bf0 |