Beispiel #1
0
        public UpdateForm(UpdateInfo info)
        {
            InitializeComponent();

            MessageLabel.Text = "DeOps needs to be restarted to finish updating to version " + info.DottedVersion;

            NotesBox.Text = info.Notes;
        }
Beispiel #2
0
        public DeOpsContext(string startupPath, Icon defaultIcon)
        {
            StartupPath = startupPath;
            DefaultIcon = defaultIcon;

            LookupConfig = new LookupSettings(startupPath);

            ContextThread = Thread.CurrentThread;

            // start timers
            SecondTimer = new Timer(SecondTimer_Tick, null, 0, 1000);

            SignedUpdate = UpdateService.LoadUpdate(LookupConfig);
        }
Beispiel #3
0
        public static UpdateInfo Decode(G2Header root)
        {
            // embedded public key of source we allow updates from
            RSACryptoServiceProvider UpdateSourcePublicKey = new RSACryptoServiceProvider() ;
            //UpdateSourcePublicKey.FromXmlString("<RSAKeyValue><Modulus>pTmHLSxyM9TDOM4tZzI5dld9JvPsHlHC/M5i0+Qtjid1DiefGAVubPToEhK9Im4Ohy37h5Ax6J3vt2pxLG4rnIDuKBJt70YH6W6XrJewQ6tid5BvVnNEzPUOIJHGMpOnyi0VjPpzZzWgp4JK6Yuh6LtsYwCyqIIJIBt9iQ/9XN0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");

            UpdateInfo info = new UpdateInfo();

            if (G2Protocol.ReadPayload(root))
                info.Embedded = Utilities.ExtractBytes(root.Data, root.PayloadPos, root.PayloadSize);

            G2Protocol.ResetPacket(root);

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
                if (G2Protocol.ReadPayload(child))
                    if(child.Name == Packet_Signature)
                        info.Signature = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);

            // verify signature
            byte[] pubKey = UpdateSourcePublicKey.ExportParameters(false).Modulus;
            if (!Utilities.CheckSignedData(pubKey, info.Embedded, info.Signature))
                return null;

            root = new G2Header(info.Embedded);
            if (!G2Protocol.ReadPacket(root))
                return null;

            child = new G2Header(info.Embedded);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                    continue;

                switch (child.Name)
                {
                    case Packet_Name:
                        info.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Key:
                        info.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Size:
                        info.Size = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Hash:
                        info.Hash = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Notes:
                        info.Notes = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Beginning:
                        info.Beginning = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_DottedVersion:
                        info.DottedVersion = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_SequentialVersion:
                        info.SequentialVersion = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                        break;
                }
            }

            info.TempName = Utilities.ToBase64String(info.Hash);

            return info;
        }
Beispiel #4
0
        public static UpdateInfo Decode(G2Header root)
        {
            // embedded public key of source we allow updates from
            RSACryptoServiceProvider UpdateSourcePublicKey = new RSACryptoServiceProvider();
            //UpdateSourcePublicKey.FromXmlString("<RSAKeyValue><Modulus>pTmHLSxyM9TDOM4tZzI5dld9JvPsHlHC/M5i0+Qtjid1DiefGAVubPToEhK9Im4Ohy37h5Ax6J3vt2pxLG4rnIDuKBJt70YH6W6XrJewQ6tid5BvVnNEzPUOIJHGMpOnyi0VjPpzZzWgp4JK6Yuh6LtsYwCyqIIJIBt9iQ/9XN0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");


            UpdateInfo info = new UpdateInfo();

            if (G2Protocol.ReadPayload(root))
            {
                info.Embedded = Utilities.ExtractBytes(root.Data, root.PayloadPos, root.PayloadSize);
            }

            G2Protocol.ResetPacket(root);

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (G2Protocol.ReadPayload(child))
                {
                    if (child.Name == Packet_Signature)
                    {
                        info.Signature = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    }
                }
            }


            // verify signature
            byte[] pubKey = UpdateSourcePublicKey.ExportParameters(false).Modulus;
            if (!Utilities.CheckSignedData(pubKey, info.Embedded, info.Signature))
            {
                return(null);
            }


            root = new G2Header(info.Embedded);
            if (!G2Protocol.ReadPacket(root))
            {
                return(null);
            }

            child = new G2Header(info.Embedded);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Name:
                    info.Name = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Key:
                    info.Key = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Size:
                    info.Size = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Hash:
                    info.Hash = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Notes:
                    info.Notes = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Beginning:
                    info.Beginning = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_DottedVersion:
                    info.DottedVersion = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_SequentialVersion:
                    info.SequentialVersion = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            info.TempName = Utilities.ToBase64String(info.Hash);

            return(info);
        }