2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-21 18:53:15 +00:00

Update the object data model to support storing key wrapping data

This change updates the KMIP object model to support explicitly
storing key wrapping data attributes. Key wrapping data is treated
externally as a dictionary and is stored as individual fields in
the back end. Various unit tests have been updated and added to
support these additions.
This commit is contained in:
Peter Hamilton
2017-09-30 16:22:52 -04:00
parent aa798d939c
commit fc86e1bef4
8 changed files with 736 additions and 30 deletions

View File

@@ -198,9 +198,13 @@ class TestPublicKey(testtools.TestCase):
key = PublicKey(
enums.CryptographicAlgorithm.RSA, 1024, self.bytes_1024,
enums.KeyFormatType.X_509)
args = "algorithm={0}, length={1}, value={2}, format_type={3}".format(
enums.CryptographicAlgorithm.RSA, 1024,
binascii.hexlify(self.bytes_1024), enums.KeyFormatType.X_509)
args = "{0}, {1}, {2}, {3}, {4}".format(
"algorithm={0}".format(enums.CryptographicAlgorithm.RSA),
"length={0}".format(1024),
"value={0}".format(binascii.hexlify(self.bytes_1024)),
"format_type={0}".format(enums.KeyFormatType.X_509),
"key_wrapping_data={0}".format({})
)
expected = "PublicKey({0})".format(args)
observed = repr(key)
self.assertEqual(expected, observed)
@@ -286,6 +290,31 @@ class TestPublicKey(testtools.TestCase):
self.assertFalse(a == b)
self.assertFalse(b == a)
def test_equal_on_not_equal_key_wrapping_data(self):
"""
Test that the equality operator returns False when comparing two
PublicKey objects with different key wrapping data.
"""
a = PublicKey(
enums.CryptographicAlgorithm.RSA,
1024,
self.bytes_1024,
enums.KeyFormatType.X_509,
key_wrapping_data={}
)
b = PublicKey(
enums.CryptographicAlgorithm.RSA,
1024,
self.bytes_1024,
enums.KeyFormatType.X_509,
key_wrapping_data={
'wrapping_method': enums.WrappingMethod.ENCRYPT
}
)
self.assertFalse(a == b)
self.assertFalse(b == a)
def test_equal_on_type_mismatch(self):
"""
Test that the equality operator returns False when comparing a
@@ -368,6 +397,31 @@ class TestPublicKey(testtools.TestCase):
self.assertTrue(a != b)
self.assertTrue(b != a)
def test_not_equal_on_not_equal_key_wrapping_data(self):
"""
Test that the inequality operator returns True when comparing two
PublicKey objects with different key wrapping data.
"""
a = PublicKey(
enums.CryptographicAlgorithm.RSA,
1024,
self.bytes_1024,
enums.KeyFormatType.X_509,
key_wrapping_data={}
)
b = PublicKey(
enums.CryptographicAlgorithm.RSA,
1024,
self.bytes_1024,
enums.KeyFormatType.X_509,
key_wrapping_data={
'wrapping_method': enums.WrappingMethod.ENCRYPT
}
)
self.assertTrue(a != b)
self.assertTrue(b != a)
def test_not_equal_on_type_mismatch(self):
"""
Test that the equality operator returns True when comparing a