All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Constant-time tag/digest validation against timing attacks, improved CMake portability.
- Use constant-time tag/digest validation to offer some resistance against
timing attacks. Applies to all decryption functions
(
ascon_aead*_decrypt*()
) and all hashing functions which compare the generated digest to the expected (ascon_hash_*_matches()
).
- Enforced name
libascon.{dll|so|dylib}
for the shared library, so it's the same when built with any toolchain. - CMake will not verify whether a compiler supports a flag before using it. This makes the CMake configuration phase slightly longer, but the result is cached, so it happens only the first time.
- CMake now defaults to
MinSizeRel
build type ifCMAKE_BUILD_TYPE
is not specified, because binary size matters more than speed for a cross-platform implementation. Additionaly, on some platforms it overperforms theRelease
build. - Explicitly setting many Doxygen settings.
- Simplified Ascon permutation code, to increase its readability.
- Internal function
byte_mask()
renamed tomask_most_signif_bytes()
.
New, lighter hashing functions: Ascon-Hasha and Ascon-XOFa, as per Ascon's NIST submission update (2021). Pre-initialised hashes.
-
Ascon-Hasha functions:
- Offline processing:
ascon_hasha()
ascon_hasha_matches()
- Online processing:
ascon_hasha_init()
ascon_hasha_update()
ascon_hasha_final()
ascon_hasha_final_matches()
- Offline processing:
-
Ascon-XOFa functions:
- Offline processing:
ascon_hasha_xof()
ascon_hasha_xof_matches()
- Online processing:
ascon_hasha_xof_init()
ascon_hasha_xof_update()
ascon_hasha_xof_final()
ascon_hasha_xof_final_matches()
- Offline processing:
- Faster initialisation phase of all hashing functions states: using precomputed sponges for each hashing function instead of applying its initialisation vector and permuting it with 12 rounds. Given that this operation is deterministic, we can trade code size space (the precomputed sponges) for computation time (no permutation needed).
- Add struct names to anonymous structs that were only typedef-ed in the library header. Helps when debugging, so the debugger can show the struct name.
- Minor internal simplifications of the benchmark and test suite.
Fix new compiler warnings appearing in GCC v11.
- Fix GCC v11 warnings about
uint8*
vsuint8[]
data types differing in signature of function declaration and definition. It was working fine so far, apparently now the compiler wants them to be consistent, so they now are. Arrays were chosen as data type (although they are just pointers behind the scenes), so the known, constant length of the binary key/nonce can be explicitly indicated for code clarity, following the recommended practice from the MISRA-C standard. - Fixed GCC v11 warning appearing only in Release mode about the internal
small_cpy()
function "writing 1 byte into a region of size 0"[-Werror=stringop-overflow=]
- Fixed
ascon_aead_common.c
file mentioning BSD license and full copyright statement, when the project is CC0 (new-file-template error). - Auto-formatting
benchmark.c
and some markdown files, including this changelog. - Simplify assert macro usage in the codebase: make it do nothing when off,
thus the
#ifdef ASCON_INPUT_ASSERTS ... #endif
condition can be removed.
Compilation fixes for some GCC versions, added ascon_
to some internal target
names to avoid name clashing.
- Avoid type-punning when clearing the context and when comparing the expected
and computed tag/digest, which may cause compilation errors
with
-Werror=strict-aliasing
in some GCC versions. - Renamed some build targets to avoid name collisions when including the whole
LibAscon project into another CMake project with
add_subdirectory()
doxygen
->ascon_doxygen
benchmark
->ascon_benchmark
copytestvectors
->ascon_copytestvectors
As these are all internal targets, it should hopefully not affect the library user.
New hashing functions comparing the expected and computed digest, support for
virtually any tag and digest size, removed dependencies malloc.h
and string.h
, better context cleanup, optional asserts validating the library
input.
-
4 new hash functions that compute the digest of a message and compare it with the expected one, informing the user if they match. This is done with constant stack memory usage, like the AEAD functions now validate the tags too. The functions need the data and the expected digest as input, providing a boolean as output, indicating whether the digest matches or not.
ascon_hash_matches()
andascon_hash_xof_matches()
to validate the digest of a contiguous message.ascon_hash_final_matches()
andascon_hash_xof_final_matches()
to validate the digest as a last step of the Init-Update-Final process, removing the need from the user to callascon_hash_final()
orascon_hash_xof_final()
and runmemcmp()
on the just calculated digest.
-
Optional runtime asserts to validate the argument of the library API functions, mostly checking for NULL pointers and correct order of calling of the Init-Update-Final functions.
- Suggested use only in Debug mode.
- Uses
assert.h
by default, but can be overridden by definingASCON_ASSERT
at compile time too. - In CMake script it's enabled only for Debug builds and only
if
assert.h
is available. - Disabled by default if compiling the library by other means (e.g. custom makefile).
-
2 new example usages in the Readme:
- Offline encryption/decryption of contiguous data.
- Hashing functions, including new digest-comparison functions.
- Library internals (not impacting API):
- The AEAD tag validation is not performed one chunk of 8 bytes at the time
rather than generating the whole contiguous tag from the user-given data
and comparing it in its entirety (
memcmp()
) with the user-given tag. This implies that tag lengths don't have a physical limitation anymore (previously tag lengths > 64 bytes were discouraged). - Renamed state variable
ascon_bufstate_t.assoc_data_state
toascon_bufstate_t.flow_state
. - Enlarged state enum
ascon_flow_t
. - Renamed
const uint8_t* tag
parameter in AEAD function toexpected_tag
to emphasise that is the one that comes next to the ciphertext. It's length is now similarlyexpected_tag_len
.
- The AEAD tag validation is not performed one chunk of 8 bytes at the time
rather than generating the whole contiguous tag from the user-given data
and comparing it in its entirety (
-
Dependency
malloc.h
: is not required on Windows anymore, as we don't allocate the whole expected tag on the stack anymore: a small 8 byte buffer is used instead. -
Dependency
string.h
: due tomemcmp()
(see Changed section) andmemset()
/memset_s()
(see Fixed section) not being used anymore, the library is not used.
-
The clearing of the context, both for AEAD and hash functions is performed without loops or
memset()
/memset_s()
, but by setting the (not so many) context fields one by one to 0 using volatile pointer dereferencing to improve the chances of the optimiser not removing the cleanup section. -
CMake fixes:
clean
target now removesascon.h
from the build directory.- Better copying of the test vectors to the build directory: use a custom
target, set it as a dependency to
testascon
andtestasconshared
to avoid issues on some systems. - Building with CMake should now work properly when using LibAscon in a Git Submodule.
-
Small fixes in the hash/XOF function tests.
Support for compilation on Windows with MSVC, other CMake improvements.
Thanks to mataron for providing the initial fixes for MSVC!
- Enable
ctest
command to run the test executables. - Added
.editorconfig
for a portable text editing configuration.
-
All
tag_len
parameters in the library API now are of typesize_t
instead ofuint8_t
so thatsizeof()
can be used on the tag buffers. As the tags are internally allocated on the stack, the lengths should not be excessive (e.g. anything above 64 B = 512 bit is already a lot for security purposes). -
LibAscon now successfully compiles with CL (MSVC) on Windows:
- Fixed errors due to inlining of static function into exposed functions.
- Fixed errors at link time as the linker did not find the library's public
API functions: now a
ASCON_API
macro is set to export their symbols properly (does nothing on any other OS) with__declspec(dllexport)
. - Use
_malloca()
and_freea()
to declare arrays on the stack without a constant length at compile-time. - Fixed a variety of compiler warnings and errors for the test suite code and benchmark executable, including paddings, Spectre mitigations, inlining notifications, incorrect macro checking.
-
Moved compiler flag settings to a separate CMake file:
compiler_flags.cmake
- Improved support for GCC vs. Clang differences in the compiler flags
-
Replaced Travis CI with GitHub Actions CI:
- Support for MSVC compilation using CL on Windows
CMake and build process improvements, 4 new targets, minor fix to avoid unwanted compiler optimisations.
- Add static build targets
ascon128hash
,ascon128ahash
,ascon80pqhash
which compile to static libraries with the indicated AEAD cipher and the Ascon-Hash/Xof functions. Useful to avoid setting manual compile targets when only one cipher and the hash functions are needed. - Add test runner which tests the shared library build target
testasconshared
to check that everything works also with dynamic linking.
- Prefer
memset_s
when available to clear the context, asmemset
may be optimised out by the compiler, whilememset_s
is guaranteed to always execute. - Improved
CMakeLists.txt
:- Bump minimum CMake version to 3.9 to use the
INTERPROCEDURAL_OPTIMISATION
property (aka Link time optimisation) on just the targets that need it. - Remove
-flto
flag, it may cause compiling issues in some cases (breaking the Travis CI build, for one), prefer CMake's abstraction as per point above. - List explicit include directories for each target.
- Add explicit dependencies to each target that has some.
- Bump minimum CMake version to 3.9 to use the
- Improved Travis CI:
- Enable parallel make-all.
- Install MSYS2 and use GCC on Windows to compile properly.
Fixed slowdowns - now as fast as reference implementation, 100% test coverage.
-
Fixed 2x slowdown compared to original reference implementation by unrolling loops in
ascon_permutation_[a12|b8|b6]
. Apparently the compiler does not do that automatically, even when requested with-funroll-loops
. This brings LibAscon to the same performance as the reference implementation, when compiled in Release mode. -
When building in MinSizeRel mode (
-DCMAKE_BUILD_TYPE=MinSizeRel
), the core round and permutation functions are not hinted to be inlined by the compiled, thus the library takes slightly less space. -
Replaced rewritten benchmark runner with original one (copy-pasted and slightly changed). Apparently the rewritten benchmark was about 2x slower. Now the benchmark results are comparable between original implementation and LibAscon.
-
Test coverage reached 100%: removed a dead branch in
ascon_aead80pq_decrypt_final()
, which was a copy-paste error. -
Fix a
int
touint8
type conversion warning. -
Removed unused internal
log_sponge()
function, making the library slightly smaller. -
Add initial Travis-CI script for a few builds. Some are still failing, but the reasons seems to be in the system configuration or old compiler versions or "linker not found", not in the LibAscon source code.
First stable version with all ciphers.
-
Breaking change from previous versions: removed
total_output_len
parameters from the functionsascon_aead*_encrypt()
ascon_aead*_decrypt()
ascon_aead*_encrypt_final()
ascon_aead*_decrypt_final()
and from theascon_bufstate_t
struct, making it 8 B smaller. Why? TL;DR it's redundant.
The reasoning is that the user of the first two (offline processing) already knows the length of the plaintext/ciphertext; the user of the second two obtains the length of the processed chunks as return values so they can simply sum the up - and anyhow the user known the length of all the chunks provided to the cipher; those could be summed up to. In most of the cases the argument was
NULL
in the function usage. For details on how to obtain the total length, the example in the Readme should suffice. -
Renamed all files in
src
so they start withascon_
.
- Added more tests to cover more branching cases of the online-buffering algorithm.
- Removal of some minor warnings after inspection with static analyser
(
scan-build
) and CLion code inspection tool. - Typos
- Added missing Known limitations paragraphs to the previous releases in this Changelog.
- Because LibAscon is implemented with reuse of existing functions in mind, in
order to spare on code size and with the Init-Update-Digest paradigm, which
has some internal buffering, the cipher is about 4x slower than the
reference implementation (
ref
). - There is no architecture-specific optimisation, only a generic portable
implementation using mostly
uint64_t
data types.
Added Ascon80pq cipher, example in Readme.
ascon_aead128a_*
functions, working exactly as theaead128
versions. Internally they absorb the data with a double rate.- Example encryption and decryption code into Readme.
- Macros to exclude some parts of the library from the previous version, as
they only complicate the building process. It's easier to exclude some source
files from the build, now that they are better organised.
ASCON_COMPILE_AEAD128
ASCON_COMPILE_AEAD128a
ASCON_COMPILE_AEAD80pq
-ASCON_COMPILE_HASH
- Because LibAscon is implemented with reuse of existing functions in mind, in
order to spare on code size and with the Init-Update-Digest paradigm, which
has some internal buffering, the cipher is about 4x slower than the
reference implementation (
ref
). - There is no architecture-specific optimisation, only a generic portable
implementation using mostly
uint64_t
data types.
Added Ascon128a cipher and macros to exclude some parts of the library.
ascon_aead128a_*
functions, working exactly as theaead128
versions. Internally they absorb the data with a double rate.- Added macros to exclude some parts of the library if they are not needed for
a smaller build
ASCON_COMPILE_AEAD128
ASCON_COMPILE_AEAD128a
ASCON_COMPILE_AEAD80pq
(which is not included in the lib yet) -ASCON_COMPILE_HASH
- Because LibAscon is implemented with reuse of existing functions in mind, in
order to spare on code size and with the Init-Update-Digest paradigm, which
has some internal buffering, the cipher is about 4x slower than the
reference implementation (
ref
). - There is no architecture-specific optimisation, only a generic portable
implementation using mostly
uint64_t
data types. - The only AEAD algorithms implemented are Ascon128 and Ascon128a. Ascon80pq is still to be done.
Variable tags length, secure context cleanup, minor QOL improvements.
ascon_aead128_cleanup()
andascon_hash_cleanup()
to securely cleanup the context in case the online processing is not terminated with the final function.
-
ascon_aead128_encrypt()
,ascon_aead128_encrypt_final()
,ascon_aead128_decrypt()
,ascon_aead128_decrypt_final()
have a new parameter:tag_len
. The user can specify the length of the tag to generate and verify respectively. The value can be any value in [0, 255] bytes. At least 16 is of course recommended.Note: the tag bytes above 16 B are an extension of the original Ascon algorithm using the same sponge squeezing technique as for the XOF.
-
Replace
ascon_tag_validity_t
enum with simplerbool
fromstdbool.h
indicating "is tag valid?":true
for valid,false
otherwise. It's one less datatype to handle. MacrosASCON_TAG_OK
andASCON_TAG_INVALID
are still available. -
Because of the previous point:
srtbool.h
as now a dependency. -
Changed ISO C standard for compilation from C99 to C11, as there are no noticeable differences for this codebase.
- Improvements in the Doxygen documentation, especially the security warnings.
- Some warnings about type casting when compiling on GCC for Windows or ARM
microcontrollers with strict warning settings (
-Wall
,-Wextra
etc.). - Variety of typos and linter warnings.
- Minor readme improvements.
- Same as in v0.1.0
Initial version.
- AEAD encryption and decryption with Ascon128, both offline and online
- Hashing with Ascon-Hash and Ascon-XOF, both offline and online
- Test suite checking against test vectors
- Wrapping everything with single extensively documented header file
- At the moment the library is optimised for size, making the cipher about 4x slower than the reference implementation. On the other hand the size of the whole library is about 2x smaller than the AEAD-Ascon128 implementation alone, while the library includes online processing, Ascon-Hash and Ascon-XOF.
- There is no architecture-specific optimisation yet, only a generic portable C
implementation using mostly
uint64_t
data types. - The only AEAD algorithm implemented is the Ascon128 AEAD. The Ascon128a and Ascon80pq are still to be done.