-
Notifications
You must be signed in to change notification settings - Fork 522
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
add release-fips package for FIPS-related functionality #3893
Changes from all commits
f330991
e786a7b
83714cc
4eb76c5
4cd64f0
51982c6
d565225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Unit] | ||
Requires=fips-modprobe@__FIPS_MODULE__.service | ||
After=fips-modprobe@__FIPS_MODULE__.service |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
sha1 | ||
sha224 | ||
sha256 | ||
sha384 | ||
sha512 | ||
sha3-224 | ||
sha3-256 | ||
sha3-384 | ||
sha3-512 | ||
crc32c | ||
crct10dif | ||
ghash | ||
xxhash64 | ||
ghash-ce | ||
sha1-ce | ||
sha2-ce | ||
sha256-arm64 | ||
sha3-ce | ||
sha512-arm64 | ||
sha512-ce | ||
cipher_null | ||
des3_ede | ||
aes | ||
cfb | ||
dh | ||
ecdh | ||
aes-arm64 | ||
aes-ce-blk | ||
aes-ce-ccm | ||
aes-ce-cipher | ||
aes-neon-blk | ||
aes-neon-bs | ||
ecb | ||
cbc | ||
ctr | ||
xts | ||
gcm | ||
ccm | ||
authenc | ||
hmac | ||
cmac | ||
ofb | ||
cts | ||
lzo | ||
essiv | ||
seqiv | ||
drbg | ||
aead | ||
cryptomgr | ||
tcrypt | ||
crypto_user | ||
rsa |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
sha1 | ||
sha224 | ||
sha256 | ||
sha384 | ||
sha512 | ||
sha3-224 | ||
sha3-256 | ||
sha3-384 | ||
sha3-512 | ||
crc32c | ||
crct10dif | ||
ghash | ||
xxhash64 | ||
ghash_clmulni_intel | ||
sha1-ssse3 | ||
sha256-ssse3 | ||
sha512-ssse3 | ||
cipher_null | ||
des3_ede | ||
aes | ||
cfb | ||
dh | ||
ecdh | ||
aesni-intel | ||
ecb | ||
cbc | ||
ctr | ||
xts | ||
gcm | ||
ccm | ||
authenc | ||
hmac | ||
cmac | ||
ofb | ||
cts | ||
lzo | ||
essiv | ||
seqiv | ||
drbg | ||
aead | ||
cryptomgr | ||
tcrypt | ||
crypto_user | ||
rsa |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "libkcapi" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
build = "../build.rs" | ||
|
||
[lib] | ||
path = "../packages.rs" | ||
|
||
[package.metadata.build-package] | ||
releases-url = "https://github.com/smuellerDD/libkcapi/releases" | ||
|
||
[[package.metadata.build-package.external-files]] | ||
url = "https://github.com/smuellerDD/libkcapi/archive/v1.5.0/libkcapi-1.5.0.tar.gz" | ||
sha512 = "510d0606cdc9479a77ed07bd3ac59b07c3996402a85cee012e6836d0a31cb06f5b7f715cdb76f3745784aab3154595caec4537b4c774236a139ebfe6e1a8be9b" | ||
|
||
[build-dependencies] | ||
glibc = { path = "../glibc" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# libkcapi since 85bce6035b (1.5.0) uses sha512hmac with the same key for all | ||
# self-checks. Earlier versions used sha256hmac with a different key to check | ||
# the shared library. | ||
%global openssl_sha512_hmac openssl sha512 -hmac FIPS-FTW-RHT2009 -hex | ||
|
||
# We need to compute the HMAC after the binaries have been stripped. | ||
%define __spec_install_post\ | ||
%{?__debug_package:%{__debug_install_post}}\ | ||
%{__arch_install_post}\ | ||
%{__os_install_post}\ | ||
cd %{buildroot}/%{_cross_bindir}\ | ||
%openssl_sha512_hmac kcapi-hasher\\\ | ||
| awk '{ print $2 }' > .kcapi-hasher.hmac\ | ||
ln -s .kcapi-hasher.hmac .sha512hmac.hmac\ | ||
cd %{buildroot}/%{_cross_libdir}\ | ||
%openssl_sha512_hmac libkcapi.so.%{version}\\\ | ||
| awk '{ print $2 }' > .libkcapi.so.%{version}.hmac\ | ||
ln -s .libkcapi.so.%{version}.hmac .libkcapi.so.1.hmac\ | ||
%{nil} | ||
|
||
Name: %{_cross_os}libkcapi | ||
Version: 1.5.0 | ||
Release: 1%{?dist} | ||
Summary: Library for kernel crypto API | ||
License: BSD-3-Clause OR GPL-2.0-only | ||
URL: https://www.chronox.de/libkcapi/html/index.html | ||
Source0: https://github.com/smuellerDD/libkcapi/archive/v%{version}/libkcapi-%{version}.tar.gz | ||
BuildRequires: %{_cross_os}glibc-devel | ||
|
||
%description | ||
%{summary}. | ||
|
||
%package devel | ||
Summary: Files for development using the library for kernel crypto API | ||
Requires: %{name} | ||
|
||
%description devel | ||
%{summary}. | ||
|
||
%prep | ||
%autosetup -n libkcapi-%{version} -p1 | ||
|
||
%build | ||
autoreconf -fi | ||
%cross_configure \ | ||
--enable-static \ | ||
--enable-shared \ | ||
--enable-kcapi-hasher \ | ||
|
||
%force_disable_rpath | ||
|
||
%make_build | ||
|
||
%install | ||
%make_install | ||
|
||
ln -s kcapi-hasher %{buildroot}%{_cross_bindir}/sha512hmac | ||
find %{buildroot} -type f -name '*.hmac' -delete | ||
|
||
%files | ||
%license COPYING COPYING.bsd COPYING.gplv2 | ||
%{_cross_attribution_file} | ||
%{_cross_libdir}/*.so.* | ||
%{_cross_libdir}/.*.so.*.hmac | ||
%{_cross_bindir}/kcapi-hasher | ||
%{_cross_bindir}/.kcapi-hasher.hmac | ||
%{_cross_bindir}/sha512hmac | ||
%{_cross_bindir}/.sha512hmac.hmac | ||
|
||
%exclude %{_cross_libexecdir}/libkcapi | ||
%exclude %{_cross_mandir} | ||
|
||
%files devel | ||
%{_cross_libdir}/*.a | ||
%{_cross_libdir}/*.so | ||
%{_cross_includedir}/kcapi.h | ||
%{_cross_pkgconfigdir}/*.pc | ||
|
||
%changelog |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Isolates preconfigured.target | ||
DefaultDependencies=no | ||
After=fipscheck.target | ||
Requires=fipscheck.target | ||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very similar to the existing |
||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/systemctl set-default preconfigured | ||
ExecStart=/usr/bin/systemctl isolate default --no-block | ||
RemainAfterExit=true | ||
StandardOutput=tty | ||
StandardError=inherit | ||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a common feature of the new units since |
||
|
||
[Install] | ||
WantedBy=fipscheck.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
kernel.fips = 1 | ||
init.systemd.unit = fipscheck.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[Unit] | ||
Description=Run FIPS crypto module check | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
DefaultDependencies=no | ||
Before=fipscheck.target | ||
After=check-kernel-integrity.service | ||
Requires=check-kernel-integrity.service | ||
ConditionKernelCommandLine=fips=1 | ||
ConditionPathExists=!/etc/.fips-module-check-passed | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/modprobe tcrypt | ||
ExecStart=/usr/bin/rmmod tcrypt | ||
ExecStart=/usr/bin/touch /etc/.fips-module-check-passed | ||
RemainAfterExit=true | ||
StandardOutput=tty | ||
StandardError=inherit | ||
|
||
[Install] | ||
RequiredBy=fipscheck.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[Unit] | ||
Description=Run FIPS kernel integrity check | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
DefaultDependencies=no | ||
Before=fipscheck.target | ||
After=prepare-boot.service | ||
Requires=prepare-boot.service | ||
ConditionKernelCommandLine=fips=1 | ||
ConditionPathExists=!/etc/.fips-kernel-check-passed | ||
|
||
[Service] | ||
Type=oneshot | ||
WorkingDirectory=/boot | ||
ExecStart=/usr/bin/sha512hmac -q -c /boot/.vmlinuz.hmac | ||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slight subtlety here - |
||
ExecStart=/usr/bin/touch /etc/.fips-kernel-check-passed | ||
RemainAfterExit=true | ||
StandardOutput=tty | ||
StandardError=inherit | ||
|
||
[Install] | ||
RequiredBy=fipscheck.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[Unit] | ||
Description=Load FIPS crypto module %i | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
DefaultDependencies=no | ||
Before=fipscheck.target | ||
After=check-kernel-integrity.service | ||
Requires=check-kernel-integrity.service | ||
StartLimitIntervalSec=0 | ||
ConditionKernelCommandLine=fips=1 | ||
ConditionPathExists=!/etc/.fips-module-check-passed | ||
|
||
[Service] | ||
Type=oneshot | ||
# Check if it's a generic algorithm the kernel provides. If so, don't continue. | ||
ExecCondition=/usr/bin/grep -qvzE '(name|driver)\\s+:\\s+%i\\s+' /proc/crypto | ||
# Otherwise, attempt to load the module. | ||
ExecStart=-/sbin/modprobe %i | ||
# Ensure that the stderr file exists. Otherwise, grep fails on an empty file. | ||
ExecStart=-/usr/bin/touch /.read-only.%i | ||
# Succeed unless there was a fatal error. | ||
ExecStart=/usr/bin/grep -Fqvzw FATAL /etc/.fips-modprobe.%i | ||
Comment on lines
+13
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my attempt at recreating fips_load_crypto from |
||
RemainAfterExit=true | ||
StandardOutput=tty | ||
StandardError=append:/etc/.fips-modprobe.%i |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Unit] | ||
Description=FIPS integrity check | ||
AllowIsolate=false | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
|
||
[Install] | ||
WantedBy=preconfigured.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are passed the
%make_install
, why do we need to delete these? Shouldn't they be deleted before?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
.hmac
files are generated bymake install
, but they refer to the unstripped binaries and would be incorrect if retained.