Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_handlePairStepOne = (request: IncomingMessage, response: ServerResponse, session: Session) => {
debug("[%s] Pair step 1/5", this.accessoryInfo.username);
var salt = crypto.randomBytes(16);
var srpParams = srp.params["3072"];
srp.genKey(32, (error: Error, key: Buffer) => {
// create a new SRP server
var srpServer = new srp.Server(srpParams, bufferShim.from(salt), bufferShim.from("Pair-Setup"), bufferShim.from(this.accessoryInfo.pincode), key);
var srpB = srpServer.computeB();
// attach it to the current TCP session
session.srpServer = srpServer;
response.writeHead(200, {"Content-Type": "application/pairing+tlv8"});
response.end(tlv.encode(TLVValues.SEQUENCE_NUM, States.M2, TLVValues.SALT, salt, TLVValues.PUBLIC_KEY, srpB));
session._pairSetupState = States.M2;
});
}