From 396ff1373aa163efa7606a5bca70d4508e59ac7e Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Wed, 2 Nov 2016 18:22:07 -0400
Subject: [PATCH 333/333] Add python client changes

---
 base/common/python/pki/key.py | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/base/common/python/pki/key.py b/base/common/python/pki/key.py
index 14e0b14250709b7e04299b81684b0c2ee1402e6b..3c6a41d36716c96d4d70310eb64e3347cb577f7e 100644
--- a/base/common/python/pki/key.py
+++ b/base/common/python/pki/key.py
@@ -291,7 +291,7 @@ class KeyArchivalRequest(pki.ResourceMessage):
                  trans_wrapped_session_key=None, pki_archive_options=None,
                  algorithm_oid=None, symkey_params=None,
                  key_algorithm=None, key_size=None,
-                 realm=None):
+                 realm=None, express=False):
         """ Constructor """
         pki.ResourceMessage.__init__(
             self,
@@ -321,6 +321,9 @@ class KeyArchivalRequest(pki.ResourceMessage):
         if realm is not None:
             self.add_attribute("realm", realm)
 
+        if express:
+            self.add_attribute("express", express)
+
 
 class KeyRecoveryRequest(pki.ResourceMessage):
     """
@@ -333,7 +336,7 @@ class KeyRecoveryRequest(pki.ResourceMessage):
                  trans_wrapped_session_key=None,
                  session_wrapped_passphrase=None,
                  nonce_data=None, certificate=None,
-                 passphrase=None):
+                 passphrase=None, express=False):
         """ Constructor """
         pki.ResourceMessage.__init__(
             self,
@@ -346,6 +349,8 @@ class KeyRecoveryRequest(pki.ResourceMessage):
         self.add_attribute("certificate", certificate)
         self.add_attribute("passphrase", passphrase)
         self.add_attribute("keyId", key_id)
+        if express:
+            self.add_attribute("express", express)
 
 
 class SymKeyGenerationRequest(pki.ResourceMessage):
@@ -671,7 +676,8 @@ class KeyClient(object):
 
     @pki.handle_exceptions()
     def archive_key(self, client_key_id, data_type, private_data,
-                    key_algorithm=None, key_size=None, realm=None):
+                    key_algorithm=None, key_size=None, realm=None,
+                    express=False):
         """ Archive a secret (symmetric key or passphrase) on the DRM.
 
             Requires a user-supplied client ID.  There can be only one active
@@ -726,7 +732,8 @@ class KeyClient(object):
             nonce_iv=nonce_iv,
             key_algorithm=key_algorithm,
             key_size=key_size,
-            realm=realm)
+            realm=realm,
+            express=express)
 
     @pki.handle_exceptions()
     def archive_encrypted_data(self,
@@ -738,7 +745,8 @@ class KeyClient(object):
                                nonce_iv=None,
                                key_algorithm=None,
                                key_size=None,
-                               realm=None):
+                               realm=None,
+                               express=False):
         """
         Archive a secret (symmetric key or passphrase) on the DRM.
 
@@ -794,13 +802,15 @@ class KeyClient(object):
                                      symkey_params=symkey_params,
                                      key_algorithm=key_algorithm,
                                      key_size=key_size,
-                                     realm=realm)
+                                     realm=realm,
+                                     express=express)
 
         return self.submit_request(request)
 
     @pki.handle_exceptions()
     def archive_pki_options(self, client_key_id, data_type, pki_archive_options,
-                            key_algorithm=None, key_size=None, realm=None):
+                            key_algorithm=None, key_size=None, realm=None,
+                            express=False):
         """ Archive a secret (symmetric key or passphrase) on the DRM.
 
             Refer to archive_key() comments for a description of client_key_id,
@@ -831,7 +841,8 @@ class KeyClient(object):
                                      pki_archive_options=data,
                                      key_algorithm=key_algorithm,
                                      key_size=key_size,
-                                     realm=realm)
+                                     realm=realm,
+                                     express=express)
         return self.submit_request(request)
 
     @pki.handle_exceptions()
@@ -884,7 +895,8 @@ class KeyClient(object):
         return Key(key_data)
 
     @pki.handle_exceptions()
-    def retrieve_key(self, key_id, trans_wrapped_session_key=None):
+    def retrieve_key(self, key_id, trans_wrapped_session_key=None,
+                     express=False):
         """ Retrieve a secret (passphrase or symmetric key) from the DRM.
 
         This function generates a key recovery request, approves it, and
@@ -936,7 +948,8 @@ class KeyClient(object):
             key_id=key_id,
             request_id=request_id,
             trans_wrapped_session_key=base64.b64encode(
-                trans_wrapped_session_key))
+                trans_wrapped_session_key),
+            express=express)
 
         key = self.retrieve_key_data(request)
         if not key_provided:
@@ -950,7 +963,8 @@ class KeyClient(object):
     def retrieve_key_by_passphrase(self, key_id, passphrase=None,
                                    trans_wrapped_session_key=None,
                                    session_wrapped_passphrase=None,
-                                   nonce_data=None):
+                                   nonce_data=None,
+                                   express=False):
         """
         Retrieve a secret (passphrase or symmetric key) from the DRM using
         a passphrase.
@@ -992,7 +1006,8 @@ class KeyClient(object):
         pass
 
     @pki.handle_exceptions()
-    def retrieve_key_by_pkcs12(self, key_id, certificate, passphrase):
+    def retrieve_key_by_pkcs12(self, key_id, certificate, passphrase,
+                               express=False):
         """ Retrieve an asymmetric private key and return it as PKCS12 data.
 
         This function generates a key recovery request, approves it, and
@@ -1016,7 +1031,8 @@ class KeyClient(object):
 
         request = KeyRecoveryRequest(key_id=key_id,
                                      request_id=request_id,
-                                     passphrase=passphrase)
+                                     passphrase=passphrase,
+                                     express=express)
 
         return self.retrieve_key_data(request)
 
-- 
2.7.4

