From 1a7538f0d73b4b35769c4df5ba32ed836e26a648 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 8 Aug 2018 13:04:04 +0300 Subject: [PATCH] ipasam: do not use RC4 in FIPS mode When creating Kerberos keys for trusted domain object account, ipasam module requests to generate keys using a series of well-known encryption types. In FIPS mode it is not possible to generate RC4-HMAC key: MIT Kerberos is using openssl crypto backend and openssl does not allow use of RC4 in FIPS mode. Thus, we have to filter out RC4-HMAC encryption type when running in FIPS mode. A side-effect is that a trust to Active Directory running with Windows Server 2003 will not be possible anymore in FIPS mode. Resolves: https://pagure.io/freeipa/issue/7659 Reviewed-By: Robbie Harwood --- daemons/ipa-sam/ipa_sam.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/daemons/ipa-sam/ipa_sam.c b/daemons/ipa-sam/ipa_sam.c index 0cd48d845b2edf9f328de0a949f80f98f9ef9025..675a511f0febf13cc5e00b547c18a050ac534f2e 100644 --- a/daemons/ipa-sam/ipa_sam.c +++ b/daemons/ipa-sam/ipa_sam.c @@ -213,6 +213,7 @@ struct ipasam_private { char *client_princ; struct sss_idmap_ctx *idmap_ctx; uint32_t supported_enctypes; + bool fips_enabled; }; @@ -1737,6 +1738,10 @@ static bool search_krb_princ(struct ipasam_private *ipasam_state, return true; } +/* Please keep ENCTYPE_ARCFOUR_HMAC the last in the list + * of the default encryption types so that we can exclude + * it when running in a FIPS mode where it is not allowed + */ #define DEF_ENCTYPE_NUM 3 long default_enctypes[DEF_ENCTYPE_NUM] = { ENCTYPE_AES256_CTS_HMAC_SHA1_96, @@ -1754,9 +1759,14 @@ static int set_cross_realm_pw(struct ipasam_private *ipasam_state, struct berval reqdata = { 0 }; struct berval *retdata = NULL; char *retoid; + int enctypes_num = DEF_ENCTYPE_NUM; + if (ipasam_state->fips_enabled) { + DEBUG(1, ("FIPS mode enabled: TDO account credentials will not have RC4-HMAC!\n")); + enctypes_num = DEF_ENCTYPE_NUM - 1; + } ret = ipaasn1_enc_getkt(true, princ, pwd, - default_enctypes, DEF_ENCTYPE_NUM, + default_enctypes, enctypes_num, &buffer, &buflen); if (!ret) goto done; @@ -3935,7 +3945,9 @@ static NTSTATUS ipasam_get_enctypes(struct ipasam_private *ipasam_state, *enctypes |= KERB_ENCTYPE_DES_CBC_MD5; break; case ENCTYPE_ARCFOUR_HMAC: - *enctypes |= KERB_ENCTYPE_RC4_HMAC_MD5; + if (!ipasam_state->fips_enabled) { + *enctypes |= KERB_ENCTYPE_RC4_HMAC_MD5; + } break; case ENCTYPE_AES128_CTS_HMAC_SHA1_96: *enctypes |= KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96; @@ -4563,6 +4575,7 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method, return NT_STATUS_INVALID_PARAMETER; } + ipasam_state->fips_enabled = ipapwd_fips_enabled(); ipasam_state->trust_dn = talloc_asprintf(ipasam_state, "cn=ad,cn=trusts,%s", ipasam_state->base_dn); @@ -4684,9 +4697,11 @@ static NTSTATUS pdb_init_ipasam(struct pdb_methods **pdb_method, &enctypes); if (!NT_STATUS_IS_OK(status)) { - enctypes = KERB_ENCTYPE_RC4_HMAC_MD5 | - KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96 | + enctypes = KERB_ENCTYPE_AES128_CTS_HMAC_SHA1_96 | KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96; + if (!ipasam_state->fips_enabled) { + enctypes |= KERB_ENCTYPE_RC4_HMAC_MD5; + } } ipasam_state->supported_enctypes = enctypes; -- 2.17.1