npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mustard3

v0.2.0

Published

Downloads

1

Readme


DISCLAIMER 1: Mustard3 WAS NOT PEER-REVIEWED. DO NOT USE FOR ANY PROJECTS UNDER ANY CIRCUMSTANCES. YOU WILL MOST LIKELY REGRET IT.
DISCLAIMER 2: I'VE NEVER RELEASED A CRYPTOGRAPHIC PROTOCOL BEFORE, AND I HAVEN'T WRITTEN DOCUMENTATION FOR ONE EITHER.
DISCLAIMER 3: THIS COULD VERY WELL BE TERRIBLE, PLEASE DON'T LAUGH AT ME IF I MESSED UP BAD. YOU CAN HELP ME OUT BY OPENING AN ISSUE.

╔═══════════════════════════════════════════╗
║                                           ║
║     Mustard3 Authentication Mechanism     ║
║                                           ║
╚═══════════════════════════════════════════╝

Mustard3, named after my previous failed attempt at a password-based authentication mechanism "Ketchup2", is a credential-based mutual authentication mechanism. Since Ketchup2 and many other aPAKEs suffered from credential stuffing and offline attacks badly, and all around it was quite complicated, it seemed like a good idea to simplify and rebrand it as a way to verify securely generated credentials instead. (imagine API tokens)
Below is a likely lacking documentation of it, hope it's understandable enough. The code in this repository is a Typescript/NodeJS implementation of it. Tested and working on NodeJS 15.5.0, though it should work with lower versions too.

~~~~ Algorithms ~~~~

  ChaCha20-Poly1305 - Authenticated cipher, used to encrypt stored tokens.
  BLAKE2b512        - Hash function, used for all hashing and key derivation throughout the project.

Data is encoded in a compact binary format.

~~~~ Flow ~~~~

<- ClientHello
    $Identifier ::
        Credential Identifier.

    ClientRandom ::
        32 random bytes from the client.

-> ServerHello
    ServerRandom ::
        32 random bytes from the server.

    ClientSalt ::
        Salt the client uses.

    ServerSalt ::
        Salt the server uses.

    ClientPrekeySalt ::
        Salt the client uses for the prekey.

-- Client
    SaltedCredential :: HMAC(ServerHello.ClientSalt, $Credential)
        Used to calculate ServerKey.

    ServerSaltedCredential :: HMAC(ServerHello.ServerSalt, Client.SaltedCredential)
        Used to create verifiers. The server stores this in an encrypted form.

<- ClientLast
    ClientSaltedPrekey :: HKDF(ServerFirst.ClientPrekeySalt, Client.SaltedCredential, 64, "ClientSaltedPrekey")
        Key used to decrypt the credential hash on the server.

    ClientResponse :: HKDF(Client.ServerSaltedCredential, ClientHello.ClientRandom | ServerHello.ServerRandom, 64, "ClientVerifier")
        Client verifier.

-- Server
    StoredCredential ::
        Encrypted credential hash, retrieved from database.

    ServerSaltedPrekey :: HKDF(Server.ServerPrekeySalt, ClientLast.ClientSaltedPrekey, 32, "ServerSaltedPrekey")
        Key used to decrypt StoredToken into ServerSaltedCredential.

    ServerSaltedCredential :: Decrypt(Server.ServerPartialKey, Server.StoredToken)
        Equal to Client.ServerSaltedCredential.

-> ServerLast
    ServerVerifier :: HKDF(Server.ServerSaltedCredential, ServerHello.ServerRandom | ClientHello.ClientRandom, 64, "ServerVerifier")
        Server verifier.

// At this point, both sides have enough information to validate each others responses, without having disclosed enough information to allow a possible man in the middle steal any sensitive data or impersonate the user, given the man in the middle does not have access to the server database, or otherwise infiltrated one of the two sides. They can also derive an ephermal shared key.

~~~~ Functions ~~~~

x | y - concatenation of x and y

Hash(data) - BLAKE2b512 over data
HMAC(key, data) - BLAKE2b512 keyed HMAC over data
HKDF(key, data, length = 64, info) - HKDF-BLAKE2b512 over key, data, info with output length.
Decrypt(key, data) - Decrypts data using chacha20-poly1305 using key as key and the first 12 bytes of data as IV.
Encrypt(key, data) - Encrypts data using chacha20-poly1305 using key as key and generating a random IV.

~~~~ Symbols and Terminology ~~~~

// : Annotation
-- : Value used locally
<- : Client to Server
-> : Server to Client