From c2f78419b242df9a4872905d41332e5ea9fcfdb6 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Thu, 5 Jan 2023 17:00:35 +0100 Subject: Add the OTPState.ot_hex property --- CHANGELOG.md | 9 +++++++++ COPYING | 2 +- LICENSE | 2 +- README.md | 6 +++--- sphinx_conf.py | 6 +++--- src/otp2289/__init__.py | 4 ++-- src/otp2289/__main__.py | 2 +- src/otp2289/generator.py | 2 +- src/otp2289/server.py | 9 ++++++++- tests/test_generator.py | 2 +- tests/test_main.py | 2 +- tests/test_server.py | 4 +++- tests/test_static.py | 2 +- 13 files changed, 35 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b7d91..6cffe69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [1.2.0](https://github.com/blackm0re/pyotp2289/tree/1.2.0) (2023-01-05) + +[Full Changelog](https://github.com/blackm0re/pyotp2289/compare/1.1.1...1.2.0) + +**Changes:** + +- Add the `OTPState.ot_hex` property + + ## [1.1.1](https://github.com/blackm0re/pyotp2289/tree/1.1.1) (2022-04-02) [Full Changelog](https://github.com/blackm0re/pyotp2289/compare/1.1.0...1.1.1) diff --git a/COPYING b/COPYING index e7fb5f0..43ef739 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ SPDX-License-Identifier: BSD-2-Clause-FreeBSD -Copyright (c) 2020-2022, Simeon Simeonov +Copyright (c) 2020-2023, Simeon Simeonov All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/LICENSE b/LICENSE index e7fb5f0..43ef739 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ SPDX-License-Identifier: BSD-2-Clause-FreeBSD -Copyright (c) 2020-2022, Simeon Simeonov +Copyright (c) 2020-2023, Simeon Simeonov All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index a3b00c5..64cd385 100644 --- a/README.md +++ b/README.md @@ -164,8 +164,8 @@ RFC-2289 consists of interactions between them. # otp2289.server.OTPInvalidResponse exception is raised. # once the state has successfully validated the corresponding response, - the state **must never be used again** and a state corresponding to the - "next" (498) step created. + # the state **must never be used again** and a state corresponding to the + # "next" (498) step created. state = state.get_next_state() # the next authentication attempt... @@ -209,7 +209,7 @@ Simeon Simeonov - sgs @ LiberaChat ## [License](https://github.com/blackm0re/pyotp2289/blob/master/LICENSE) -Copyright (c) 2020-2022 Simeon Simeonov +Copyright (c) 2020-2023 Simeon Simeonov All rights reserved. [Licensed](https://github.com/blackm0re/pyotp2289/blob/master/LICENSE) under the BSD 2-clause. diff --git a/sphinx_conf.py b/sphinx_conf.py index 561db43..f9f0eca 100644 --- a/sphinx_conf.py +++ b/sphinx_conf.py @@ -21,14 +21,14 @@ # -- Project information ----------------------------------------------------- project = 'pyotp2289' -copyright = '2020-2022, Simeon Simeonov' +copyright = '2020-2023, Simeon Simeonov' author = 'Simeon Simeonov' # The short X.Y version -version = '1.1.0' +version = '1.2.0' # The full version, including alpha/beta/rc tags -release = '1.1.0' +release = '1.2.0' # -- General configuration --------------------------------------------------- diff --git a/src/otp2289/__init__.py b/src/otp2289/__init__.py index af8638c..4b600a0 100644 --- a/src/otp2289/__init__.py +++ b/src/otp2289/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022 Simeon Simeonov +# Copyright (c) 2020-2023 Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -40,7 +40,7 @@ from .server import ( ) __author__ = 'Simeon Simeonov' -__version__ = '1.1.1' +__version__ = '1.2.0' __license__ = 'BSD 2-Clause' diff --git a/src/otp2289/__main__.py b/src/otp2289/__main__.py index 78e60e8..d267b1b 100644 --- a/src/otp2289/__main__.py +++ b/src/otp2289/__main__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022 Simeon Simeonov +# Copyright (c) 2020-2023 Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/src/otp2289/generator.py b/src/otp2289/generator.py index 7b86e1b..73ca18b 100644 --- a/src/otp2289/generator.py +++ b/src/otp2289/generator.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022 Simeon Simeonov +# Copyright (c) 2020-2023 Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/src/otp2289/server.py b/src/otp2289/server.py index 066cba2..4305f75 100644 --- a/src/otp2289/server.py +++ b/src/otp2289/server.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022 Simeon Simeonov +# Copyright (c) 2020-2023 Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -115,6 +115,13 @@ class OTPState: """hash_algo-property""" return self._hash_algo + @property + def ot_hex(self) -> str: + """ot_hex-property""" + if self._current_digest is None: + return '' + return binascii.hexlify(self._current_digest).decode() + @property def seed(self) -> str: """seed-property""" diff --git a/tests/test_generator.py b/tests/test_generator.py index aa795a3..b4bb961 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022, Simeon Simeonov +# Copyright (c) 2020-2023, Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tests/test_main.py b/tests/test_main.py index a331274..35bd2a2 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022, Simeon Simeonov +# Copyright (c) 2020-2023, Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tests/test_server.py b/tests/test_server.py index 3d3b77d..64e7f67 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022, Simeon Simeonov +# Copyright (c) 2020-2023, Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -80,6 +80,7 @@ def test_state_validation_md5(): assert state.validated is False assert state.response_validates('0x9e876134d90499dd') is True assert state.response_validates('INCH SEA ANNE LONG AHEM TOUR') is True + assert state.ot_hex == '7965e05436f5029f' assert state.validated is True @@ -94,6 +95,7 @@ def test_state_validation_sha1(): assert state.validated is False assert state.response_validates('0xbb9e6ae1979d8ff4') is True assert state.response_validates('MILT VARY MAST OK SEES WENT') is True + assert state.ot_hex == '63d936639734385b' assert state.validated is True diff --git a/tests/test_static.py b/tests/test_static.py index a942374..7635e5e 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # -# Copyright (c) 2020-2022, Simeon Simeonov +# Copyright (c) 2020-2023, Simeon Simeonov # All rights reserved. # # Redistribution and use in source and binary forms, with or without -- cgit v1.3