From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id E82D74BCC8 for <ffmpegdev@gitmailbox.com>; Thu, 3 Apr 2025 20:59:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EE3D268B788; Thu, 3 Apr 2025 23:59:32 +0300 (EEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3A9D6882FB for <ffmpeg-devel@ffmpeg.org>; Thu, 3 Apr 2025 23:59:24 +0300 (EEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-736a72220edso1361112b3a.3 for <ffmpeg-devel@ffmpeg.org>; Thu, 03 Apr 2025 13:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743713962; x=1744318762; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=0ExuNh3Vo+ER7Nyn2AdER/WW2ongz6skrlakcbHyyz8=; b=cOEn15ala2q1/pQuMsiPZH/vl2yeARDu82L9nOLXcM2PInuOBaxHAKXwICHvClxoQx vdbxwoSw5t2iNUUG0JqTXIgQjN65mMMhNFxfMUxEUcLMBXOqATA/fw9zzXDh5sGBjkLL iqQNv/gGAAYsN3Bg34UrQuNqvrvYfhjPqbBCZNg1vqYONh6oqAbLdWJX4ymJ84XZKa74 qEGQrpIHi0xoOQ+KpZZClGEI74U4ZIsckz6Nl34H9PXCkTWd3iUCsZeKwTXYqGFJnXoj J8bSY2Uhp1OBM2eoK6s2GkpkI4q6BBDs0hm3NOJ8BLv0I8PxyuqMNi/1TuNrRMUQWrQI Op7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743713962; x=1744318762; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0ExuNh3Vo+ER7Nyn2AdER/WW2ongz6skrlakcbHyyz8=; b=slb3ScMdzC+fnVEvAsZd6ZpVkIa5tTMSRVCEB5SsTvNg6CEEUYPbBXVmyODI5UDmey CqR6jlvsNORZu2M784F48E2dtaPjOBz1XMW/69eXJKmtef88IAXUig/n4dzb1Quo+gS2 n09gUWzXHg6DitfZFtqxSUatiPxzS+mkzq3rWc/exmCGTls9rSFQ3nhQt1HlIMUdPzJq FOmRcJTy+7C6bp1/t4Fhp5OkaIUGKNclyFzBwRHWuNbOJKkIoDegZSbWcctD6cqbF/50 S0agsvkEMqWufaTRvgEG3DmoUc09abbq7nT/mxv/JS4vdZC0zT/6nBY4ueYhrrhyKdqP m9gQ== X-Gm-Message-State: AOJu0YwnnVD76WawlGHz2kc3wPjswbajs24+sHPKZZcA3JL1DKKifa0s rZpU4KfHAce8MBwOHex3O8NZtA+bhC0+RVlXfSfXfPPcEFe4VPFgDi2Y0g== X-Gm-Gg: ASbGncs1FesucNDHrwiatyTLG/T9r7RT3JPJgllZEV5GQjjaL4co2dKoUKsLgI1vbON xLuaW8KMPfnBUE/Du07aMznU2AoM/zYP4lcZ5KRTizzWlCQSjfY4NtC+6aQ271px5DVNY/w0lVr v7cxbxs7/Ter6TNw9UrhrM5j9Gt1CjNWFYOUYAehVM5TM3c6GwvPikr9BrygH0iuVJQQ4RguTLu kYC4CajHLklRQikxMiipvQV1R8FJ+3VwMnj6N6URLUpZ0LsRxS3ClXsViV7L8GRjcai6wtSjRmv vMmjwUn6jL86zp8mDBE5le87eqOIeKy+6+hdxkQA3ttpR4YlL6auGnstSUc0zUtw X-Google-Smtp-Source: AGHT+IEsacOVA3flmlwFha4x8u1faBpbP76BRq0WPZsZ0hlPZRoKMJJ9J7dUgY27fB9knG5VDFW70Q== X-Received: by 2002:a05:6a21:3a8d:b0:1fe:90c5:7cfd with SMTP id adf61e73a8af0-201045a78bdmr1221045637.16.1743713962101; Thu, 03 Apr 2025 13:59:22 -0700 (PDT) Received: from localhost.localdomain ([2800:2121:b000:82e:8402:2797:4dd9:1af3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-af9cc090c72sm32611a12.50.2025.04.03.13.59.20 for <ffmpeg-devel@ffmpeg.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Apr 2025 13:59:21 -0700 (PDT) From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Apr 2025 17:59:03 -0300 Message-ID: <20250403205903.1390-3-jamrial@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250401151637.2021-1-jamrial@gmail.com> References: <20250401151637.2021-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] avutil/tests/aes_ctr: also randomize the encryption key X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250403205903.1390-3-jamrial@gmail.com/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> And not just the IV. Signed-off-by: James Almer <jamrial@gmail.com> --- libavutil/tests/aes_ctr.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c index 6f21b8bda1..fad24014cc 100644 --- a/libavutil/tests/aes_ctr.c +++ b/libavutil/tests/aes_ctr.c @@ -18,6 +18,7 @@ #include <string.h> +#include "libavutil/random_seed.h" #include "libavutil/log.h" #include "libavutil/mem_internal.h" #include "libavutil/aes_ctr.h" @@ -36,13 +37,20 @@ static const DECLARE_ALIGNED(8, uint8_t, fixed_iv)[] = { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef }; +static const DECLARE_ALIGNED(8, uint8_t, fixed_key)[] = { + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66 +}; + +static DECLARE_ALIGNED(8, uint32_t, key)[2]; + static DECLARE_ALIGNED(8, uint8_t, tmp)[20]; int main (void) { int ret = 1; struct AVAESCTR *ae, *ad; - const uint8_t *iv; + const uint8_t *iv, *k; for (int i = 0; i < 2; i++) { ae = av_aes_ctr_alloc(); @@ -51,10 +59,21 @@ int main (void) if (!ae || !ad) goto ERROR; - if (av_aes_ctr_init(ae, (const uint8_t*)"0123456789abcdef") < 0) + if (i) + k = fixed_key; + else { + // Note: av_random_bytes() should be used in a real world scenario, + // but since that function can fail, av_get_random_seed() is used + // here for the purpose of this test, as its output is sufficient. + key[0] = av_get_random_seed(); + key[1] = av_get_random_seed(); + k = (uint8_t *)key; + } + + if (av_aes_ctr_init(ae, k) < 0) goto ERROR; - if (av_aes_ctr_init(ad, (const uint8_t*)"0123456789abcdef") < 0) + if (av_aes_ctr_init(ad, k) < 0) goto ERROR; if (i) -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".