Main Content

mavlinksigning

Store MAVLink signing channel information

Since R2022a

    Description

    The mavlinksigning enables you protect UAVs from unauthorized communication using message signing. Use this object to store up to 16 MAVLink signing channels, and use the addmavlinkkeys, lsmavlinkkeys, rmmavlinkkeys functions to add, list, and remove MAVLink keys in the current MATLAB session for use with signing channels.

    Note

    Note that message signing is not the same as message encryption. MAVLink does not provide message encryption. See MAVLink Message Signing (Authentication) for more details about MAVLink message signing.

    Creation

    Description

    stream = mavlinksigning creates a mavlinksigning object to store signing channels.

    example

    Object Functions

    addChannelAdd MAVLink signing channel
    removeChannelRemove MAVLink signing channel

    Examples

    collapse all

    Create a mavlinksigning object to store MAVLink signing channels.

    stream = mavlinksigning;

    Load and list the keys from the keys.env file.

    addmavlinkkeys("keys.env");
    lsmavlinkkeys
    ans = 1x2 string
        "Key1"    "Key2"
    
    

    Add channel with a system ID of 1, component ID of 2, link ID of 3.

    addChannel(stream,1,2,3,"Key1")
    ans = struct with fields:
              Stream: [1x1 mavlinksigning]
            SystemID: 1
         ComponentID: 2
              LinkID: 3
                 Key: "Key1"
           Timestamp: 30146033496224
        CreationTime: 21-Jul-2024 02:58:54
    
    

    Remove the same channel.

    removeChannel(stream,1,2,3)

    Add MAVLink signing keys from the keys.env file to the MATLAB session.

    addmavlinkkeys("keys.env")
    lsmavlinkkeys
    ans = 1x2 string
        "Key1"    "Key2"
    
    

    Create MAVLink signing streams for UAV and the ground control system.

    signingStream = mavlinksigning;
    signingChannelUAV = signingStream.addChannel(1,1,1,"Key1");
    signingChannelGCS =  signingStream.addChannel(255,1,1,"Key1");

    Create signed dialect and MAVLink IO object.

    dialectUAV = mavlinkdialect("common.xml",2,SigningChannel=signingChannelUAV);
    dialectGCS = mavlinkdialect("common.xml",2,SigningChannel=signingChannelGCS);
    ioUAV = mavlinkio(dialectUAV);

    Create signed message and display the signature at the end of the buffer.

    msg = dialectUAV.createmsg("HEARTBEAT");
    buffer = ioUAV.serializemsg(msg)
    buffer = 1x34 uint8 row vector
    
       253     9     1     0     0     1     1     0     0     0     0     0     0     0     0     0     0     0     3    86    89     1    87    59    91   237   106    27   231   189    59    26    47   220
    
    

    Read the signed message.

    [msgReceived,status] = dialectGCS.deserializemsg(buffer,OutputAllMessages=true)
    msgReceived = struct with fields:
              MsgID: 0
           SystemID: 1
        ComponentID: 1
            Payload: [1x1 struct]
                Seq: 0
    
    
    status = 
    0
    

    Version History

    Introduced in R2022a