mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-16 10:51:00 +00:00
chore: update aegir
This commit is contained in:
parent
e0ecce18ce
commit
2f065167fa
15
package.json
15
package.json
@ -34,12 +34,12 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asn1.js": "^4.9.1",
|
"asn1.js": "^4.9.1",
|
||||||
"async": "^2.1.4",
|
"async": "^2.1.5",
|
||||||
"browserify-aes": "^1.0.6",
|
"browserify-aes": "^1.0.6",
|
||||||
"keypair": "^1.0.1",
|
"keypair": "^1.0.1",
|
||||||
"libp2p-crypto-secp256k1": "^0.1.3",
|
"libp2p-crypto-secp256k1": "^0.1.4",
|
||||||
"multihashing-async": "~0.4.2",
|
"multihashing-async": "~0.4.4",
|
||||||
"nodeify": "^1.0.0",
|
"nodeify": "^1.0.1",
|
||||||
"pem-jwk": "^1.5.1",
|
"pem-jwk": "^1.5.1",
|
||||||
"protocol-buffers": "^3.2.1",
|
"protocol-buffers": "^3.2.1",
|
||||||
"rsa-pem-to-jwk": "^1.1.3",
|
"rsa-pem-to-jwk": "^1.1.3",
|
||||||
@ -48,13 +48,14 @@
|
|||||||
"webcrypto-shim": "github:dignifiedquire/webcrypto-shim#master"
|
"webcrypto-shim": "github:dignifiedquire/webcrypto-shim#master"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aegir": "^10.0.0",
|
"aegir": "^11.0.0",
|
||||||
"benchmark": "^2.1.3",
|
"benchmark": "^2.1.3",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
|
"dirty-chai": "^1.2.2",
|
||||||
"pre-commit": "^1.2.2"
|
"pre-commit": "^1.2.2"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"node-webcrypto-ossl": "^1.0.17"
|
"node-webcrypto-ossl": "^1.0.21"
|
||||||
},
|
},
|
||||||
"pre-commit": [
|
"pre-commit": [
|
||||||
"lint",
|
"lint",
|
||||||
@ -84,4 +85,4 @@
|
|||||||
"greenkeeperio-bot <support@greenkeeper.io>",
|
"greenkeeperio-bot <support@greenkeeper.io>",
|
||||||
"nikuda <nikuda@gmail.com>"
|
"nikuda <nikuda@gmail.com>"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const series = require('async/series')
|
const series = require('async/series')
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
|
|
||||||
@ -25,7 +28,7 @@ describe('AES-CTR', () => {
|
|||||||
iv.fill(1)
|
iv.fill(1)
|
||||||
|
|
||||||
crypto.aes.create(key, iv, (err, cipher) => {
|
crypto.aes.create(key, iv, (err, cipher) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
series([
|
series([
|
||||||
encryptAndDecrypt(cipher),
|
encryptAndDecrypt(cipher),
|
||||||
@ -46,17 +49,17 @@ describe('AES-CTR', () => {
|
|||||||
iv.fill(1)
|
iv.fill(1)
|
||||||
|
|
||||||
crypto.aes.create(key, iv, (err, cipher) => {
|
crypto.aes.create(key, iv, (err, cipher) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
series(fixtures[byte].inputs.map((rawIn, i) => (cb) => {
|
series(fixtures[byte].inputs.map((rawIn, i) => (cb) => {
|
||||||
const input = Buffer.from(rawIn)
|
const input = Buffer.from(rawIn)
|
||||||
const output = Buffer.from(fixtures[byte].outputs[i])
|
const output = Buffer.from(fixtures[byte].outputs[i])
|
||||||
cipher.encrypt(input, (err, res) => {
|
cipher.encrypt(input, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(res).to.have.length(output.length)
|
expect(res).to.have.length(output.length)
|
||||||
expect(res).to.be.eql(output)
|
expect(res).to.be.eql(output)
|
||||||
cipher.decrypt(res, (err, res) => {
|
cipher.decrypt(res, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(res).to.be.eql(input)
|
expect(res).to.be.eql(input)
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
@ -79,17 +82,17 @@ describe('AES-CTR', () => {
|
|||||||
iv.fill(1)
|
iv.fill(1)
|
||||||
|
|
||||||
crypto.aes.create(key, iv, (err, cipher) => {
|
crypto.aes.create(key, iv, (err, cipher) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
series(goFixtures[byte].inputs.map((rawIn, i) => (cb) => {
|
series(goFixtures[byte].inputs.map((rawIn, i) => (cb) => {
|
||||||
const input = Buffer.from(rawIn)
|
const input = Buffer.from(rawIn)
|
||||||
const output = Buffer.from(goFixtures[byte].outputs[i])
|
const output = Buffer.from(goFixtures[byte].outputs[i])
|
||||||
cipher.encrypt(input, (err, res) => {
|
cipher.encrypt(input, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(res).to.have.length(output.length)
|
expect(res).to.have.length(output.length)
|
||||||
expect(res).to.be.eql(output)
|
expect(res).to.be.eql(output)
|
||||||
cipher.decrypt(res, (err, res) => {
|
cipher.decrypt(res, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(res).to.be.eql(input)
|
expect(res).to.be.eql(input)
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
@ -105,9 +108,9 @@ function encryptAndDecrypt (cipher) {
|
|||||||
data.fill(Math.ceil(Math.random() * 100))
|
data.fill(Math.ceil(Math.random() * 100))
|
||||||
return (cb) => {
|
return (cb) => {
|
||||||
cipher.encrypt(data, (err, res) => {
|
cipher.encrypt(data, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
cipher.decrypt(res, (err, res) => {
|
cipher.decrypt(res, (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(res).to.be.eql(data)
|
expect(res).to.be.eql(data)
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
|
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
@ -231,7 +234,7 @@ describe('ed25519', () => {
|
|||||||
let privateKey
|
let privateKey
|
||||||
before((done) => {
|
before((done) => {
|
||||||
crypto.unmarshalPrivateKey(fixtures.verify.privateKey, (err, key) => {
|
crypto.unmarshalPrivateKey(fixtures.verify.privateKey, (err, key) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
privateKey = key
|
privateKey = key
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@ -242,7 +245,7 @@ describe('ed25519', () => {
|
|||||||
|
|
||||||
key.verify(fixtures.verify.data, fixtures.verify.signature, (err, ok) => {
|
key.verify(fixtures.verify.data, fixtures.verify.signature, (err, ok) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(ok).to.be.eql(true)
|
expect(ok).to.be.eql(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@ -250,7 +253,7 @@ describe('ed25519', () => {
|
|||||||
|
|
||||||
it('generates the same signature as go', (done) => {
|
it('generates the same signature as go', (done) => {
|
||||||
privateKey.sign(fixtures.verify.data, (err, sig) => {
|
privateKey.sign(fixtures.verify.data, (err, sig) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(sig).to.deep.equal(fixtures.verify.signature)
|
expect(sig).to.deep.equal(fixtures.verify.signature)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const parallel = require('async/parallel')
|
const parallel = require('async/parallel')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/go-elliptic-key')
|
const fixtures = require('./fixtures/go-elliptic-key')
|
||||||
@ -27,12 +30,12 @@ describe('generateEphemeralKeyPair', () => {
|
|||||||
(cb) => crypto.generateEphemeralKeyPair(curve, cb),
|
(cb) => crypto.generateEphemeralKeyPair(curve, cb),
|
||||||
(cb) => crypto.generateEphemeralKeyPair(curve, cb)
|
(cb) => crypto.generateEphemeralKeyPair(curve, cb)
|
||||||
], (err, keys) => {
|
], (err, keys) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(keys[0].key).to.have.length(lengths[curve])
|
expect(keys[0].key).to.have.length(lengths[curve])
|
||||||
expect(keys[1].key).to.have.length(lengths[curve])
|
expect(keys[1].key).to.have.length(lengths[curve])
|
||||||
|
|
||||||
keys[0].genSharedKey(keys[1].key, (err, shared) => {
|
keys[0].genSharedKey(keys[1].key, (err, shared) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(shared).to.have.length(secretLengths[curve])
|
expect(shared).to.have.length(secretLengths[curve])
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
@ -48,7 +51,7 @@ describe('generateEphemeralKeyPair', () => {
|
|||||||
(cb) => crypto.generateEphemeralKeyPair(curve, cb),
|
(cb) => crypto.generateEphemeralKeyPair(curve, cb),
|
||||||
(cb) => crypto.generateEphemeralKeyPair(curve, cb)
|
(cb) => crypto.generateEphemeralKeyPair(curve, cb)
|
||||||
], (err, res) => {
|
], (err, res) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
const alice = res[0]
|
const alice = res[0]
|
||||||
const bob = res[1]
|
const bob = res[1]
|
||||||
bob.key = fixtures.bob.public
|
bob.key = fixtures.bob.public
|
||||||
@ -57,7 +60,7 @@ describe('generateEphemeralKeyPair', () => {
|
|||||||
(cb) => alice.genSharedKey(bob.key, cb),
|
(cb) => alice.genSharedKey(bob.key, cb),
|
||||||
(cb) => bob.genSharedKey(alice.key, fixtures.bob, cb)
|
(cb) => bob.genSharedKey(alice.key, fixtures.bob, cb)
|
||||||
], (err, secrets) => {
|
], (err, secrets) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
secrets[0]
|
secrets[0]
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
|
|
||||||
@ -13,10 +16,10 @@ describe('HMAC', () => {
|
|||||||
hashes.forEach((hash) => {
|
hashes.forEach((hash) => {
|
||||||
it(`${hash} - sign and verify`, (done) => {
|
it(`${hash} - sign and verify`, (done) => {
|
||||||
crypto.hmac.create(hash, Buffer.from('secret'), (err, hmac) => {
|
crypto.hmac.create(hash, Buffer.from('secret'), (err, hmac) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
hmac.digest(Buffer.from('hello world'), (err, sig) => {
|
hmac.digest(Buffer.from('hello world'), (err, sig) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(sig).to.have.length(hmac.length)
|
expect(sig).to.have.length(hmac.length)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
const fixtures = require('./fixtures/go-key-rsa')
|
const fixtures = require('./fixtures/go-key-rsa')
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
const fixtures = require('./fixtures/go-stretch-key')
|
const fixtures = require('./fixtures/go-stretch-key')
|
||||||
|
|
||||||
@ -39,8 +41,8 @@ describe('keyStretcher', () => {
|
|||||||
return done(err)
|
return done(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(keys.k1).to.exist
|
expect(keys.k1).to.exist()
|
||||||
expect(keys.k2).to.exist
|
expect(keys.k2).to.exist()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
|
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
@ -169,8 +172,8 @@ describe('RSA', () => {
|
|||||||
|
|
||||||
key.verify(fixtures.verify.data, fixtures.verify.signature, (err, ok) => {
|
key.verify(fixtures.verify.data, fixtures.verify.signature, (err, ok) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist()
|
||||||
expect(ok).to.be.eql(true)
|
expect(ok).to.equal(true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
const fixtures = require('./fixtures/secp256k1')
|
const fixtures = require('./fixtures/secp256k1')
|
||||||
const crypto = require('../src')
|
const crypto = require('../src')
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ describe('with libp2p-crypto-secp256k1 module present', () => {
|
|||||||
it('generates a valid key', (done) => {
|
it('generates a valid key', (done) => {
|
||||||
expect(
|
expect(
|
||||||
key
|
key
|
||||||
).to.exist
|
).to.exist()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -82,16 +85,16 @@ describe('with libp2p-crypto-secp256k1 module present', () => {
|
|||||||
describe('without libp2p-crypto-secp256k1 module present', () => {
|
describe('without libp2p-crypto-secp256k1 module present', () => {
|
||||||
it('fails to generate a secp256k1 key', (done) => {
|
it('fails to generate a secp256k1 key', (done) => {
|
||||||
crypto.generateKeyPair('secp256k1', 256, (err, key) => {
|
crypto.generateKeyPair('secp256k1', 256, (err, key) => {
|
||||||
expect(err).to.exist
|
expect(err).to.exist()
|
||||||
expect(key).to.not.exist
|
expect(key).to.not.exist()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('fails to unmarshal a secp256k1 private key', (done) => {
|
it('fails to unmarshal a secp256k1 private key', (done) => {
|
||||||
crypto.unmarshalPrivateKey(fixtures.pbmPrivateKey, (err, key) => {
|
crypto.unmarshalPrivateKey(fixtures.pbmPrivateKey, (err, key) => {
|
||||||
expect(err).to.exist
|
expect(err).to.exist()
|
||||||
expect(key).to.not.exist
|
expect(key).to.not.exist()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const expect = require('chai').expect
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
|
const expect = chai.expect
|
||||||
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
const util = require('../src/crypto/util')
|
const util = require('../src/crypto/util')
|
||||||
const BN = require('bn.js')
|
const BN = require('bn.js')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user