Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Travis CI builds as well as update dependencies to latest versions #199

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,150 changes: 597 additions & 553 deletions example/bundle.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions example/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var crypto = require('crypto')
var abc = crypto.createHash('sha1').update('abc').digest('hex')
const crypto = require('crypto')
const abc = crypto.createHash('sha1').update('abc').digest('hex')
console.log(abc)
// require('hello').inlineCall().call2()
61 changes: 24 additions & 37 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = r
exports.createHash = exports.Hash = require('create-hash')
exports.createHmac = exports.Hmac = require('create-hmac')

var algos = require('browserify-sign/algos')
var algoKeys = Object.keys(algos)
var hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
const algos = require('browserify-sign/algos')
rawr51919 marked this conversation as resolved.
Show resolved Hide resolved
const algoKeys = Object.keys(algos)
const hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(algoKeys)
exports.getHashes = function () {
return hashes
}

var p = require('pbkdf2')
const p = require('pbkdf2')
exports.pbkdf2 = p.pbkdf2
exports.pbkdf2Sync = p.pbkdf2Sync

var aes = require('browserify-cipher')
const aes = require('browserify-cipher')

exports.Cipher = aes.Cipher
exports.createCipher = aes.createCipher
Expand All @@ -28,15 +28,15 @@ exports.createDecipheriv = aes.createDecipheriv
exports.getCiphers = aes.getCiphers
exports.listCiphers = aes.listCiphers

var dh = require('diffie-hellman')
const dh = require('diffie-hellman')

exports.DiffieHellmanGroup = dh.DiffieHellmanGroup
exports.createDiffieHellmanGroup = dh.createDiffieHellmanGroup
exports.getDiffieHellman = dh.getDiffieHellman
exports.createDiffieHellman = dh.createDiffieHellman
exports.DiffieHellman = dh.DiffieHellman

var sign = require('browserify-sign')
const sign = require('browserify-sign')

exports.createSign = sign.createSign
exports.Sign = sign.Sign
Expand All @@ -45,27 +45,14 @@ exports.Verify = sign.Verify

exports.createECDH = require('create-ecdh')

var publicEncrypt = require('public-encrypt')
const publicEncrypt = require('public-encrypt')

exports.publicEncrypt = publicEncrypt.publicEncrypt
exports.privateEncrypt = publicEncrypt.privateEncrypt
exports.publicDecrypt = publicEncrypt.publicDecrypt
exports.privateDecrypt = publicEncrypt.privateDecrypt

// the least I can do is make error messages for the rest of the node.js/crypto api.
// ;[
// 'createCredentials'
// ].forEach(function (name) {
// exports[name] = function () {
// throw new Error([
// 'sorry, ' + name + ' is not implemented yet',
// 'we accept pull requests',
// 'https://github.com/crypto-browserify/crypto-browserify'
// ].join('\n'))
// }
// })

var rf = require('randomfill')
const rf = require('randomfill')

exports.randomFill = rf.randomFill
exports.randomFillSync = rf.randomFillSync
Expand All @@ -79,19 +66,19 @@ exports.createCredentials = function () {
}

