Exemplo n.º 1
0
 protected override void DeserializePayload(BEReader reader)
 {
     Flags       = (DeviceFlags)reader.ReadUInt32();
     DeviceType  = (DeviceType)reader.ReadUInt16();
     Name        = reader.ReadString();
     HardwareId  = Guid.Parse(reader.ReadString());
     LastError   = reader.ReadUInt32();
     Certificate = CryptoExtensions.DeserializeCertificateAsn(reader.ReadBlob());
 }
Exemplo n.º 2
0
        public void TestCryptoSetup()
        {
            byte[] cert = ResourcesProvider.GetBytes("selfsigned_cert.bin", ResourceType.Misc);
            var    x509 = CryptoExtensions.DeserializeCertificateAsn(cert);

            CryptoContext context = new CryptoContext(x509);

            Assert.NotNull(context);
            Assert.Equal <PublicKeyType>(PublicKeyType.EC_DH_P256, context.PublicKeyType);
        }
Exemplo n.º 3
0
        public void TestCertificateDeserialize()
        {
            byte[] cert      = ResourcesProvider.GetBytes("selfsigned_cert.bin", ResourceType.Misc);
            var    x509      = CryptoExtensions.DeserializeCertificateAsn(cert);
            var    publicKey = x509.GetPublicKey();

            Assert.NotNull(x509);
            Assert.Equal <int>(3, x509.Version);
            Assert.Equal <string>("CN=Rust", x509.IssuerDN.ToString());
            Assert.Equal <string>("CN=FFFFFFFFFFF", x509.SubjectDN.ToString());
            Assert.NotNull(publicKey);
        }
Exemplo n.º 4
0
        public DeviceTests()
        {
            byte[] cert     = ResourcesProvider.GetBytes("selfsigned_cert.bin", ResourceType.Misc);
            byte[] msgBytes = ResourcesProvider.GetBytes("presence_response.bin", ResourceType.SmartGlass);
            var    x509     = CryptoExtensions.DeserializeCertificateAsn(cert);

            _presenceResponse = new PresenceResponseMessage();
            using (EndianReader er = new EndianReader(msgBytes))
            {
                _presenceResponse.Deserialize(er);
            }
            _presenceResponse.Origin = new IPEndPoint(IPAddress.Parse("192.168.1.2"), 5234);

            _deviceManual = new Device(
                DeviceType.XboxOne,
                IPAddress.Parse("192.168.1.3"),
                "XboxOne",
                "FD0123456789",
                new Guid("de305d54-75b4-431b-adb2-eb6b9e546014")
                );

            _deviceFromResponse = new Device(_presenceResponse);
        }