GstMIKEYMessage: GStreamer Base Plugins Library Reference Manual

## GstMIKEYMessage GstMIKEYMessage — Helper methods for dealing with MIKEY messages |

## Functions

GstMIKEYMessage * | gst_mikey_message_new ()
GstMIKEYMessage * | gst_mikey_message_new_from_bytes ()
GstMIKEYMessage * | gst_mikey_message_new_from_caps ()
GstMIKEYMessage * | gst_mikey_message_new_from_data ()
GBytes * | gst_mikey_message_to_bytes ()
gboolean | gst_mikey_message_to_caps ()
gchar * | gst_mikey_message_base64_encode ()
GstMIKEYMessage * | gst_mikey_message_copy ()
GstMIKEYMessage * | gst_mikey_message_ref ()
void | gst_mikey_message_unref ()
gboolean | gst_mikey_message_set_info ()
guint | gst_mikey_message_get_n_cs ()
const GstMIKEYMapSRTP * | gst_mikey_message_get_cs_srtp ()
gboolean | gst_mikey_message_insert_cs_srtp ()
gboolean | gst_mikey_message_remove_cs_srtp ()
gboolean | gst_mikey_message_replace_cs_srtp ()
gboolean | gst_mikey_message_add_cs_srtp ()
guint | gst_mikey_message_get_n_payloads ()
const GstMIKEYPayload * | gst_mikey_message_get_payload ()
const GstMIKEYPayload * | gst_mikey_message_find_payload ()
gboolean | gst_mikey_message_insert_payload ()
gboolean | gst_mikey_message_remove_payload ()
gboolean | gst_mikey_message_replace_payload ()
gboolean | gst_mikey_message_add_payload ()
GstMIKEYPayload * | gst_mikey_payload_new ()
GstMIKEYPayload * | gst_mikey_payload_copy ()
gboolean | gst_mikey_payload_key_data_set_interval ()
gboolean | gst_mikey_payload_key_data_set_key ()
gboolean | gst_mikey_payload_key_data_set_salt ()
gboolean | gst_mikey_payload_key_data_set_spi ()
GstMIKEYPayload * | gst_mikey_payload_ref ()
void | gst_mikey_payload_unref ()
gboolean | gst_mikey_payload_kemac_set ()
gboolean | gst_mikey_payload_kemac_add_sub ()
guint | gst_mikey_payload_kemac_get_n_sub ()
const GstMIKEYPayload * | gst_mikey_payload_kemac_get_sub ()
gboolean | gst_mikey_payload_kemac_remove_sub ()
gboolean | gst_mikey_payload_pke_set ()
gboolean | gst_mikey_message_add_pke ()
gboolean | gst_mikey_payload_t_set ()
gboolean | gst_mikey_message_add_t ()
gboolean | gst_mikey_message_add_t_now_ntp_utc ()
gboolean | gst_mikey_payload_rand_set ()
gboolean | gst_mikey_message_add_rand ()
gboolean | gst_mikey_message_add_rand_len ()
gboolean | gst_mikey_payload_sp_set ()
guint | gst_mikey_payload_sp_get_n_params ()
const GstMIKEYPayloadSPParam * | gst_mikey_payload_sp_get_param ()
gboolean | gst_mikey_payload_sp_add_param ()
gboolean | gst_mikey_payload_sp_remove_param ()

## Types and Values

#define | GST_MIKEY_VERSION
enum | GstMIKEYType
struct | GstMIKEYMessage
| GstMIKEYDecryptInfo
| GstMIKEYEncryptInfo
enum | GstMIKEYPRFFunc
enum | GstMIKEYMapType
| GstMIKEYMapSRTP
enum | GstMIKEYKVType
enum | GstMIKEYKeyDataType
| GstMIKEYPayloadKeyData
enum | GstMIKEYPayloadType
struct | GstMIKEYPayload
enum | GstMIKEYEncAlg
enum | GstMIKEYMacAlg
| GstMIKEYPayloadKEMAC
enum | GstMIKEYCacheType
| GstMIKEYPayloadPKE
enum | GstMIKEYTSType
| GstMIKEYPayloadT
| GstMIKEYPayloadRAND
enum | GstMIKEYSecProto
enum | GstMIKEYSecSRTP
| GstMIKEYPayloadSP
| GstMIKEYPayloadSPParam

## Includes

    #include <gst/sdp/sdp.h>

## Description

The GstMIKEY helper functions makes it easy to parse and create MIKEY messages.

## Functions

### gst_mikey_message_new ()

    GstMIKEYMessage *
    gst_mikey_message_new (void);

