diff -Nru node-cryptiles-3.1.1/CHANGELOG.md node-cryptiles-4.2.0/CHANGELOG.md --- node-cryptiles-3.1.1/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ node-cryptiles-4.2.0/CHANGELOG.md 2019-04-02 06:15:37.000000000 +0000 @@ -0,0 +1,3 @@ +Breaking changes are documented using GitHub issues, see [issues labeled "release notes"](https://github.com/hapijs/cryptiles/issues?q=is%3Aissue+label%3A%22release+notes%22). + +If you want changes of a specific minor or patch release, you can browse the [GitHub milestones](https://github.com/hapijs/cryptiles/milestones?state=closed&direction=asc&sort=due_date). diff -Nru node-cryptiles-3.1.1/debian/changelog node-cryptiles-4.2.0/debian/changelog --- node-cryptiles-3.1.1/debian/changelog 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/changelog 2019-09-16 09:44:18.000000000 +0000 @@ -1,3 +1,26 @@ +node-cryptiles (4.2.0-3) unstable; urgency=medium + + * Team upload + * Fix debci + + -- Bastien Roucariès Mon, 16 Sep 2019 11:44:18 +0200 + +node-cryptiles (4.2.0-2) unstable; urgency=medium + + * Team upload + * Upload to unstable + + -- Bastien Roucariès Thu, 05 Sep 2019 11:04:49 +0200 + +node-cryptiles (4.2.0-1) experimental; urgency=medium + + * Team upload + * New upstream version move to @hapi/cryptiles + * Bump compat and policy (no changes) + * Move to section javascript + + -- Bastien Roucariès Thu, 05 Sep 2019 01:19:04 +0200 + node-cryptiles (3.1.1-1) unstable; urgency=low * Initial release (Closes: #861654) diff -Nru node-cryptiles-3.1.1/debian/compat node-cryptiles-4.2.0/debian/compat --- node-cryptiles-3.1.1/debian/compat 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru node-cryptiles-3.1.1/debian/control node-cryptiles-4.2.0/debian/control --- node-cryptiles-3.1.1/debian/control 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/control 2019-09-04 23:23:42.000000000 +0000 @@ -1,27 +1,29 @@ Source: node-cryptiles -Section: web +Section: javascript Priority: optional Maintainer: Debian Javascript Maintainers Uploaders: Pirate Praveen Build-Depends: - debhelper (>= 9) + debhelper-compat (= 12) , dh-buildinfo , nodejs -Standards-Version: 3.9.8 + , node-hapi-boom (>= 7.0.0) +Standards-Version: 4.4.0 Homepage: https://github.com/hapijs/cryptiles#readme -Vcs-Git: https://anonscm.debian.org/git/pkg-javascript/node-cryptiles.git -Vcs-Browser: https://anonscm.debian.org/cgit/pkg-javascript/node-cryptiles.git +Vcs-Git: https://salsa.debian.org/js-team/node-cryptiles.git +Vcs-Browser: https://salsa.debian.org/js-team/node-cryptiles Package: node-cryptiles Architecture: all Depends: ${misc:Depends} , nodejs - , node-boom (>= 4.0.0) + , node-hapi-boom (>= 7.0.0) +Provides: node-hapi-cryptiles (=${source:Version}) Description: General purpose crypto utilities This library provides methods for generating cryptographically strong pseudo-random data (string or digits) of specified length. It can also compare two strings using fixed time algorithm (to prevent time-based analysis of MAC - digest match). + digest match). . Node.js is an event-based server-side JavaScript engine. diff -Nru node-cryptiles-3.1.1/debian/copyright node-cryptiles-4.2.0/debian/copyright --- node-cryptiles-3.1.1/debian/copyright 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/copyright 2019-09-04 23:22:54.000000000 +0000 @@ -1,10 +1,11 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: cryptiles Upstream-Contact: https://github.com/hapijs/cryptiles/issues Source: https://github.com/hapijs/cryptiles#readme Files: * Copyright: 2014-2016, Eran Hammer and Project contributors + 2014-2019, Sideway Inc, and project contributors License: BSD-3-Clause Files: debian/* diff -Nru node-cryptiles-3.1.1/debian/install node-cryptiles-4.2.0/debian/install --- node-cryptiles-3.1.1/debian/install 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/install 2019-09-04 23:13:36.000000000 +0000 @@ -1,2 +1,2 @@ -lib usr/lib/nodejs/cryptiles/ -package.json usr/lib/nodejs/cryptiles/ +lib usr/share/nodejs/@hapi/cryptiles/ +package.json usr/share/nodejs/@hapi/cryptiles/ diff -Nru node-cryptiles-3.1.1/debian/rules node-cryptiles-4.2.0/debian/rules --- node-cryptiles-3.1.1/debian/rules 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/rules 2019-09-04 23:14:14.000000000 +0000 @@ -9,8 +9,11 @@ #override_dh_auto_build: -#override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES))) +override_dh_auto_test: + nodejs -e "require('.')" +endif override_dh_fixperms: dh_fixperms - chmod -x debian/node-cryptiles/usr/lib/nodejs/cryptiles/package.json + chmod -x debian/node-cryptiles/usr/share/nodejs/@hapi/cryptiles/package.json diff -Nru node-cryptiles-3.1.1/debian/tests/require node-cryptiles-4.2.0/debian/tests/require --- node-cryptiles-3.1.1/debian/tests/require 2017-05-02 10:11:02.000000000 +0000 +++ node-cryptiles-4.2.0/debian/tests/require 2019-09-16 09:43:41.000000000 +0000 @@ -1,3 +1,3 @@ #!/bin/sh set -e -nodejs -e "require('cryptiles');" +nodejs -e "require('@hapi/cryptiles');" diff -Nru node-cryptiles-3.1.1/.gitignore node-cryptiles-4.2.0/.gitignore --- node-cryptiles-3.1.1/.gitignore 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/.gitignore 2019-04-02 06:15:37.000000000 +0000 @@ -1,18 +1,13 @@ -.idea -*.iml -npm-debug.log -dump.rdb -node_modules -results.tap -results.xml -npm-shrinkwrap.json -config.json -.DS_Store -*/.DS_Store -*/*/.DS_Store -._* -*/._* -*/*/._* +**/node_modules +**/package-lock.json + coverage.* -lib-cov +**/.DS_Store +**/._* + +**/*.pem + +**/.vs +**/.vscode +**/.idea diff -Nru node-cryptiles-3.1.1/lib/index.js node-cryptiles-4.2.0/lib/index.js --- node-cryptiles-3.1.1/lib/index.js 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/lib/index.js 2019-04-02 06:15:37.000000000 +0000 @@ -1,12 +1,9 @@ 'use strict'; -// Load modules - const Crypto = require('crypto'); -const Boom = require('boom'); +const Boom = require('@hapi/boom'); -// Declare internals const internals = {}; @@ -16,10 +13,6 @@ exports.randomString = function (size) { const buffer = exports.randomBits((size + 1) * 6); - if (buffer instanceof Error) { - return buffer; - } - const string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); return string.slice(0, size); }; @@ -29,14 +22,22 @@ exports.randomDigits = function (size) { - const buffer = exports.randomBits(size * 8); - if (buffer instanceof Error) { - return buffer; - } - const digits = []; - for (let i = 0; i < buffer.length; ++i) { - digits.push(Math.floor(buffer[i] / 25.6)); + + let buffer = internals.random(size * 2); // Provision twice the amount of bytes needed to increase chance of single pass + let pos = 0; + + while (digits.length < size) { + if (pos >= buffer.length) { + buffer = internals.random(size * 2); + pos = 0; + } + + if (buffer[pos] < 250) { + digits.push(buffer[pos] % 10); + } + + ++pos; } return digits.join(''); @@ -50,39 +51,31 @@ if (!bits || bits < 0) { - return Boom.internal('Invalid random bits count'); + throw Boom.internal('Invalid random bits count'); } const bytes = Math.ceil(bits / 8); - try { - return Crypto.randomBytes(bytes); - } - catch (err) { - return Boom.internal('Failed generating random bits: ' + err.message); - } + return internals.random(bytes); }; -// Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match) - exports.fixedTimeComparison = function (a, b) { - if (typeof a !== 'string' || - typeof b !== 'string') { - + try { + return Crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b)); + } + catch (err) { return false; } +}; - let mismatch = (a.length === b.length ? 0 : 1); - if (mismatch) { - b = a; - } - for (let i = 0; i < a.length; ++i) { - const ac = a.charCodeAt(i); - const bc = b.charCodeAt(i); - mismatch |= (ac ^ bc); - } +internals.random = function (bytes) { - return (mismatch === 0); + try { + return Crypto.randomBytes(bytes); + } + catch (err) { + throw Boom.internal('Failed generating random bits: ' + err.message); + } }; diff -Nru node-cryptiles-3.1.1/LICENSE node-cryptiles-4.2.0/LICENSE --- node-cryptiles-3.1.1/LICENSE 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -Copyright (c) 2014-2016, Eran Hammer and Project contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * The names of any contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * * * - -The complete list of contributors can be found at: https://github.com/hueniverse/cryptiles/graphs/contributors diff -Nru node-cryptiles-3.1.1/LICENSE.md node-cryptiles-4.2.0/LICENSE.md --- node-cryptiles-3.1.1/LICENSE.md 1970-01-01 00:00:00.000000000 +0000 +++ node-cryptiles-4.2.0/LICENSE.md 2019-04-02 06:15:37.000000000 +0000 @@ -0,0 +1,9 @@ +Copyright (c) 2014-2019, Sideway Inc, and project contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff -Nru node-cryptiles-3.1.1/package.json node-cryptiles-4.2.0/package.json --- node-cryptiles-3.1.1/package.json 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/package.json 2019-04-02 06:15:37.000000000 +0000 @@ -1,7 +1,7 @@ { - "name": "cryptiles", + "name": "@hapi/cryptiles", "description": "General purpose crypto utilities", - "version": "3.1.1", + "version": "4.2.0", "repository": "git://github.com/hapijs/cryptiles", "main": "lib/index.js", "keywords": [ @@ -9,19 +9,16 @@ "security", "utilites" ], - "engines": { - "node": ">=4.0.0" - }, "dependencies": { - "boom": "4.x.x" + "@hapi/boom": "7.x.x" }, "devDependencies": { - "code": "3.x.x", - "lab": "11.x.x" + "@hapi/code": "5.x.x", + "@hapi/lab": "18.x.x" }, "scripts": { - "test": "lab -a code -t 100 -L", - "test-cov-html": "lab -a code -r html -o coverage.html" + "test": "lab -a @hapi/code -t 100 -L", + "test-cov-html": "lab -a @hapi/code -r html -o coverage.html" }, "license": "BSD-3-Clause" } diff -Nru node-cryptiles-3.1.1/README.md node-cryptiles-4.2.0/README.md --- node-cryptiles-3.1.1/README.md 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/README.md 2019-04-02 06:15:37.000000000 +0000 @@ -1,11 +1,10 @@ -cryptiles -========= +# cryptiles General purpose crypto utilities [![Build Status](https://secure.travis-ci.org/hapijs/cryptiles.png)](http://travis-ci.org/hapijs/cryptiles) -Lead Maintainer - [C J Silverio](https://github.com/ceejbot) +Lead Maintainer - [Eran Hammer](https://github.com/hueniverse) ## Methods @@ -14,6 +13,3 @@ ### `randomDigits( size)` Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9). Takes a size argument for the length of the string. - -### `fixedTimeComparison( a, b)` -Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match). Returns `true` if the strings match, `false` if they differ. diff -Nru node-cryptiles-3.1.1/test/index.js node-cryptiles-4.2.0/test/index.js --- node-cryptiles-3.1.1/test/index.js 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/test/index.js 2019-04-02 06:15:37.000000000 +0000 @@ -1,124 +1,76 @@ 'use strict'; -// Load modules - -const Code = require('code'); +const Code = require('@hapi/code'); const Cryptiles = require('..'); -const Lab = require('lab'); - +const Lab = require('@hapi/lab'); -// Declare internals const internals = {}; -// Test shortcuts - -const lab = exports.lab = Lab.script(); -const describe = lab.describe; -const it = lab.it; +const { describe, it } = exports.lab = Lab.script(); const expect = Code.expect; describe('randomString()', () => { - it('should generate the right length string', (done) => { + it('should generate the right length string', () => { for (let i = 1; i <= 1000; ++i) { expect(Cryptiles.randomString(i).length).to.equal(i); } - - done(); }); - it('returns an error on invalid bits size', (done) => { + it('returns an error on invalid bits size', () => { - expect(Cryptiles.randomString(99999999999999999999).message).to.match(/Failed generating random bits/); - done(); + expect(() => Cryptiles.randomString(99999999999999999999)).to.throw(/Failed generating random bits/); }); }); describe('randomDigits()', () => { - it('should generate the right length string', (done) => { + it('should generate the right length string', () => { for (let i = 1; i <= 1000; ++i) { const string = Cryptiles.randomDigits(i); expect(string.length).to.equal(i); expect(string).to.match(/^\d+$/); } - - done(); }); - it('returns an error on invalid bits size', (done) => { + it('returns an error on invalid bits size', () => { - expect(Cryptiles.randomDigits(99999999999999999999).message).to.match(/Failed generating random bits/); - done(); + expect(() => Cryptiles.randomDigits(99999999999999999999)).to.throw(/Failed generating random bits/); }); -}); -describe('randomBits()', () => { + it('generates equal digits distribution', () => { - it('returns an error on invalid input', (done) => { + const digits = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0 }; + for (let i = 0; i < 1000000; ++i) { + digits[Cryptiles.randomDigits(1)] += 1; + } - expect(Cryptiles.randomBits(0).message).to.equal('Invalid random bits count'); - done(); + for (const digit in digits) { + expect(digits[digit]).to.be.between(99000, 101000); + } }); }); -describe('fixedTimeComparison()', () => { - - const a = Cryptiles.randomString(50000); - const b = Cryptiles.randomString(150000); - - it('should take the same amount of time comparing different string sizes', (done) => { - - let now = Date.now(); - Cryptiles.fixedTimeComparison(b, a); - const t1 = Date.now() - now; - - now = Date.now(); - Cryptiles.fixedTimeComparison(b, b); - const t2 = Date.now() - now; - - expect(t2 - t1).to.be.within(-20, 20); - done(); - }); - - it('should return true for equal strings', (done) => { - - expect(Cryptiles.fixedTimeComparison(a, a)).to.equal(true); - done(); - }); - - it('should return false for different strings (size, a < b)', (done) => { - - expect(Cryptiles.fixedTimeComparison(a, a + 'x')).to.equal(false); - done(); - }); - - it('should return false for different strings (size, a > b)', (done) => { - - expect(Cryptiles.fixedTimeComparison(a + 'x', a)).to.equal(false); - done(); - }); +describe('randomBits()', () => { - it('should return false for different strings (size, a = b)', (done) => { + it('returns an error on invalid input', () => { - expect(Cryptiles.fixedTimeComparison(a + 'x', a + 'y')).to.equal(false); - done(); + expect(() => Cryptiles.randomBits(0)).to.throw('Invalid random bits count'); + expect(() => Cryptiles.randomBits(-1)).to.throw('Invalid random bits count'); }); +}); - it('should return false when not a string', (done) => { - - expect(Cryptiles.fixedTimeComparison('x', null)).to.equal(false); - done(); - }); +describe('fixedTimeComparison()', () => { - it('should return false when not a string (left)', (done) => { + it('validates strings', () => { - expect(Cryptiles.fixedTimeComparison(null, 'x')).to.equal(false); - done(); + expect(Cryptiles.fixedTimeComparison('asdasd', 'asdasd')).to.be.true(); + expect(Cryptiles.fixedTimeComparison('', '')).to.be.true(); + expect(Cryptiles.fixedTimeComparison('asdas', 'asdasd')).to.be.false(); }); }); diff -Nru node-cryptiles-3.1.1/.travis.yml node-cryptiles-4.2.0/.travis.yml --- node-cryptiles-3.1.1/.travis.yml 2016-09-05 22:10:22.000000000 +0000 +++ node-cryptiles-4.2.0/.travis.yml 2019-04-02 06:15:37.000000000 +0000 @@ -1,8 +1,17 @@ language: node_js node_js: - - "4" - - "6" + - "8" + - "10" + - "11" - "node" sudo: false + +install: + - "npm install" + +os: + - "linux" + - "osx" + - "windows"