exports.constants = {
'DH_CHECK_P_NOT_SAFE_PRIME': 2,
'DH_CHECK_P_NOT_PRIME': 1,
'DH_UNABLE_TO_CHECK_GENERATOR': 4,
'DH_NOT_SUITABLE_GENERATOR': 8,
'NPN_ENABLED': 1,
'ALPN_ENABLED': 1,
'RSA_PKCS1_PADDING': 1,
'RSA_SSLV23_PADDING': 2,
'RSA_NO_PADDING': 3,
'RSA_PKCS1_OAEP_PADDING': 4,
'RSA_X931_PADDING': 5,
'RSA_PKCS1_PSS_PADDING': 6,
'POINT_CONVERSION_COMPRESSED': 2,
'POINT_CONVERSION_UNCOMPRESSED': 4,
'POINT_CONVERSION_HYBRID': 6
DH_CHECK_P_NOT_SAFE_PRIME: 2,
DH_CHECK_P_NOT_PRIME: 1,
DH_UNABLE_TO_CHECK_GENERATOR: 4,
DH_NOT_SUITABLE_GENERATOR: 8,
NPN_ENABLED: 1,
ALPN_ENABLED: 1,
RSA_PKCS1_PADDING: 1,
RSA_SSLV23_PADDING: 2,
RSA_NO_PADDING: 3,
RSA_PKCS1_OAEP_PADDING: 4,
RSA_X931_PADDING: 5,
RSA_PKCS1_PSS_PADDING: 6,
POINT_CONVERSION_COMPRESSED: 2,
POINT_CONVERSION_UNCOMPRESSED: 4,
POINT_CONVERSION_HYBRID: 6
}
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@
"scripts": {
"standard": "standard",
"test": "npm run standard && npm run unit",
"unit": "node test/",
"unit": "node test",
"browser": "zuul --browser-version $BROWSER_VERSION --browser-name $BROWSER_NAME -- test/index.js"
},
"engines": {
"node": "*"
},
"dependencies": {
"browserify-cipher": "^1.0.0",
"browserify-sign": "^4.0.0",
"create-ecdh": "^4.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.0",
"diffie-hellman": "^5.0.0",
"inherits": "^2.0.1",
"pbkdf2": "^3.0.3",
"public-encrypt": "^4.0.0",
"randombytes": "^2.0.0",
"randomfill": "^1.0.3"
"browserify-cipher": "^1.0.1",
"browserify-sign": "^4.2.1",
"create-ecdh": "^4.0.4",
"create-hash": "^1.2.0",
"create-hmac": "^1.1.7",
"diffie-hellman": "^5.0.3",
"inherits": "^2.0.4",
"pbkdf2": "^3.1.1",
"public-encrypt": "^4.0.3",
"randombytes": "^2.1.0",
"randomfill": "^1.0.4"
},
"devDependencies": {
"hash-test-vectors": "~1.3.2",
"hash-test-vectors": "^1.3.2",
"pseudorandombytes": "^2.0.0",
"safe-buffer": "^5.1.1",
"standard": "^5.0.2",
"tape": "~2.3.2",
"zuul": "^3.6.0"
"safe-buffer": "^5.2.1",
"standard": "^16.0.3",
"tape": "^5.1.1",
"zuul": "^3.12.0"
},
"optionalDependencies": {},
"browser": {
Expand Down
30 changes: 15 additions & 15 deletions test/aes.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
var test = require('tape')
var crypto = require('browserify-cipher/browser')
var randomBytes = require('pseudorandombytes')
const test = require('tape')
const crypto = require('browserify-cipher/browser')
const randomBytes = require('pseudorandombytes')

function runIt (i) {
crypto.listCiphers().forEach(function (cipher) {
test('run: ' + i, function (t) {
t.test('ciphers: ' + cipher, function (t) {
t.plan(1)
var data = randomBytes(562)
var password = randomBytes(20)
var crypter = crypto.createCipher(cipher, password)
var decrypter = crypto.createDecipher(cipher, password)
var out = []
const data = randomBytes(562)
const password = randomBytes(20)
const crypter = crypto.createCipher(cipher, password)
const decrypter = crypto.createDecipher(cipher, password)
const out = []
out.push(decrypter.update(crypter.update(data)))
out.push(decrypter.update(crypter.final()))
if (cipher.indexOf('gcm') > -1) {
Expand All @@ -34,13 +34,13 @@ test('getCiphers', function (t) {

test('through crypto browserify works', function (t) {
t.plan(2)
var crypto = require('../')
var cipher = 'aes-128-ctr'
var data = randomBytes(562)
var password = randomBytes(20)
var crypter = crypto.createCipher(cipher, password)
var decrypter = crypto.createDecipher(cipher, password)
var out = []
const crypto = require('../')
const cipher = 'aes-128-ctr'
const data = randomBytes(562)
const password = randomBytes(20)
const crypter = crypto.createCipher(cipher, password)
const decrypter = crypto.createDecipher(cipher, password)
const out = []
out.push(decrypter.update(crypter.update(data)))
out.push(decrypter.update(crypter.final()))
out.push(decrypter.final())
Expand Down
26 changes: 13 additions & 13 deletions test/create-hash.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var test = require('tape')
const test = require('tape')

var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
var encodings = ['hex', 'base64'] // FIXME: test binary
var vectors = require('hash-test-vectors')
const algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
const encodings = ['hex', 'base64'] // FIXME: test binary
const vectors = require('hash-test-vectors')

testLib('createHash in crypto-browserify', require('../').createHash)
testLib('create-hash/browser', require('create-hash/browser'))
Expand All @@ -19,26 +19,26 @@ function runTest (name, createHash, algorithm) {
if (i >= vectors.length) {
return t.end()
}
var obj = vectors[i]
const obj = vectors[i]

var input = new Buffer(obj.input, 'base64')
var node = obj[algorithm]
var js = createHash(algorithm).update(input).digest('hex')
let input = Buffer.from(obj.input, 'base64')
let node = obj[algorithm]
let js = createHash(algorithm).update(input).digest('hex')
if (js !== node) {
t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node)
}

encodings.forEach(function (encoding) {
var input = new Buffer(obj.input, 'base64').toString(encoding)
var node = obj[algorithm]
var js = createHash(algorithm).update(input, encoding).digest('hex')
const input = Buffer.from(obj.input, 'base64').toString(encoding)
const node = obj[algorithm]
const js = createHash(algorithm).update(input, encoding).digest('hex')
if (js !== node) {
t.equal(js, node, algorithm + '(testVector[' + i + '], ' + encoding + ') == ' + node)
}
})
input = new Buffer(obj.input, 'base64')
input = Buffer.from(obj.input, 'base64')
node = obj[algorithm]
var hash = createHash(algorithm)
const hash = createHash(algorithm)
hash.end(input)
js = hash.read().toString('hex')
if (js !== node) {
Expand Down
16 changes: 8 additions & 8 deletions test/create-hmac.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var test = require('tape')
const test = require('tape')

var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
var vectors = require('hash-test-vectors/hmac')
const algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160']
const vectors = require('hash-test-vectors/hmac')
testLib('createHmac in crypto-browserify', require('../').createHmac)
testLib('create-hmac/browser', require('create-hmac/browser'))

Expand All @@ -13,8 +13,8 @@ function testLib (name, createHmac) {
if (i >= vectors.length) {
return t.end()
}
var input = vectors[i]
var output = createHmac(alg, new Buffer(input.key, 'hex'))
const input = vectors[i]
let output = createHmac(alg, Buffer.from(input.key, 'hex'))
.update(input.data, 'hex').digest()

output = input.truncate ? output.slice(0, input.truncate) : output
Expand All @@ -32,11 +32,11 @@ function testLib (name, createHmac) {
if (i >= vectors.length) {
return t.end()
}
var input = vectors[i]
var hmac = createHmac(alg, new Buffer(input.key, 'hex'))
const input = vectors[i]
const hmac = createHmac(alg, Buffer.from(input.key, 'hex'))

hmac.end(input.data, 'hex')
var output = hmac.read()
let output = hmac.read()

output = input.truncate ? output.slice(0, input.truncate) : output
output = output.toString('hex')
Expand Down
38 changes: 19 additions & 19 deletions test/dh.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
var test = require('tape')
var crypto = require('diffie-hellman/browser')
const test = require('tape')
const crypto = require('diffie-hellman/browser')

test('diffie-hellman mod groups', function (t) {
[
'modp1', 'modp2', 'modp5', 'modp14', 'modp15', 'modp16'
].forEach(function (mod) {
t.test(mod, function (t) {
t.plan(3)
var dh1 = crypto.getDiffieHellman(mod)
var p1 = dh1.getPrime().toString('hex')
const dh1 = crypto.getDiffieHellman(mod)
const p1 = dh1.getPrime().toString('hex')
dh1.generateKeys()
var dh2 = crypto.getDiffieHellman(mod)
var p2 = dh2.getPrime().toString('hex')
const dh2 = crypto.getDiffieHellman(mod)
const p2 = dh2.getPrime().toString('hex')
dh2.generateKeys()
t.equals(p1, p2, 'equal primes')
var pubk1 = dh1.getPublicKey()
var pubk2 = dh2.getPublicKey()
const pubk1 = dh1.getPublicKey()
const pubk2 = dh2.getPublicKey()
t.notEquals(pubk1, pubk2, 'diff public keys')
var pub1 = dh1.computeSecret(pubk2).toString('hex')
var pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex')
const pub1 = dh1.computeSecret(pubk2).toString('hex')
const pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex')
t.equals(pub1, pub2, 'equal secrets')
})
})
Expand All @@ -30,19 +30,19 @@ test('diffie-hellman key lengths', function (t) {
].forEach(function (len) {
t.test('' + len, function (t) {
t.plan(3)
var dh2 = crypto.createDiffieHellman(len)
var prime2 = dh2.getPrime()
var p2 = prime2.toString('hex')
var dh1 = crypto.createDiffieHellman(prime2)
var p1 = dh1.getPrime().toString('hex')
const dh2 = crypto.createDiffieHellman(len)
const prime2 = dh2.getPrime()
const p2 = prime2.toString('hex')
const dh1 = crypto.createDiffieHellman(prime2)
const p1 = dh1.getPrime().toString('hex')
dh1.generateKeys()
dh2.generateKeys()
t.equals(p1, p2, 'equal primes')
var pubk1 = dh1.getPublicKey()
var pubk2 = dh2.getPublicKey()
const pubk1 = dh1.getPublicKey()
const pubk2 = dh2.getPublicKey()
t.notEquals(pubk1, pubk2, 'diff public keys')
var pub1 = dh1.computeSecret(pubk2).toString('hex')
var pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex')
const pub1 = dh1.computeSecret(pubk2).toString('hex')
const pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex')
t.equals(pub1, pub2, 'equal secrets')
})
})
Expand Down
Loading