Make a new MIKEY message.

#### Returns

a new GstMIKEYMessage on success

Since: 1.4

### gst_mikey_message_new_from_bytes ()

    GstMIKEYMessage *
    gst_mikey_message_new_from_bytes (GBytes *bytes,
                                      GstMIKEYDecryptInfo *info,
                                      GError **error);

Make a new GstMIKEYMessage from `bytes` .

#### Parameters

bytes | a GBytes |
info | a GstMIKEYDecryptInfo |
error | a GError |

#### Returns

a new GstMIKEYMessage

Since: 1.4

### gst_mikey_message_new_from_caps ()

    GstMIKEYMessage *
    gst_mikey_message_new_from_caps (GstCaps *caps);

Makes mikey message including:

- Security Policy Payload

- Key Data Transport Payload

- Key Data Sub-Payload

#### Parameters

caps | a GstCaps, including SRTP parameters (srtp/srtcp cipher, authorization, key data) |

#### Returns

a GstMIKEYMessage, or `NULL` if there is no srtp information in the caps.

[transfer full]

Since: 1.8

### gst_mikey_message_new_from_data ()

    GstMIKEYMessage *
    gst_mikey_message_new_from_data (gconstpointer data,
                                     gsize size,
                                     GstMIKEYDecryptInfo *info,
                                     GError **error);

Parse `size` bytes from `data` into a GstMIKEYMessage. `info` contains the parameters to decrypt and verify the data.

#### Parameters

data | bytes to read. | [array length=size][element-type guint8]
size | length of `data` |
info | GstMIKEYDecryptInfo |
error | a GError |

#### Returns

a GstMIKEYMessage on success or `NULL` when parsing failed and `error` will be set.

Since: 1.4

### gst_mikey_message_to_bytes ()

    GBytes *
    gst_mikey_message_to_bytes (GstMIKEYMessage *msg,
                                GstMIKEYEncryptInfo *info,
                                GError **error);

Convert `msg` to a GBytes.

#### Parameters

msg | a GstMIKEYMessage |
info | a GstMIKEYEncryptInfo |
error | a GError |

#### Returns

a new GBytes for `msg` .

Since: 1.4

### gst_mikey_message_to_caps ()

    gboolean
    gst_mikey_message_to_caps (const GstMIKEYMessage *msg,
                               GstCaps *caps);

#### Parameters

msg | a GstMIKEYMessage |
caps | a GstCaps to be filled with SRTP parameters (srtp/srtcp cipher, authorization, key data) |

#### Returns

`TRUE` on success

Since: 1.8.1

### gst_mikey_message_base64_encode ()

    gchar *
    gst_mikey_message_base64_encode (GstMIKEYMessage *msg);

#### Parameters

msg | a GstMIKEYMessage |

#### Returns

a gchar, base64-encoded data.

[transfer full]

Since: 1.8

### gst_mikey_message_copy ()

    GstMIKEYMessage *
    gst_mikey_message_copy (const GstMIKEYMessage *message);

Create a copy of the given message.

#### Parameters

message | a GstMIKEYMessage. |

#### Returns

a new copy of `message` .

[transfer full]

Since: 1.4

### gst_mikey_message_ref ()

    GstMIKEYMessage *
    gst_mikey_message_ref (GstMIKEYMessage *message);

Increase the refcount of this message.

#### Parameters

message | The message to refcount |

#### Returns

`message` (for convenience when doing assignments).

[transfer full]

Since: 1.4

### gst_mikey_message_unref ()

    void
    gst_mikey_message_unref (GstMIKEYMessage *message);

Decrease the refcount of an message, freeing it if the refcount reaches 0.

#### Parameters

message | the message to refcount. | [transfer full]

Since: 1.4

### gst_mikey_message_set_info ()

    gboolean
    gst_mikey_message_set_info (GstMIKEYMessage *msg,
                                guint8 version,
                                GstMIKEYType type,
                                gboolean V,
                                GstMIKEYPRFFunc prf_func,
                                guint32 CSB_id,
                                GstMIKEYMapType map_type);

Set the information in `msg` .

#### Parameters

msg | a GstMIKEYMessage |
version | a version |
type | a GstMIKEYType |
V | verify flag |
prf_func | the GstMIKEYPRFFunc function to use |
CSB_id | the Crypto Session Bundle id |
map_type | the GstMIKEYMapType |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_get_n_cs ()

    guint
    gst_mikey_message_get_n_cs (const GstMIKEYMessage *msg);

Get the number of crypto sessions in `msg` .

