%global sysctl_prio 50
%global sysctl_optmem_max 81920
%global distroname_ext %{_vendor}
# Define enable_docbook_pdf to 0,
# if you don't need pdf and ps document.
%global enable_docbook_pdf 1
%global hmaccalc_apps sha1hmac sha224hmac sha256hmac sha384hmac sha512hmac sm3hmac fipscheck fipshmac
# Calculate hmac file after installing for binary
# Add generation of HMAC checksum of the final stripped
# binary. %%define with lazy globbing is used here
# intentionally, because using %%global does not work.
%define __spec_install_post \
%{?__debug_package:%{__debug_install_post}} \
%{__arch_install_post} \
%{__os_install_post} \
bin_path=%{buildroot}%{_bindir} \
lib_path=%{buildroot}/%{_lib} \
{ bin/kcapi-hasher -n sha512hmac "$bin_path"/kcapi-hasher || exit 1; } | \\\
cut -f 1 -d ' ' >"$lib_path"/hmaccalc/kcapi-hasher.hmac \
{ bin/kcapi-hasher -n sha512hmac "$lib_path"/libkcapi.so.%{version} || exit 1; } | \\\
cut -f 1 -d ' ' >"$lib_path"/hmaccalc/libkcapi.so.%{version}.hmac \
%{__ln_s} libkcapi.so.%{version}.hmac \\\
"$lib_path"/hmaccalc/libkcapi.so.1.hmac \
%{nil}
Name: libkcapi
Version: 1.5.1
Release: 1
Summary: libkcapi - Linux Kernel Crypto API User Space Interface Library
License: BSD-3-Clause OR GPL-2.0-only
URL: https://www.chronox.de/%{name}/
Source0: https://www.chronox.de/%{name}/releases/%{version}/%{name}-%{version}.tar.xz
Source1: https://www.chronox.de/%{name}/releases/%{version}/%{name}-%{version}.tar.xz.asc
Patch0: libkcapi-1.1.1-lib_Fix_kcapi_handle_destroy_closing_FD_0.patch
BuildRequires: clang coreutils cppcheck gcc hardlink
BuildRequires: libtool openssl perl systemd xmlto kernel-headers >= 4.10.0
%if 0%{?enable_docbook_pdf}
BuildRequires: docbook-utils-pdf
%endif
Requires: systemd
Provides: %{name}-tools
Provides: hmaccalc == 0.9.14-10.1
Provides: hmaccalc%{?_isa} == 0.9.14-10.1
Provides: %{name}-hmaccalc
Obsoletes: %{name}-replacements <= %{version}-%{release}
Obsoletes: %{name}-tools
Obsoletes: hmaccalc <= 0.9.14-10
Obsoletes: %{name}-hmaccalc
%description
The Linux kernel exports a Netlink interface of type AF_ALG to allow user space to utilize the kernel crypto API.
libkcapi uses this Netlink interface and exports easy to use APIs so that a developer does not need to consider the low-level Netlink interface handling.
The library does not implement any cipher algorithms. All consumer requests are sent to the kernel for processing.
Results from the kernel crypto API are returned to the consumer via the library API.
%package devel
Summary: Development files for the %{name} package
Requires: %{name} = %{version}-%{release}
Obsoletes: %{name}-static < %{version}-%{release}
Provides: %{name}-static = %{version}-%{release}
%description devel
Header files for applications that use %{name}.
%package tests
Summary: Testing scripts for the %{name} package
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-tools
Requires: %{name}-hmaccalc
Requires: coreutils
Requires: openssl
Requires: perl
%description tests
Auxiliary scripts for testing %{name}.
%package fipscheck
Summary: Drop-in replacements for fipscheck/fipshmac provided by the %{name} package
Requires: %{name} = %{version}-%{release}
Obsoletes: fipscheck < %{version}-%{release}
Provides: fipscheck = %{version}-%{release}
Provides: fipscheck%{?_isa} = %{version}-%{release}
%description fipscheck
Provides drop-in replacements for fipscheck and fipshmac tools (from
package fipscheck) using %{name}.
%package_help
%prep
%autosetup -p 1
cat << EOF > README.%{distroname_ext}
This package increases the default limit of the ancillary buffer size
per kernel socket defined in \`net.core.optmem_max\` to %{sysctl_optmem_max} bytes.
For this preset to become active it requires a reboot after the
installation of this package. You can also manually increase this
limit by invocing \`sysctl net.core.optmem_max=%{sysctl_optmem_max}\` as the
super-user, e.g. using \`su\` or \`sudo\` on the terminal.
This is done to provide consumers of the new Linux Kernel Crypto API
User Space Interface a well sufficient and reasonable maximum limit
by default, especially when using AIO with a larger amount of IOVECs.
For further information about the AF_ALG kernel socket and AIO, see
the discussion at the kernel-crypto mailing-list:
https://www.mail-archive.com/linux-crypto@vger.kernel.org/msg30417.html
See the instructions given in '%{_sysctldir}/50-default.conf',
if you need or want to override the preset made by this package.
EOF
cat << EOF > %{sysctl_prio}-%{name}-optmem_max.conf
# See the 'README.%{distroname_ext}' file shipped in %%doc
# with the %{name} package.
#
# See '%{_sysctldir}/50-default.conf',
# if you need or want to override this preset.
# Increase the ancillary buffer size per socket.
net.core.optmem_max = %{sysctl_optmem_max}
EOF
%{_bindir}/autoreconf -fiv
%build
%if 0%{?enable_docbook_pdf}
# db2pdf and db2ps can't work with the 4.5 Docbook DTD
# use the 4.1.2 Docbook DTD like old libkcapi
sed -i -e 's|XML V45|XML V4.1.2|' lib/doc/libkcapi.tmpl
sed -i -e 's|/xml/4\.5/|/xml/4.1.2/|' lib/doc/libkcapi.tmpl
%endif
%configure \
--libdir=/%{_lib} \
--disable-silent-rules \
--enable-kcapi-encapp \
--enable-kcapi-dgstapp \
--enable-kcapi-hasher \
--enable-kcapi-rngapp \
--enable-kcapi-speed \
--enable-kcapi-test \
--enable-shared \
--enable-static \
--enable-sum-prefix= \
--enable-sum-dir=/%{_lib} \
--with-pkgconfigdir=%{_libdir}/pkgconfig
%make_build all doc
%install
%make_install
%delete_la
# Install sysctl.d preset.
mkdir -p %{buildroot}%{_sysctldir}
install -Dpm 0644 -t %{buildroot}%{_sysctldir} %{sysctl_prio}-%{name}-optmem_max.conf
# Install into proper location for inclusion by %%doc.
mkdir -p %{buildroot}%{_pkgdocdir}
install -Dpm 0644 -t %{buildroot}%{_pkgdocdir} README.%{distroname_ext} README.md CHANGES.md TODO
%if 0%{?enable_docbook_pdf}
install -Dpm 0644 -t %{buildroot}%{_pkgdocdir} doc/%{name}.p{df,s}
%endif
cp -pr lib/doc/html %{buildroot}%{_pkgdocdir}
find %{buildroot} -type f -name '*.hmac' -print -delete
find %{buildroot} -type f -size 0 -print -delete
find %{buildroot}%{_pkgdocdir} -type f -print | xargs %{__chmod} -c 0644
find %{buildroot}%{_pkgdocdir} -type d -print | xargs %{__chmod} -c 0755
for d in %{_mandir} %{_pkgdocdir}; do
hardlink -cfv %{buildroot}$d
done
# create symbolic link to /usr/bin/
for app in %hmaccalc_apps; do
ln -s ../libexec/%{name}/$app %{buildroot}%{_bindir}/$app
done
%check
%make_build scan
%make_build cppcheck CPPCHECK="cppcheck --check-level=exhaustive -UCHECK_DIR"
pushd test
ENABLE_FUZZ_TEST=1 \
NO_32BIT_TEST=1 \
./test-invocation.sh ||:
popd
%files
%doc %dir %{_pkgdocdir}
%doc %{_pkgdocdir}/README.md
%license COPYING*
/%{_lib}/%{name}.so.*
/%{_lib}/hmaccalc/%{name}.so.*
%doc %{_pkgdocdir}/README.%{distroname_ext}
%{_sysctldir}/%{sysctl_prio}-%{name}-optmem_max.conf
%{_bindir}/kcapi*
%{_bindir}/sha*hmac
%{_bindir}/sm*hmac
%{_libexecdir}/%{name}/md5sum
%{_libexecdir}/%{name}/sha*sum
%{_libexecdir}/%{name}/sm*sum
%{_libexecdir}/%{name}/fips*
%{_libexecdir}/%{name}/sha*hmac
%{_libexecdir}/%{name}/sm*hmac
/%{_lib}/hmaccalc/kcapi-hasher.hmac
%files devel
%doc %{_pkgdocdir}/CHANGES.md
%doc %{_pkgdocdir}/TODO
%{_includedir}/kcapi.h
/%{_lib}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
/%{_lib}/%{name}.a
%files tests
%{_libexecdir}/%{name}/kcapi
%{_libexecdir}/%{name}/kcapi-convenience
%{_libexecdir}/%{name}/kcapi-enc-test-large
%{_libexecdir}/%{name}/*.sh
%files fipscheck
%{_bindir}/fips*
%files help
%doc %{_pkgdocdir}
%exclude %{_pkgdocdir}/README.md
%exclude %{_pkgdocdir}/README.%{distroname_ext}
%exclude %{_pkgdocdir}/CHANGES.md
%exclude %{_pkgdocdir}/TODO
%{_mandir}/man1/kcapi*.1.*
%{_mandir}/man3/kcapi_*.3.*
%changelog
* Tue Aug 11 2026 yixiangzhike <yixiangzhike007@163.com> - 1.5.1-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update to 1.5.1
* Thu Jul 10 2025 yixiangzhike <yixiangzhike007@163.com> - 1.5.0-14
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix history changelog
* Sat Feb 01 2025 Funda Wang <fundawang@yeah.net> - 1.5.0-13
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:obsoletes fipscheck package
* Wed Dec 11 2024 yixiangzhike <yixiangzhike007@163.com> - 1.5.0-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update version to 1.5.0
add new APIS: kcapi_md_sha3_224 kcapi_md_sha3_256 kcapi_md_sha3_384 kcapi_md_sha3_512.
move all apps sha*hmac and sm*hmac to /usr/libexec/libkcapi dir.
use symbolic link /usr/bin/{sha,sm}*hmac instead of old binaries.
* Thu Nov 28 2024 xu_ping <707078654@qq.com> - 1.4.0-8
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the failure of building with cppcheck>=2.16.
* Wed Nov 20 2024 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the failure of testcase compiled with kernel-6.x
* Thu Jan 18 2024 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:simplified control macro
* Wed Aug 16 2023 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:refix the failure of building with cppcheck>=2.11 by using upstream patch
* Tue Aug 15 2023 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:append newline to command /usr/bin/sha*hmac
* Tue Jul 25 2023 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix the failure of building with cppcheck >= 2.11
* Fri Apr 28 2023 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:calculate hmac file after installing for binary
* Wed Nov 16 2022 yixiangzhike <yixiangzhike007@163.com> - 1.4.0-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Update to 1.4.0
* Wed Jul 13 2022 yixiangzhike <yixiangzhike007@163.com> - 1.3.1-5
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add macro to control docbook-utils-pdf dependency
* Fri Apr 29 2022 yixiangzhike <yixiangzhike007@163.com> - 1.3.1-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:delete duplicate files from libkcapi-help
* Fri Apr 15 2022 yixiangzhike <yixiangzhike007@163.com> - 1.3.1-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix printf usage errors highlighted by covscan
* Wed Jan 26 2022 yixiangzhike <yixiangzhike007@163.com> - 1.3.1-2
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:enable test suite in check
* Thu Dec 30 2021 yixiangzhike <yixiangzhike007@163.com> - 1.3.1-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Update to 1.3.1
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 1.2.0-5
- DESC: delete -S git from autosetup, and delete BuildRequires git
* Fri Nov 20 2020 panxiaohe <panxiaohe@huawei.com> - 1.2.0-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Solve the failure when installing libkcapi-devel
* Thu Oct 22 2020 zhangxingliang <zhangxingliang3@huawei.com> - 1.2.0-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Solve the failure when installing libkcapi-tests
* Fri Oct 16 2020 zhangxingliang <zhangxingliang3@huawei.com> - 1.2.0-2
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Detach the sub package libkcapi-tests from libkcapi
* Fri Jul 17 2020 yang_zhuang_zhuang<yangzhuangzhuang1@huawei.com> - 1.2.0-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:update to 1.2.0
* Thu Nov 14 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.1.5-2
- Correct provides of hmaccalc
* Tue Sep 3 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.1.5-1
- Package init