Blame SOURCES/cryptsetup-argon2-fips.patch

8af939
diff --git a/lib/luks2/luks2_keyslot_luks2.c b/lib/luks2/luks2_keyslot_luks2.c
8af939
index 3716c26..540915b 100644
8af939
--- a/lib/luks2/luks2_keyslot_luks2.c
8af939
+++ b/lib/luks2/luks2_keyslot_luks2.c
8af939
@@ -350,6 +350,13 @@ static int luks2_keyslot_get_key(struct crypt_device *cd,
8af939
 		crypt_free_volume_key(derived_key);
8af939
 		return -ENOMEM;
8af939
 	}
8af939
+
8af939
+	if (crypt_fips_mode() &&
8af939
+	    (!strcmp(pbkdf.type, CRYPT_KDF_ARGON2I) ||
8af939
+	     !strcmp(pbkdf.type, CRYPT_KDF_ARGON2ID)))
8af939
+		log_verbose(cd, _("%s key derivation function is not currently FIPS-compliant."),
8af939
+			    pbkdf.type);
8af939
+
8af939
 	/*
8af939
 	 * Calculate derived key, decrypt keyslot content and merge it.
8af939
 	 */
8af939
@@ -406,6 +413,14 @@ static int luks2_keyslot_update_json(struct crypt_device *cd,
8af939
 	if (!pbkdf)
8af939
 		return -EINVAL;
8af939
 
8af939
+	if (crypt_fips_mode() &&
8af939
+	    (!strcmp(pbkdf->type, CRYPT_KDF_ARGON2I) ||
8af939
+	     !strcmp(pbkdf->type, CRYPT_KDF_ARGON2ID))) {
8af939
+		log_err(cd, _("%s key derivation function is not allowed in FIPS mode."),
8af939
+			pbkdf->type);
8af939
+		return -EINVAL;
8af939
+	}
8af939
+
8af939
 	r = crypt_benchmark_pbkdf_internal(cd, CONST_CAST(struct crypt_pbkdf_type *)pbkdf, keyslot_key_len);
8af939
 	if (r < 0)
8af939
 		return r;