From 243117389cca916b2b9bd57a550f2a27a628ce15 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 15 Sep 2022 00:18:28 +0200 Subject: accesspoints: initial tests with 802.11r --- filter_plugins/crypto.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'filter_plugins/crypto.py') 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): -- cgit v1.2.3