Skip to content

Commit a130020

Browse files
committed
leancrypto: add initial recipe
Cryptographic library that exclusively contains Quantum resistant cryptographic algorithms. It is lean has minimal dependencies, supports stack-only operation and provides optimized implementations for ML-KEM (Kyber), ML-DSA (Dilithium), SLH-DSA (Sphincs+) and many more Signed-off-by: Ayoub Zaki <ayoub.zaki@embetrix.com>
1 parent 0bc67b6 commit a130020

2 files changed

Lines changed: 105 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: MIT
3+
#
4+
# leancrypto test runner
5+
# Runs all leancrypto test binaries and reports pass/fail summary
6+
#
7+
8+
TESTDIR="/usr/libexec/leancrypto/tests"
9+
GREEN='\033[0;32m'
10+
RED='\033[0;31m'
11+
NC='\033[0m'
12+
PASS=0
13+
FAIL=0
14+
FAILED=""
15+
16+
if [ ! -d "$TESTDIR" ]; then
17+
echo "ERROR: Test directory $TESTDIR not found"
18+
exit 1
19+
fi
20+
21+
count=$(find "$TESTDIR" -maxdepth 1 -type f -executable | wc -l)
22+
if [ "$count" -eq 0 ]; then
23+
echo "ERROR: No test binaries found in $TESTDIR"
24+
exit 1
25+
fi
26+
27+
echo "Running $count leancrypto tests..."
28+
echo ""
29+
30+
for t in "$TESTDIR"/*; do
31+
[ -x "$t" ] || continue
32+
name=$(basename "$t")
33+
printf "%-60s " "$name"
34+
if "$t" > /dev/null 2>&1; then
35+
printf "${GREEN}PASS${NC}\n"
36+
PASS=$((PASS + 1))
37+
else
38+
printf "${RED}FAIL${NC}\n"
39+
FAIL=$((FAIL + 1))
40+
FAILED="$FAILED $name"
41+
fi
42+
done
43+
44+
echo ""
45+
echo "Results: $PASS passed, $FAIL failed, $((PASS + FAIL)) total"
46+
47+
if [ "$FAIL" -gt 0 ]; then
48+
echo "Failed tests:$FAILED"
49+
exit 1
50+
fi
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
SUMMARY = "Lean cryptographic library with PQC-resistant algorithms"
2+
DESCRIPTION = "leancrypto is a cryptographic library that exclusively contains \
3+
PQC-resistant cryptographic algorithms. It is lean, has minimal dependencies, \
4+
supports stack-only operation and provides optimized implementations for \
5+
ML-KEM (Kyber), ML-DSA (Dilithium), SLH-DSA (Sphincs+) and many more"
6+
HOMEPAGE = "https://leancrypto.org"
7+
LICENSE = "BSD-3-Clause | GPL-2.0-only"
8+
LIC_FILES_CHKSUM = " \
9+
file://LICENSE;md5=7e96f38306550c165071e7cab7b6b824 \
10+
file://LICENSE.bsd;md5=66a5cedaf62c4b2637025f049f9b826f \
11+
file://LICENSE.gplv2;md5=eb723b61539feef013de476e68b5c50a \
12+
"
13+
14+
SRC_URI = "git://github.com/smuellerDD/leancrypto.git;branch=master;protocol=https \
15+
file://leancrypto-tests.sh \
16+
"
17+
# SRCREV tagged v1.6.0
18+
SRCREV = "38215249fbe3951d1992b12447fca3c0c5e7e245"
19+
20+
inherit pkgconfig meson
21+
22+
EXTRA_OEMESON = "-Dstrip=false"
23+
24+
PACKAGECONFIG ??= "secure-exec apps tests"
25+
PACKAGECONFIG[apps] = "-Dapps=enabled,-Dapps=disabled"
26+
PACKAGECONFIG[small-stack] = "-Dsmall_stack=enabled,-Dsmall_stack=disabled"
27+
PACKAGECONFIG[no-asm] = "-Ddisable-asm=true,-Ddisable-asm=false"
28+
PACKAGECONFIG[efi] = "-Defi=enabled,-Defi=disabled"
29+
PACKAGECONFIG[secure-exec] = "-Dsecure_execution=enabled,-Dsecure_execution=disabled"
30+
PACKAGECONFIG[tests] = "-Dtests=enabled,-Dtests=disabled"
31+
32+
do_install:append () {
33+
if ${@bb.utils.contains('PACKAGECONFIG', 'tests', 'true', 'false', d)}; then
34+
install -d ${D}${libexecdir}/leancrypto/tests
35+
for t in $(find ${B} -maxdepth 3 -type f -executable \( -name '*_tester*' -o -name '*_test' \)); do
36+
basename=$(basename "$t")
37+
install -m 0755 "$t" ${D}${libexecdir}/leancrypto/tests/leancrypto_${basename}
38+
done
39+
install -d ${D}${bindir}
40+
install -m 0755 ${UNPACKDIR}/leancrypto-tests.sh ${D}${bindir}/leancrypto-tests
41+
fi
42+
}
43+
44+
PACKAGES =+ "${PN}-tests ${PN}-apps"
45+
46+
RDEPENDS:${PN}-apps += "${PN}"
47+
FILES:${PN}-apps = "${bindir}/lc_* \
48+
${libexecdir}/leancrypto \
49+
"
50+
RDEPENDS:${PN}-tests += "${PN}"
51+
FILES:${PN}-tests = "${bindir}/leancrypto-tests \
52+
${libexecdir}/leancrypto/tests \
53+
"
54+
55+
BBCLASSEXTEND = "native nativesdk"

0 commit comments

Comments
 (0)