Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to Ascon Draft Standard #26

Merged
merged 71 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7f8f98a
Increase column limit in clang-format style spec. file
itzmeanjan Nov 10, 2024
97c1cf6
Format source files with new style spec
itzmeanjan Nov 10, 2024
c7fab00
Define MACRO using compiler attributes for ease of force inlining fun…
itzmeanjan Nov 10, 2024
25e06f6
Extend Ascon permutation to support till 16 -rounds
itzmeanjan Nov 10, 2024
9b97d4f
Make necessary changes to ensure that existing tests keep running
itzmeanjan Nov 10, 2024
aff84b8
Remove dudect as git submodule based dependency
itzmeanjan Nov 10, 2024
56af54c
Move benchmark files to different directory
itzmeanjan Nov 10, 2024
a268170
Format headers in include directory
itzmeanjan Nov 10, 2024
39b9f6e
Remove dudect tests
itzmeanjan Nov 10, 2024
b30037e
Improve the organization of Makefile(s)
itzmeanjan Nov 10, 2024
053d3f7
Update Github Actions CI script to run all test targets
itzmeanjan Nov 10, 2024
e2f0a48
Register 10 -rounds Ascon permutation for benchmarking
itzmeanjan Nov 10, 2024
39f30e4
Add benchmark result (in JSON format) collected on Intel x86_64 machi…
itzmeanjan Nov 10, 2024
78f5c80
Subtle must be downloaded before we try to compile any translation units
itzmeanjan Nov 10, 2024
c818659
Make std::span extent statically defined
itzmeanjan Nov 27, 2024
e561b69
Make to/from bytes function little-endian
itzmeanjan Nov 27, 2024
6605dd5
Remove obsolete AEAD implementations
itzmeanjan Nov 27, 2024
4be239a
Reorganize ascon permutation and utility headers
itzmeanjan Nov 30, 2024
e836285
Compile-time evaluated function for computing IV for Ascon variants
itzmeanjan Nov 30, 2024
9fcbfb6
Implement Ascon AEAD mode of operation
itzmeanjan Nov 30, 2024
02e0c74
Implement Ascon-AEAD128
itzmeanjan Nov 30, 2024
83442e6
Remove Ascon permutation based authentication schemes
itzmeanjan Nov 30, 2024
f68c879
Implement sponge mode of operation for Ascon -based hashing
itzmeanjan Nov 30, 2024
1f20652
Add useful constants and compile-time evaluable constraints on Ascon …
itzmeanjan Nov 30, 2024
0008300
Remove unnecessary header include
itzmeanjan Nov 30, 2024
ea7a8cb
Implement Ascon-Hash256 hash function
itzmeanjan Nov 30, 2024
220d10b
Rename Ascon hash header file
itzmeanjan Nov 30, 2024
97fc615
Refactor how ascon-hash256 digest byte length is computed
itzmeanjan Nov 30, 2024
6319795
Implement Ascon-Xof128
itzmeanjan Nov 30, 2024
c32e913
Refactor common utility functions
itzmeanjan Nov 30, 2024
94777a5
Use correct namespace for utility functions
itzmeanjan Nov 30, 2024
86f6f96
Rename Ascon AEAD mode as Duplex mode of operation
itzmeanjan Nov 30, 2024
67e576c
Use Gemini to write better comments for Ascon-AEAD128 public API
itzmeanjan Nov 30, 2024
c2d346d
Add Ascon-cxof128
itzmeanjan Dec 1, 2024
6067539
Remove reset function from ascon-hash256 struct
itzmeanjan Dec 1, 2024
9772c2e
Remove reset function from ascon-xof128 struct
itzmeanjan Dec 1, 2024
21d2cda
Add common helper functions for Ascon tests
itzmeanjan Dec 1, 2024
b429700
Add property -based tests ensuring functional correctness of Ascon-AE…
itzmeanjan Dec 1, 2024
d6bd709
Split Ascon-AEAD128 decryption failure tests into mutiple test cases …
itzmeanjan Dec 1, 2024
d5f758b
Implement bit-flipping logic correctly
itzmeanjan Dec 1, 2024
7a774c6
Add missing `[[nodiscard]]` attribute to functions which return values
itzmeanjan Dec 2, 2024
1d7a563
Add property based tests ensuring functional correctness of Ascon-Has…
itzmeanjan Dec 2, 2024
b8c0c59
Make AEAD mode functions `constexpr` and explicitly ignore return val…
itzmeanjan Dec 2, 2024
c1abcef
Add property based tests ensuring functional correctness of Ascon-Xof…
itzmeanjan Dec 2, 2024
955d674
Remove tests for schemes which are not proposed in Ascon IPD
itzmeanjan Dec 2, 2024
53108af
Add function for ease of generating random data for bencmarking
itzmeanjan Dec 2, 2024
40b2965
Add benchmark function for Ascon-AEAD128 encrypt function
itzmeanjan Dec 2, 2024
3775ef8
Update benchmark function for Ascon permutation
itzmeanjan Dec 2, 2024
99242db
Add benchmark function for Ascon-Hash256
itzmeanjan Dec 2, 2024
844e6f5
Add benchmark function for Ascon-Xof128
itzmeanjan Dec 2, 2024
a3051c2
Remove benchmark functions for schemes which are not part of Ascon IPD
itzmeanjan Dec 2, 2024
3a95daf
Add property based tests for Ascon-CXOF128, ensuring functional corre…
itzmeanjan Dec 2, 2024
6317df4
Update Ascon-AEAD128 KAT file
itzmeanjan Dec 2, 2024
098bbc0
Update Ascon-Hash256 KAT file
itzmeanjan Dec 2, 2024
04a66bf
Update Ascon-Xof128 KAT file
itzmeanjan Dec 2, 2024
9df9a60
Fix padding to use little-endian convention
itzmeanjan Dec 3, 2024
597e267
Fix domain separation to use little-endian convention
itzmeanjan Dec 3, 2024
26ee0a2
Delete KATs for schemes which are not being standardized by NIST
itzmeanjan Dec 3, 2024
3fe3806
Add function for parsing hex-string in KAT files
itzmeanjan Dec 3, 2024
4bbc331
Add known answer tests (KATs) for Ascon-AEAD128
itzmeanjan Dec 3, 2024
becf099
Add Known Answer Tests for Ascon-Hash256
itzmeanjan Dec 3, 2024
01dcae1
Fix padding issue in Ascon sponge mode of operation
itzmeanjan Dec 3, 2024
3cbf186
Add Known Answer Tests for Ascon-Xof128
itzmeanjan Dec 3, 2024
70f4f41
Add examples demonstrating how to use Ascon AEAD, Hash and Xof API
itzmeanjan Dec 3, 2024
d03abe7
Manually unroll Ascon permutation loop
itzmeanjan Dec 3, 2024
a7381fe
Update Github Actions CI script to be more compact
itzmeanjan Dec 3, 2024
eed9683
Update benchmark results JSON file for x86_64 target running Linux ke…
itzmeanjan Dec 3, 2024
ea12463
Add benchmark results JSON file for aarch64 target running Linux kern…
itzmeanjan Dec 3, 2024
f154991
Add compile-time evaluated tests to ensure that the library is `const…
itzmeanjan Dec 4, 2024
2e994f9
Ensure that the tag matches in compile-time evaluable test for Ascon-…
itzmeanjan Dec 4, 2024
a568295
Update project documentation
itzmeanjan Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add known answer tests (KATs) for Ascon-AEAD128
Signed-off-by: Anjan Roy <[email protected]>
  • Loading branch information
itzmeanjan committed Dec 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4bbc33103fde1f61145160330fc2f94a8e4fe7a7
72 changes: 72 additions & 0 deletions tests/kat_ascon_aead128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "ascon/aead/ascon_aead128.hpp"
#include "test_helper.hpp"
#include <fstream>
#include <gtest/gtest.h>

TEST(AsconAEAD128, KnownAnswerTests)
{
using namespace std::literals;

const std::string kat_file = "./kats/ascon_aead128.kat";
std::fstream file(kat_file);

while (true) {
std::string count0;

if (!std::getline(file, count0).eof()) {
std::string key0;
std::string nonce0;
std::string pt0;
std::string ad0;
std::string ct0;

std::getline(file, key0);
std::getline(file, nonce0);
std::getline(file, pt0);
std::getline(file, ad0);
std::getline(file, ct0);

auto key1 = std::string_view(key0);
auto nonce1 = std::string_view(nonce0);
auto pt1 = std::string_view(pt0);
auto ad1 = std::string_view(ad0);
auto ct1 = std::string_view(ct0);

auto key2 = key1.substr(key1.find("="sv) + 2, key1.size());
auto nonce2 = nonce1.substr(nonce1.find("="sv) + 2, nonce1.size());
auto pt2 = ((pt1.find("="sv) + 2) > pt1.size()) ? ""sv : pt1.substr(pt1.find("="sv) + 2, pt1.size());
auto ad2 = ((ad1.find("="sv) + 2) > ad1.size()) ? ""sv : ad1.substr(ad1.find("="sv) + 2, ad1.size());
auto ct2 = ct1.substr(ct1.find("="sv) + 2, ct1.size());

auto key = hex_to_bytes(key2);
auto nonce = hex_to_bytes(nonce2);
auto pt = hex_to_bytes(pt2);
auto ad = hex_to_bytes(ad2);
auto ct = hex_to_bytes(ct2); // cipher text + tag

auto key_span = std::span<const uint8_t, ascon_aead128::KEY_BYTE_LEN>(key);
auto nonce_span = std::span<const uint8_t, ascon_aead128::NONCE_BYTE_LEN>(nonce);

std::vector<uint8_t> computed_ct(pt.size());
std::array<uint8_t, ascon_aead128::TAG_BYTE_LEN> computed_tag{};
std::vector<uint8_t> computed_pt(computed_ct.size());

ascon_aead128::encrypt(key_span, nonce_span, ad, pt, computed_ct, computed_tag);
const auto is_decrypted = ascon_aead128::decrypt(key_span, nonce_span, ad, computed_ct, computed_pt, computed_tag);

EXPECT_TRUE(is_decrypted);

auto ct_span = std::span(ct);

EXPECT_TRUE(std::ranges::equal(ct_span.first(pt.size()), computed_ct));
EXPECT_TRUE(std::ranges::equal(ct_span.last(computed_tag.size()), computed_tag));

std::string empty_line;
std::getline(file, empty_line);
} else {
break;
}
}

file.close();
}