Coder Social home page Coder Social logo

subkey's Introduction

subkey

Build Status

npm install subkey

Create signatures based on an RSA key, but using a ed25519 session key to avoid signature oracle issues. Uses elliptic for ECDSA.

API

var subkey = require('subkey');

var signature = subkey.sign(yourPrivateKey, 'your message');

subkey.verify(yourPublicKey, signature, 'not your message');
// returns true

subkey.verify(yourPublicKey, signature, 'not your message');
// returns false

The first time you sign with an RSA key an ed25519 key is created and signed with your RSA key. This key is used to sign all messaged and they public key, and the key signature are included with the message signature each time you sign something. This ephemeral subkey is only saved in memory and will not be saved.

When verifying, the first time a key, session key, and session key signature combination is seen it is verified and will fail to verify if the session key in the signature does not match the RSA key. It then verifies against session key returning true or false depending on whether it verifies.

ASYNC!!!!

There are async methods, mainly in here for compatibility with ssh-agent, the api is

subkey.signAsync(yourPrivateKey, 'your message', signFunction, callback);
function signFunction (key, message, callback) {
   //obtain signature of message with key
   callback(null, sig);
}
subkey.verifyAsync(yourPublicKey, signature, 'your message', function (err, valid) {
  // err = null and valid = true
});
subkey.verifyAsync(yourPublicKey, signature, 'not your message', function (err, valid) {
  // err = null and valid = false
});

The sign function takes a key and a message and the callback must be called with the rsa-ssh1 signature of the message. This is used to sign the ephemeral key the rest of signing works the same.

verifyAsync is like verify except (beside being async) it uses sha1 as the hash method used to sign they subkey instead of sha-224 like the sync method. In other words they are not compatible.

subkey's People

Contributors

calvinmetcalf avatar

Watchers

 avatar  avatar  avatar  avatar

subkey's Issues

Correctly hash object private keys

It just stringifys them currently so all private keys with passwords will hash the same,only an issue if you're using multiple private keys with passwords

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.