From 36e3462a82cc27de8329e1117b19398d7cb506df Mon Sep 17 00:00:00 2001 From: morrigan Date: Sat, 8 Feb 2020 11:21:51 +0100 Subject: [PATCH] Fix fetching ephemeral keys from IK --- src/handshake-ik.ts | 2 +- src/noise.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/handshake-ik.ts b/src/handshake-ik.ts index ca7ea9a..92a1cbd 100644 --- a/src/handshake-ik.ts +++ b/src/handshake-ik.ts @@ -101,7 +101,7 @@ export class IKHandshake implements IHandshake { return this.ik.encryptWithAd(cs, Buffer.alloc(0), plaintext); } - public getRemoteEphemeralKeys(): KeyPair { + public getLocalEphemeralKeys(): KeyPair { if (!this.session.hs.e) { throw new Error("Ephemeral keys do not exist."); } diff --git a/src/noise.ts b/src/noise.ts index eb7dc14..304b3d3 100644 --- a/src/noise.ts +++ b/src/noise.ts @@ -136,8 +136,8 @@ export class Noise implements INoiseConnection { } catch (e) { // IK failed, go to XX fallback let ephemeralKeys; - if (!params.isInitiator) { - ephemeralKeys = ikHandshake.getRemoteEphemeralKeys(); + if (params.isInitiator) { + ephemeralKeys = ikHandshake.getLocalEphemeralKeys(); } return await this.performXXFallbackHandshake(params, payload, e.initialMsg, ephemeralKeys); }