* Q: crypto/cipher.c
@ 2009-04-18 0:24 H Hartley Sweeten
2009-04-20 18:41 ` Paulo Marques
0 siblings, 1 reply; 2+ messages in thread
From: H Hartley Sweeten @ 2009-04-18 0:24 UTC (permalink / raw)
To: linux-kernel
Hello all,
I have a question about the following code in crypto/cipher.c.
static void cipher_crypt_unaligned(void (*fn)(struct crypto_tfm *, u8 *,
const u8 *),
struct crypto_tfm *tfm,
u8 *dst, const u8 *src)
{
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
unsigned int size = crypto_tfm_alg_blocksize(tfm);
u8 buffer[size + alignmask];
u8 *tmp = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
memcpy(tmp, src, size);
fn(tfm, tmp, tmp);
memcpy(dst, tmp, size);
}
Doesn't the size of buffer need to be known at compile time for this
to actually work? Or do alignmask and size work out to be constants?
This appears to be buggy. But I may just be missing something...
Thanks,
Hartley
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Q: crypto/cipher.c
2009-04-18 0:24 Q: crypto/cipher.c H Hartley Sweeten
@ 2009-04-20 18:41 ` Paulo Marques
0 siblings, 0 replies; 2+ messages in thread
From: Paulo Marques @ 2009-04-20 18:41 UTC (permalink / raw)
To: H Hartley Sweeten; +Cc: linux-kernel
H Hartley Sweeten wrote:
> Hello all,
Hi,
> I have a question about the following code in crypto/cipher.c.
>
> static void cipher_crypt_unaligned(void (*fn)(struct crypto_tfm *, u8 *,
> const u8 *),
> struct crypto_tfm *tfm,
> u8 *dst, const u8 *src)
> {
> unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
> unsigned int size = crypto_tfm_alg_blocksize(tfm);
> u8 buffer[size + alignmask];
> u8 *tmp = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
>
> memcpy(tmp, src, size);
> fn(tfm, tmp, tmp);
> memcpy(dst, tmp, size);
> }
>
> Doesn't the size of buffer need to be known at compile time for this
> to actually work? Or do alignmask and size work out to be constants?
>
> This appears to be buggy. But I may just be missing something...
It's a GCC extension:
http://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html
--
Paulo Marques - www.grupopie.com
"All generalizations are false."
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-20 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-18 0:24 Q: crypto/cipher.c H Hartley Sweeten
2009-04-20 18:41 ` Paulo Marques
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.