From 25f6cc9e5ce4ae2d4add6e5a03cd1085366f90c1 Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Wed, 11 Apr 2018 20:44:20 -0400 Subject: [PATCH] Add cryptographic usage mask support for DeriveKey This change updates the ProxyKmipClient support for the DeriveKey operation, now allowing the caller to specify a list of CryptographicUsageMask enumerations to set on the newly derived key. Fixes #417 --- kmip/pie/client.py | 7 +++++++ kmip/tests/unit/pie/test_client.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kmip/pie/client.py b/kmip/pie/client.py index c4296cc..3500fc2 100644 --- a/kmip/pie/client.py +++ b/kmip/pie/client.py @@ -484,6 +484,13 @@ class ProxyKmipClient(object): kwargs.get('cryptographic_algorithm') ) ) + if kwargs.get('cryptographic_usage_mask'): + attributes.append( + self.attribute_factory.create_attribute( + enums.AttributeType.CRYPTOGRAPHIC_USAGE_MASK, + kwargs.get('cryptographic_usage_mask') + ) + ) template_attribute = cobjects.TemplateAttribute( attributes=attributes ) diff --git a/kmip/tests/unit/pie/test_client.py b/kmip/tests/unit/pie/test_client.py index e3fb6fc..3c392e9 100644 --- a/kmip/tests/unit/pie/test_client.py +++ b/kmip/tests/unit/pie/test_client.py @@ -1586,7 +1586,11 @@ class TestProxyKmipClient(testtools.TestCase): 'derivation_data': b'\xFF\xFE\xFE\xFC' }, cryptographic_length=128, - cryptographic_algorithm=enums.CryptographicAlgorithm.AES + cryptographic_algorithm=enums.CryptographicAlgorithm.AES, + cryptographic_usage_mask=[ + enums.CryptographicUsageMask.ENCRYPT, + enums.CryptographicUsageMask.DECRYPT + ] ) self.assertEqual('1', derived_id)