[PATCH 1/6] crypto: api - laying macros for statically allocated buffers
Creating 2 new compile-time constants for internal use, in preparation for the removal of VLAs[1] from crypto code. All ciphers implemented in Linux have a block size less than or equal to 16 bytes and the most demanding hw require 16 bytes alignment for the block buffer. [1] http://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Salvatore Mesoraca --- crypto/internal.h | 8 1 file changed, 8 insertions(+) diff --git a/crypto/internal.h b/crypto/internal.h index 9a3f399..89ae41e 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -26,6 +26,14 @@ #include #include +/* + * Maximum values for blocksize and alignmask, used to allocate + * static buffers that are big enough for any combination of + * ciphers and architectures. + */ +#define MAX_BLOCKSIZE 16 +#define MAX_ALIGNMASK 15 + /* Crypto notification events. */ enum { CRYPTO_MSG_ALG_REQUEST, -- 1.9.1
Re: [PATCH 1/6] crypto: api - laying macros for statically allocated buffers
2018-04-08 5:15 GMT+02:00 Herbert Xu : > On Sat, Apr 07, 2018 at 08:38:18PM +0200, Salvatore Mesoraca wrote: >> Creating 2 new compile-time constants for internal use, >> in preparation for the removal of VLAs[1] from crypto code. >> All ciphers implemented in Linux have a block size less than or >> equal to 16 bytes and the most demanding hw require 16 bytes >> alignment for the block buffer. >> >> [1] >> http://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com >> >> Signed-off-by: Salvatore Mesoraca >> --- >> crypto/internal.h | 8 >> 1 file changed, 8 insertions(+) >> >> diff --git a/crypto/internal.h b/crypto/internal.h >> index 9a3f399..89ae41e 100644 >> --- a/crypto/internal.h >> +++ b/crypto/internal.h >> @@ -26,6 +26,14 @@ >> #include >> #include >> >> +/* >> + * Maximum values for blocksize and alignmask, used to allocate >> + * static buffers that are big enough for any combination of >> + * ciphers and architectures. >> + */ >> +#define MAX_BLOCKSIZE16 >> +#define MAX_ALIGNMASK15 > > No please don't put this here if you intend on using it everywhere. > This file is reserved for truly internal bits. > > Perhaps include/crypto/algapi.h would be a better place. OK, thank you for the suggestion :) Salvatore
Re: [PATCH 1/6] crypto: api - laying macros for statically allocated buffers
On Sat, Apr 07, 2018 at 08:38:18PM +0200, Salvatore Mesoraca wrote: > Creating 2 new compile-time constants for internal use, > in preparation for the removal of VLAs[1] from crypto code. > All ciphers implemented in Linux have a block size less than or > equal to 16 bytes and the most demanding hw require 16 bytes > alignment for the block buffer. > > [1] > http://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com > > Signed-off-by: Salvatore Mesoraca > --- > crypto/internal.h | 8 > 1 file changed, 8 insertions(+) > > diff --git a/crypto/internal.h b/crypto/internal.h > index 9a3f399..89ae41e 100644 > --- a/crypto/internal.h > +++ b/crypto/internal.h > @@ -26,6 +26,14 @@ > #include > #include > > +/* > + * Maximum values for blocksize and alignmask, used to allocate > + * static buffers that are big enough for any combination of > + * ciphers and architectures. > + */ > +#define MAX_BLOCKSIZE16 > +#define MAX_ALIGNMASK15 No please don't put this here if you intend on using it everywhere. This file is reserved for truly internal bits. Perhaps include/crypto/algapi.h would be a better place. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[PATCH 1/6] crypto: api - laying macros for statically allocated buffers
Creating 2 new compile-time constants for internal use, in preparation for the removal of VLAs[1] from crypto code. All ciphers implemented in Linux have a block size less than or equal to 16 bytes and the most demanding hw require 16 bytes alignment for the block buffer. [1] http://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Salvatore Mesoraca --- crypto/internal.h | 8 1 file changed, 8 insertions(+) diff --git a/crypto/internal.h b/crypto/internal.h index 9a3f399..89ae41e 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -26,6 +26,14 @@ #include #include +/* + * Maximum values for blocksize and alignmask, used to allocate + * static buffers that are big enough for any combination of + * ciphers and architectures. + */ +#define MAX_BLOCKSIZE 16 +#define MAX_ALIGNMASK 15 + /* Crypto notification events. */ enum { CRYPTO_MSG_ALG_REQUEST, -- 1.9.1