Merge "Reuse method to convert key to passphrase"

This commit is contained in:
Jenkins 2015-11-18 22:34:50 +00:00 committed by Gerrit Code Review
commit bf6f84078d
2 changed files with 2 additions and 2 deletions

View File

@ -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):

View File

@ -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)