How to use the fast-srp-hap.params function in fast-srp-hap

To help you get started, we’ve selected a few fast-srp-hap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evandcoleman / node-appletv / dist / lib / pairing.js View on Github external
completePairing(pin) {
        this.srp = srp.Client(srp.params['3072'], this.deviceSalt, Buffer.from('Pair-Setup'), Buffer.from(pin), this.key);
        this.srp.setB(this.devicePublicKey);
        this.publicKey = this.srp.computeA();
        this.proof = this.srp.computeM1();
        // console.log("DEBUG: Client Public Key=" + this.publicKey.toString('hex') + "\nProof=" + this.proof.toString('hex'));
        let that = this;
        let tlvData = tlv_1.default.encode(tlv_1.default.Tag.Sequence, 0x03, tlv_1.default.Tag.PublicKey, that.publicKey, tlv_1.default.Tag.Proof, that.proof);
        let message = {
            status: 0,
            pairingData: tlvData
        };
        return this.device
            .sendMessage('CryptoPairingMessage', 'CryptoPairingMessage', message, false)
            .then(() => {
            return that.waitForSequence(0x04);
        })
            .then(message => {
github evandcoleman / node-appletv / src / lib / pairing.ts View on Github external
private completePairing(pin: string): Promise {
    this.srp = srp.Client(
      srp.params['3072'],
      this.deviceSalt,
      Buffer.from('Pair-Setup'),
      Buffer.from(pin),
      this.key
    );
    this.srp.setB(this.devicePublicKey);
    this.publicKey = this.srp.computeA();
    this.proof = this.srp.computeM1();

    // console.log("DEBUG: Client Public Key=" + this.publicKey.toString('hex') + "\nProof=" + this.proof.toString('hex'));

    let that = this;
    let tlvData = tlv.encode(
      tlv.Tag.Sequence, 0x03,
      tlv.Tag.PublicKey, that.publicKey,
      tlv.Tag.Proof, that.proof
github hensm / fx_cast / app / src / bridge / airplay / auth.ts View on Github external
public async finishPairing (pin: string) {
        // Stage 1 response
        const { pk: serverPk
              , salt: serverSalt } = await this.pairSetupPin1();

        // SRP params must 2048-bit SHA1
        const srpParams = srp6a.params[2048];
        srpParams.hash = "sha1";

        // Create SRP client
        const srpClient = new srp6a.Client(
                srpParams                                // Params
              , serverSalt                               // Receiver salt
              , Buffer.from(this.credentials.clientId)   // Username
              , Buffer.from(pin)                         // Password (receiver pin)
              , Buffer.from(this.credentials.clientSk)); // Client secret key

        // Add receiver's public key
        srpClient.setB(serverPk);

        // Stage 2 response
        await this.pairSetupPin2(
                srpClient.computeA()    // SRP public key
github KhaosT / HAP-NodeJS / src / lib / HAPServer.ts View on Github external
_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;
    });
  }
github grover / homebridge-ranger / src / hap / pairing / PairSetup.js View on Github external
constructor(log, attributeDatabase, pin) {
    this.log = log;

    this._state = 0;
    this._acknowledgeFragment = false;
    this._address = {
      service: '000000550000100080000026bb765291',
      characteristic: '0000004c0000100080000026bb765291'
    };
    this._cid = attributeDatabase.getCharacteristic(this._address).cid;
    this._encryptionKey;
    this._error = undefined;
    this._key = crypto.randomBytes(32);
    this._params = srp.params["3072"];
    this._pin = pin;
    this._srp;
    this._rangerPairingID;
    this._rangerPublicKey;
    this._rangerProof;
    this._rangerLTPK;
    this._rangerLTSK;
    this._reassemblyBuffer = Buffer.alloc(0);
    this._srpSharedSecret;
  }

fast-srp-hap

Secure Remote Password (SRP)

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages