From patchwork Sun Oct 9 20:30:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Oliver X-Patchwork-Id: 933 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp2150902vsd; Sun, 9 Oct 2016 13:30:27 -0700 (PDT) X-Received: by 10.194.106.169 with SMTP id gv9mr16043548wjb.129.1476045027286; Sun, 09 Oct 2016 13:30:27 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n7si33786655wjr.97.2016.10.09.13.30.26; Sun, 09 Oct 2016 13:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A2DFA689947; Sun, 9 Oct 2016 23:30:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C157B689897 for ; Sun, 9 Oct 2016 23:30:01 +0300 (EEST) Received: by mail-io0-f180.google.com with SMTP id r30so93350638ioi.1 for ; Sun, 09 Oct 2016 13:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=iG4eOpelu3PvJ9e9YK/nmc+qgj+xyx8fujLdnn7vZZ0=; b=MX1kAvRmrUY1lPUGX//8jnxRu5L21vWnsR24Fsmz+axQ8AaDDVKtG+w5zN+qbIJEvP ouMM/bTk/ms5Y/7Ym/11MXC+MbFjYbVWZRJXnO/TJqTxlFj8k50ZkJ0Y//6Ufj+oCgdk uzfIyc0iV0gbiIb3MhSmEsntQ1kstyN+J/iJMWpjVOv/txqnMPR/ukXbm57Sr7uzWtsg cvFOF/l9eUnHrHGVv0wkYmAlXiwFEPigJCYC5iZwtGu7zdpS9YWJCUlFM78k/c7vsR+D vDLLzcqAhScKmeelgbTfryZHdHSXD3ZGVXmxPJkkAiz6hRcNyVfxsH7XKKcmgYYpBRcX H6pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=iG4eOpelu3PvJ9e9YK/nmc+qgj+xyx8fujLdnn7vZZ0=; b=ah3grV87nGdOgNo/t15iTAyYuxCvIFCOcZESU4AkZdAnA+MmUAMiWO5L0g2mki4tSJ FcGGNgccw9zHu8atE2nRKALD7BOPLQVxSFtzNpljQuTtX0MpqjX/pNoggB/ayLFtoKz3 2Qz68pYPPqhZtVwigfHsvpuac2MN239hnxXy9HeJZQ+OYy+/cc+ZWBYSfuHaD/7FGeME SDc66tsfjJ2YF47BkUscByJccpFgWLogrrMqdyuHob5wINz2KaP1QqBBGaYDz8emXrEb VTY1Y+SWKqMGtwMfbkiXqAz8FzrHcF9zAOXP5fdLdR5VdtRxdzOrs1rb4i2EygaiH6Jb UTBQ== X-Gm-Message-State: AA6/9RkFO2c9mxtwq3xq47sJXZoEVik7XKo4RNIfb3Q2rhmCyXp0Pc2YdgjU37w0oHRnydebPfMW8XYW324Teg== X-Received: by 10.107.140.150 with SMTP id o144mr1684006iod.8.1476045017099; Sun, 09 Oct 2016 13:30:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.111.18 with HTTP; Sun, 9 Oct 2016 13:30:16 -0700 (PDT) In-Reply-To: References: <1476038933.3628647.750493801.4F6C2270@webmail.messagingengine.com> From: Matt Oliver Date: Mon, 10 Oct 2016 07:30:16 +1100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] openssl: Support version 1.1.0. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From ad4d838ed6673c6d12aeaa7b00036b66371b4d63 Mon Sep 17 00:00:00 2001 From: Matt Oliver Date: Mon, 10 Oct 2016 06:49:54 +1100 Subject: [PATCH] openssl: Support version 1.1.0. Fixes #5675 Signed-off-by: Matt Oliver --- configure | 3 +- libavformat/tls_openssl.c | 163 ++++++++++++++++++++++++++++------------------ 2 files changed, 102 insertions(+), 64 deletions(-) avpriv_unlock_avformat(); @@ -107,6 +199,9 @@ void ff_openssl_deinit(void) av_free(openssl_mutexes); } #endif +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + BIO_meth_free(url_bio_method); +#endif } avpriv_unlock_avformat(); } @@ -132,69 +227,6 @@ static int tls_close(URLContext *h) return 0; } -static int url_bio_create(BIO *b) -{ - b->init = 1; - b->ptr = NULL; - b->flags = 0; - return 1; -} - -static int url_bio_destroy(BIO *b) -{ - return 1; -} - -static int url_bio_bread(BIO *b, char *buf, int len) -{ - URLContext *h = b->ptr; - int ret = ffurl_read(h, buf, len); - if (ret >= 0) - return ret; - BIO_clear_retry_flags(b); - if (ret == AVERROR_EXIT) - return 0; - return -1; -} - -static int url_bio_bwrite(BIO *b, const char *buf, int len) -{ - URLContext *h = b->ptr; - int ret = ffurl_write(h, buf, len); - if (ret >= 0) - return ret; - BIO_clear_retry_flags(b); - if (ret == AVERROR_EXIT) - return 0; - return -1; -} - -static long url_bio_ctrl(BIO *b, int cmd, long num, void *ptr) -{ - if (cmd == BIO_CTRL_FLUSH) { - BIO_clear_retry_flags(b); - return 1; - } - return 0; -} - -static int url_bio_bputs(BIO *b, const char *str) -{ - return url_bio_bwrite(b, str, strlen(str)); -} - -static BIO_METHOD url_bio_method = { - .type = BIO_TYPE_SOURCE_SINK, - .name = "urlprotocol bio", - .bwrite = url_bio_bwrite, - .bread = url_bio_bread, - .bputs = url_bio_bputs, - .bgets = NULL, - .ctrl = url_bio_ctrl, - .create = url_bio_create, - .destroy = url_bio_destroy, -}; - static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) { TLSContext *p = h->priv_data; @@ -240,8 +272,13 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op ret = AVERROR(EIO); goto fail; } +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + bio = BIO_new(url_bio_method); + BIO_set_data(bio, c->tcp); +#else bio = BIO_new(&url_bio_method); bio->ptr = c->tcp; +#endif SSL_set_bio(p->ssl, bio, bio); if (!c->listen && !c->numerichost) SSL_set_tlsext_host_name(p->ssl, c->host); diff --git a/configure b/configure index e014615..3a92eb3 100755 --- a/configure +++ b/configure @@ -5816,7 +5816,8 @@ enabled omx && { check_header OMX_Core.h || add_cflags -isystem/opt/vc/include/IL ; } check_header OMX_Core.h ; } || die "ERROR: OpenMAX IL headers not found"; } -enabled openssl && { use_pkg_config openssl openssl/ssl.h SSL_library_init || +enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl || + use_pkg_config openssl openssl/ssl.h SSL_library_init || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 46eb3e6..2206ab0 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -63,6 +63,89 @@ static unsigned long openssl_thread_id(void) #endif #endif +static int url_bio_create(BIO *b) +{ +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + BIO_set_init(b, 1); + BIO_set_data(b, NULL); + BIO_set_flags(b, 0); +#else + b->init = 1; + b->ptr = NULL; + b->flags = 0; +#endif + return 1; +} + +static int url_bio_destroy(BIO *b) +{ + return 1; +} + +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#define BIO_GET_DATA(x) BIO_get_data(x); +#else +#define BIO_GET_DATA(x) (x)->ptr; +#endif + +static int url_bio_bread(BIO *b, char *buf, int len) +{ + URLContext *h; + int ret; + h = BIO_GET_DATA(b); + ret = ffurl_read(h, buf, len); + if (ret >= 0) + return ret; + BIO_clear_retry_flags(b); + if (ret == AVERROR_EXIT) + return 0; + return -1; +} + +static int url_bio_bwrite(BIO *b, const char *buf, int len) +{ + URLContext *h; + int ret; + h = BIO_GET_DATA(b); + ret = ffurl_write(h, buf, len); + if (ret >= 0) + return ret; + BIO_clear_retry_flags(b); + if (ret == AVERROR_EXIT) + return 0; + return -1; +} + +static long url_bio_ctrl(BIO *b, int cmd, long num, void *ptr) +{ + if (cmd == BIO_CTRL_FLUSH) { + BIO_clear_retry_flags(b); + return 1; + } + return 0; +} + +static int url_bio_bputs(BIO *b, const char *str) +{ + return url_bio_bwrite(b, str, strlen(str)); +} + +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +static BIO_METHOD* url_bio_method; +#else +static BIO_METHOD url_bio_method = { + .type = BIO_TYPE_SOURCE_SINK, + .name = "urlprotocol bio", + .bwrite = url_bio_bwrite, + .bread = url_bio_bread, + .bputs = url_bio_bputs, + .bgets = NULL, + .ctrl = url_bio_ctrl, + .create = url_bio_create, + .destroy = url_bio_destroy, +}; +#endif + int ff_openssl_init(void) { avpriv_lock_avformat(); @@ -86,6 +169,15 @@ int ff_openssl_init(void) #endif } #endif +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + url_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "urlprotocol bio"); + BIO_meth_set_write(url_bio_method, url_bio_bwrite); + BIO_meth_set_read(url_bio_method, url_bio_bread); + BIO_meth_set_puts(url_bio_method, url_bio_bputs); + BIO_meth_set_ctrl(url_bio_method, url_bio_ctrl); + BIO_meth_set_create(url_bio_method, url_bio_create); + BIO_meth_set_destroy(url_bio_method, url_bio_destroy); +#endif } openssl_init++;