Socket
Socket
Sign inDemoInstall

tsscmp

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tsscmp

Timing safe string compare using double HMAC


Version published
Maintainers
1
Install size
9.15 kB
Created

Readme

Source

[![Node.js Version][node-version-image]][node-version-url] [![npm][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Build Status][travis-image]][travis-url] [![Build Status][appveyor-image]][appveyor-url] [![Dependency Status][david-image]][david-url] [![github-license][github-license-image]][license-url] [travis-image]: https://img.shields.io/travis/suryagh/tsscmp/master.svg?style=flat-square [travis-url]: https://travis-ci.org/suryagh/tsscmp [appveyor-image]: https://img.shields.io/appveyor/ci/suryagh/tsscmp/master.svg?style=flat-square&label=windows [appveyor-url]: https://ci.appveyor.com/project/suryagh/tsscmp [npm-image]: https://img.shields.io/npm/v/tsscmp.svg?style=flat-square [npm-url]: https://npmjs.org/package/tsscmp [node-version-image]: https://img.shields.io/node/v/tsscmp.svg?style=flat-square [node-version-url]: https://nodejs.org/en/download [downloads-image]: https://img.shields.io/npm/dm/tsscmp.svg?style=flat-square [downloads-url]: https://npmjs.org/package/tsscmp [david-image]: http://img.shields.io/david/suryagh/tsscmp.svg?style=flat-square [david-url]: https://david-dm.org/suryagh/tsscmp [npm-license-image]: http://img.shields.io/npm/l/tsscmp.svg?style=flat-square [github-license-image]: https://img.shields.io/github/license/suryagh/tsscmp.svg?style=flat-square [license-url]: LICENSE

Timing safe string compare using double HMAC

Prevents timing attacks using Brad Hill's Double HMAC pattern to perform secure string comparison. Double HMAC avoids the timing atacks by blinding the timing channel using random time per attempt comparison against iterative brute force attacks.

Install

npm install tsscmp

Why

High level languages like JavaScript cannot perform reliable constant-time string comparison because of the many layers of software and hardware optimizers.

Example

var timingSafeCompare = require('tsscmp');

var sessionToken = '127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935 ';
var givenToken = '127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935 ';

if (timingSafeCompare(sessionToken, givenToken)) {
  console.log('good token');
} else {
  console.log('bad token');
}

Credits to

@jsha
@bnoordhuis

License

MIT

Keywords

FAQs

Last updated on 22 May 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc