Code Monkey home page Code Monkey logo

footprint-otp's People

Contributors

zevlee avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

mvandermeulen

footprint-otp's Issues

Secrets module does not create one-time-pads.

One-time-pad is a bit of an odd bird in the world of cryptography, as it has exact requirements

  1. The pad must be truly random. In other words, you can not use any algorithm to create the one-time pad, but a HWRNG. Your application is using the secrets.token_bytes() method, which is a wrapper for os.urandom() which in turn reads from the kernel CSPRNG algorithm. the PR in CSPRNG stand's for pseudo-random, which is not the same.

  2. One-time pad is an optimal cipher among the ciphers that provide perfect secrecy, as it satisfies the "key must be at least as long as the message" condition with equality. The kernel CSPRNG is usually seeded from the CPU's HWRNG and/or the chaotic events (interrupt events etc.) that happen during the use, but as the kernel CSPRNG expands the computationally secure seed, it does not provide perfect secrecy, only computational security.

XORing plaintext with keystream is what all stream ciphers do. Since the kernel CSPRNG is ChaCha20 stream cipher on Linux and AES on Windows, you're effectively using either ChaCha20 or AES encryption, with pre-shared keystream.

Please strongly consider removing all references to OTP, or change the system to utilize a hardware random number generator.

The encryption scheme does not provide any authentication whatsoever

https://github.com/zevlee/footprint-otp/blob/main/lib/otp.py#L48 shows the software is XORing plaintext with the keystream, without adding message authentication code to the message. This makes the ciphertext vulnerable to known plaintext attacks (KPA), where if the attacker knows the plaintext for any reason, they're able to obtain key with key = ciphertext XOR plaintext, and they can then substitute message with their own by passing new_ciphertext = new_plaintext XOR key to the recipient.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.