{"id":15833679,"url":"https://github.com/itzmeanjan/isap","last_synced_at":"2025-06-13T11:37:32.892Z","repository":{"id":39409462,"uuid":"504197090","full_name":"itzmeanjan/isap","owner":"itzmeanjan","description":"Lightweight Authenticated Encryption with Associated Data","archived":false,"fork":false,"pushed_at":"2023-02-11T05:46:22.000Z","size":180,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-05T18:49:18.708Z","etag":null,"topics":["aead","ascon","authenticated-encryption","isap","keccak","lightweight-cryptography","nist-lwc","verified-decryption"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itzmeanjan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-16T14:55:06.000Z","updated_at":"2022-06-28T08:02:36.000Z","dependencies_parsed_at":"2024-10-26T18:42:42.095Z","dependency_job_id":"ae3cfebf-45ae-43d7-b7f1-bb35a7c77141","html_url":"https://github.com/itzmeanjan/isap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/itzmeanjan/isap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fisap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fisap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fisap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fisap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzmeanjan","download_url":"https://codeload.github.com/itzmeanjan/isap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fisap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259638616,"owners_count":22888469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aead","ascon","authenticated-encryption","isap","keccak","lightweight-cryptography","nist-lwc","verified-decryption"],"created_at":"2024-10-05T13:41:31.004Z","updated_at":"2025-06-13T11:37:32.867Z","avatar_url":"https://github.com/itzmeanjan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# isap\nLightweight Authenticated Encryption with Associated Data\n\n## Overview\n\nISAP is the sixth NIST Light Weight Cryptography (LWC) competition's final round candidate, which I've decided to work on. Here I'm maintaining a zero-dependency, easy-to-use, header-only C++ library, implementing all variants of ISAP Authenticated Encryption with Associated Data ( AEAD ) scheme.\n\nVariant | Based on\n--- | ---\nISAP-A-128A ( **default** ) | Ascon permutation, with smaller # -of rounds\nISAP-A-128 | Ascon permutation, with higher # -of rounds\nISAP-K-128A | Keccak-p[400] permutation, with smaller # -of rounds\nISAP-K-128 | Keccak-p[400] permutation, with higher # -of rounds\n\nEach of these four AEAD schemes offer following functionalities\n\nRoutine | What does it do ?\n--- | --:\n`encrypt` | Given 16 -bytes secret key, 16 -bytes public message nonce, N -bytes associated data \u0026 M -bytes plain text, authenticated encryption algorithm computes M -bytes cipher text along with 16 -bytes authentication tag s.t. N, M \u003e= 0\n`decrypt` | Given 16 -bytes secret key, 16 -bytes public message nonce, 16 -bytes authentication tag, N -bytes associated data \u0026 M -bytes cipher text, verified decryption algorithm computes M -bytes plain text along with boolean verification flag denoting success status of authenticity, integrity check s.t. N, M \u003e= 0\n\n\u003e **Note** Associated data is never encrypted i.e. AEAD provides secrecy only for plain text but integrity for both cipher text \u0026 associated data.\n\n\u003e **Warning** Avoid reusing same nonce under same secret key.\n\n\u003e **Note** If boolean verification flag returned from decryption routine holds false value then plain text bytes are never attempted to be decrypted. That's because of the fact --- ISAP performs authentication tag verification first and only in case that is successful it attempts decryption.\n\nDuring this work, I followed ISAP specification, which was submitted to NIST's final round call in Light Weight Cryptography standardization effort. I suggest to go through ISAP [specification](https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/finalist-round/updated-spec-doc/isap-spec-final.pdf) to better understand ISAP AEAD schemes.\n\nOther Lightweight AEAD scheme which I've already worked on\n\n- Ascon, see [here](https://github.com/itzmeanjan/ascon)\n- TinyJambu, see [here](https://github.com/itzmeanjan/tinyjambu)\n- Xoodyak, see [here](https://github.com/itzmeanjan/xoodyak)\n- Sparkle, see [here](https://github.com/itzmeanjan/sparkle)\n- Photon-Beetle, see [here](https://github.com/itzmeanjan/photon-beetle)\n\n## Prerequisites\n\n- C++ compiler such as `g++`/ `clang++`, with C++20 standard library\n\n```fish\n$ g++ --version\ng++ (Homebrew GCC 12.2.0) 12.2.0\n\n$ clang++ --version\nApple clang version 14.0.0 (clang-1400.0.29.202)\n```\n\n- System development utilities such as `make`, `cmake`, `python3`, `unzip` and `wget`\n\n```fish\n$ make --version\nGNU Make 3.81\n\n$ cmake --version\ncmake version 3.25.2\n\n$ python3 --version\nPython 3.10.10\n\n$ unzip -v\nUnZip 6.00 of 20 April 2009, by Info-ZIP\n\n$ wget --version\nGNU Wget 1.21.3 built on darwin22.1.0.\n```\n\n- Install Python3 dependencies using\n\n```fish\n# Must have pip installed, if pip is not available you can try following on Debian/ Ubuntu\n# sudo apt-get install python3-pip\n\npython3 -m pip install -r wrapper/python/requirements.txt --user\n```\n\n- For benchmarking ISAP on CPU targets, install `google-benchmark` globally; follow [here](https://github.com/google/benchmark/tree/0ce66c0#installation) for how to.\n\n## Testing\n\nFor testing functional correctness of ISAP implementation, I make use of ISAP Known Answer Tests ( KATs ) submitted to NIST Light Weight Cryptography Competition's final round call. \n\nGiven secret key, nonce, associated data \u0026 plain text, I check whether computed cipher text and authentication tag matches what's provided in specific KAT. Along with that I also attempt to decrypt cipher text back to plain text, while ensuring that it can be verifiably decrypted.\n\nFor executing the tests, issue\n\n```fish\nmake\n```\n\n## Benchmarking\n\nFor benchmarking ISAP implementation on CPU targets, issue\n\n```fish\nmake benchmark\n```\n\n\u003e **Warning** Your CPU may have scaling enabled, for disabling that check [here](https://github.com/google/benchmark/blob/0ce66c0/docs/user_guide.md#disabling-cpu-frequency-scaling)\n\n### On Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz ( Compiled with Clang )\n\n```fish\n2023-02-11T08:45:45+04:00\nRunning ./bench/a.out\nRun on (8 X 2400 MHz CPU s)\nCPU Caches:\n  L1 Data 32 KiB\n  L1 Instruction 32 KiB\n  L2 Unified 256 KiB (x4)\n  L3 Unified 6144 KiB\nLoad Average: 2.11, 1.89, 1.96\n-------------------------------------------------------------------------------------------------------\nBenchmark                                             Time             CPU   Iterations UserCounters...\n-------------------------------------------------------------------------------------------------------\nisap_bench::ascon_permutation\u003c1\u003e                   4.19 ns         4.19 ns    165294720 bytes_per_second=8.89142G/s\nisap_bench::ascon_permutation\u003c6\u003e                   23.7 ns         23.7 ns     29427468 bytes_per_second=1.57244G/s\nisap_bench::ascon_permutation\u003c12\u003e                  45.9 ns         45.9 ns     15265810 bytes_per_second=831.842M/s\nisap_bench::keccak_permutation\u003c1\u003e                  42.0 ns         42.0 ns     16647839 bytes_per_second=1.10898G/s\nisap_bench::keccak_permutation\u003c8\u003e                   334 ns          333 ns      2073417 bytes_per_second=142.984M/s\nisap_bench::keccak_permutation\u003c12\u003e                  501 ns          501 ns      1350517 bytes_per_second=95.1938M/s\nisap_bench::keccak_permutation\u003c16\u003e                  670 ns          670 ns      1021182 bytes_per_second=71.2197M/s\nisap_bench::keccak_permutation\u003c20\u003e                  835 ns          835 ns       824296 bytes_per_second=57.1209M/s\nisap_bench::isap_a_128a_aead_encrypt/32/64         2105 ns         2104 ns       329441 bytes_per_second=43.5211M/s\nisap_bench::isap_a_128a_aead_decrypt/32/64         2118 ns         2117 ns       329536 bytes_per_second=43.2487M/s\nisap_bench::isap_a_128a_aead_encrypt/32/128        2708 ns         2706 ns       256933 bytes_per_second=56.3969M/s\nisap_bench::isap_a_128a_aead_decrypt/32/128        2736 ns         2726 ns       255245 bytes_per_second=55.9667M/s\nisap_bench::isap_a_128a_aead_encrypt/32/256        3910 ns         3899 ns       180598 bytes_per_second=70.4436M/s\nisap_bench::isap_a_128a_aead_decrypt/32/256        3885 ns         3883 ns       178589 bytes_per_second=70.7392M/s\nisap_bench::isap_a_128a_aead_encrypt/32/512        6246 ns         6242 ns       109592 bytes_per_second=83.1082M/s\nisap_bench::isap_a_128a_aead_decrypt/32/512        6256 ns         6250 ns       108899 bytes_per_second=83.0079M/s\nisap_bench::isap_a_128a_aead_encrypt/32/1024      10944 ns        10937 ns        62696 bytes_per_second=92.079M/s\nisap_bench::isap_a_128a_aead_decrypt/32/1024      10963 ns        10958 ns        62166 bytes_per_second=91.9001M/s\nisap_bench::isap_a_128a_aead_encrypt/32/2048      20418 ns        20407 ns        34121 bytes_per_second=97.2024M/s\nisap_bench::isap_a_128a_aead_decrypt/32/2048      20541 ns        20529 ns        34199 bytes_per_second=96.6265M/s\nisap_bench::isap_a_128a_aead_encrypt/32/4096      39222 ns        39197 ns        17805 bytes_per_second=100.435M/s\nisap_bench::isap_a_128a_aead_decrypt/32/4096      39546 ns        39513 ns        17851 bytes_per_second=99.6334M/s\nisap_bench::isap_a_128_aead_encrypt/32/64         12825 ns        12820 ns        53666 bytes_per_second=7.14163M/s\nisap_bench::isap_a_128_aead_decrypt/32/64         13638 ns        13586 ns        50369 bytes_per_second=6.7389M/s\nisap_bench::isap_a_128_aead_encrypt/32/128        13628 ns        13620 ns        50953 bytes_per_second=11.203M/s\nisap_bench::isap_a_128_aead_decrypt/32/128        13597 ns        13586 ns        50979 bytes_per_second=11.2308M/s\nisap_bench::isap_a_128_aead_encrypt/32/256        15187 ns        15176 ns        45671 bytes_per_second=18.0984M/s\nisap_bench::isap_a_128_aead_decrypt/32/256        15066 ns        15058 ns        45817 bytes_per_second=18.2396M/s\nisap_bench::isap_a_128_aead_encrypt/32/512        18145 ns        18133 ns        37706 bytes_per_second=28.6115M/s\nisap_bench::isap_a_128_aead_decrypt/32/512        18174 ns        18163 ns        38314 bytes_per_second=28.5631M/s\nisap_bench::isap_a_128_aead_encrypt/32/1024       24355 ns        24341 ns        28589 bytes_per_second=41.3736M/s\nisap_bench::isap_a_128_aead_decrypt/32/1024       24244 ns        24231 ns        28660 bytes_per_second=41.5616M/s\nisap_bench::isap_a_128_aead_encrypt/32/2048       36498 ns        36478 ns        19100 bytes_per_second=54.3796M/s\nisap_bench::isap_a_128_aead_decrypt/32/2048       36350 ns        36322 ns        19077 bytes_per_second=54.613M/s\nisap_bench::isap_a_128_aead_encrypt/32/4096       60919 ns        60900 ns        11196 bytes_per_second=64.6428M/s\nisap_bench::isap_a_128_aead_decrypt/32/4096       60678 ns        60620 ns        11152 bytes_per_second=64.9416M/s\nisap_bench::isap_k_128a_aead_encrypt/32/64        18668 ns        18660 ns        37236 bytes_per_second=4.90627M/s\nisap_bench::isap_k_128a_aead_decrypt/32/64        18529 ns        18519 ns        37059 bytes_per_second=4.94385M/s\nisap_bench::isap_k_128a_aead_encrypt/32/128       22815 ns        22799 ns        30714 bytes_per_second=6.69276M/s\nisap_bench::isap_k_128a_aead_decrypt/32/128       22610 ns        22599 ns        30568 bytes_per_second=6.7519M/s\nisap_bench::isap_k_128a_aead_encrypt/32/256       29827 ns        29815 ns        23375 bytes_per_second=9.21208M/s\nisap_bench::isap_k_128a_aead_decrypt/32/256       29807 ns        29789 ns        23374 bytes_per_second=9.22004M/s\nisap_bench::isap_k_128a_aead_encrypt/32/512       44277 ns        44242 ns        15841 bytes_per_second=11.7264M/s\nisap_bench::isap_k_128a_aead_decrypt/32/512       44022 ns        43988 ns        15799 bytes_per_second=11.7941M/s\nisap_bench::isap_k_128a_aead_encrypt/32/1024      72972 ns        72912 ns         9437 bytes_per_second=13.8122M/s\nisap_bench::isap_k_128a_aead_decrypt/32/1024      73282 ns        73230 ns         9606 bytes_per_second=13.7524M/s\nisap_bench::isap_k_128a_aead_encrypt/32/2048     131380 ns       131313 ns         5262 bytes_per_second=15.1062M/s\nisap_bench::isap_k_128a_aead_decrypt/32/2048     131033 ns       130971 ns         5208 bytes_per_second=15.1456M/s\nisap_bench::isap_k_128a_aead_encrypt/32/4096     246820 ns       246732 ns         2791 bytes_per_second=15.9557M/s\nisap_bench::isap_k_128a_aead_decrypt/32/4096     248281 ns       247999 ns         2814 bytes_per_second=15.8742M/s\nisap_bench::isap_k_128_aead_encrypt/32/64        143033 ns       142518 ns         5047 bytes_per_second=657.81k/s\nisap_bench::isap_k_128_aead_decrypt/32/64        136099 ns       136043 ns         5044 bytes_per_second=689.119k/s\nisap_bench::isap_k_128_aead_encrypt/32/128       143498 ns       143409 ns         4854 bytes_per_second=1089.54k/s\nisap_bench::isap_k_128_aead_decrypt/32/128       141048 ns       140983 ns         4872 bytes_per_second=1108.29k/s\nisap_bench::isap_k_128_aead_encrypt/32/256       153301 ns       153169 ns         4546 bytes_per_second=1.79317M/s\nisap_bench::isap_k_128_aead_decrypt/32/256       151099 ns       150963 ns         4594 bytes_per_second=1.81938M/s\nisap_bench::isap_k_128_aead_encrypt/32/512       171353 ns       171252 ns         4029 bytes_per_second=3.02945M/s\nisap_bench::isap_k_128_aead_decrypt/32/512       169892 ns       169752 ns         4085 bytes_per_second=3.05622M/s\nisap_bench::isap_k_128_aead_encrypt/32/1024      230412 ns       212757 ns         3325 bytes_per_second=4.73348M/s\nisap_bench::isap_k_128_aead_decrypt/32/1024      209167 ns       209044 ns         3350 bytes_per_second=4.81754M/s\nisap_bench::isap_k_128_aead_encrypt/32/2048      286222 ns       286096 ns         2419 bytes_per_second=6.93349M/s\nisap_bench::isap_k_128_aead_decrypt/32/2048      285025 ns       284868 ns         2433 bytes_per_second=6.96337M/s\nisap_bench::isap_k_128_aead_encrypt/32/4096      440289 ns       440103 ns         1585 bytes_per_second=8.94511M/s\nisap_bench::isap_k_128_aead_decrypt/32/4096      440478 ns       440231 ns         1590 bytes_per_second=8.9425M/s\n```\n\n## Usage\n\nStarting to use ISAP C++ API is as easy as including proper header files in your program and letting your compiler know where it can find these header files, which is `./include` directory in this repository.\n\nHere I've implemented full ISAP specification ( as submitted to NIST LWC final round call, see [here](https://csrc.nist.gov/projects/lightweight-cryptography/finalists) ) as zero-dependency, header-only C++ library. Following AEAD schemes can be used by importing respective header files, while you can also find usage examples in below table\n\nAEAD Scheme | Respective Header | Example\n--- | --- | ---\nISAP-A-128A | [./include/isap_a_128a.hpp](./include/isap_a_128a.hpp) | [isap_a_128a.cpp](./example/isap_a_128a.cpp)\nISAP-A-128 | [./include/isap_a_128.hpp](./include/isap_a_128.hpp) | [isap_a_128.cpp](./example/isap_a_128.cpp)\nISAP-K-128A | [./include/isap_k_128a.hpp](./include/isap_k_128a.hpp) | [isap_k_128a.cpp](./example/isap_k_128a.cpp)\nISAP-K-128 | [./include/isap_k_128.hpp](./include/isap_k_128.hpp) | [isap_k_128.cpp](./example/isap_k_128.cpp)\n\n\u003e **Note** You can just import `include/isap.hpp` which includes all `isap_{a,k}_128{a}.hpp` headers.\n\nThe interface that these AEAD schemes expose to users look like below\n\nRoutine | Input | Output\n--- | --: | --:\n`encrypt` | 16 -bytes secret key, 16 -bytes public message nonce, N -bytes associated data s.t. N \u003e= 0, M -bytes plain text s.t. M \u003e= 0 | 16 -bytes authentication tag, M -bytes cipher text s.t. M \u003e= 0\n`decrypt` | 16 -bytes secret key, 16 -bytes public message nonce, 16 -bytes authentication tag, N -bytes associated data s.t. N \u003e= 0, M -bytes cipher text s.t. M \u003e= 0 | Boolean verification flag, M -bytes plain text s.t. M \u003e= 0\n\n\u003e **Warning** Avoid reusing same nonce under same secret key. \n\nThese AEAD schemes are different based on what underlying permutation ( say whether `ascon` or `keccak-p[400]` ) they use and how many rounds of those are applied.\n\n```bash\n$ g++ -Wall -std=c++20 -O3 -march=native -I ./include example/isap_a_128.cpp \u0026\u0026 ./a.out\nISAP-A-128 AEAD\n\nKey          : c4cf08bfaa5b003f3e179a92a2d69f08\nNonce        : 03a6b07c1a41f92785acdfa53a3c0163\nData         : 5311325ebe357cc243cd4f847dda150ecfd434fba1271af5f291384e5098301f\nText         : da17ed022c4c260e76302501dd196674471058cd876720eb3215f86a1a9fe780\nCiphered     : b023a5eb8ac307e741bbf83c5dcfa0bf17d4c25db6895c333504171fa19bdf54\nTag          : f550b682cdfe42e7fb22868003dbc872\nDeciphered   : da17ed022c4c260e76302501dd196674471058cd876720eb3215f86a1a9fe780\n\n# ---\n\ng++ -Wall -std=c++20 -O3 -march=native -I ./include example/isap_a_128a.cpp \u0026\u0026 ./a.out\nISAP-A-128A AEAD\n\nKey          : 089dc67e6fb61f7ebb71e60e306837e9\nNonce        : 81b49eda969fd568462dea1712f73a65\nData         : 04f71996f3278d9de25634ab7a2d4691be4fc1014f91388032a029e2606b5356\nText         : 95304afd8fa04343c40e683cfb37e122866fd981dd877d4432b4e5e9939d14e5\nCiphered     : 33efaed5efbe5a3d10127f7eae4fb7b16498067bad17d92efee8c64c499c442f\nTag          : 5f50bc7f930e046288ff79edab3d4fe0\nDeciphered   : 95304afd8fa04343c40e683cfb37e122866fd981dd877d4432b4e5e9939d14e5\n\n# ---\n\ng++ -Wall -std=c++20 -O3 -march=native -I ./include example/isap_k_128.cpp \u0026\u0026 ./a.out\nISAP-K-128 AEAD\n\nKey          : f5d2c6030737e196bf4e8399cbcfa42d\nNonce        : 7461ab3b02f65eacae877167c9cc9b9e\nData         : 6c7a9dea487073bf293da800ea0b6730c19b09db940caf505304c5799eff98cc\nText         : 3ca67224924eee58f91e099b7e5b314574c241ccac93279c6e3d174e0cc2108b\nCiphered     : dfa8901c806d017d0d0b36cbe046ea754921a4cef8689cbcbcca10bc63e84104\nTag          : 44f51e49aca0146d96364c1a2130cd50\nDeciphered   : 3ca67224924eee58f91e099b7e5b314574c241ccac93279c6e3d174e0cc2108b\n\n# ---\n\ng++ -Wall -std=c++20 -O3 -march=native -I ./include example/isap_k_128a.cpp \u0026\u0026 ./a.out\nISAP-K-128A AEAD\n\nKey          : 27d1cf5b827b5f79498e7a872432aca7\nNonce        : 1b3d2785f58dcd59839c5bb47afd7f96\nData         : a696671d061dbcec1e7eefe1a061da7f0677ad8251ccaf4a4be975264a66cb91\nText         : 52b3ef2f8fb8696e1059f0fe10d084485fd3517d0c9970590ec5c2e5f1748389\nCiphered     : f622401d78f6f473e63402a77a97d3e0eccf2017cd7e5e00f338b9760237411f\nTag          : 1d10da32bb26efc388d3233e07e18a71\nDeciphered   : 52b3ef2f8fb8696e1059f0fe10d084485fd3517d0c9970590ec5c2e5f1748389\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fisap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzmeanjan%2Fisap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fisap/lists"}