#### Parameters

msg | a GstMIKEYMessage |

#### Returns

the number of crypto sessions

Since: 1.4

### gst_mikey_message_get_cs_srtp ()

    const GstMIKEYMapSRTP *
    gst_mikey_message_get_cs_srtp (const GstMIKEYMessage *msg,
                                   guint idx);

Get the policy information of `msg` at `idx` .

#### Parameters

msg | a GstMIKEYMessage |
idx | an index |

#### Returns

a GstMIKEYMapSRTP

Since: 1.4

### gst_mikey_message_insert_cs_srtp ()

    gboolean
    gst_mikey_message_insert_cs_srtp (GstMIKEYMessage *msg,
                                      gint idx,
                                      const GstMIKEYMapSRTP *map);

Insert a Crypto Session map for SRTP in `msg` at `idx`

When `idx` is -1, the policy will be appended.

#### Parameters

msg | a GstMIKEYMessage |
idx | the index to insert at |
map | the map info |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_remove_cs_srtp ()

    gboolean
    gst_mikey_message_remove_cs_srtp (GstMIKEYMessage *msg,
                                      gint idx);

Remove the SRTP policy at `idx` .

#### Parameters

msg | a GstMIKEYMessage |
idx | the index to remove |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_replace_cs_srtp ()

    gboolean
    gst_mikey_message_replace_cs_srtp (GstMIKEYMessage *msg,
                                       gint idx,
                                       const GstMIKEYMapSRTP *map);

Replace a Crypto Session map for SRTP in `msg` at `idx` with `map` .

#### Parameters

msg | a GstMIKEYMessage |
idx | the index to insert at |
map | the map info |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_cs_srtp ()

    gboolean
    gst_mikey_message_add_cs_srtp (GstMIKEYMessage *msg,
                                   guint8 policy,
                                   guint32 ssrc,
                                   guint32 roc);

Add a Crypto policy for SRTP to `msg` .

#### Parameters

msg | a GstMIKEYMessage |
policy | The security policy applied for the stream with `ssrc` |
ssrc | the SSRC that must be used for the stream |
roc | current rollover counter |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_get_n_payloads ()

    guint
    gst_mikey_message_get_n_payloads (const GstMIKEYMessage *msg);

Get the number of payloads in `msg` .

#### Parameters

msg | a GstMIKEYMessage |

#### Returns

the number of payloads in `msg`

Since: 1.4

### gst_mikey_message_get_payload ()

    const GstMIKEYPayload *
    gst_mikey_message_get_payload (const GstMIKEYMessage *msg,
                                   guint idx);

Get the GstMIKEYPayload at `idx` in `msg`

#### Parameters

msg | a GstMIKEYMessage |
idx | an index |

#### Returns

the GstMIKEYPayload at `idx` . The payload remains valid for as long as it is part of `msg` .

[transfer none]

Since: 1.4

### gst_mikey_message_find_payload ()

    const GstMIKEYPayload *
    gst_mikey_message_find_payload (const GstMIKEYMessage *msg,
                                    GstMIKEYPayloadType type,
                                    guint nth);

Find the `nth` occurence of the payload with `type` in `msg` .

#### Parameters

msg | a GstMIKEYMessage |
type | a GstMIKEYPayloadType |
nth | payload to find |

#### Returns

the `nth` GstMIKEYPayload of `type` .

Since: 1.4

### gst_mikey_message_insert_payload ()

    gboolean
    gst_mikey_message_insert_payload (GstMIKEYMessage *msg,
                                      guint idx,
                                      GstMIKEYPayload *payload);

Insert the `payload` at index `idx` in `msg` . If `idx` is -1, the payload will be appended to `msg` .

#### Parameters

msg | a GstMIKEYMessage |
idx | an index |
payload | a GstMIKEYPayload. | [transfer full]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_remove_payload ()

    gboolean
    gst_mikey_message_remove_payload (GstMIKEYMessage *msg,
                                      guint idx);

Remove the payload in `msg` at `idx`

#### Parameters

msg | a GstMIKEYMessage |
idx | an index |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_replace_payload ()

    gboolean
    gst_mikey_message_replace_payload (GstMIKEYMessage *msg,
                                       guint idx,
                                       GstMIKEYPayload *payload);

Replace the payload at `idx` in `msg` with `payload` .

#### Parameters

msg | a GstMIKEYMessage |
idx | an index |
payload | a GstMIKEYPayload. | [transfer full]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_payload ()

    gboolean
    gst_mikey_message_add_payload (GstMIKEYMessage *msg,
                                   GstMIKEYPayload *payload);

Add a new payload to `msg` .

#### Parameters

msg | a GstMIKEYMessage |
payload | a GstMIKEYPayload. | [transfer full]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_new ()

    GstMIKEYPayload *
    gst_mikey_payload_new (GstMIKEYPayloadType type);

Make a new GstMIKEYPayload with `type` .

#### Parameters

type | a GstMIKEYPayloadType |

#### Returns

a new GstMIKEYPayload or `NULL` on failure.

[nullable]

Since: 1.4

### gst_mikey_payload_copy ()

    GstMIKEYPayload *
    gst_mikey_payload_copy (const GstMIKEYPayload *payload);

Create a copy of the given payload.

#### Parameters

payload | a GstMIKEYPayload. |

#### Returns

a new copy of `payload` .

[transfer full]

Since: 1.4

### gst_mikey_payload_key_data_set_interval ()

    gboolean
    gst_mikey_payload_key_data_set_interval
                                   (GstMIKEYPayload *payload,
                                    guint8 vf_len,
                                    const guint8 *vf_data,
                                    guint8 vt_len,
                                    const guint8 *vt_data);

Set the key validity period in the `GST_MIKEY_PT_KEY_DATA` `payload` .

#### Parameters

payload | a GstMIKEYPayload |
vf_len | the length of `vf_data` |
vf_data | the Valid From data. | [array length=vf_data]
vt_len | the length of `vt_data` |
vt_data | the Valid To data. | [array length=vt_len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_key_data_set_key ()

    gboolean
    gst_mikey_payload_key_data_set_key (GstMIKEYPayload *payload,
                                        GstMIKEYKeyDataType key_type,
                                        guint16 key_len,
                                        const guint8 *key_data);

Set `key_len` bytes of `key_data` of type `key_type` as the key for the `GST_MIKEY_PT_KEY_DATA` `payload` .

#### Parameters

payload | a GstMIKEYPayload |
key_type | a GstMIKEYKeyDataType |
key_len | the length of `key_data` |
key_data | the key of type `key_type` . | [array length=key_len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_key_data_set_salt ()

    gboolean
    gst_mikey_payload_key_data_set_salt (GstMIKEYPayload *payload,
                                         guint16 salt_len,
                                         const guint8 *salt_data);

Set the salt key data. If `salt_len` is 0 and `salt_data` is `NULL`, the salt data will be removed.

#### Parameters

payload | a GstMIKEYPayload |
salt_len | the length of `salt_data` |
salt_data | the salt. | [array length=salt_len][allow-none]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_key_data_set_spi ()

    gboolean
    gst_mikey_payload_key_data_set_spi (GstMIKEYPayload *payload,
                                        guint8 spi_len,
                                        const guint8 *spi_data);

Set the SPI/MKI validity in the `GST_MIKEY_PT_KEY_DATA` `payload` .

#### Parameters

payload | a GstMIKEYPayload |
spi_len | the length of `spi_data` |
spi_data | the SPI/MKI data. | [array length=spi_len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_ref ()

    GstMIKEYPayload *
    gst_mikey_payload_ref (GstMIKEYPayload *payload);

Increase the refcount of this payload.

#### Parameters

payload | The payload to refcount |

#### Returns

`payload` (for convenience when doing assignments).

[transfer full]

Since: 1.4

### gst_mikey_payload_unref ()

    void
    gst_mikey_payload_unref (GstMIKEYPayload *payload);

Decrease the refcount of an payload, freeing it if the refcount reaches 0.

#### Parameters

payload | the payload to refcount. | [transfer full]

Since: 1.4

### gst_mikey_payload_kemac_set ()

    gboolean
    gst_mikey_payload_kemac_set (GstMIKEYPayload *payload,
                                 GstMIKEYEncAlg enc_alg,
                                 GstMIKEYMacAlg mac_alg);

Set the KEMAC parameters. `payload` should point to a `GST_MIKEY_PT_KEMAC` payload.

#### Parameters

payload | a GstMIKEYPayload |
enc_alg | the GstMIKEYEncAlg |
mac_alg | a GstMIKEYMacAlg |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_kemac_add_sub ()

    gboolean
    gst_mikey_payload_kemac_add_sub (GstMIKEYPayload *payload,
                                     GstMIKEYPayload *newpay);

Add a new sub payload to `payload` .

#### Parameters

payload | a GstMIKEYPayload |
newpay | a GstMIKEYPayload to add. | [transfer full]

#### Returns

`TRUE` on success.

Since: 1.4

### gst_mikey_payload_kemac_get_n_sub ()

    guint
    gst_mikey_payload_kemac_get_n_sub (const GstMIKEYPayload *payload);

Get the number of sub payloads of `payload` . `payload` should be of type `GST_MIKEY_PT_KEMAC`.

#### Parameters

payload | a GstMIKEYPayload |

#### Returns

the number of sub payloads in `payload`

Since: 1.4

### gst_mikey_payload_kemac_get_sub ()

    const GstMIKEYPayload *
    gst_mikey_payload_kemac_get_sub (const GstMIKEYPayload *payload,
                                     guint idx);

Get the sub payload of `payload` at `idx` . `payload` should be of type `GST_MIKEY_PT_KEMAC`.

#### Parameters

payload | a GstMIKEYPayload |
idx | an index |

#### Returns

the GstMIKEYPayload at `idx` .

[transfer none]

Since: 1.4

### gst_mikey_payload_kemac_remove_sub ()

    gboolean
    gst_mikey_payload_kemac_remove_sub (GstMIKEYPayload *payload,
                                        guint idx);

Remove the sub payload at `idx` in `payload` .

#### Parameters

payload | a GstMIKEYPayload |
idx | the index to remove |

#### Returns

`TRUE` on success.

Since: 1.4

### gst_mikey_payload_pke_set ()

    gboolean
    gst_mikey_payload_pke_set (GstMIKEYPayload *payload,
                               GstMIKEYCacheType C,
                               guint16 data_len,
                               const guint8 *data);

Set the PKE values in `payload` . `payload` must be of type `GST_MIKEY_PT_PKE`.

#### Parameters

payload | a GstMIKEYPayload |
C | envelope key cache indicator |
data_len | the length of `data` |
data | the encrypted envelope key. | [array length=data_len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_pke ()

    gboolean
    gst_mikey_message_add_pke (GstMIKEYMessage *msg,
                               GstMIKEYCacheType C,
                               guint16 data_len,
                               const guint8 *data);

Add a new PKE payload to `msg` with the given parameters.

#### Parameters

msg | a GstMIKEYMessage |
C | envelope key cache indicator |
data_len | the length of `data` |
data | the encrypted envelope key. | [array length=data_len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_t_set ()

    gboolean
    gst_mikey_payload_t_set (GstMIKEYPayload *payload,
                             GstMIKEYTSType type,
                             const guint8 *ts_value);

Set the timestamp in a `GST_MIKEY_PT_T` `payload` .

#### Parameters

payload | a GstMIKEYPayload |
type | the GstMIKEYTSType |
ts_value | the timestamp value. | [array]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_t ()

    gboolean
    gst_mikey_message_add_t (GstMIKEYMessage *msg,
                             GstMIKEYTSType type,
                             const guint8 *ts_value);

Add a new T payload to `msg` with the given parameters.

#### Parameters

msg | a GstMIKEYMessage |
type | specifies the timestamp type used |
ts_value | The timestamp value of the specified `type` . | [array]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_t_now_ntp_utc ()

    gboolean
    gst_mikey_message_add_t_now_ntp_utc (GstMIKEYMessage *msg);

Add a new T payload to `msg` that contains the current time in NTP-UTC format.

#### Parameters

msg | a GstMIKEYMessage |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_rand_set ()

    gboolean
    gst_mikey_payload_rand_set (GstMIKEYPayload *payload,
                                guint8 len,
                                const guint8 *rand);

Set the random values in a `GST_MIKEY_PT_RAND` `payload` .

#### Parameters

payload | a GstMIKEYPayload |
len | the length of `rand` |
rand | random values. | [array length=len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_rand ()

    gboolean
    gst_mikey_message_add_rand (GstMIKEYMessage *msg,
                                guint8 len,
                                const guint8 *rand);

Add a new RAND payload to `msg` with the given parameters.

#### Parameters

msg | a GstMIKEYMessage |
len | the length of `rand` |
rand | random data. | [array length=len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_message_add_rand_len ()

    gboolean
    gst_mikey_message_add_rand_len (GstMIKEYMessage *msg,
                                    guint8 len);

Add a new RAND payload to `msg` with `len` random bytes.

#### Parameters

msg | a GstMIKEYMessage |
len | length |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_sp_set ()

    gboolean
    gst_mikey_payload_sp_set (GstMIKEYPayload *payload,
                              guint policy,
                              GstMIKEYSecProto proto);

Set the Security Policy parameters for `payload` .

#### Parameters

payload | a GstMIKEYPayload |
policy | the policy number |
proto | a GstMIKEYSecProto |

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_sp_get_n_params ()

    guint
    gst_mikey_payload_sp_get_n_params (const GstMIKEYPayload *payload);

Get the number of security policy parameters in a `GST_MIKEY_PT_SP` `payload` .

#### Parameters

payload | a GstMIKEYPayload |

#### Returns

the number of parameters in `payload`

Since: 1.4

### gst_mikey_payload_sp_get_param ()

    const GstMIKEYPayloadSPParam *
    gst_mikey_payload_sp_get_param (const GstMIKEYPayload *payload,
                                    guint idx);

Get the Security Policy parameter in a `GST_MIKEY_PT_SP` `payload` at `idx` .

#### Parameters

payload | a GstMIKEYPayload |
idx | an index |

#### Returns

the GstMIKEYPayloadSPParam at `idx` in `payload`

Since: 1.4

### gst_mikey_payload_sp_add_param ()

    gboolean
    gst_mikey_payload_sp_add_param (GstMIKEYPayload *payload,
                                    guint8 type,
                                    guint8 len,
                                    const guint8 *val);

Add a new parameter to the `GST_MIKEY_PT_SP` `payload` with `type` , `len` and `val` .

#### Parameters

payload | a GstMIKEYPayload |
type | a type |
len | a length |
val | `len` bytes of data. | [array length=len]

#### Returns

`TRUE` on success

Since: 1.4

### gst_mikey_payload_sp_remove_param ()

    gboolean
    gst_mikey_payload_sp_remove_param (GstMIKEYPayload *payload,
                                       guint idx);

Remove the Security Policy parameters from a `GST_MIKEY_PT_SP` `payload` at `idx` .

#### Parameters

payload | a GstMIKEYPayload |
idx | an index |

#### Returns

`TRUE` on success

Since: 1.4

## Types and Values

### GST_MIKEY_VERSION

    #define GST_MIKEY_VERSION 1

The supported MIKEY version 1.

### enum GstMIKEYType

Different MIKEY data types.

#### Members

GST_MIKEY_TYPE_INVALID | Invalid type |
GST_MIKEY_TYPE_PSK_INIT | Initiator's pre-shared key message |
GST_MIKEY_TYPE_PSK_VERIFY | Verification message of a Pre-shared key message |
GST_MIKEY_TYPE_PK_INIT | Initiator's public-key transport message |
GST_MIKEY_TYPE_PK_VERIFY | Verification message of a public-key message |
GST_MIKEY_TYPE_DH_INIT | Initiator's DH exchange message |
GST_MIKEY_TYPE_DH_RESP | Responder's DH exchange message |
GST_MIKEY_TYPE_ERROR | Error message |

### struct GstMIKEYMessage

    struct GstMIKEYMessage {
      guint8 version;
      GstMIKEYType type;
      gboolean V;
      GstMIKEYPRFFunc prf_func;
      guint32 CSB_id;
      GstMIKEYMapType map_type;
      GArray *map_info;
      GArray *payloads;
    };

Structure holding the information of the MIKEY message

#### Members

guint8 `version`; | the version |
GstMIKEYType `type`; | the GstMIKEYType message type |
gboolean `V`; | verify flag |
GstMIKEYPRFFunc `prf_func`; | a GstMIKEYPRFFunc |
guint32 `CSB_id`; | Identifies the Crypto Session Bundle |
GstMIKEYMapType `map_type`; | a GstMIKEYMapType |
GArray *`map_info`; | map info array of type depending on `map_type` |
GArray *`payloads`; | the payload array of GstMIKEYPayload |

### GstMIKEYDecryptInfo

    typedef struct _GstMIKEYDecryptInfo GstMIKEYDecryptInfo;

### GstMIKEYEncryptInfo

    typedef struct _GstMIKEYEncryptInfo GstMIKEYEncryptInfo;

### enum GstMIKEYPRFFunc

The PRF function that has been/will be used for key derivation

#### Members

GST_MIKEY_PRF_MIKEY_1 | MIKEY-1 PRF function |

### enum GstMIKEYMapType

Specifies the method of uniquely mapping Crypto Sessions to the security protocol sessions.

#### Members

GST_MIKEY_MAP_TYPE_SRTP | SRTP |

### GstMIKEYMapSRTP

    typedef struct {
      guint8  policy;
      guint32 ssrc;
      guint32 roc;
    } GstMIKEYMapSRTP;

The Security policy Map item for SRTP

#### Members

guint8 `policy`; | The security policy applied for the stream with `ssrc` |
guint32 `ssrc`; | the SSRC that must be used for the stream |
guint32 `roc`; | current rollover counter |

### enum GstMIKEYKVType

The key validity type

#### Members

GST_MIKEY_KV_NULL | No specific usage rule |
GST_MIKEY_KV_SPI | The key is associated with the SPI/MKI |
GST_MIKEY_KV_INTERVAL | The key has a start and expiration time |

### enum GstMIKEYKeyDataType

The type of key.

#### Members

GST_MIKEY_KD_TGK | a TEK Generation Key |
GST_MIKEY_KD_TEK | Traffic-Encrypting Key |

### GstMIKEYPayloadKeyData

    typedef struct {
      GstMIKEYPayload pt;

      GstMIKEYKeyDataType key_type;
      guint16  key_len;
      guint8  *key_data;
      guint16  salt_len;
      guint8  *salt_data;
      GstMIKEYKVType kv_type;
      guint8   kv_len[2];
      guint8  *kv_data[2];
    } GstMIKEYPayloadKeyData;

The Key data payload contains key material. It should be added as sub payload to the KEMAC.

#### Members

GstMIKEYPayload `pt`; | the payload header |
GstMIKEYKeyDataType `key_type`; | the GstMIKEYKeyDataType of `key_data` |
guint16 `key_len`; | length of `key_data` |
guint8 *`key_data`; | the key data |
guint16 `salt_len`; | the length of `salt_data` , can be 0 |
guint8 *`salt_data`; | salt data |
GstMIKEYKVType `kv_type`; | the Key Validity type |
guint8 `kv_len`[2]; | length of `kv_data` |
guint8 *`kv_data`[2]; | key validity data |

### enum GstMIKEYPayloadType

Different MIKEY Payload types.

#### Members

GST_MIKEY_PT_LAST | Last payload |
GST_MIKEY_PT_KEMAC | Key data transport payload |
GST_MIKEY_PT_PKE | Envelope data payload |
GST_MIKEY_PT_DH | DH data payload |
GST_MIKEY_PT_SIGN | Signature payload |
GST_MIKEY_PT_T | Timestamp payload |
GST_MIKEY_PT_ID | ID payload |
GST_MIKEY_PT_CERT | Certificate Payload |
GST_MIKEY_PT_CHASH | Cert hash payload |
GST_MIKEY_PT_V | Verfication message payload |
GST_MIKEY_PT_SP | Security Policy payload |
GST_MIKEY_PT_RAND | RAND payload |
GST_MIKEY_PT_ERR | Error payload |
GST_MIKEY_PT_KEY_DATA | Key data sub-payload |
GST_MIKEY_PT_GEN_EXT | General Extension Payload |

### struct GstMIKEYPayload

    struct GstMIKEYPayload {
      GstMIKEYPayloadType type;
      guint len;
    };

Hold the common fields for all payloads

#### Members

GstMIKEYPayloadType `type`; | the payload type |
guint `len`; | length of the payload |

### enum GstMIKEYEncAlg

The encryption algorithm used to encrypt the Encr data field

#### Members

GST_MIKEY_ENC_NULL | no encryption |
GST_MIKEY_ENC_AES_CM_128 | AES-CM using a 128-bit key |
GST_MIKEY_ENC_AES_KW_128 | AES Key Wrap using a 128-bit key |
GST_MIKEY_ENC_AES_GCM_128 | AES-GCM using a 128-bit key (Since 1.16) |

### enum GstMIKEYMacAlg

Specifies the authentication algorithm used

#### Members

GST_MIKEY_MAC_NULL | no authentication |
GST_MIKEY_MAC_HMAC_SHA_1_160 | HMAC-SHA-1-160 |

### GstMIKEYPayloadKEMAC

    typedef struct {
      GstMIKEYPayload pt;

      GstMIKEYEncAlg  enc_alg;
      GstMIKEYMacAlg  mac_alg;
      GArray *subpayloads;
    } GstMIKEYPayloadKEMAC;

A structure holding the KEMAC payload

#### Members

GstMIKEYPayload `pt`; | the common GstMIKEYPayload |
GstMIKEYEncAlg `enc_alg`; | the GstMIKEYEncAlg |
GstMIKEYMacAlg `mac_alg`; | the GstMIKEYMacAlg |
GArray *`subpayloads`; | the subpayloads |

### enum GstMIKEYCacheType

The different cache types

#### Members

GST_MIKEY_CACHE_NONE | The envelope key MUST NOT be cached |
GST_MIKEY_CACHE_ALWAYS | The envelope key MUST be cached |
GST_MIKEY_CACHE_FOR_CSB | The envelope key MUST be cached, but only to be used for the specific CSB. |

### GstMIKEYPayloadPKE

    typedef struct {
      GstMIKEYPayload pt;

      GstMIKEYCacheType C;
      guint16           data_len;
      guint8           *data;
    } GstMIKEYPayloadPKE;

The Envelope data payload contains the encrypted envelope key that is used in the public-key transport to protect the data in the Key data transport payload. The encryption algorithm used is implicit from the certificate/public key used.

#### Members

GstMIKEYPayload `pt`; | the common GstMIKEYPayload |
GstMIKEYCacheType `C`; | envelope key cache indicator |
guint16 `data_len`; | length of `data` |
guint8 *`data`; | the encrypted envelope key |

### enum GstMIKEYTSType

Specifies the timestamp type.

#### Members

GST_MIKEY_TS_TYPE_NTP_UTC | an NTP time in UTC timezone |
GST_MIKEY_TS_TYPE_NTP | an NTP time |
GST_MIKEY_TS_TYPE_COUNTER | a counter |

### GstMIKEYPayloadT

    typedef struct {
      GstMIKEYPayload pt;

      GstMIKEYTSType  type;
      guint8         *ts_value;
    } GstMIKEYPayloadT;

The timestamp payload carries the timestamp information

#### Members

GstMIKEYPayload `pt`; | the payload header |
GstMIKEYTSType `type`; | a GstMIKEYTSType |
guint8 *`ts_value`; | the timestamp value |

### GstMIKEYPayloadRAND

    typedef struct {
      GstMIKEYPayload pt;

      guint8  len;
      guint8 *rand;
    } GstMIKEYPayloadRAND;

The RAND payload consists of a (pseudo-)random bit-string

#### Members

GstMIKEYPayload `pt`; | the payload header |
guint8 `len`; | the length of `rand` |
guint8 *`rand`; | random values |

### enum GstMIKEYSecProto

Specifies the security protocol

#### Members

GST_MIKEY_SEC_PROTO_SRTP | SRTP |

### enum GstMIKEYSecSRTP

This policy specifies the parameters for SRTP and SRTCP

#### Members

GST_MIKEY_SP_SRTP_ENC_ALG | Encryption algorithm |
GST_MIKEY_SP_SRTP_ENC_KEY_LEN | Session Encr. key length |
GST_MIKEY_SP_SRTP_AUTH_ALG | Authentication algorithm |
GST_MIKEY_SP_SRTP_AUTH_KEY_LEN | Session Auth. key length |
GST_MIKEY_SP_SRTP_SALT_KEY_LEN | Session Salt key length |
GST_MIKEY_SP_SRTP_PRF | SRTP Pseudo Random Function |
GST_MIKEY_SP_SRTP_KEY_DERIV_RATE | Key derivation rate |
GST_MIKEY_SP_SRTP_SRTP_ENC | SRTP encryption off/on, 0 if off, 1 if on |
GST_MIKEY_SP_SRTP_SRTCP_ENC | SRTCP encryption off/on, 0 if off, 1 if on |
GST_MIKEY_SP_SRTP_FEC_ORDER | sender's FEC order |
GST_MIKEY_SP_SRTP_SRTP_AUTH | SRTP authentication off/on, 0 if off, 1 if on |
GST_MIKEY_SP_SRTP_AUTH_TAG_LEN | Authentication tag length |
GST_MIKEY_SP_SRTP_SRTP_PREFIX_LEN | SRTP prefix length |
GST_MIKEY_SP_SRTP_AEAD_AUTH_TAG_LEN | AEAD authentication tag length (Since 1.16) |

### GstMIKEYPayloadSP

    typedef struct {
      GstMIKEYPayload pt;

      guint policy;
      GstMIKEYSecProto proto;
      GArray *params;
    } GstMIKEYPayloadSP;

The Security Policy payload defines a set of policies that apply to a specific security protocol

#### Members

GstMIKEYPayload `pt`; | the payload header |
guint `policy`; | the policy number |
GstMIKEYSecProto `proto`; | the security protocol |
GArray *`params`; | array of GstMIKEYPayloadSPParam |

### GstMIKEYPayloadSPParam

    typedef struct {
      guint8  type;
      guint8  len;
      guint8 *val;
    } GstMIKEYPayloadSPParam;

A Type/Length/Value field for security paramaters

#### Members

guint8 `type`; | specifies the type of the parameter |
guint8 `len`; | specifies the length of `val` |
guint8 *`val`; | specifies the value of the parameter |