コード例 #1
0
        public bool setupSigning(string userseed)
        {
            // sha the user input string
            SHA256Managed signit = new SHA256Managed();
            var shauser = signit.ComputeHash(Encoding.UTF8.GetBytes(userseed));
            Array.Resize(ref shauser, 32);

            signingKey = shauser;

            mavlink_setup_signing_t sign = new mavlink_setup_signing_t();
            sign.initial_timestamp = (UInt64)((DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalMilliseconds*1000);
            sign.secret_key = shauser;
            sign.target_component = (byte)compidcurrent;
            sign.target_system = (byte)sysidcurrent;

            generatePacket((int)MAVLINK_MSG_ID.SETUP_SIGNING, sign);

            generatePacket((int)MAVLINK_MSG_ID.SETUP_SIGNING, sign);

            return enableSigning();
        }
コード例 #2
0
        public bool setupSigning(string userseed)
        {
            bool clearkey = String.IsNullOrEmpty(userseed);
            
            // sha the user input string
            SHA256Managed signit = new SHA256Managed();
            var shauser = signit.ComputeHash(Encoding.UTF8.GetBytes(userseed));
            Array.Resize(ref shauser, 32);

            mavlink_setup_signing_t sign = new mavlink_setup_signing_t();
            if (!clearkey)
            {
                MAV.signingKey = shauser;
                sign.initial_timestamp = (UInt64) ((DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalMilliseconds*100);
                sign.secret_key = shauser;
            }
            else
            {
                MAV.signingKey = new byte[32];
                sign.initial_timestamp = 0;
                sign.secret_key = new byte[32];
            }
            sign.target_component = (byte)compidcurrent;
            sign.target_system = (byte)sysidcurrent;

            generatePacket((int) MAVLINK_MSG_ID.SETUP_SIGNING, sign, MAV.sysid, MAV.compid);

            generatePacket((int) MAVLINK_MSG_ID.SETUP_SIGNING, sign, MAV.sysid, MAV.compid);

            if (clearkey)
            {
                return disableSigning(sysidcurrent, compidcurrent);
            }

            return enableSigning(sysidcurrent, compidcurrent);
        }