Enabling mavlink 2.0 packet and Signing with pymavlink library

I am trying to set up an authentication over mavlink 2.0 packet with its inbuilt signature feature, But
having a problem while setting up the initial parameter with pymavlink library

I learned for the other sources that to set signing in mavlink 2.0 packet, we need to configure 3 parameters
1)Timestamp
2)Secret Key
3)Link-ID

In my case, I am taking timestamp directly from pixhawk which is having GPS on it, and using the same timestamp to create a signature for my arm_diarm mavlink 2.0 packet. For the dummy case, I am using sceret_key=‘x’ and link_id=0 while generating the packet, However, the pixhawk in which I have added the same secret key from the mission planner is discarding the signing packet.

I am attaching my code screenshot

Can anyone help in solving it,I believe I am setting wrong link_id value

Are you using the latest ArduCopter and pymavlink versions?

@amilcarlucas

Yes, I am using the latest Arducopter and pymavlink version

I actually found that a mission planner uses an input seed to generate a secret key. Earlier I thought that the input seed is itself is the secret key. So, I was setting the wrong secret key value from pymavlink side.
However, I am still struggling to find the secret key value set by mission planner that i can use in pymavlink script

Can help me!!

@samarth_kapila
I am facing the same issue in the simulation.

If I setup_signing using pymavlink and setup a key as bytearray(‘A’*32, ‘utf-8’ ) over udp connection and then pass the same key i.e AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA to my MP(mission planner) over tcp. It simply throws an error “INFO MissionPlanner.MAVLinkInterface - Packet failed signature but passed crc”.

Also I am not able to disable signing after disarm using pymavlinks setup_signing command.
Even if I create a setup_signing messages with secret as all zeroes and time stamp as zero it still uses it as a key. The signing is not disabled. I have to pass a mavproxy command to remove keys and diable signing i.e “signing remove key” .

import time
from pymavlink import mavutil
from pymavlink.dialects.v10 import ardupilotmega as mavlink1
from pymavlink.dialects.v20 import ardupilotmega as mavlink2
from drone_command import take_off,rth
drone=mavutil.mavlink_connection("127.0.0.1:14550")
a=drone.wait_heartbeat()
print(a)
key = bytearray("A"*32, 'utf-8' )
print(key)

sign=mavlink2.MAVLink_setup_signing_message(
    secret_key = key,
    target_component=drone.target_component,
    target_system=drone.target_system,
    initial_timestamp=0
)
# to start signing 
drone.mav.send(sign)
time.sleep(2)
take_off(drone=drone)
time.sleep(10)
rth(drone=drone)
time.sleep(15)

#to undo signing and regain tcp GCS connection 
drone.setup_signing(
    secret_key = key,
    initial_timestamp=0,
    sign_outgoing=True,
)

Pls lemme know if it is a programmatical error or am i missing something ??