summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2011-05-27 19:50:57 +0000
committerChris Behrens <cbehrens@codestud.com>2011-05-27 19:50:57 +0000
commit1af3ac5f60bb9a4ad201f0bd84a355235be2f354 (patch)
treea4333af822ed005c752b4cd7763bbae4efc788c6
parent90280230c0ceebcea7db80c6a05ae0cef5599bc1 (diff)
fixed so all the new encryption tests pass.. including data with newlines and so forth
-rw-r--r--nova/virt/xenapi/vmops.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 1fcaaeede..e116ef2d1 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1190,8 +1190,12 @@ class SimpleDH(object):
mpi = M2Crypto.m2.bn_to_mpi(bn)
return mpi
- def _run_ssl(self, subcommand, text):
- proc = _runproc('openssl %s' % subcommand)
+ def _run_ssl(self, text, extra_args=None):
+ if not extra_args:
+ extra_args = ''
+ cmd = 'enc -aes-128-cbc -a -pass pass:%s -nosalt %s' % (
+ self._shared, extra_args)
+ proc = _runproc('openssl %s' % cmd)
proc.stdin.write(text)
proc.stdin.close()
proc.wait()
@@ -1201,9 +1205,9 @@ class SimpleDH(object):
return proc.stdout.read()
def encrypt(self, text):
- cmd = 'enc -aes-128-cbc -a -A -pass pass:%s -nosalt' % self._shared
- return self._run_ssl(cmd, text).strip('\n')
+ return self._run_ssl(text).strip('\n')
def decrypt(self, text):
- cmd = 'enc -aes-128-cbc -a -A -pass pass:%s -nosalt -d' % self._shared
- return self._run_ssl(cmd, text)
+ if text[len(text)-1:] != '\n':
+ text = text + '\n'
+ return self._run_ssl(text, '-d')