2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 08:52:15 +00:00
Files
xcat-core/build-utils/fips-policy.sh
T
Vinícius Ferrão 5ea05d0e60 refactor(fips): share shell policy across runtime artifacts
Generate the Genesis and postscript policy blocks from one POSIX source.
Keep the runtime libraries self-contained and reject stale generated blocks
before RPM or Debian builds.

Preserve the existing state predicate, key algorithms, key sizes and
public-key export fallbacks. Keep caller-specific helpers separate.
2026-10-17 02:53:25 -03:00

34 lines
652 B
Bash

xcat_fips_enabled()
{
grep -q '^1$' "${1:-/proc/sys/crypto/fips_enabled}" 2>/dev/null
}
xcat_fips_state()
{
if xcat_fips_enabled "${1:-}"; then
printf '1'
else
printf '0'
fi
}
xcat_generate_discovery_private_key()
{
case "$1" in
1) openssl ecparam -name prime256v1 -genkey -noout -out "$2" ;;
0) openssl genrsa -out "$2" 1024 ;;
*) return 1 ;;
esac
}
xcat_discovery_public_key()
{
case "$1" in
0|1) ;;
*) return 1 ;;
esac
openssl pkey -in "$2" -pubout 2>/dev/null ||
openssl rsa -in "$2" -pubout 2>/dev/null ||
openssl ec -in "$2" -pubout
}