summaryrefslogtreecommitdiff
path: root/filter_plugins/crypto.py
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-09-25 16:52:39 +0200
committerChristian Pointner <equinox@spreadspace.org>2022-09-25 16:52:39 +0200
commite8e7b6330c1c1eddeb00575f74328f5c4f306589 (patch)
treecf5fcd126ed06d20d279c56b68de3da6afb259f2 /filter_plugins/crypto.py
parentfinalize ch-mc* setups for now (diff)
parentaccesspoints/usteer: band steering works now (diff)
Merge branch 'topic/wifi-roaming'
Diffstat (limited to 'filter_plugins/crypto.py')
-rw-r--r--filter_plugins/crypto.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/filter_plugins/crypto.py b/filter_plugins/crypto.py
index b3dc32c4..54547a34 100644
--- a/filter_plugins/crypto.py
+++ b/filter_plugins/crypto.py
@@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import hashlib
+from binascii import hexlify
from passlib.utils.binary import Base64Engine, HASH64_CHARS, BCRYPT_CHARS
from ansible.module_utils._text import to_bytes, to_text
from ansible import errors
@@ -41,6 +42,17 @@ def bcrypt_salt(seed):
raise errors.AnsibleFilterError("bcrypt_salt(): %s" % str(e))
+def wifi_80211r_key(seed):
+ ''' generate keys 802.11r r0kh and r1kh keys based on seed-value '''
+ try:
+ h = hashlib.new('sha256')
+ h.update(to_bytes(seed, errors='surrogate_or_strict'))
+ return to_text(hexlify(h.digest()))
+
+ except Exception as e:
+ raise errors.AnsibleFilterError("wifi_80211r_key(): %s" % str(e))
+
+
class FilterModule(object):
''' crypto helpers '''
@@ -49,6 +61,7 @@ class FilterModule(object):
'sha256_salt': sha2_crypt_salt,
'sha512_salt': sha2_crypt_salt,
'bcrypt_salt': bcrypt_salt,
+ 'wifi_80211r_key': wifi_80211r_key,
}
def filters(self):