2020
2121from digi .xbee .util import utils
2222
23+
2324@unique
2425class HAType (Enum ):
2526 """
@@ -78,6 +79,7 @@ def get(cls, code):
7879
7980HAType .__doc__ += utils .doc_enum (HAType )
8081
82+
8183@unique
8284class NgGroupParams (Enum ):
8385 """
@@ -286,11 +288,11 @@ def get(cls, code):
286288
287289
288290def create_salted_verification_key (user , password , hash_alg = HAType .SHA256 ,
289- ng_type = NgGroupParams .NG_1024 , salt_len = 4 ):
291+ ng_type = NgGroupParams .NG_1024 , salt_len = 4 ):
290292 """
291293 Generates a salted verification key for the provided username and password.
292294
293- Params :
295+ Args :
294296 user (String): Username string.
295297 password (String): Plain text password.
296298 hash_alg (:class:`.HAType`, optional, default=`HAType.SHA256`): Hash algorithm.
@@ -301,39 +303,39 @@ def create_salted_verification_key(user, password, hash_alg=HAType.SHA256,
301303 Returns:
302304 Tuple (bytes, bytes): Tuple with salt and verifier.
303305 """
304- s = generate_salt (l = salt_len )
306+ s = generate_salt (length = salt_len )
305307 v = generate_verifier (user , password , hash_alg = hash_alg , ng_type = ng_type ,
306308 salt = s , sep = ":" )
307309
308310 return s , v
309311
310312
311- def generate_salt (l = 4 ):
313+ def generate_salt (length = 4 ):
312314 """
313315 Generates new salt.
314316
315- Params :
316- l (Integer, optional, default=`4`): Number of bytes.
317+ Args :
318+ length (Integer, optional, default=`4`): Number of bytes.
317319
318320 Returns:
319321 Bytes: The generated salt.
320322 """
321- return os .urandom (l )
323+ return os .urandom (length )
322324
323325
324326def generate_verifier (user , password , salt , hash_alg = HAType .SHA256 ,
325327 ng_type = NgGroupParams .NG_1024 , sep = ":" ):
326328 """
327329 Calculates a verifier for the provided salt and configured password.
328330
329- Params :
331+ Args :
330332 user (String): Username string.
331333 password (String): Plain text password.
332334 salt (bytes): Salt to generate a verifier.
333335 hash_alg (:class:`.HAType`, optional, default=`HAType.SHA256`): Hash algorithm.
334336 ng_type (:class:`.NgGroupParams`, optional, default=`NgGroupParams.NG_1024`):
335337 Prime generator type.
336- sep (String, optional, default= `:` ): Separator string.
338+ sep (String, optional): Separator string.
337339
338340 Returns:
339341 Bytes: The generated verifier.
@@ -352,12 +354,12 @@ def __calculate_x(user, password, salt, hash_alg=HAType.SHA256, sep=":"):
352354 """
353355 Calculates the user secret parameter.
354356
355- Params :
357+ Args :
356358 user (String): Username string.
357359 password (String): Plain text password.
358360 salt (bytes): Salt byte array.
359361 hash_alg (:class:`.HAType`, optional, default=`HAType.SHA256`): Hash algorithm.
360- sep (String, optional, default= `:` ): Separator string.
362+ sep (String, optional): Separator string.
361363
362364 Returns:
363365 Integer: The user secret value.
@@ -376,7 +378,7 @@ def __hash(hash_alg, *args):
376378 """
377379 Calculates the hash of the provided arguments.
378380
379- Params :
381+ Args :
380382 args: Variable argument list of object to use for hash.
381383
382384 Returns:
@@ -393,7 +395,7 @@ def __to_bytes(obj):
393395 """
394396 Converts object to byte array, with optional context.
395397
396- Params :
398+ Args :
397399 obj: Object to convert.
398400
399401 Returns:
0 commit comments