mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-04 20:07:36 +00:00
srtp-utils: Strip padding characters in crypto attribute lines
https://www.rfc-editor.org/rfc/rfc4568.html#section-6.1 says: When base64 decoding the key and salt, padding characters (i.e., one or two "=" at the end of the base64-encoded data) are discarded (see [RFC3548] for details). https://www.rfc-editor.org/rfc/rfc3548#section-2.2 says: In some circumstances, the use of padding ("=") in base encoded data is not required nor used. In the general case, when assumptions on size of transported data cannot be made, padding is required to yield correct decoded data.
This commit is contained in:
parent
037d2c55f6
commit
cfd371d72e
1 changed files with 12 additions and 1 deletions
|
@ -584,8 +584,19 @@ calls_srtp_print_sdp_crypto_attribute (calls_srtp_crypto_attribute *attr,
|
|||
/* key parameters */
|
||||
for (guint i = 0; i < attr->n_key_params; i++) {
|
||||
calls_srtp_crypto_key_param *key_param = &attr->key_params[i];
|
||||
int keylen = strlen (key_param->b64_keysalt);
|
||||
|
||||
g_string_append_printf (attr_str, "inline:%s", key_param->b64_keysalt);
|
||||
/* https://www.rfc-editor.org/rfc/rfc4568.html#section-6.1 says:
|
||||
When base64 decoding the key and salt, padding characters (i.e.,
|
||||
one or two "=" at the end of the base64-encoded data) are discarded
|
||||
(see [RFC3548] for details).
|
||||
*/
|
||||
if (key_param->b64_keysalt[keylen - 2] == '=')
|
||||
g_string_append_printf (attr_str, "inline:%.*s", keylen - 2, key_param->b64_keysalt);
|
||||
else if (key_param->b64_keysalt[keylen - 1] == '=')
|
||||
g_string_append_printf (attr_str, "inline:%.*s", keylen - 1, key_param->b64_keysalt);
|
||||
else
|
||||
g_string_append_printf (attr_str, "inline:%s", key_param->b64_keysalt);
|
||||
if (key_param->lifetime_type == CALLS_SRTP_LIFETIME_AS_DECIMAL_NUMBER)
|
||||
g_string_append_printf (attr_str, "|%" G_GINT64_FORMAT, key_param->lifetime);
|
||||
if (key_param->lifetime_type == CALLS_SRTP_LIFETIME_AS_POWER_OF_TWO)
|
||||
|
|
Loading…
Reference in a new issue