@@ -211,7 +211,7 @@ def _detect_luks_aes_module(self, luks_cipher_name: str) -> None:
211211 self ["_kmod_auto" ] = crypto_config ["module" ]
212212
213213
214- def _detect_luks_header_aes (self , luks_info : dict ) -> dict :
214+ def _detect_luks_header_aes (self , luks_info : dict ) -> None :
215215 """Checks the cipher type in the LUKS header, reads /proc/crypto to find the
216216 corresponding driver. If it's not builtin, adds the module to the kernel modules."""
217217 for keyslot in luks_info .get ("keyslots" , {}).values ():
@@ -222,7 +222,7 @@ def _detect_luks_header_aes(self, luks_info: dict) -> dict:
222222 _detect_luks_aes_module (self , segment ["encryption" ])
223223
224224
225- def _detect_luks_header_sha (self , luks_info : dict ) -> dict :
225+ def _detect_luks_header_sha (self , luks_info : dict ) -> None :
226226 """Reads the hash algorithm from the LUKS header,
227227 enables the corresponding kernel module using _crypto_ciphers"""
228228 for keyslot in luks_info .get ("keyslots" , {}).values ():
@@ -233,13 +233,19 @@ def _detect_luks_header_sha(self, luks_info: dict) -> dict:
233233 self ["kernel_modules" ] = self ._crypto_ciphers [digest ["hash" ]]["driver" ]
234234
235235
236- def _detect_luks_header_integrity (self , luks_info : dict ) -> dict :
236+ def _detect_luks_header_integrity (self , luks_info : dict , mapped_name : str ) -> None :
237237 """Reads the integrity algorithm from the LUKS header,
238238 Enables the dm-integrity module, and returns the integrity type."""
239239 for segment in luks_info .get ("segments" , {}).values ():
240240 if integrity_type := segment .get ("integrity" , {}).get ("type" ):
241- self ["_kmod_auto" ] = ["dm_integrity" , "authenc" ]
242- return integrity_type
241+ integrity_kmods = ["dm_integrity" , "authenc" ]
242+ if integrity_type .startswith ("hmac" ):
243+ integrity_kmods .append ("hmac" )
244+ self .logger .info (
245+ f"[{ c_ (mapped_name , 'blue' )} ]({ c_ (integrity_type , 'cyan' )} ) Enabling kernel modules for dm-integrity: { c_ (' ' .join (integrity_kmods ), 'magenta' )} "
246+ )
247+ self ["cryptsetup" ][mapped_name ]["_dm-integrity" ] = integrity_type
248+ return
243249
244250
245251@contains ("cryptsetup_header_validation" , "Skipping cryptsetup header validation." , log_level = 30 )
@@ -278,9 +284,7 @@ def _validate_cryptsetup_header(self, mapped_name: str) -> None:
278284
279285 _detect_luks_header_aes (self , luks_info )
280286 _detect_luks_header_sha (self , luks_info )
281- if integrity_type := _detect_luks_header_integrity (self , luks_info ):
282- self .logger .info (f"[{ c_ (mapped_name , 'blue' )} ] Detected dm-integrity type: { c_ (integrity_type , 'cyan' )} " )
283- self ["cryptsetup" ][mapped_name ]["_dm-integrity" ] = integrity_type
287+ _detect_luks_header_integrity (self , luks_info , mapped_name )
284288
285289 if not self ["argon2" ]: # if argon support was not detected, check if the header wants it
286290 for keyslot in luks_info .get ("keyslots" , {}).values ():
0 commit comments