Git Product home page Git Product logo

roll13's Introduction

ROLL13

Note: This project is unfinished and doesn't really do anything, but it might contain some useful info so I'm publishing it anyway. It contains BROKEN AND VULNERABLE CRYPTOGRAPHIC IMPLEMENTATIONS - look but don't touch!!

ROLL13 is a pure python implementation of a TLS 1.3 client, hand-rolled from first principles, including all cryptographic operations. It implements the TLS_AES_128_GCM_SHA256 cipher suite, and secp256r1 (NIST P-256) for key exchange.

Motivations

I wanted to learn about the protocols and cryptography involved, in excruciating detail. This is explicitly NOT intended to be complete, secure, or fast. Although correctness is a goal, I can't make any guarantees there either.

As a secondary goal, it proves that modern-ish cryptography standards are still accessible to mere mortals.

The code is intended to be as readable as possible (even at the cost of performance). There are lost of performance optimisations that could be made (especially in AES), but these make the implementation harder to understand. As a concrete example, take a look at pyaes, a popular pure-python AES implementation. It's a perfectly reasonable implementation*, however, it is not intuitively obvious how that code maps onto what is described in the FIPS 197 spec.

*Although its use of lookup tables likely makes it vulnerable to cache timing side-channel attacks. (not that I can claim mine is any better in terms of security...)

Self-Imposed Restrictions

  • No libraries. Everything is from scratch.
  • No reading other peoples' implementations - only specifications. I'm slightly "tainted" in this regard, because I've spent a lot of time reading other peoples' code over the years. My goal is to translate the specifications into code as literally as possible.
  • No magic numbers, except for those explicitly defined in a spec - and even then, they should be derived from first-principles, if possible (see ./derivations/).

Implemented Specs

The following tree of bullet points lists all the standards/specifications referenced in the code.

To recap, that includes the following cryptographic operations:

  • SHA-256 hash function.
  • secp256r1 elliptic curves, for signatures and key exchange.
  • AES-128 symmetric encryption,
  • GCM, an authenticated block mode, used with AES.

How much work would it take to make this competitive with e.g. OpenSSL?

  • It needs exponentially more code, to implement the full TLS feature-set.
  • It would need to be written in a language that isn't Python, to improve performance.
  • The cryptographic implementations would need to be re-worked to prioritise performance, and remove side-channel vulnerabilities (the current priority is readability). This typically results in much more complex code.
  • It would need to be audited and tested by a team of professionals.

roll13's People

Contributors

davidbuchanan314 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.