Thread (51 messages) 51 messages, 6 authors, 2026-01-14

Re: [PATCH 19/36] Bluetooth: SMP: Use new AES library API

From: David Laight <hidden>
Date: 2026-01-05 19:05:07
Also in: linux-arm-kernel, linux-crypto, linux-riscv, linux-s390, lkml, sparclinux

On Mon, 5 Jan 2026 15:40:22 +0000
Andrew Cooper [off-list ref] wrote:
quoted
 	/* 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
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help