From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 691A91EB5F8 for ; Mon, 5 Jan 2026 19:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767639908; cv=none; b=Ygj+Bz+FhsBV3UG7+rpKsbblUCXLtlQDoipUFfa/MmQxz3/rh7VyrSd2C4OR2HgsIP0YdduRyQt6CBWrxq5sYT03J92gGf/7KGKlrgoMIGC6f6ESCRvXvD91c7glV33rb+bNQCDbmFEfe/hrPXb+DJmT/6qobWeEmKz4z9CnPpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767639908; c=relaxed/simple; bh=Gx9eSAVj6IjIV1MJpCWyW5YSmZ2/sdTWOEru/YL3xKs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LjX+Y8/wjWktNk14MAdXPdx7m9BOzgUo2R1/u2K3qWeJvMa/hwh1s/uDX9MS8Am+B1ix5SX66W7X4Y/GbtDIebHgddV8u4jruxEUZ5utMDVjx3WNYxfyFqAlvvPbDpBtg0Ts9yntqpPU3zR6oqrGNFqxpEM6ZHcDNxX5DTr5UqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YdUNqBQK; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YdUNqBQK" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-47d1d8a49f5so1827015e9.3 for ; Mon, 05 Jan 2026 11:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767639906; x=1768244706; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=l+T85xG7RFn5rLmFPcEnHN9rx8p/ELEmXn/p/BMRsk4=; b=YdUNqBQKJEX+77z3OK0BMbFIGnG9FUSz9ocwbsaeRS85fTTMLByCu9om2Zej/u8jav GG7+0mmoe+rzbzTA2+11anpt7HA6faMgzIC7c6/9XFiUUbPYkn/4p+xo6gSHhsTPtS7Z 43pK1XO9KGjyTAnoo1yjBTam0lrkaqWx46nDH7Yvk0STRr7T3418xPAuPqUu6d9E6YMi /7h9c/Ya1oYwTmC/xL9Vmr9eGQH+ip5eDfi9O2u110ReCvCUdsuC2q6elLgOoImVt1eh YZtvtC6SJaKZwpSVl7/zLeydpNYwsJIpxu7qimGMOcTYXdrNhY+vJw2lFW20tfcxC5PA KQbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767639906; x=1768244706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=l+T85xG7RFn5rLmFPcEnHN9rx8p/ELEmXn/p/BMRsk4=; b=eRXav7wNr2KlAw/ugC6kC7YWcQBsFiKia5f7OSiZKQbRxYjBkH4CIJ+06k5GCBG/Nv N0iKJUlpofxdYufhRqQAml+PEnxURkQxEyG5TqqmG0jDF4Lh+TWSopsIoZb3WSrLH5+p iN12dEII7do8BMuKJbaaSiA4I0pV4oy0UyrrmZZmoXYyBj5HUvZ7pkj/rQs9X9cAbRa7 esEI76swcevNfC2kj326U83fXHmrcf/idUKTLTPmz4oRDbxSu/Ex7q48fOHJ/cYJSiht Sp2O8PeJQL9sZEFDIxe/5Ya106+3qhAshfH4bjJKExJdWOVvzDhkRZ3C/vN++j4fgTE6 I3vg== X-Forwarded-Encrypted: i=1; AJvYcCUwVsBKHJQhwEvM6lnYCqQ+ROsvPtbhmXTFt3T6exWMxj1HT/57lxRJSHWL+2YbANrqeNBKw31+6pIsAnk=@vger.kernel.org X-Gm-Message-State: AOJu0YyiRb1j/2MJZteoDsmKWbYyfvMcg3Jg190Y0lojH1dZKqC1zBom A1cM43hfx212FAk7mJNA85A4q3OhdDAnC/8x7nLGzF53mfRz5wdFPRR8 X-Gm-Gg: AY/fxX4EpzVD6vapObqHzem/5fyJ9GrbKPNU4khG6854IbNbei8bvc0uspj3z2MS7xm Rhh7Z+szEh4d1R+HS3AGLPIkUf8UA5V9TImVjDUtqF5dfmk6GtTEpKpBHOcdara48PWj9WNpKN6 wq0nnvIL1/na8KvgGOnXwp5MLBz4E/953ELZsJBgDp+vYM9fHTjm69RefrHgh1ihE5w4jlemtvS z0pbuA2tm4KFko1TpEO3hJbZ9BXGizYZXIsG0ah6P18rK+zqoUR2OBcLL4udmVh+hzNJcXD8hiE tyxiNuz5zGKyHiVTyw4bW/LjR+Baji7byQHnkhOKIew5n8/jEfXb7RJ8EYY0Fi8NRWpNhgn5MF8 JxKLVMbBIyLMTw0zUIJZBK3VqPU/SZj8qsr/T7LxmePqMCIOeAd26QfOKID8V7ae7yqwJDDSXzo 4Z40VgiCIrFBhAOsvMh8N4ldbyUTb9dhFzlfwXmHX0cYBZYaEf1re/R+Lai9hTcFk= X-Google-Smtp-Source: AGHT+IGlHrTGN9QhI9D4GcPAN0WpXBCiJkY6o1Su8HuTrk460ua/0mSfGa1CiVo2PPimvYizFp7ESg== X-Received: by 2002:a05:600c:4f93:b0:46e:53cb:9e7f with SMTP id 5b1f17b1804b1-47d7f0929c2mr4085365e9.18.1767639905594; Mon, 05 Jan 2026 11:05:05 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f41eb3bsm2991115e9.7.2026.01.05.11.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 11:05:05 -0800 (PST) Date: Mon, 5 Jan 2026 19:05:03 +0000 From: David Laight To: Andrew Cooper Cc: ebiggers@kernel.org, Jason@zx2c4.com, ardb@kernel.org, dengler@linux.ibm.com, freude@linux.ibm.com, herbert@gondor.apana.org.au, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 19/36] Bluetooth: SMP: Use new AES library API Message-ID: <20260105190503.53cc31dd@pumpkin> In-Reply-To: <859377de-cb72-4e87-8ee5-97f8c58a5720@citrix.com> References: <20260105051311.1607207-20-ebiggers@kernel.org> <859377de-cb72-4e87-8ee5-97f8c58a5720@citrix.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 5 Jan 2026 15:40:22 +0000 Andrew Cooper wrote: > > /* Most significant octet of plaintextData corresponds to data[0] */ > > swap_buf(r, data, 16); > > =20 > > - aes_encrypt(&ctx, data, data); + aes_encrypt_new(&aes, data, data); = =20 >=20 > One thing you might want to consider, which reduces the churn in the seri= es. >=20 > You can use _Generic() to do type-based dispatch on the first pointer.=C2= =A0 > Something like this: >=20 > void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); > void aes_encrypt_new(aes_encrypt_arg key, u8 out[at_least AES_BLOCK_SIZE], > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = const u8 in[at_least AES_BLOCK_SIZE]); >=20 > #define aes_encrypt(ctx, out, in)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \ > =C2=A0=C2=A0=C2=A0 _Generic(ctx,=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = const struct crypto_aes_ctx *: aes_encrypt(ctx, out, in),=C2=A0 \ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = aes_encrypt_arg: aes_encrypt_new(ctx, out, in)) >=20 >=20 > i.e. it keeps the _new()-ism in a single header, without needing to > change the drivers a second time. You'll need to cast the 'ctx' argument in both calls. All the code in an _Generic() must compile cleanly in all the cases. (Totally annoying....) David >=20 > ~Andrew >=20