Merge "Reuse method to convert key to passphrase"
This commit is contained in:
commit
bf6f84078d
|
@ -53,6 +53,7 @@ class CryptsetupEncryptor(base.VolumeEncryptor):
|
|||
self.dev_path = os.path.realpath(self.symlink_path)
|
||||
|
||||
def _get_passphrase(self, key):
|
||||
"""Convert raw key to string."""
|
||||
return ''.join(hex(x).replace('0x', '') for x in key)
|
||||
|
||||
def _open_volume(self, passphrase, **kwargs):
|
||||
|
|
|
@ -99,8 +99,7 @@ class LuksEncryptor(cryptsetup.CryptsetupEncryptor):
|
|||
"""
|
||||
|
||||
key = self._get_key(context).get_encoded()
|
||||
# LUKS uses a passphrase rather than a raw key -- convert to string
|
||||
passphrase = ''.join(hex(x).replace('0x', '') for x in key)
|
||||
passphrase = self._get_passphrase(key)
|
||||
|
||||
try:
|
||||
self._open_volume(passphrase, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue