Package list python-castellan / 39e139f
Add managed objects hierarchy Castellan will support multiple objects, not just symmetric keys. The bytes of the managed object are returned as bytestrings. Change-Id: If75ff5d458604a8210980a4f50d1e4fc27d2b037 Kaitlin Farr 6 years ago
18 changed file(s) with 529 addition(s) and 149 deletion(s). Raw diff Collapse all Expand all
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base Certificate Class
17
18 This module defines the Certificate class.
19 """
20
21 import abc
22
23 import six
24
25 from castellan.common.objects import managed_object
26
27
28 @six.add_metaclass(abc.ABCMeta)
29 class Certificate(managed_object.ManagedObject):
30 """Base class to represent all certificates."""
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base Key Class
17
18 This module defines the Key class. The Key class is the base class to
19 represent all encryption keys. The basis for this class was copied
20 from Java.
21 """
22
23 from castellan.common.objects import managed_object
24
25 import abc
26
27 import six
28
29
30 @six.add_metaclass(abc.ABCMeta)
31 class Key(managed_object.ManagedObject):
32 """Base class to represent all keys."""
33
34 @abc.abstractproperty
35 def algorithm(self):
36 """Returns the key's algorithm.
37
38 Returns the key's algorithm. For example, "DSA" indicates that this key
39 is a DSA key and "AES" indicates that this key is an AES key.
40 """
41 pass
42
43 @abc.abstractproperty
44 def bit_length(self):
45 """Returns the key's bit length.
46
47 Returns the key's bit length. For example, for AES symmetric keys,
48 this refers to the length of the key, and for RSA keys, this refers to
49 the length of the modulus.
50 """
51 pass
0 # Copyright (c) The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base ManagedObject Class
17
18 This module defines the ManagedObject class. The ManagedObject class
19 is the base class to represent all objects managed by the key manager.
20 """
21
22 import abc
23
24 import six
25
26
27 @six.add_metaclass(abc.ABCMeta)
28 class ManagedObject(object):
29 """Base class to represent all managed objects."""
30
31 @abc.abstractproperty
32 def format(self):
33 """Returns the encoding format.
34
35 Returns the object's encoding format or None if this object is not
36 encoded.
37 """
38 pass
39
40 @abc.abstractmethod
41 def get_encoded(self):
42 """Returns the encoded object.
43
44 Returns a bytestring object in a format represented in the encoding
45 specified.
46 """
47 pass
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base OpaqueData Class
17
18 This module defines the OpaqueData class.
19 """
20
21 from castellan.common.objects import managed_object
22
23
24 class OpaqueData(managed_object.ManagedObject):
25 """This class represents opaque data."""
26
27 def __init__(self, data):
28 """Create a new OpaqueData object.
29
30 Expected type for data is a bytestring.
31 """
32 self._data = data
33
34 @property
35 def format(self):
36 """This method returns 'Opaque'."""
37 return "Opaque"
38
39 def get_encoded(self):
40 """Returns the data in its original format."""
41 return self._data
42
43 def __eq__(self, other):
44 if isinstance(other, OpaqueData):
45 return self._data == other._data
46 else:
47 return False
48
49 def __ne__(self, other):
50 result = self.__eq__(other)
51 return not result
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base Passphrase Class
17
18 This module defines the Passphrase class.
19 """
20
21 from castellan.common.objects import managed_object
22
23
24 class Passphrase(managed_object.ManagedObject):
25 """This class represents a passphrase."""
26
27 def __init__(self, passphrase):
28 """Create a new Passphrase object.
29
30 The expected type for the passphrase is a bytestring.
31 """
32 self._passphrase = passphrase
33
34 @property
35 def format(self):
36 """This method returns 'RAW'."""
37 return "RAW"
38
39 def get_encoded(self):
40 """Returns the data in a bytestring."""
41 return self._passphrase
42
43 def __eq__(self, other):
44 if isinstance(other, Passphrase):
45 return self._passphrase == other._passphrase
46 else:
47 return False
48
49 def __ne__(self, other):
50 result = self.__eq__(other)
51 return not result
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base PrivateKey Class
17
18 This module defines the PrivateKey class.
19 """
20
21 from castellan.common.objects import key
22
23
24 class PrivateKey(key.Key):
25 """This class represents private keys."""
26
27 def __init__(self, algorithm, bit_length, key):
28 """Create a new PrivateKey object.
29
30 The arguments specify the algorithm and bit length for the asymmetric
31 encryption and the bytes for the key in a bytestring.
32 """
33 self._alg = algorithm
34 self._bit_length = bit_length
35 self._key = key
36
37 @property
38 def algorithm(self):
39 """Returns the algorithm for asymmetric encryption."""
40 return self._alg
41
42 @property
43 def format(self):
44 """This method returns 'PKCS8'."""
45 return "PKCS8"
46
47 @property
48 def bit_length(self):
49 """Returns the key length."""
50 return self._bit_length
51
52 def get_encoded(self):
53 """Returns the key in DER encoded format."""
54 return self._key
55
56 def __eq__(self, other):
57 if isinstance(other, PrivateKey):
58 return (self._alg == other._alg and
59 self._key == other._key)
60 else:
61 return False
62
63 def __ne__(self, other):
64 result = self.__eq__(other)
65 return not result
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base PublicKey Class
17
18 This module defines the PublicKey class.
19 """
20
21 from castellan.common.objects import key
22
23
24 class PublicKey(key.Key):
25 """This class represents public keys."""
26
27 def __init__(self, algorithm, bit_length, key):
28 """Create a new PublicKey object.
29
30 The arguments specify the algorithm and bit length for the asymmetric
31 encryption and the bytes for the key. The bytes should be in a
32 bytestring.
33 """
34 self._alg = algorithm
35 self._bit_length = bit_length
36 self._key = key
37
38 @property
39 def algorithm(self):
40 """Returns the algorithm for asymmetric encryption."""
41 return self._alg
42
43 @property
44 def format(self):
45 """This method returns 'SubjectPublicKeyInfo'."""
46 return "SubjectPublicKeyInfo"
47
48 def get_encoded(self):
49 """Returns the key in its encoded format."""
50 return self._key
51
52 @property
53 def bit_length(self):
54 """Returns the key length."""
55 return self._bit_length
56
57 def __eq__(self, other):
58 if isinstance(other, PublicKey):
59 return (self._alg == other._alg and
60 self._key == other._key)
61 else:
62 return False
63
64 def __ne__(self, other):
65 result = self.__eq__(other)
66 return not result
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base SymmetricKey Class
17
18 This module defines the SymmetricKey class.
19 """
20
21 from castellan.common.objects import key
22
23
24 class SymmetricKey(key.Key):
25 """This class represents symmetric keys."""
26
27 def __init__(self, algorithm, bit_length, key):
28 """Create a new SymmetricKey object.
29
30 The arguments specify the algorithm and bit length for the symmetric
31 encryption and the bytes for the key in a bytestring.
32 """
33 self._alg = algorithm
34 self._bit_length = bit_length
35 self._key = key
36
37 @property
38 def algorithm(self):
39 """Returns the algorithm for symmetric encryption."""
40 return self._alg
41
42 @property
43 def format(self):
44 """This method returns 'RAW'."""
45 return "RAW"
46
47 def get_encoded(self):
48 """Returns the key in its encoded format."""
49 return self._key
50
51 @property
52 def bit_length(self):
53 """Returns the key length."""
54 return self._bit_length
55
56 def __eq__(self, other):
57 if isinstance(other, SymmetricKey):
58 return (self._alg == other._alg and
59 self._bit_length == other._bit_length and
60 self._key == other._key)
61 else:
62 return False
63
64 def __ne__(self, other):
65 result = self.__eq__(other)
66 return not result
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 X509 Class
17
18 This module defines the X509 class, used to represent X.509 certificates.
19 """
20
21 from castellan.common.objects import certificate
22
23
24 class X509(certificate.Certificate):
25 """This class represents X.509 certificates."""
26
27 def __init__(self, data):
28 """Create a new X509 object.
29
30 The data should be in a bytestring.
31 """
32 self._data = data
33
34 @property
35 def format(self):
36 """This method returns 'X.509'."""
37 return "X.509"
38
39 def get_encoded(self):
40 """Returns the data in its encoded format."""
41 return self._data
42
43 def __eq__(self, other):
44 if isinstance(other, X509):
45 return (self._data == other._data)
46 else:
47 return False
48
49 def __ne__(self, other):
50 result = self.__eq__(other)
51 return not result
2424 from oslo_utils import excutils
2525
2626 from castellan.common import exception
27 from castellan.common.objects import symmetric_key as sym_key
2728 from castellan.key_manager import key_manager
28 from castellan.key_manager import symmetric_key as key_manager_key
2929 from castellan.openstack.common import _i18n as u
3030
3131 from six.moves import urllib
151151 barbican_client = self._get_barbican_client(context)
152152
153153 try:
154 if key.get_algorithm():
155 algorithm = key.get_algorithm()
154 if key.algorithm:
155 algorithm = key.algorithm
156156 encoded_key = key.get_encoded()
157157 # TODO(kfarr) add support for objects other than symmetric keys
158158 secret = barbican_client.secrets.create(payload=encoded_key,
182182 secret = self._get_secret(context, key_id)
183183 secret_data = self._get_secret_data(secret)
184184 # TODO(kfarr) modify to support other types of keys
185 key = key_manager_key.SymmetricKey(secret.algorithm, secret_data)
185 key = sym_key.SymmetricKey(secret.algorithm, secret_data)
186186 copy_uuid = self.store_key(context, key, secret.expiration)
187187 return copy_uuid
188188 except (barbican_exceptions.HTTPAuthError,
265265 secret = self._get_secret(context, key_id)
266266 secret_data = self._get_secret_data(secret)
267267 # TODO(kfarr) add support for other objects
268 key = key_manager_key.SymmetricKey(secret.algorithm, secret_data)
268 key = sym_key.SymmetricKey(secret.algorithm,
269 secret.bit_length,
270 secret_data)
269271 return key
270272 except (barbican_exceptions.HTTPAuthError,
271273 barbican_exceptions.HTTPClientError,
+0
-53
castellan/key_manager/key.py less more
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base Key Class
17
18 This module defines the Key class. The Key class is the base class to
19 represent all encryption keys. The basis for this class was copied
20 from Java.
21 """
22
23 import abc
24
25 import six
26
27
28 @six.add_metaclass(abc.ABCMeta)
29 class Key(object):
30 """Base class to represent all keys."""
31
32 @abc.abstractmethod
33 def get_algorithm(self):
34 """Returns the key's algorithm.
35
36 Returns the key's algorithm. For example, "DSA" indicates that this key
37 is a DSA key and "AES" indicates that this key is an AES key.
38 """
39 pass
40
41 @abc.abstractmethod
42 def get_format(self):
43 """Returns the encoding format.
44
45 Returns the key's encoding format or None if this key is not encoded.
46 """
47 pass
48
49 @abc.abstractmethod
50 def get_encoded(self):
51 """Returns the key in the format specified by its encoding."""
52 pass
+0
-59
castellan/key_manager/symmetric_key.py less more
0 # Copyright (c) 2015 The Johns Hopkins University/Applied Physics Laboratory
1 # All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 """
16 Base SymmetricKey Class
17
18 This module defines the SymmetricKey class.
19 """
20
21 from castellan.key_manager import key
22
23
24 class SymmetricKey(key.Key):
25 """This class represents symmetric keys."""
26
27 def __init__(self, alg, key):
28 """Create a new SymmetricKey object.
29
30 The arguments specify the algorithm for the symmetric encryption and
31 the bytes for the key.
32 """
33 self.alg = alg
34 self.key = key
35
36 def get_algorithm(self):
37 """Returns the algorithm for symmetric encryption."""
38 return self.alg
39
40 def get_format(self):
41 """This method returns 'RAW'."""
42 return "RAW"
43
44 def get_encoded(self):
45 """Returns the key in its encoded format."""
46 return self.key
47
48 def __eq__(self, other):
49 if isinstance(other, SymmetricKey):
50 return (self.alg == other.alg and
51 self.key == other.key)
52 return NotImplemented
53
54 def __ne__(self, other):
55 result = self.__eq__(other)
56 if result is NotImplemented:
57 return result
58 return not result
2525 from oslo_context import context
2626
2727 from castellan.common import exception
28 from castellan.common.objects import symmetric_key
2829 from castellan.key_manager import barbican_key_manager
29 from castellan.key_manager import symmetric_key
3030 from castellan.tests.functional import config
3131 from castellan.tests.functional.key_manager import test_key_manager
3232
2525 this class.
2626 """
2727
28 import array
2928 import binascii
3029 import random
3130 import uuid
3231
3332 from castellan.common import exception
33 from castellan.common.objects import symmetric_key as sym_key
3434 from castellan.key_manager import key_manager
35 from castellan.key_manager import symmetric_key as sym_key
3635
3736
3837 class MockKeyManager(key_manager.KeyManager):
5150 def __init__(self):
5251 self.keys = {}
5352
54 def _generate_hex_key(self, **kwargs):
55 key_length = kwargs.get('key_length', 256)
53 def _generate_hex_key(self, key_length):
5654 # hex digit => 4 bits
5755 length = int(key_length / 4)
5856 hex_encoded = self._generate_password(length=length,
6058 return hex_encoded
6159
6260 def _generate_key(self, **kwargs):
63 _hex = self._generate_hex_key(**kwargs)
61 key_length = kwargs.get('key_length', 256)
62 _hex = self._generate_hex_key(key_length)
6463 return sym_key.SymmetricKey(
6564 'AES',
66 array.array('B', binascii.unhexlify(_hex)).tolist())
65 key_length,
66 bytes(binascii.unhexlify(_hex)))
6767
6868 def create_key(self, context, **kwargs):
6969 """Creates a key.
1616 Test cases for the barbican key manager.
1717 """
1818
19 import array
20
2119 import mock
2220
2321 from castellan.common import exception
22 from castellan.common.objects import symmetric_key as key_manager_key
2423 from castellan.key_manager import barbican_key_manager
25 from castellan.key_manager import symmetric_key as key_manager_key
2624 from castellan.tests.unit.key_manager import test_key_manager
2725
2826
7472
7573 def fake_sym_key(alg, key):
7674 self.mock_symKey.get_encoded.return_value = key
77 self.mock_symKey.get_algorithm.return_value = alg
75 p = mock.PropertyMock(return_value=alg)
76 type(self.mock_symKey).algorithm = p
7877 return self.mock_symKey
7978 self.original_key = key_manager_key.SymmetricKey
8079 key_manager_key.SymmetricKey = fake_sym_key
183182
184183 def test_store_key_base64(self):
185184 # Create Key to store
186 secret_key = array.array('B', [0x01, 0x02, 0xA0, 0xB3]).tolist()
187 _key = key_manager_key.SymmetricKey('AES', secret_key)
185 secret_key = bytes(b'\x01\x02\xA0\xB3')
186 _key = key_manager_key.SymmetricKey('AES',
187 len(secret_key) * 8,
188 secret_key)
188189
189190 # Define the return values
190191 secret = mock.Mock()
202203 def test_store_key_plaintext(self):
203204 # Create the plaintext key
204205 secret_key_text = "This is a test text key."
205 _key = key_manager_key.SymmetricKey('AES', secret_key_text)
206 _key = key_manager_key.SymmetricKey('AES',
207 len(secret_key_text) * 8,
208 secret_key_text)
206209
207210 # Store the Key
208211 self.key_mgr.store_key(self.ctxt, _key)
1313 # under the License.
1414
1515 """
16 Test cases for the key classes.
16 Test cases for the symmetric key class.
1717 """
1818
19 import array
20 import binascii
21
22 from castellan.key_manager import symmetric_key as sym_key
19 from castellan.common.objects import symmetric_key as sym_key
2320 from castellan.tests import base
2421
2522
3734 class SymmetricKeyTestCase(KeyTestCase):
3835
3936 def _create_key(self):
40 return sym_key.SymmetricKey(self.algorithm, self.encoded)
37 return sym_key.SymmetricKey(self.algorithm,
38 self.bit_length,
39 self.encoded)
4140
4241 def setUp(self):
4342 self.algorithm = 'AES'
44 self.encoded = array.array('B', binascii.unhexlify('0' * 64)).tolist()
43 self.encoded = bytes(b'0' * 64)
44 self.bit_length = len(self.encoded) * 8
4545
4646 super(SymmetricKeyTestCase, self).setUp()
4747
48 def test_get_algorithm(self):
49 self.assertEqual(self.key.get_algorithm(), self.algorithm)
50
5148 def test_get_format(self):
52 self.assertEqual(self.key.get_format(), 'RAW')
49 self.assertEqual('RAW', self.key.format)
5350
5451 def test_get_encoded(self):
55 self.assertEqual(self.key.get_encoded(), self.encoded)
52 self.assertEqual(self.encoded, self.key.get_encoded())
53
54 def test_get_algorithm(self):
55 self.assertEqual(self.algorithm, self.key.algorithm)
56
57 def test_get_bit_length(self):
58 self.assertEqual(self.bit_length, self.key.bit_length)
5659
5760 def test___eq__(self):
5861 self.assertTrue(self.key == self.key)
1616 Test cases for the mock key manager.
1717 """
1818
19 import array
20 import binascii
21
2219 from oslo_context import context
2320
2421 from castellan.common import exception
25 from castellan.key_manager import symmetric_key as sym_key
22 from castellan.common.objects import symmetric_key as sym_key
2623 from castellan.tests.unit.key_manager import mock_key_manager as mock_key_mgr
2724 from castellan.tests.unit.key_manager import test_key_manager as test_key_mgr
2825
5451 self.key_mgr.create_key, None)
5552
5653 def test_store_and_get_key(self):
57 secret_key = array.array('B', binascii.unhexlify('0' * 64)).tolist()
58 _key = sym_key.SymmetricKey('AES', secret_key)
54 secret_key = bytes(b'0' * 64)
55 _key = sym_key.SymmetricKey('AES', 64 * 8, secret_key)
5956 key_id = self.key_mgr.store_key(self.context, _key)
6057
6158 actual_key = self.key_mgr.get_key(self.context, key_id)