mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 02:32:23 +00:00
hlsdemux: fix compilation with OpenSSL 1.1.0
OpenSSL 1.1.0 no longer allows stack-allocated structures; it hides the implementation behind typedefs https://bugzilla.gnome.org/show_bug.cgi?id=787309
This commit is contained in:
parent
58a2df001c
commit
e796a7cb97
2 changed files with 27 additions and 6 deletions
|
@ -1656,11 +1656,17 @@ static gboolean
|
||||||
gst_hls_demux_stream_decrypt_start (GstHLSDemuxStream * stream,
|
gst_hls_demux_stream_decrypt_start (GstHLSDemuxStream * stream,
|
||||||
const guint8 * key_data, const guint8 * iv_data)
|
const guint8 * key_data, const guint8 * iv_data)
|
||||||
{
|
{
|
||||||
|
EVP_CIPHER_CTX *ctx;
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
EVP_CIPHER_CTX_init (&stream->aes_ctx);
|
EVP_CIPHER_CTX_init (&stream->aes_ctx);
|
||||||
if (!EVP_DecryptInit_ex (&stream->aes_ctx, EVP_aes_128_cbc (), NULL, key_data,
|
ctx = &stream->aes_ctx;
|
||||||
iv_data))
|
#else
|
||||||
|
stream->aes_ctx = EVP_CIPHER_CTX_new ();
|
||||||
|
ctx = stream->aes_ctx;
|
||||||
|
#endif
|
||||||
|
if (!EVP_DecryptInit_ex (ctx, EVP_aes_128_cbc (), NULL, key_data, iv_data))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
EVP_CIPHER_CTX_set_padding (&stream->aes_ctx, 0);
|
EVP_CIPHER_CTX_set_padding (ctx, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,15 +1675,21 @@ decrypt_fragment (GstHLSDemuxStream * stream, gsize length,
|
||||||
const guint8 * encrypted_data, guint8 * decrypted_data)
|
const guint8 * encrypted_data, guint8 * decrypted_data)
|
||||||
{
|
{
|
||||||
int len, flen = 0;
|
int len, flen = 0;
|
||||||
|
EVP_CIPHER_CTX *ctx;
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
|
ctx = &stream->aes_ctx;
|
||||||
|
#else
|
||||||
|
ctx = stream->aes_ctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (G_UNLIKELY (length > G_MAXINT || length % 16 != 0))
|
if (G_UNLIKELY (length > G_MAXINT || length % 16 != 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
len = (int) length;
|
len = (int) length;
|
||||||
if (!EVP_DecryptUpdate (&stream->aes_ctx, decrypted_data, &len,
|
if (!EVP_DecryptUpdate (ctx, decrypted_data, &len, encrypted_data, len))
|
||||||
encrypted_data, len))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
EVP_DecryptFinal_ex (&stream->aes_ctx, decrypted_data + len, &flen);
|
EVP_DecryptFinal_ex (ctx, decrypted_data + len, &flen);
|
||||||
g_return_val_if_fail (len + flen == length, FALSE);
|
g_return_val_if_fail (len + flen == length, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1685,7 +1697,12 @@ decrypt_fragment (GstHLSDemuxStream * stream, gsize length,
|
||||||
static void
|
static void
|
||||||
gst_hls_demux_stream_decrypt_end (GstHLSDemuxStream * stream)
|
gst_hls_demux_stream_decrypt_end (GstHLSDemuxStream * stream)
|
||||||
{
|
{
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
EVP_CIPHER_CTX_cleanup (&stream->aes_ctx);
|
EVP_CIPHER_CTX_cleanup (&stream->aes_ctx);
|
||||||
|
#else
|
||||||
|
EVP_CIPHER_CTX_free (stream->aes_ctx);
|
||||||
|
stream->aes_ctx = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_NETTLE)
|
#elif defined(HAVE_NETTLE)
|
||||||
|
|
|
@ -101,7 +101,11 @@ struct _GstHLSDemuxStream
|
||||||
|
|
||||||
/* decryption tooling */
|
/* decryption tooling */
|
||||||
#if defined(HAVE_OPENSSL)
|
#if defined(HAVE_OPENSSL)
|
||||||
|
# if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
EVP_CIPHER_CTX aes_ctx;
|
EVP_CIPHER_CTX aes_ctx;
|
||||||
|
# else
|
||||||
|
EVP_CIPHER_CTX *aes_ctx;
|
||||||
|
# endif
|
||||||
#elif defined(HAVE_NETTLE)
|
#elif defined(HAVE_NETTLE)
|
||||||
struct CBC_CTX (struct aes_ctx, AES_BLOCK_SIZE) aes_ctx;
|
struct CBC_CTX (struct aes_ctx, AES_BLOCK_SIZE) aes_ctx;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue