SDB:Crypto-policies

跳转到:导航搜索
密码算法和协议的安全性会随着时间而变化。为了对它们的弃用进行一致的系统范围内的处理,我们使用 crypto-policies。这个软件包允许使用预定义的策略,修改现有的策略以及创建新的策略。

简介

为了统一不同应用程序和库使用的密码策略,我们在 SUSE 和 openSUSE 中引入了 crypto-policies 软件包。这个软件包允许为所有使用受策略支持的密码后端应用程序设置密码安全级别。遵循 crypto-policies 的软件包列表非常广泛,包括 OpenSSL、GnuTLS、Apache2、Java/OpenJDK、Stunnel、BIND、Python、perl-IO-Socket-SSL、NSS/mozilla-nss、pacemaker、Kerberos/krb5、openssh、libssh、vsftpd 等。请注意,crypto-policies 的支持已添加到 Tumbleweed 自 20201216 快照以来,并且存在于 SLE-15 自 SP4 以来。

预定义的安全级别

主要思想是拥有四个预定义的安全级别,管理员可以通过修改 /etc/crypto-policies/config 或使用 update-crypto-policies 脚本来配置这些级别。这些策略组是 LEGACY、DEFAULT、NEXT、FUTURE、BSI、FIPS 和 EMPTY,它们具有以下详细信息

 * LEGACY
    MACs: All HMAC with SHA-1 or better + all modern MACs (Poly1305, ...)
    Curves: All prime >= 256 bits (including Bernstein curves)
    Signature algorithms: SHA-1 hash or better (DSA allowed)
    TLS Ciphers: All available >= 112-bit key, >= 128-bit block (including 3DES and excluding RC4)
    Non-TLS Ciphers: Same as TLS ciphers with added Camellia
    key exchange: ECDHE, RSA, DHE
    DH params size: >= 1024
    RSA params size: >= 1024
    DSA params size: >= 1024
    TLS protocols: TLS >= 1.0, DTLS >= 1.0
 * DEFAULT
    MACs: All HMAC with SHA-1 or better + all modern MACs (Poly1305, ...)
    Curves: All prime >= 256 bits (including Bernstein curves)
    Signature algorithms: With SHA-224 hash or better (no DSA)
    TLS Ciphers: >= 128-bit key, >= 128-bit block (AES, ChaCha20, including AES-CBC)
    non-TLS Ciphers: Same as TLS Ciphers with added Camellia
    key exchange: ECDHE, RSA, DHE (no DHE-DSS)
    DH params size: >= 2048
    RSA params size: >= 2048
    TLS protocols: TLS >= 1.2, DTLS >= 1.2
 * NEXT
    The NEXT policy is just an alias to the DEFAULT policy.
 * FIPS
    MACs: All HMAC with SHA-1 or better
    Curves: All prime >= 256 bits, hybrid ML-KEM
    Signature algorithms: SHA-256 hash or better (no DSA), pure ML-DSA
    TLS Ciphers: >= 128-bit key, >= 128-bit block (AES, including AES-CBC)
    non-TLS Ciphers: Same as TLS ciphers
    key exchange: ECDHE, DHE (no DHE-DSS, no DSA), KEM-ECDH
    DH params size: >= 2048
    RSA params size: >= 2048
    TLS protocols: TLS >= 1.2, DTLS >= 1.2
 * BSI
    MACs: All HMAC with SHA-256 or better + all modern MACs
    Curves: All prime >= 256 bits (including Bernstein curves)
    Signature algorithms: SHA-256 hash or better (no DSA)
    TLS Ciphers: >= 256-bit key, >= 128-bit block, only Authenticated Encryption (AE) ciphers
    non-TLS Ciphers: Same as TLS ciphers with added non AE ciphers
    key exchange: ECDHE, DHE (no *DHE-DSS*)
    DH params size: >= 3072
    RSA params size: >= 3072 (until the end of 2023, now its 3072)
    TLS protocols: TLS >= 1.2, DTLS >= 1.2
 * FUTURE
    MACs: All HMAC with SHA-256 or better + all modern MACs (Poly1305, ...)
    Curves: All prime >= 256 bits (including Bernstein curves)
    Signature algorithms: SHA-256 hash or better (no DSA)
    TLS Ciphers: >= 256-bit key, >= 128-bit block, only Authenticated Encryption (AE) ciphers
    non-TLS Ciphers: Same as TLS ciphers with added non AE ciphers and Camellia
    key exchange: ECDHE, DHE (no DHE-DSS)
    DH params size: >= 3072
    RSA params size: >= 3072
    TLS protocols: TLS >= 1.2, DTLS >= 1.2
 * EMPTY
    All cryptographic algorithms are disabled (used for debugging only, do not use).

这些策略也会随着密码组件的安全性而随着时间而变化。拥有 crypto-policies 允许以简单的方式系统范围内和透明地处理算法或协议的弃用。

在首次安装 crypto-policies 软件包时,DEFAULT 策略被设置为默认策略。可以使用 update-crypto-policies 命令检查当前使用的策略

   update-crypto-policies --show

某些策略可能会破坏连接到使用弱密码算法的服务器的应用程序。如果发生这种情况,可以使用 LEGACY 策略级别,直到通过使用 update-crypto-policies 解决为止

   update-crypto-policies --set LEGACY

如果我们注意到用户体验显著下降,例如,由于许多自定义服务器使用旧协议,我们将考虑推迟该更改或调整该策略。

创建新的策略

从头开始定义新的策略需要创建一个名为 <POLICY>.pol 的文件,其中名称必须大写且不含空格。此文件必须位于 /etc/crypto-policies/policies 文件夹或 /usr/share/crypto-policies/policies 文件夹中。如前所示,可以使用以下命令应用新创建的策略

  update-crypto-policies --set <POLICY>

有关策略示例,请参阅 /usr/share/crypto-policies/policies/ 中的 .pol 文件。

修改现有的密码策略

密码策略可以通过策略修改器来调整某些算法或协议。修改现有策略可以通过策略修改器模块来完成。这些策略修改器是文本文件,扩展名为 .pmod,其中包含修改。修改器模块的名称必须是 <MODULE>.pmod,其中 <MODULE> 是修改器名称的大写形式且不含空格。这些文件必须位于 /etc/crypto-policies/policies/modules 文件夹中,或者如果它们是预安装的,则位于 /usr/share/crypto-policies/policies/modules 文件夹中)。

例如,要禁用 SHA-1 哈希,修改器模块 /usr/share/crypto-policies/policies/modules/NO-SHA1.pmod 包含

   hash = -SHA1
   sign = -RSA-PSS-SHA1 -RSA-SHA1 -ECDSA-SHA1

并且,可以使用以下命令应用新定制的策略

   update-crypto-policies --set DEFAULT:NO-SHA1

强制执行系统密码策略

为了遵循 crypto-policies,某些应用程序的配置文件或编译选项应设置系统默认选项。也就是说,例如,对于使用 OpenSSL 或 GnuTLS 的应用程序,使用优先级字符串或密码“SYSTEM”。然后,发货的库将确保,一旦遇到“SYSTEM”选项,将应用预配置的系统设置。当应用程序未指定任何默认设置时,应应用系统设置。

例如,对于 OpenSSL 和 GnuTLS 来说就是

 * OpenSSL: The cipher string "PROFILE=SYSTEM" will be used to specify the system ciphers. Any applications not explicitly specifying ciphers will use the system ciphers.
 * GnuTLS: The "@SYSTEM" priority string will be used to specify the system ciphers. Any applications using gnutls_set_default_priority() will also use the system ciphers.

我们已仔细审查依赖于 OpenSSL 和 GnuTLS 的软件包。如果您在 openSUSE bugzilla 中提交错误报告,请向我们反馈任何不一致之处。

启用内核 FIPS 模式

可以使用 fips-mode-setup 命令来启用内核 FIPS 模式,该模式还将系统策略设置为 FIPS

 # fips-mode-setup --enable
 Setting system policy to FIPS
 FIPS mode will be enabled.
 [...]
 Please reboot the system for the setting to take effect.

重启后,可以使用以下命令验证 fips 模式

 # fips-mode-setup --check
 FIPS mode is enabled.
 Initramfs fips module is enabled.
 The current crypto policy (FIPS) is based on the FIPS policy.

还可以使用以下命令验证 fips 模式

 # sysctl -a | grep fips
 crypto.fips_enabled = 1

同样,要禁用 FIPS 模式

 # fips-mode-setup --disable
 Setting system policy to DEFAULT
 FIPS mode will be disabled.
 [...]
 Please reboot the system for the setting to take effect.

文档和上游项目

有关更多信息,请参阅以下手册页

   man 7 crypto-policies
   man 8 update-crypto-policies
   man 8 fips-mode-setup
   man 8 fips-finish-install

还请查看 crypto-policies GitLab 中的上游项目和 openSUSE 会议演示