Signed-off-by: Balazs Lecz <[email protected]>
---
lib/serializer.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/serializer.py b/lib/serializer.py
index b568497..ec9c769 100644
--- a/lib/serializer.py
+++ b/lib/serializer.py
@@ -101,11 +101,13 @@ def LoadJson(txt):
return simplejson.loads(txt)
-def DumpSignedJson(data, key, salt=None):
+def DumpSignedJson(data, key, salt=None, key_selector=None):
"""Serialize a given object and authenticate it.
@param data: the data to serialize
@param key: shared hmac key
+ @param key_selector: name/id that identifies the key (in case there are
+ multiple keys in use, e.g. in a multi-cluster environment)
@return: the string representation of data signed by the hmac key
"""
@@ -117,6 +119,8 @@ def DumpSignedJson(data, key, salt=None):
'salt': salt,
'hmac': hmac.new(key, salt + txt, sha1).hexdigest(),
}
+ if key_selector:
+ signed_dict['key_selector'] = key_selector
return DumpJson(signed_dict, indent=False)
--
1.6.6.2