lkml.org 
[lkml]   [2023]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v7 10/12] crypto: x86/aesni - Use the proper data type in struct aesni_xts_ctx
From
On 5/25/2023 11:54 PM, Eric Biggers wrote:
> On Wed, May 24, 2023 at 09:57:15AM -0700, Chang S. Bae wrote:
>> +static inline unsigned long aes_align_addr(unsigned long addr)
>> +{
>> + return (crypto_tfm_ctx_alignment() >= AESNI_ALIGN) ?
>> + ALIGN(addr, 1) : ALIGN(addr, AESNI_ALIGN);
>> +}
>
> Wouldn't it be simpler to make this take and return 'void *'? Then the callers
> wouldn't need to cast to/from 'unsigned long'.
>
> Also, aligning to a 1-byte boundary is a no-op.
>
> So, please consider the following:
>
> static inline void *aes_align_addr(void *addr)
> {
> if (crypto_tfm_ctx_alignment() >= AES_ALIGN)
> return addr;
> return PTR_ALIGN(addr, AES_ALIGN);
> }
>
> Also, aesni_rfc4106_gcm_ctx_get() and generic_gcmaes_ctx_get() should call this
> too, rather than duplicating similar code.

Indeed, your suggestion can improve the overall code there.

Thanks!
Chang

\
 
 \ /
  Last update: 2023-05-30 22:51    [W:0.143 / U:0.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site