linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Q: crypto/cipher.c
Date: Mon, 20 Apr 2009 19:41:35 +0100	[thread overview]
Message-ID: <49ECC1DF.3040401@grupopie.com> (raw)
In-Reply-To: <BD79186B4FD85F4B8E60E381CAEE1909015F9237@mi8nycmail19.Mi8.com>

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."

      reply	other threads:[~2009-04-20 18:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-18  0:24 Q: crypto/cipher.c H Hartley Sweeten
2009-04-20 18:41 ` Paulo Marques [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49ECC1DF.3040401@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=hartleys@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).