@stablelib/x25519
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -5,5 +5,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var random_1 = require("@stablelib/random"); | ||
var wipe_1 = require("@stablelib/wipe"); | ||
var x25519_1 = require("./x25519"); | ||
exports.X25519KeyAgreement = exports.SECRET_SEED_LENGTH = exports.SAVED_STATE_LENGTH = exports.ACCEPT_MESSAGE_LENGTH = exports.OFFER_MESSAGE_LENGTH = void 0; | ||
const random_1 = require("@stablelib/random"); | ||
const wipe_1 = require("@stablelib/wipe"); | ||
const x25519_1 = require("./x25519"); | ||
/** Constants for key agreement */ | ||
@@ -21,4 +22,4 @@ exports.OFFER_MESSAGE_LENGTH = x25519_1.PUBLIC_KEY_LENGTH; | ||
*/ | ||
var X25519KeyAgreement = /** @class */ (function () { | ||
function X25519KeyAgreement(secretSeed, prng) { | ||
class X25519KeyAgreement { | ||
constructor(secretSeed, prng) { | ||
this.offerMessageLength = exports.OFFER_MESSAGE_LENGTH; | ||
@@ -29,25 +30,25 @@ this.acceptMessageLength = exports.ACCEPT_MESSAGE_LENGTH; | ||
this._offered = false; | ||
this._secretKey = secretSeed || random_1.randomBytes(x25519_1.SECRET_KEY_LENGTH, prng); | ||
this._secretKey = secretSeed || (0, random_1.randomBytes)(x25519_1.SECRET_KEY_LENGTH, prng); | ||
} | ||
X25519KeyAgreement.prototype.saveState = function () { | ||
saveState() { | ||
return new Uint8Array(this._secretKey); | ||
}; | ||
X25519KeyAgreement.prototype.restoreState = function (savedState) { | ||
} | ||
restoreState(savedState) { | ||
this._secretKey = new Uint8Array(savedState); | ||
return this; | ||
}; | ||
X25519KeyAgreement.prototype.clean = function () { | ||
} | ||
clean() { | ||
if (this._secretKey) { | ||
wipe_1.wipe(this._secretKey); | ||
(0, wipe_1.wipe)(this._secretKey); | ||
} | ||
if (this._sharedKey) { | ||
wipe_1.wipe(this._sharedKey); | ||
(0, wipe_1.wipe)(this._sharedKey); | ||
} | ||
}; | ||
X25519KeyAgreement.prototype.offer = function () { | ||
} | ||
offer() { | ||
this._offered = true; | ||
var keyPair = x25519_1.generateKeyPairFromSeed(this._secretKey); | ||
const keyPair = (0, x25519_1.generateKeyPairFromSeed)(this._secretKey); | ||
return keyPair.publicKey; | ||
}; | ||
X25519KeyAgreement.prototype.accept = function (offerMsg) { | ||
} | ||
accept(offerMsg) { | ||
if (this._offered) { | ||
@@ -59,8 +60,8 @@ throw new Error("X25519KeyAgreement: accept shouldn't be called by offering party"); | ||
} | ||
var keyPair = x25519_1.generateKeyPairFromSeed(this._secretKey); | ||
this._sharedKey = x25519_1.sharedKey(keyPair.secretKey, offerMsg); | ||
wipe_1.wipe(keyPair.secretKey); | ||
const keyPair = (0, x25519_1.generateKeyPairFromSeed)(this._secretKey); | ||
this._sharedKey = (0, x25519_1.sharedKey)(keyPair.secretKey, offerMsg); | ||
(0, wipe_1.wipe)(keyPair.secretKey); | ||
return keyPair.publicKey; | ||
}; | ||
X25519KeyAgreement.prototype.finish = function (acceptMsg) { | ||
} | ||
finish(acceptMsg) { | ||
if (acceptMsg.length !== this.acceptMessageLength) { | ||
@@ -75,6 +76,6 @@ throw new Error("X25519KeyAgreement: incorrect accept message length"); | ||
} | ||
this._sharedKey = x25519_1.sharedKey(this._secretKey, acceptMsg); | ||
this._sharedKey = (0, x25519_1.sharedKey)(this._secretKey, acceptMsg); | ||
return this; | ||
}; | ||
X25519KeyAgreement.prototype.getSharedKey = function () { | ||
} | ||
getSharedKey() { | ||
if (!this._sharedKey) { | ||
@@ -84,6 +85,5 @@ throw new Error("X25519KeyAgreement: no shared key established"); | ||
return new Uint8Array(this._sharedKey); | ||
}; | ||
return X25519KeyAgreement; | ||
}()); | ||
} | ||
} | ||
exports.X25519KeyAgreement = X25519KeyAgreement; | ||
//# sourceMappingURL=keyagreement.js.map |
@@ -5,19 +5,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var x25519_1 = require("./x25519"); | ||
var keyagreement_1 = require("./keyagreement"); | ||
var benchmark_1 = require("@stablelib/benchmark"); | ||
var r = new Uint8Array(32); | ||
const x25519_1 = require("./x25519"); | ||
const keyagreement_1 = require("./keyagreement"); | ||
const benchmark_1 = require("@stablelib/benchmark"); | ||
const r = new Uint8Array(32); | ||
r[0] = 1; | ||
benchmark_1.report("x25519.scalarMultBase", benchmark_1.benchmark(function () { return x25519_1.scalarMultBase(r); })); | ||
var seed = benchmark_1.byteSeq(32); | ||
var offerMsg = new keyagreement_1.X25519KeyAgreement(seed).offer(); | ||
var acceptMsg = new keyagreement_1.X25519KeyAgreement(seed).accept(offerMsg); | ||
benchmark_1.report("X25519KeyAgreement offer/finish", benchmark_1.benchmark(function () { | ||
var state = new keyagreement_1.X25519KeyAgreement(seed); | ||
(0, benchmark_1.report)("x25519.scalarMultBase", (0, benchmark_1.benchmark)(() => (0, x25519_1.scalarMultBase)(r))); | ||
const seed = (0, benchmark_1.byteSeq)(32); | ||
const offerMsg = new keyagreement_1.X25519KeyAgreement(seed).offer(); | ||
const acceptMsg = new keyagreement_1.X25519KeyAgreement(seed).accept(offerMsg); | ||
(0, benchmark_1.report)("X25519KeyAgreement offer/finish", (0, benchmark_1.benchmark)(() => { | ||
const state = new keyagreement_1.X25519KeyAgreement(seed); | ||
state.offer(); | ||
state.finish(acceptMsg); | ||
})); | ||
benchmark_1.report("X25519KeyAgreement accept", benchmark_1.benchmark(function () { | ||
return new keyagreement_1.X25519KeyAgreement(seed).accept(offerMsg); | ||
})); | ||
(0, benchmark_1.report)("X25519KeyAgreement accept", (0, benchmark_1.benchmark)(() => new keyagreement_1.X25519KeyAgreement(seed).accept(offerMsg))); | ||
//# sourceMappingURL=x25519.bench.js.map |
@@ -5,7 +5,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sharedKey = exports.generateKeyPair = exports.generateKeyPairFromSeed = exports.scalarMultBase = exports.scalarMult = exports.SHARED_KEY_LENGTH = exports.SECRET_KEY_LENGTH = exports.PUBLIC_KEY_LENGTH = void 0; | ||
/** | ||
* Package x25519 implements X25519 key agreement. | ||
*/ | ||
var random_1 = require("@stablelib/random"); | ||
var wipe_1 = require("@stablelib/wipe"); | ||
const random_1 = require("@stablelib/random"); | ||
const wipe_1 = require("@stablelib/wipe"); | ||
exports.PUBLIC_KEY_LENGTH = 32; | ||
@@ -21,5 +22,5 @@ exports.SECRET_KEY_LENGTH = 32; | ||
function gf(init) { | ||
var r = new Float64Array(16); | ||
const r = new Float64Array(16); | ||
if (init) { | ||
for (var i = 0; i < init.length; i++) { | ||
for (let i = 0; i < init.length; i++) { | ||
r[i] = init[i]; | ||
@@ -31,9 +32,9 @@ } | ||
// Base point. | ||
var _9 = new Uint8Array(32); | ||
const _9 = new Uint8Array(32); | ||
_9[0] = 9; | ||
var _121665 = gf([0xdb41, 1]); | ||
const _121665 = gf([0xdb41, 1]); | ||
function car25519(o) { | ||
var c = 1; | ||
for (var i = 0; i < 16; i++) { | ||
var v = o[i] + c + 65535; | ||
let c = 1; | ||
for (let i = 0; i < 16; i++) { | ||
let v = o[i] + c + 65535; | ||
c = Math.floor(v / 65536); | ||
@@ -45,5 +46,5 @@ o[i] = v - c * 65536; | ||
function sel25519(p, q, b) { | ||
var c = ~(b - 1); | ||
for (var i = 0; i < 16; i++) { | ||
var t = c & (p[i] ^ q[i]); | ||
const c = ~(b - 1); | ||
for (let i = 0; i < 16; i++) { | ||
const t = c & (p[i] ^ q[i]); | ||
p[i] ^= t; | ||
@@ -54,5 +55,5 @@ q[i] ^= t; | ||
function pack25519(o, n) { | ||
var m = gf(); | ||
var t = gf(); | ||
for (var i = 0; i < 16; i++) { | ||
const m = gf(); | ||
const t = gf(); | ||
for (let i = 0; i < 16; i++) { | ||
t[i] = n[i]; | ||
@@ -63,5 +64,5 @@ } | ||
car25519(t); | ||
for (var j = 0; j < 2; j++) { | ||
for (let j = 0; j < 2; j++) { | ||
m[0] = t[0] - 0xffed; | ||
for (var i = 1; i < 15; i++) { | ||
for (let i = 1; i < 15; i++) { | ||
m[i] = t[i] - 0xffff - ((m[i - 1] >> 16) & 1); | ||
@@ -71,7 +72,7 @@ m[i - 1] &= 0xffff; | ||
m[15] = t[15] - 0x7fff - ((m[14] >> 16) & 1); | ||
var b = (m[15] >> 16) & 1; | ||
const b = (m[15] >> 16) & 1; | ||
m[14] &= 0xffff; | ||
sel25519(t, m, 1 - b); | ||
} | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
o[2 * i] = t[i] & 0xff; | ||
@@ -82,3 +83,3 @@ o[2 * i + 1] = t[i] >> 8; | ||
function unpack25519(o, n) { | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
o[i] = n[2 * i] + (n[2 * i + 1] << 8); | ||
@@ -89,3 +90,3 @@ } | ||
function add(o, a, b) { | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
o[i] = a[i] + b[i]; | ||
@@ -95,3 +96,3 @@ } | ||
function sub(o, a, b) { | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
o[i] = a[i] - b[i]; | ||
@@ -101,3 +102,3 @@ } | ||
function mul(o, a, b) { | ||
var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; | ||
let v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15]; | ||
v = a[0]; | ||
@@ -514,7 +515,7 @@ t0 += v * b0; | ||
function inv25519(o, inp) { | ||
var c = gf(); | ||
for (var i = 0; i < 16; i++) { | ||
const c = gf(); | ||
for (let i = 0; i < 16; i++) { | ||
c[i] = inp[i]; | ||
} | ||
for (var i = 253; i >= 0; i--) { | ||
for (let i = 253; i >= 0; i--) { | ||
square(c, c); | ||
@@ -525,3 +526,3 @@ if (i !== 2 && i !== 4) { | ||
} | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
o[i] = c[i]; | ||
@@ -531,6 +532,6 @@ } | ||
function scalarMult(n, p) { | ||
var z = new Uint8Array(32); | ||
var x = new Float64Array(80); | ||
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(); | ||
for (var i = 0; i < 31; i++) { | ||
const z = new Uint8Array(32); | ||
const x = new Float64Array(80); | ||
const a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(); | ||
for (let i = 0; i < 31; i++) { | ||
z[i] = n[i]; | ||
@@ -541,8 +542,8 @@ } | ||
unpack25519(x, p); | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
b[i] = x[i]; | ||
} | ||
a[0] = d[0] = 1; | ||
for (var i = 254; i >= 0; --i) { | ||
var r = (z[i >>> 3] >>> (i & 7)) & 1; | ||
for (let i = 254; i >= 0; --i) { | ||
const r = (z[i >>> 3] >>> (i & 7)) & 1; | ||
sel25519(a, b, r); | ||
@@ -571,3 +572,3 @@ sel25519(c, d, r); | ||
} | ||
for (var i = 0; i < 16; i++) { | ||
for (let i = 0; i < 16; i++) { | ||
x[i + 16] = a[i]; | ||
@@ -578,7 +579,7 @@ x[i + 32] = c[i]; | ||
} | ||
var x32 = x.subarray(32); | ||
var x16 = x.subarray(16); | ||
const x32 = x.subarray(32); | ||
const x16 = x.subarray(16); | ||
inv25519(x32, x32); | ||
mul(x16, x16, x32); | ||
var q = new Uint8Array(32); | ||
const q = new Uint8Array(32); | ||
pack25519(q, x16); | ||
@@ -594,9 +595,9 @@ return q; | ||
if (seed.length !== exports.SECRET_KEY_LENGTH) { | ||
throw new Error("x25519: seed must be " + exports.SECRET_KEY_LENGTH + " bytes"); | ||
throw new Error(`x25519: seed must be ${exports.SECRET_KEY_LENGTH} bytes`); | ||
} | ||
var secretKey = new Uint8Array(seed); | ||
var publicKey = scalarMultBase(secretKey); | ||
const secretKey = new Uint8Array(seed); | ||
const publicKey = scalarMultBase(secretKey); | ||
return { | ||
publicKey: publicKey, | ||
secretKey: secretKey | ||
publicKey, | ||
secretKey | ||
}; | ||
@@ -606,5 +607,5 @@ } | ||
function generateKeyPair(prng) { | ||
var seed = random_1.randomBytes(32, prng); | ||
var result = generateKeyPairFromSeed(seed); | ||
wipe_1.wipe(seed); | ||
const seed = (0, random_1.randomBytes)(32, prng); | ||
const result = generateKeyPairFromSeed(seed); | ||
(0, wipe_1.wipe)(seed); | ||
return result; | ||
@@ -634,4 +635,3 @@ } | ||
*/ | ||
function sharedKey(mySecretKey, theirPublicKey, rejectZero) { | ||
if (rejectZero === void 0) { rejectZero = false; } | ||
function sharedKey(mySecretKey, theirPublicKey, rejectZero = false) { | ||
if (mySecretKey.length !== exports.PUBLIC_KEY_LENGTH) { | ||
@@ -643,6 +643,6 @@ throw new Error("X25519: incorrect secret key length"); | ||
} | ||
var result = scalarMult(mySecretKey, theirPublicKey); | ||
const result = scalarMult(mySecretKey, theirPublicKey); | ||
if (rejectZero) { | ||
var zeros = 0; | ||
for (var i = 0; i < result.length; i++) { | ||
let zeros = 0; | ||
for (let i = 0; i < result.length; i++) { | ||
zeros |= result[i]; | ||
@@ -649,0 +649,0 @@ } |
@@ -5,33 +5,33 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var hex_1 = require("@stablelib/hex"); | ||
var x25519_1 = require("./x25519"); | ||
var keyagreement_1 = require("./keyagreement"); | ||
describe("x25519.scalarMultBase", function () { | ||
it("should return correct result", function () { | ||
const hex_1 = require("@stablelib/hex"); | ||
const x25519_1 = require("./x25519"); | ||
const keyagreement_1 = require("./keyagreement"); | ||
describe("x25519.scalarMultBase", () => { | ||
it("should return correct result", () => { | ||
// This takes takes a bit of time. | ||
// Similar to https://code.google.com/p/go/source/browse/curve25519/curve25519_test.go?repo=crypto | ||
var golden = hex_1.decode("89161fde887b2b53de549af483940106ecc114d6982daa98256de23bdf77661a"); | ||
var input = new Uint8Array(32); | ||
const golden = (0, hex_1.decode)("89161fde887b2b53de549af483940106ecc114d6982daa98256de23bdf77661a"); | ||
let input = new Uint8Array(32); | ||
input[0] = 1; | ||
for (var i = 0; i < 200; i++) { | ||
input = x25519_1.scalarMultBase(input); | ||
for (let i = 0; i < 200; i++) { | ||
input = (0, x25519_1.scalarMultBase)(input); | ||
} | ||
expect(input).toEqual(golden); | ||
}); | ||
it("should calculate shared key", function () { | ||
var k0 = x25519_1.generateKeyPair(); | ||
var k1 = x25519_1.generateKeyPair(); | ||
var s0 = x25519_1.sharedKey(k0.secretKey, k1.publicKey); | ||
var s1 = x25519_1.sharedKey(k1.secretKey, k0.publicKey); | ||
it("should calculate shared key", () => { | ||
const k0 = (0, x25519_1.generateKeyPair)(); | ||
const k1 = (0, x25519_1.generateKeyPair)(); | ||
const s0 = (0, x25519_1.sharedKey)(k0.secretKey, k1.publicKey); | ||
const s1 = (0, x25519_1.sharedKey)(k1.secretKey, k0.publicKey); | ||
expect(s0).toEqual(s1); | ||
}); | ||
it("should throw if shared key is all-zero and rejectZero = true", function () { | ||
var k = x25519_1.generateKeyPair(); | ||
var z = new Uint8Array(32); | ||
expect(function () { return x25519_1.sharedKey(k.secretKey, z, true); }).toThrowError(/invalid/); | ||
it("should throw if shared key is all-zero and rejectZero = true", () => { | ||
const k = (0, x25519_1.generateKeyPair)(); | ||
const z = new Uint8Array(32); | ||
expect(() => (0, x25519_1.sharedKey)(k.secretKey, z, true)).toThrowError(/invalid/); | ||
}); | ||
it("should not throw if shared key is all-zero and rejectZero = false", function () { | ||
var k = x25519_1.generateKeyPair(); | ||
var z = new Uint8Array(32); | ||
expect(x25519_1.sharedKey(k.secretKey, z)).toBeTruthy(); | ||
it("should not throw if shared key is all-zero and rejectZero = false", () => { | ||
const k = (0, x25519_1.generateKeyPair)(); | ||
const z = new Uint8Array(32); | ||
expect((0, x25519_1.sharedKey)(k.secretKey, z)).toBeTruthy(); | ||
}); | ||
@@ -48,11 +48,10 @@ }); | ||
// client part, like in the test below. | ||
var BadSource = /** @class */ (function () { | ||
function BadSource(v) { | ||
if (v === void 0) { v = 0; } | ||
class BadSource { | ||
constructor(v = 0) { | ||
this.v = v; | ||
this.isAvailable = true; | ||
} | ||
BadSource.prototype.randomBytes = function (length) { | ||
var out = new Uint8Array(length); | ||
for (var i = 0; i < out.length; i++) { | ||
randomBytes(length) { | ||
const out = new Uint8Array(length); | ||
for (let i = 0; i < out.length; i++) { | ||
out[i] = this.v; | ||
@@ -62,6 +61,5 @@ this.v = (this.v + 1) & 0xff; | ||
return out; | ||
}; | ||
return BadSource; | ||
}()); | ||
var testVector = { | ||
} | ||
} | ||
const testVector = { | ||
offerMsg: "8F40C5ADB68F25624AE5B214EA767A6EC94D829D3D7B5E1AD1BA6F3E2138285F", | ||
@@ -71,35 +69,35 @@ acceptMsg: "79A631EEDE1BF9C98F12032CDEADD0E7A079398FC786B88CC846EC89AF85A51A", | ||
}; | ||
describe("X25518KeyAgreement", function () { | ||
it("should establish shared key", function () { | ||
for (var i = 0; i < 5; i++) { | ||
var server = new keyagreement_1.X25519KeyAgreement(); | ||
var offerMsg = server.offer(); | ||
describe("X25519KeyAgreement", () => { | ||
it("should establish shared key", () => { | ||
for (let i = 0; i < 5; i++) { | ||
const server = new keyagreement_1.X25519KeyAgreement(); | ||
const offerMsg = server.offer(); | ||
// console.log("offerMsg:", encode(offerMsg)); | ||
var client = new keyagreement_1.X25519KeyAgreement(); | ||
var acceptMsg = client.accept(offerMsg); | ||
const client = new keyagreement_1.X25519KeyAgreement(); | ||
const acceptMsg = client.accept(offerMsg); | ||
// console.log("acceptMsg:", encode(acceptMsg)); | ||
server.finish(acceptMsg); | ||
var serverKey = server.getSharedKey(); | ||
var clientKey = client.getSharedKey(); | ||
const serverKey = server.getSharedKey(); | ||
const clientKey = client.getSharedKey(); | ||
// console.log("serverKey:", encode(serverKey)); | ||
// console.log("clientKey:", encode(clientKey)); | ||
expect(hex_1.encode(serverKey)).toEqual(hex_1.encode(clientKey)); | ||
expect((0, hex_1.encode)(serverKey)).toEqual((0, hex_1.encode)(clientKey)); | ||
} | ||
}); | ||
it("should match test vector", function () { | ||
var serverPrng = new BadSource(0); | ||
var server = new keyagreement_1.X25519KeyAgreement(undefined, serverPrng); | ||
var offerMsg = server.offer(); | ||
expect("offerMsg: " + hex_1.encode(offerMsg)) | ||
it("should match test vector", () => { | ||
const serverPrng = new BadSource(0); | ||
const server = new keyagreement_1.X25519KeyAgreement(undefined, serverPrng); | ||
const offerMsg = server.offer(); | ||
expect("offerMsg: " + (0, hex_1.encode)(offerMsg)) | ||
.toEqual("offerMsg: " + testVector.offerMsg); | ||
var clientPrng = new BadSource(64); | ||
var client = new keyagreement_1.X25519KeyAgreement(undefined, clientPrng); | ||
var acceptMsg = client.accept(offerMsg); | ||
expect("acceptMsg: " + hex_1.encode(acceptMsg)) | ||
const clientPrng = new BadSource(64); | ||
const client = new keyagreement_1.X25519KeyAgreement(undefined, clientPrng); | ||
const acceptMsg = client.accept(offerMsg); | ||
expect("acceptMsg: " + (0, hex_1.encode)(acceptMsg)) | ||
.toEqual("acceptMsg: " + testVector.acceptMsg); | ||
server.finish(acceptMsg); | ||
expect(hex_1.encode(server.getSharedKey())).toEqual(testVector.sharedKey); | ||
expect(hex_1.encode(client.getSharedKey())).toEqual(testVector.sharedKey); | ||
expect((0, hex_1.encode)(server.getSharedKey())).toEqual(testVector.sharedKey); | ||
expect((0, hex_1.encode)(client.getSharedKey())).toEqual(testVector.sharedKey); | ||
}); | ||
}); | ||
//# sourceMappingURL=x25519.test.js.map |
{ | ||
"name": "@stablelib/x25519", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "X25519 key agreement (Curve25519)", | ||
@@ -23,3 +23,3 @@ "main": "./lib/x25519.js", | ||
"@stablelib/keyagreement": "^1.0.1", | ||
"@stablelib/random": "^1.0.1", | ||
"@stablelib/random": "^1.0.2", | ||
"@stablelib/wipe": "^1.0.1" | ||
@@ -31,3 +31,3 @@ }, | ||
}, | ||
"gitHead": "d8b909d49245c040e5e4a59ff8c9b269fc1781ee" | ||
"gitHead": "a402dc74f45c6a93a777a0e2840ce50ba68c3010" | ||
} |
{ | ||
"extends": "../../configs/tsconfig.json", | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"strict": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"removeComments": false, | ||
"preserveConstEnums": true, | ||
"moduleResolution": "node", | ||
"newLine": "LF", | ||
"sourceMap": true, | ||
"declaration": true, | ||
"outDir": "lib", | ||
"lib": [ | ||
"es5", | ||
"es2015.promise", | ||
"dom", | ||
"scripthost" | ||
] | ||
}, | ||
@@ -23,0 +6,0 @@ "exclude": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87154
1712
Updated@stablelib/random@^1.0.2