Skip to main content

Time relative one time computed code

Project description

Intro

This is an experimental auth library. It has not been tested in production yet. The scope of this experiment is to provide an auth method where the user can remember a target pin (much like a cipher) and calculate a one time code (otc) relative to the current time.

Foreword

From a security standpoint, this is not very secure, but does prevent brute forcing to some extent.

Problem 1:

If a third party knows the code and the timestamp of the code, they can easily compute the target and validate whenever they want.

Problem 2:

Once the code has been computed, it is incremental, meaning that depending on the method, the code increments or decrements by 1 every minute.

Problem 3:

Every day at the same time of the day the code will be the same if the target does not change.

How it works

Given a pin only the user knows which will be referenced as the "target", validation is done by manually computing a code based on the difference between the current time and a code they manually compute.

Depending on the method, subtracting or adding, the code is calculated differently.

Given the method is adding

If the target is 1111 and the current time is 12:34, the code would be 0987.

If the method is subtracting

Using the same approach, the code would be 0123.

The code is then hashed and compared to the hash of the target.

How to use

Install

pip install timedotc

Import

from timedotc import timedotc

Create the auth object

method = "sub"
auth = timedotc(
    method=method,
    secret_key=secret_key,
)

target = auth.hash("0000")

Validate

code = "1111"
auth.verify(code, target)

Usage scenarios

This might be useful for loggin into an admin panel where there is only one user intended.

Improvements

Problem 3:

The target could have a parent target which depends on the current date (month and day) which once computed would modify the initial target (calulated based on H:M). This is still susceptible to problem 1 however.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timedotc-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

timedotc-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file timedotc-0.1.0.tar.gz.

File metadata

  • Download URL: timedotc-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for timedotc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af5115aee73e20ca6c8a7dc2ac6e2a2cbfdfbf51aa0bbe49165de1288caf2a78
MD5 7125038699924fc8c6b3a752a0213423
BLAKE2b-256 7a9bcfe1f4f4761dedfe737f00f42dc879f4dc6fcfed878ee1fa69ddfb925f3a

See more details on using hashes here.

File details

Details for the file timedotc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: timedotc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for timedotc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e7fb23f4926130b4633721a79f2a39ad0689e6c63b432304018f000300fb771
MD5 d750ed5ff09f7e0aa8f2ae346aa18ee1
BLAKE2b-256 22186207e076715be00bb9e7b85ebd521ecb564a5bd77d1e6e0a7545177e4aad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page