From patchwork Mon Jan 8 22:12:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Trimble X-Patchwork-Id: 7206 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp3171862jaa; Mon, 8 Jan 2018 14:13:28 -0800 (PST) X-Google-Smtp-Source: ACJfBosJYma1KOaIkwZi7F2H6K7aKBEsylnjnH0bB4StaZ0Lh/hja3wzK9FD3Zgv6dMaMa9LzRGF X-Received: by 10.223.134.161 with SMTP id 30mr11650324wrx.93.1515449608614; Mon, 08 Jan 2018 14:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515449608; cv=none; d=google.com; s=arc-20160816; b=opD3aLi+Pkbndf3WE4pZB7tXrF0ghvvFySXzyTXmE6pav6c2xW0dpDCIlEFD0OQUxT L3rUakvYBxhLtCCVwFKAEudA4KDekCTH9z23Wg/Pg5Hou91V1DtU20fXPFkvcP1rJKPb laFiCKZYCa92cwr9J7M8XxNlR0rpQaBi0sXVFxDqg0szhVeL2YbF+x14+vd8Z4ql4SsC 0KqyZIvkveHfSzrrQa1WUO1Vo9xwoH/a78PfKwKBN4rjha0eOCeslQ7PdxDQyYfKOXRT zviqjNBKzQ/CHmWqdUK6zpukSQZXD9x9pdrmaUZZMrORH0BLi3etmUQ3N2vR0hBuHC3Z VH3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:from:message-id:date:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=VoPdYqo9rYyN7tz0c/LDSruL5PqquMi29FLXmTmb9T0=; b=bWnEbW3o2zTOTA+z4Urb3wDn0R6VYE187d6wwb2CrsY2c+hA2gfvkNIjEDy50Iwihn wb5dZrmlngVgYx2OwKuAkjjIiVzo4DnjU78NbyjMccbKuIPlsDEgNkYfOHM5Yw3mCCTp tC0EYTJAElSppViJphwgQiY+Z7Tqr4PP16V+90pOdYd5O4sD8onlpCLGUi0zJU+dIslE LQtRchElBkni4FoAWCx4YBCKM47Mx9Kp54AnWhE3AWgHGqCAfHf75fjhrKJ8cdOCO/9t CUihqO3UE8U2YOVOyRIDQfP7XL9NQAbjWkxE0/sGxQAKFrnKctz/qM3CQxgXaW/InoAm ZNMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=clQwh4H5; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j10si9583014wrc.173.2018.01.08.14.13.27; Mon, 08 Jan 2018 14:13:28 -0800 (PST) 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=@google.com header.s=20161025 header.b=clQwh4H5; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5DD646882BF; Tue, 9 Jan 2018 00:13:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f73.google.com (mail-oi0-f73.google.com [209.85.218.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C9681680A9B for ; Tue, 9 Jan 2018 00:13:18 +0200 (EET) Received: by mail-oi0-f73.google.com with SMTP id y195so6801350oia.22 for ; Mon, 08 Jan 2018 14:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=0iSiy8+Co2KMCNS7MsD3OJC/tgU/h8/kV2S9Qec/vqE=; b=clQwh4H5IcYaNvgsIwbFatVXljDEzhqZtFYjmFK8PAzai9aFSqK1ZMUeo6npp1KQDw 0vwYlq6rFG/QSShypLcvWrk9wQt6bGkJVEKf1QWMEflD8z6RdYbBhfshDOtdRUVfyYVV AR98QOJ9hrqtu1JEpHg5Q9/3xqRLsgwbokECGnxdPOZiC2GZrGVI+qFMyGP/8HXy5MlR 71cZaujwZs+WW32Zw2W7zBAziP4aY7DAPpuVmgFsGVS8yrT60+LmXCxsG8Pvui6GExgD AZbUtjuKBPsR6ADzlQIq2JssHXFlruCKM5JsA7V1y9OjpQG3B6bn1PH9sJ9OzFYr8kar xceQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=0iSiy8+Co2KMCNS7MsD3OJC/tgU/h8/kV2S9Qec/vqE=; b=UKfwl8XCgsLtGBfiExr97TkWJ7WIq9lQdi+bVtZmnVy7jAWOaMkWZC/IK8YFpb5Fdw YJ8iuCTlPZD+QD2E2qn0Xx9BOv1zSUzQXDnipqDIpOAxgMXHqI4+mPQut1cGk3Pk9983 d7eTijdssvRXkHgnTRIFvG8FMbBa8g+5ppn2fbZFef6VNP7dJUXPmvenSJtAFkwQB4EM edpF1D4dnePEziTQO92Ma7PT/O5c5gdi+iyYYqjPBLHqWHVg6lLV45QtSMEoJZlVZsTV 3dVrSU4dXDTOJS52SzE/2QgKj+MdCx6xIiNNwZOEKadIpKyK8N5yZeFe02Yy2TgaeUlz S4Dw== X-Gm-Message-State: AKwxytfX+bQoZUcupm4gGeT2eYDB0EWmUGIy8CjBTvjgTN43I9GOEzkM lmOsThxpiW8ryIqX6Detu3W+iD5EL53vZYMp53N/LcXzXf1llIZrelUol8eZw0lT2ufaiLpsmNT qJBEV5Cce8Jt2TeLy7aWW0I4tPE2GchxeqjCBdZsQW7y7TZh0dk2p4lBPVl8vF8CevIgc MIME-Version: 1.0 X-Received: by 10.157.46.247 with SMTP id w110mr7301795ota.62.1515449598392; Mon, 08 Jan 2018 14:13:18 -0800 (PST) Date: Mon, 8 Jan 2018 14:12:43 -0800 Message-Id: <20180108221243.80244-1-modmaker@google.com> X-Mailer: git-send-email 2.16.0.rc0.223.g4a4ac83678-goog From: Jacob Trimble To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avutil/aes_ctr: Add method to set 16-byte IV. 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 Cc: Jacob Trimble Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Jacob Trimble --- doc/APIchanges | 3 +++ libavutil/aes_ctr.c | 6 ++++++ libavutil/aes_ctr.h | 7 ++++++- libavutil/tests/aes_ctr.c | 2 +- libavutil/version.h | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b771031740..4e07a806eb 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-xx-xx - xxxxxxx - lavu 56.9.100 - aes_ctr.h + Add method to set the 16-byte IV. + 2018-xx-xx - xxxxxxx - lavu 56.8.100 - encryption_info.h Add AVEncryptionInitInfo and AVEncryptionInfo structures to hold new side-data for encryption info. diff --git a/libavutil/aes_ctr.c b/libavutil/aes_ctr.c index e9c568fe0d..0c2e86785f 100644 --- a/libavutil/aes_ctr.c +++ b/libavutil/aes_ctr.c @@ -45,6 +45,12 @@ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv) a->block_offset = 0; } +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv) +{ + memcpy(a->counter, iv, sizeof(a->counter)); + a->block_offset = 0; +} + const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a) { return a->counter; diff --git a/libavutil/aes_ctr.h b/libavutil/aes_ctr.h index f596fa6a46..e4aae126a7 100644 --- a/libavutil/aes_ctr.h +++ b/libavutil/aes_ctr.h @@ -67,10 +67,15 @@ const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a); void av_aes_ctr_set_random_iv(struct AVAESCTR *a); /** - * Forcefully change the iv + * Forcefully change the 8-byte iv */ void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv); +/** + * Forcefully change the "full" 16-byte iv, including the counter + */ +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv); + /** * Increment the top 64 bit of the iv (performed after each frame) */ diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c index c5ebeda7ac..00fdb05d13 100644 --- a/libavutil/tests/aes_ctr.c +++ b/libavutil/tests/aes_ctr.c @@ -45,7 +45,7 @@ int main (void) av_aes_ctr_set_random_iv(ae); iv = av_aes_ctr_get_iv(ae); - av_aes_ctr_set_iv(ad, iv); + av_aes_ctr_set_full_iv(ad, iv); av_aes_ctr_crypt(ae, tmp, plain, sizeof(tmp)); av_aes_ctr_crypt(ad, tmp, tmp, sizeof(tmp)); diff --git a/libavutil/version.h b/libavutil/version.h index d7398c41c5..0c032c8553 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 8 +#define LIBAVUTIL_VERSION_MINOR 9 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \