Skip to content

Commit

Permalink
Update fast-srp-hap dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstegeman committed Apr 22, 2020
1 parent dcc1bfb commit a4eb9c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
34 changes: 15 additions & 19 deletions lib/protocol/pairing-protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const HKDF = require('hkdf');
const TLV = require('../model/tlv');
const sodium = require('libsodium-wrappers');
const srp = require('fast-srp-hap');
const {SRP, SrpClient} = require('fast-srp-hap');
const {v4: uuidv4} = require('uuid');

const Steps = {
Expand Down Expand Up @@ -211,25 +211,21 @@ class PairingProtocol {
* @returns {Promise} Promise which resolves to a Buffer.
*/
buildPairSetupM3(m2Tlv, pin) {
return new Promise((resolve) => {
srp.genKey(32, (err, key) => {
this.srpClient = new srp.Client(
srp.params['3072'],
m2Tlv.get(Types.kTLVType_Salt),
Buffer.from('Pair-Setup'),
Buffer.from(pin),
key
);
this.srpClient.setB(m2Tlv.get(Types.kTLVType_PublicKey));

const data = new Map();
data.set(Types.kTLVType_State, Buffer.from([Steps.M3]));
data.set(Types.kTLVType_PublicKey, this.srpClient.computeA());
data.set(Types.kTLVType_Proof, this.srpClient.computeM1());
const packet = TLV.encodeObject(data);
return SRP.genKey(32).then((key) => {
this.srpClient = new SrpClient(
SRP.params['3072'],
m2Tlv.get(Types.kTLVType_Salt),
Buffer.from('Pair-Setup'),
Buffer.from(pin),
key
);
this.srpClient.setB(m2Tlv.get(Types.kTLVType_PublicKey));

resolve(packet);
});
const data = new Map();
data.set(Types.kTLVType_State, Buffer.from([Steps.M3]));
data.set(Types.kTLVType_PublicKey, this.srpClient.computeA());
data.set(Types.kTLVType_Proof, this.srpClient.computeM1());
return TLV.encodeObject(data);
});
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hap-controller",
"version": "0.3.3",
"version": "0.3.4",
"description": "Library to implement a HAP (HomeKit) controller",
"main": "lib/index.js",
"directories": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@abandonware/noble": "^1.9.2-8",
"dnssd": "^0.4.1",
"fast-srp-hap": "^1.0.1",
"fast-srp-hap": "^2.0.2",
"hkdf": "0.0.2",
"http-parser-js": "^0.5.2",
"libsodium-wrappers": "^0.7.6",
Expand Down

0 comments on commit a4eb9c6

Please sign in to comment.