-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
> prettier --write $(git ls-files)
- Loading branch information
Showing
12 changed files
with
1,388 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ dist: trusty | |
language: node_js | ||
|
||
node_js: | ||
- "8" | ||
- '8' | ||
env: | ||
- TASK=test | ||
- TASK=lint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,58 @@ | ||
const packet = require('dns-packet'); | ||
|
||
exports.realEntries = [ | ||
{ | ||
name: ".", | ||
type: 'DS', | ||
class: 'IN', | ||
ttl: 3600, | ||
data:{ | ||
keyTag: 19036, | ||
algorithm: 8, | ||
digestType: 2, | ||
digest: new Buffer("49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5", "hex") | ||
} | ||
}, | ||
{ | ||
name: ".", | ||
type: 'DS', | ||
klass: 'IN', | ||
ttl: 3600, | ||
data:{ | ||
keyTag: 20326, | ||
algorithm: 8, | ||
digestType: 2, | ||
digest: new Buffer("E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D", "hex") | ||
} | ||
}, | ||
]; | ||
|
||
{ | ||
name: '.', | ||
type: 'DS', | ||
class: 'IN', | ||
ttl: 3600, | ||
data: { | ||
keyTag: 19036, | ||
algorithm: 8, | ||
digestType: 2, | ||
digest: new Buffer( | ||
'49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5', | ||
'hex' | ||
) | ||
} | ||
}, | ||
{ | ||
name: '.', | ||
type: 'DS', | ||
klass: 'IN', | ||
ttl: 3600, | ||
data: { | ||
keyTag: 20326, | ||
algorithm: 8, | ||
digestType: 2, | ||
digest: new Buffer( | ||
'E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D', | ||
'hex' | ||
) | ||
} | ||
} | ||
]; | ||
|
||
exports.dummyEntry = { | ||
name: ".", | ||
name: '.', | ||
type: 'DS', | ||
class: 'IN', | ||
ttl: 3600, | ||
data:{ | ||
data: { | ||
keyTag: 5647, // Empty body, flags == 0x0101, algorithm = 253, body = 0x1111 | ||
algorithm: 253, | ||
digestType: 253, | ||
digest: new Buffer("", "hex") | ||
digest: new Buffer('', 'hex') | ||
} | ||
} | ||
}; | ||
|
||
exports.encode = (anchors) =>{ | ||
return '0x' + anchors.map((anchor)=>{ | ||
return packet.answer.encode(anchor).toString('hex') | ||
}).join('') | ||
} | ||
exports.encode = anchors => { | ||
return ( | ||
'0x' + | ||
anchors | ||
.map(anchor => { | ||
return packet.answer.encode(anchor).toString('hex'); | ||
}) | ||
.join('') | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,75 @@ | ||
const RSASHA1Algorithm = artifacts.require("./algorithms/RSASHA1Algorithm"); | ||
const RSASHA256Algorithm = artifacts.require("./algorithms/RSASHA256Algorithm"); | ||
const SHA1Digest = artifacts.require("./digests/SHA1Digest"); | ||
const SHA256Digest = artifacts.require("./digests/SHA256Digest"); | ||
const SHA1NSEC3Digest = artifacts.require("./nsec3digests/SHA1NSEC3Digest"); | ||
const DNSSEC = artifacts.require("./DNSSECImpl"); | ||
const DummyAlgorithm = artifacts.require("./algorithms/DummyAlgorithm"); | ||
const DummyDigest = artifacts.require("./digests/DummyDigest"); | ||
const P256SHA256Algorithm = artifacts.require("P256SHA256Algorithm.sol"); | ||
const EllipticCurve = artifacts.require("EllipticCurve.sol"); | ||
|
||
const dnsAnchors = require("../lib/anchors.js"); | ||
const RSASHA1Algorithm = artifacts.require('./algorithms/RSASHA1Algorithm'); | ||
const RSASHA256Algorithm = artifacts.require('./algorithms/RSASHA256Algorithm'); | ||
const SHA1Digest = artifacts.require('./digests/SHA1Digest'); | ||
const SHA256Digest = artifacts.require('./digests/SHA256Digest'); | ||
const SHA1NSEC3Digest = artifacts.require('./nsec3digests/SHA1NSEC3Digest'); | ||
const DNSSEC = artifacts.require('./DNSSECImpl'); | ||
const DummyAlgorithm = artifacts.require('./algorithms/DummyAlgorithm'); | ||
const DummyDigest = artifacts.require('./digests/DummyDigest'); | ||
const P256SHA256Algorithm = artifacts.require('P256SHA256Algorithm.sol'); | ||
const EllipticCurve = artifacts.require('EllipticCurve.sol'); | ||
|
||
const dnsAnchors = require('../lib/anchors.js'); | ||
|
||
module.exports = function(deployer, network) { | ||
return deployer.then(async () => { | ||
let dev = (network == "test" || network == "local"); | ||
// From http://data.iana.org/root-anchors/root-anchors.xml | ||
let anchors = dnsAnchors.realEntries; | ||
return deployer.then(async () => { | ||
let dev = network == 'test' || network == 'local'; | ||
// From http://data.iana.org/root-anchors/root-anchors.xml | ||
let anchors = dnsAnchors.realEntries; | ||
|
||
if (dev) { | ||
anchors.push(dnsAnchors.dummyEntry); | ||
} | ||
await deployer.deploy(DNSSEC, dnsAnchors.encode(anchors)); | ||
if (dev) { | ||
anchors.push(dnsAnchors.dummyEntry); | ||
} | ||
await deployer.deploy(DNSSEC, dnsAnchors.encode(anchors)); | ||
|
||
await deployer.deploy(RSASHA256Algorithm); | ||
await deployer.deploy(RSASHA1Algorithm); | ||
await deployer.deploy(SHA256Digest); | ||
await deployer.deploy(SHA1Digest); | ||
await deployer.deploy(SHA1NSEC3Digest); | ||
await deployer.deploy(RSASHA256Algorithm); | ||
await deployer.deploy(RSASHA1Algorithm); | ||
await deployer.deploy(SHA256Digest); | ||
await deployer.deploy(SHA1Digest); | ||
await deployer.deploy(SHA1NSEC3Digest); | ||
|
||
await deployer.deploy(EllipticCurve); | ||
await deployer.deploy(EllipticCurve); | ||
|
||
let curve = await EllipticCurve.deployed() | ||
await deployer.deploy(P256SHA256Algorithm, curve.address) | ||
let curve = await EllipticCurve.deployed(); | ||
await deployer.deploy(P256SHA256Algorithm, curve.address); | ||
|
||
if (dev) { | ||
await deployer.deploy(DummyAlgorithm); | ||
await deployer.deploy(DummyDigest); | ||
} | ||
|
||
if (dev) { | ||
await deployer.deploy(DummyAlgorithm) | ||
await deployer.deploy(DummyDigest) | ||
} | ||
let tasks = []; | ||
|
||
let tasks = []; | ||
const dnssec = await DNSSEC.deployed(); | ||
|
||
const dnssec = await DNSSEC.deployed(); | ||
const rsasha1 = await RSASHA1Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(5, rsasha1.address)); | ||
tasks.push(dnssec.setAlgorithm(7, rsasha1.address)); | ||
|
||
const rsasha1 = await RSASHA1Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(5, rsasha1.address)); | ||
tasks.push(dnssec.setAlgorithm(7, rsasha1.address)); | ||
const rsasha256 = await RSASHA256Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(8, rsasha256.address)); | ||
|
||
const rsasha256 = await RSASHA256Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(8, rsasha256.address)); | ||
const sha1 = await SHA1Digest.deployed(); | ||
tasks.push(dnssec.setDigest(1, sha1.address)); | ||
|
||
const sha1 = await SHA1Digest.deployed(); | ||
tasks.push(dnssec.setDigest(1, sha1.address)); | ||
const sha256 = await SHA256Digest.deployed(); | ||
tasks.push(dnssec.setDigest(2, sha256.address)); | ||
|
||
const sha256 = await SHA256Digest.deployed(); | ||
tasks.push(dnssec.setDigest(2, sha256.address)); | ||
const nsec3sha1 = await SHA1NSEC3Digest.deployed(); | ||
tasks.push(dnssec.setNSEC3Digest(1, nsec3sha1.address)); | ||
|
||
const nsec3sha1 = await SHA1NSEC3Digest.deployed(); | ||
tasks.push(dnssec.setNSEC3Digest(1, nsec3sha1.address)); | ||
const p256 = await P256SHA256Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(13, p256.address)); | ||
|
||
const p256 = await P256SHA256Algorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(13, p256.address)); | ||
if (dev) { | ||
const dummyalgorithm = await DummyAlgorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(253, dummyalgorithm.address)); | ||
tasks.push(dnssec.setAlgorithm(254, dummyalgorithm.address)); | ||
|
||
if (dev) { | ||
const dummyalgorithm = await DummyAlgorithm.deployed(); | ||
tasks.push(dnssec.setAlgorithm(253, dummyalgorithm.address)); | ||
tasks.push(dnssec.setAlgorithm(254, dummyalgorithm.address)); | ||
const dummydigest = await DummyDigest.deployed(); | ||
tasks.push(dnssec.setDigest(253, dummydigest.address)); | ||
} | ||
|
||
const dummydigest = await DummyDigest.deployed(); | ||
tasks.push(dnssec.setDigest(253, dummydigest.address)); | ||
} | ||
|
||
await Promise.all(tasks) | ||
}); | ||
await Promise.all(tasks); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
const algorithms = require("./data/algorithms"); | ||
const algorithms = require('./data/algorithms'); | ||
|
||
algorithms.forEach(function ([algo, vector]) { | ||
contract(algo, function (accounts) { | ||
algorithms.forEach(function([algo, vector]) { | ||
contract(algo, function(accounts) { | ||
const algorithm = artifacts.require('./algorithms/' + algo + '.sol'); | ||
|
||
const algorithm = artifacts.require("./algorithms/" + algo + ".sol"); | ||
it('should return true for valid signatures', async function() { | ||
var instance = await algorithm.deployed(); | ||
|
||
it('should return true for valid signatures', async function() { | ||
var instance = await algorithm.deployed(); | ||
|
||
assert.equal(await instance.verify(vector[0], vector[1], vector[2]), true); | ||
}); | ||
assert.equal( | ||
await instance.verify(vector[0], vector[1], vector[2]), | ||
true | ||
); | ||
}); | ||
|
||
it('should return false for invalid signatures', async function() { | ||
var instance = await algorithm.deployed(); | ||
it('should return false for invalid signatures', async function() { | ||
var instance = await algorithm.deployed(); | ||
|
||
vector[1] = vector[1] + "00"; | ||
assert.equal(await instance.verify(vector[0], vector[1], vector[2]), false); | ||
}); | ||
vector[1] = vector[1] + '00'; | ||
assert.equal( | ||
await instance.verify(vector[0], vector[1], vector[2]), | ||
false | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.