Example #1
0
        public static byte[] _SRP_Salt; //session salt

        private byte[] handlePairStepOne(List <TypeValue> requestValue)
        {
            _SRP_Salt = SRP.s();

            _SRP_b = SRP.b();
            var vBytes    = Encoding.UTF8.GetBytes("Pair-Setup");
            var publicKey = SRP.B(_SRP_b, vBytes);


            var sequence = new HomeKit.Protocol.TypeLengthValue.TypeLengthValue.TypeValue()
            {
                Type = kTLVType_State.Type, Value = new byte[] { 0x02 }
            };
            var saltMessage = new HomeKit.Protocol.TypeLengthValue.TypeLengthValue.TypeValue()
            {
                Type = kTLVType_Salt.Type, Value = _SRP_Salt
            };
            var publicKeyMessage = new HomeKit.Protocol.TypeLengthValue.TypeLengthValue.TypeValue()
            {
                Type = kTLVType_PublicKey.Type, Value = publicKey
            };

            var result = HomeKit.Protocol.TypeLengthValue.TypeLengthValue.Encode(sequence, saltMessage, publicKeyMessage);

            return(result);
        }
Example #2
0
        private byte[] TestErrorResponse()
        {
            //spec says should abort user
            var statem2 = new HomeKit.Protocol.TypeLengthValue.TypeLengthValue.TypeValue()
            {
                Type = kTLVType_State.Type, Value = new byte[] { 0x02 }
            };
            var erro = new HomeKit.Protocol.TypeLengthValue.TypeLengthValue.TypeValue()
            {
                Type = kTLVType_Error.Type, Value = new byte[] { 0x07 }
            };
            var response = HomeKit.Protocol.TypeLengthValue.TypeLengthValue.Encode(statem2, erro);

            return(response);
            //byte[] control = new byte[] {
            //    0x06,0x01,0x02, //State M2
            //    0x07, 0x01, 0x07, //Error BUSY
            //};
        }