summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2013-07-23 13:29:18 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-23 13:30:52 +0200
commitb9124cad884205c7db716a634737964297c9d85b (patch)
treed6ba13b7d49cb0f1808f5716d5be4e19d46e10df /ext
parent92bcdd9c4be315bb791c965c9748075667711c07 (diff)
downloadgstreamer-plugins-bad-b9124cad884205c7db716a634737964297c9d85b.tar.gz
hlsdemux: Implement pkcs7 unpadding
Every encrypted fragment will be a multiple of 128 bits, the last byte contains the number of bytes that were added as padding in the end and should be removed. https://bugzilla.gnome.org/show_bug.cgi?id=701673
Diffstat (limited to 'ext')
-rw-r--r--ext/hls/gsthlsdemux.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c
index ec9b25ae4..2dfb8560a 100644
--- a/ext/hls/gsthlsdemux.c
+++ b/ext/hls/gsthlsdemux.c
@@ -1243,6 +1243,7 @@ gst_hls_demux_decrypt_fragment (GstHLSDemux * demux,
GstMapInfo key_info, encrypted_info, decrypted_info;
gnutls_cipher_hd_t aes_ctx;
gnutls_datum_t key_d, iv_d;
+ gsize unpadded_size;
GST_INFO_OBJECT (demux, "Fetching key %s", key);
key_fragment = gst_uri_downloader_fetch_uri (demux->downloader, key);
@@ -1269,10 +1270,16 @@ gst_hls_demux_decrypt_fragment (GstHLSDemux * demux,
decrypted_info.data, decrypted_info.size);
gnutls_cipher_deinit (aes_ctx);
+ /* Handle pkcs7 unpadding here */
+ unpadded_size =
+ decrypted_info.size - decrypted_info.data[decrypted_info.size - 1];
+
gst_buffer_unmap (decrypted_buffer, &decrypted_info);
gst_buffer_unmap (encrypted_buffer, &encrypted_info);
gst_buffer_unmap (key_buffer, &key_info);
+ gst_buffer_resize (decrypted_buffer, 0, unpadded_size);
+
gst_buffer_unref (key_buffer);
gst_buffer_unref (encrypted_buffer);
g_object_unref (key_fragment);