diff --git a/meta-oe/recipes-crypto/leancrypto/files/leancrypto-tests.sh b/meta-oe/recipes-crypto/leancrypto/files/leancrypto-tests.sh new file mode 100644 index 00000000000..5db9c4dc8be --- /dev/null +++ b/meta-oe/recipes-crypto/leancrypto/files/leancrypto-tests.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT +# +# leancrypto test runner +# Runs all leancrypto test binaries and reports pass/fail summary +# + +TESTDIR="/usr/libexec/leancrypto/tests" +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[0;33m' +NC='\033[0m' +PASS=0 +FAIL=0 +SKIP=0 +FAILED="" + +if [ ! -d "$TESTDIR" ]; then + echo "ERROR: Test directory $TESTDIR not found" + exit 1 +fi + +count=$(find "$TESTDIR" -maxdepth 1 -type f -executable | wc -l) +if [ "$count" -eq 0 ]; then + echo "ERROR: No test binaries found in $TESTDIR" + exit 1 +fi + +echo "Running $count leancrypto tests..." +echo "" + +for t in "$TESTDIR"/*; do + [ -x "$t" ] || continue + name=$(basename "$t") + printf "%-60s " "$name" + "$t" > /dev/null 2>&1 + rc=$? + if [ "$rc" -eq 0 ]; then + printf "${GREEN}PASS${NC}\n" + PASS=$((PASS + 1)) + elif [ "$rc" -eq 77 ]; then + printf "${YELLOW}SKIP${NC}\n" + SKIP=$((SKIP + 1)) + else + printf "${RED}FAIL${NC}\n" + FAIL=$((FAIL + 1)) + FAILED="$FAILED $name" + fi +done + +echo "" +echo "Results: $PASS passed, $FAIL failed, $SKIP skipped, $((PASS + FAIL + SKIP)) total" + +if [ "$FAIL" -gt 0 ]; then + echo "Failed tests:$FAILED" + exit 1 +fi diff --git a/meta-oe/recipes-crypto/leancrypto/leancrypto_1.6.0.bb b/meta-oe/recipes-crypto/leancrypto/leancrypto_1.6.0.bb new file mode 100644 index 00000000000..05aae78273e --- /dev/null +++ b/meta-oe/recipes-crypto/leancrypto/leancrypto_1.6.0.bb @@ -0,0 +1,57 @@ +SUMMARY = "Lean cryptographic library with PQC-resistant algorithms" +DESCRIPTION = "leancrypto is a cryptographic library that exclusively contains \ +PQC-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" +HOMEPAGE = "https://leancrypto.org" +LICENSE = "BSD-3-Clause | GPL-2.0-only" +LIC_FILES_CHKSUM = " \ + file://LICENSE;md5=7e96f38306550c165071e7cab7b6b824 \ + file://LICENSE.bsd;md5=66a5cedaf62c4b2637025f049f9b826f \ + file://LICENSE.gplv2;md5=eb723b61539feef013de476e68b5c50a \ + " +SECTION = "libs" +SRC_URI = "git://github.com/smuellerDD/leancrypto.git;branch=master;protocol=https \ + file://leancrypto-tests.sh \ + " +# SRCREV tagged v1.6.0 +SRCREV = "38215249fbe3951d1992b12447fca3c0c5e7e245" + +inherit pkgconfig meson + +EXTRA_OEMESON = "-Dstrip=false" + +PACKAGECONFIG ??= "secure-exec apps tests" +PACKAGECONFIG[apps] = "-Dapps=enabled,-Dapps=disabled" +PACKAGECONFIG[small-stack] = "-Dsmall_stack=enabled,-Dsmall_stack=disabled" +PACKAGECONFIG[no-asm] = "-Ddisable-asm=true,-Ddisable-asm=false" +PACKAGECONFIG[efi] = "-Defi=enabled,-Defi=disabled" +PACKAGECONFIG[secure-exec] = "-Dsecure_execution=enabled,-Dsecure_execution=disabled" +PACKAGECONFIG[tests] = "-Dtests=enabled,-Dtests=disabled" + +do_install:append () { + if ${@bb.utils.contains('PACKAGECONFIG', 'tests', 'true', 'false', d)}; then + install -d ${D}${libexecdir}/leancrypto/tests + for t in $(find ${B} -maxdepth 3 -type f -executable \( -name '*_tester*' -o -name '*_test' \)); do + basename=$(basename "$t") + install -m 0755 "$t" ${D}${libexecdir}/leancrypto/tests/leancrypto_${basename} + done + install -d ${D}${bindir} + install -m 0755 ${UNPACKDIR}/leancrypto-tests.sh ${D}${bindir}/leancrypto-tests + fi +} + +PACKAGES =+ "${PN}-tests ${PN}-apps" + +RDEPENDS:${PN}-apps += "${PN}" +FILES:${PN}-apps = "${bindir}/lc_* \ + ${libexecdir}/leancrypto \ + " +RDEPENDS:${PN}-tests += "${PN}" +FILES:${PN}-tests = "${bindir}/leancrypto-tests \ + ${libexecdir}/leancrypto/tests \ + " + +INSANE_SKIP:${PN}-dbg = "buildpaths" + +BBCLASSEXTEND = "native nativesdk"