lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260105190503.53cc31dd@pumpkin>
Date: Mon, 5 Jan 2026 19:05:03 +0000
From: David Laight <david.laight.linux@...il.com>
To: Andrew Cooper <andrew.cooper3@...rix.com>
Cc: ebiggers@...nel.org, Jason@...c4.com, ardb@...nel.org,
 dengler@...ux.ibm.com, freude@...ux.ibm.com, herbert@...dor.apana.org.au,
 linux-arm-kernel@...ts.infradead.org, linux-crypto@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
 linux-s390@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
 sparclinux@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH 19/36] Bluetooth: SMP: Use new AES library API

On Mon, 5 Jan 2026 15:40:22 +0000
Andrew Cooper <andrew.cooper3@...rix.com> wrote:

> >  	/* Most significant octet of plaintextData corresponds to data[0] */
> >  	swap_buf(r, data, 16);
> >  
> > - aes_encrypt(&ctx, data, data); + aes_encrypt_new(&aes, data, data);  
> 
> One thing you might want to consider, which reduces the churn in the series.
> 
> You can use _Generic() to do type-based dispatch on the first pointer. 
> Something like this:
> 
> 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],
>              const u8 in[at_least AES_BLOCK_SIZE]);
> 
> #define aes_encrypt(ctx, out, in)                                       \
>     _Generic(ctx,                                                       \
>              const struct crypto_aes_ctx *: aes_encrypt(ctx, out, in),  \
>              aes_encrypt_arg: aes_encrypt_new(ctx, out, in))
> 
> 
> 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

> 
> ~Andrew
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