diff options
Diffstat (limited to 'otp2289')
| -rw-r--r-- | otp2289/generator.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/otp2289/generator.py b/otp2289/generator.py index 6147d82..b007d87 100644 --- a/otp2289/generator.py +++ b/otp2289/generator.py | |||
| @@ -282,16 +282,16 @@ class OTPGeneratorException(Exception): | |||
| 282 | class OTPGenerator: | 282 | class OTPGenerator: |
| 283 | """OTPGenerator class""" | 283 | """OTPGenerator class""" |
| 284 | 284 | ||
| 285 | def __init__(self, password, salt, hash_algo=OTP_ALGO_MD5): | 285 | def __init__(self, password, seed, hash_algo=OTP_ALGO_MD5): |
| 286 | """ | 286 | """ |
| 287 | Constructs an OTPGenerator object with a given password and salt | 287 | Constructs an OTPGenerator object with a given password and seed |
| 288 | 288 | ||
| 289 | Keyword Arguments: | 289 | Keyword Arguments: |
| 290 | :param password: the password string | 290 | :param password: the password string |
| 291 | :type password: bytes | 291 | :type password: bytes |
| 292 | 292 | ||
| 293 | :param salt: the salt received from the server-challenge | 293 | :param seed: the seed received from the server-challenge |
| 294 | :type salt: str | 294 | :type seed: str |
| 295 | 295 | ||
| 296 | :param hash_algo: the hash algo. | 296 | :param hash_algo: the hash algo. |
| 297 | :type hash_algo: int or str | 297 | :type hash_algo: int or str |
| @@ -304,16 +304,16 @@ class OTPGenerator: | |||
| 304 | raise OTPGeneratorException( | 304 | raise OTPGeneratorException( |
| 305 | 'Password must be longer than 10 bytes') | 305 | 'Password must be longer than 10 bytes') |
| 306 | self._password = password | 306 | self._password = password |
| 307 | if not isinstance(salt, str): | 307 | if not isinstance(seed, str): |
| 308 | raise OTPGeneratorException('Salt must be a string') | 308 | raise OTPGeneratorException('Seed must be a string') |
| 309 | if not salt or len(salt) > 16: | 309 | if not seed or len(seed) > 16: |
| 310 | raise OTPGeneratorException( | 310 | raise OTPGeneratorException( |
| 311 | 'The seed MUST be of 1 to 16 characters in length') | 311 | 'The seed MUST be of 1 to 16 characters in length') |
| 312 | for char in salt: | 312 | for char in seed: |
| 313 | if char not in string.ascii_letters + string.digits: | 313 | if char not in string.ascii_letters + string.digits: |
| 314 | raise OTPGeneratorException( | 314 | raise OTPGeneratorException( |
| 315 | 'The seed MUST consist of purely alphanumeric characters') | 315 | 'The seed MUST consist of purely alphanumeric characters') |
| 316 | self._salt = salt | 316 | self._seed = seed |
| 317 | if isinstance(hash_algo, int): | 317 | if isinstance(hash_algo, int): |
| 318 | self._hash_algo = _ALGO_DICT.get(hash_algo, 'md5') | 318 | self._hash_algo = _ALGO_DICT.get(hash_algo, 'md5') |
| 319 | elif isinstance(hash_algo, str): | 319 | elif isinstance(hash_algo, str): |
| @@ -521,7 +521,7 @@ class OTPGenerator: | |||
| 521 | hash_obj = hashlib.new(self._hash_algo) | 521 | hash_obj = hashlib.new(self._hash_algo) |
| 522 | if not digest: | 522 | if not digest: |
| 523 | # 0 step | 523 | # 0 step |
| 524 | hash_obj.update(self._salt.lower().encode() + self._password) | 524 | hash_obj.update(self._seed.lower().encode() + self._password) |
| 525 | else: | 525 | else: |
| 526 | hash_obj.update(digest) | 526 | hash_obj.update(digest) |
| 527 | large_digest = hash_obj.digest() | 527 | large_digest = hash_obj.digest() |
