* [PATCH] crypto: fix key alignment in tcrypt
@ 2006-03-08 14:11 Atsushi Nemoto
2006-03-11 23:12 ` Matt Mackall
0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2006-03-08 14:11 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-crypto, herbert, akpm
Force 32-bit alignment on keys in tcrypt test vectors.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index 733d07e..050f852 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -31,7 +31,7 @@ struct hash_testvec {
char digest[MAX_DIGEST_SIZE];
unsigned char np;
unsigned char tap[MAX_TAP];
- char key[128]; /* only used with keyed hash algorithms */
+ char key[128] __attribute__((__aligned__(4))); /* only used with keyed hash algorithms */
unsigned char ksize;
};
@@ -48,7 +48,7 @@ struct hmac_testvec {
struct cipher_testvec {
unsigned char fail;
unsigned char wk; /* weak key flag */
- char key[MAX_KEYLEN];
+ char key[MAX_KEYLEN] __attribute__((__aligned__(4)));
unsigned char klen;
char iv[MAX_IVLEN];
char input[48];
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] crypto: fix key alignment in tcrypt
2006-03-08 14:11 [PATCH] crypto: fix key alignment in tcrypt Atsushi Nemoto
@ 2006-03-11 23:12 ` Matt Mackall
2006-03-11 23:29 ` Andreas Schwab
0 siblings, 1 reply; 5+ messages in thread
From: Matt Mackall @ 2006-03-11 23:12 UTC (permalink / raw)
To: Atsushi Nemoto; +Cc: linux-kernel, linux-crypto, herbert, akpm
On Wed, Mar 08, 2006 at 11:11:55PM +0900, Atsushi Nemoto wrote:
> Force 32-bit alignment on keys in tcrypt test vectors.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>
> diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
> index 733d07e..050f852 100644
> --- a/crypto/tcrypt.h
> +++ b/crypto/tcrypt.h
> @@ -31,7 +31,7 @@ struct hash_testvec {
> char digest[MAX_DIGEST_SIZE];
> unsigned char np;
> unsigned char tap[MAX_TAP];
> - char key[128]; /* only used with keyed hash algorithms */
> + char key[128] __attribute__((__aligned__(4))); /* only used with keyed hash algorithms */
> unsigned char ksize;
> };
>
> @@ -48,7 +48,7 @@ struct hmac_testvec {
> struct cipher_testvec {
> unsigned char fail;
> unsigned char wk; /* weak key flag */
> - char key[MAX_KEYLEN];
> + char key[MAX_KEYLEN] __attribute__((__aligned__(4)));
> unsigned char klen;
> char iv[MAX_IVLEN];
> char input[48];
Wouldn't it be better to simply move this to the head of the structure?
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] crypto: fix key alignment in tcrypt
2006-03-11 23:12 ` Matt Mackall
@ 2006-03-11 23:29 ` Andreas Schwab
2006-03-11 23:48 ` Matt Mackall
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2006-03-11 23:29 UTC (permalink / raw)
To: Matt Mackall; +Cc: Atsushi Nemoto, linux-kernel, linux-crypto, herbert, akpm
Matt Mackall <mpm@selenic.com> writes:
> On Wed, Mar 08, 2006 at 11:11:55PM +0900, Atsushi Nemoto wrote:
>> Force 32-bit alignment on keys in tcrypt test vectors.
>>
>> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>>
>> diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
>> index 733d07e..050f852 100644
>> --- a/crypto/tcrypt.h
>> +++ b/crypto/tcrypt.h
>> @@ -31,7 +31,7 @@ struct hash_testvec {
>> char digest[MAX_DIGEST_SIZE];
>> unsigned char np;
>> unsigned char tap[MAX_TAP];
>> - char key[128]; /* only used with keyed hash algorithms */
>> + char key[128] __attribute__((__aligned__(4))); /* only used with keyed hash algorithms */
>> unsigned char ksize;
>> };
>>
>> @@ -48,7 +48,7 @@ struct hmac_testvec {
>> struct cipher_testvec {
>> unsigned char fail;
>> unsigned char wk; /* weak key flag */
>> - char key[MAX_KEYLEN];
>> + char key[MAX_KEYLEN] __attribute__((__aligned__(4)));
>> unsigned char klen;
>> char iv[MAX_IVLEN];
>> char input[48];
>
> Wouldn't it be better to simply move this to the head of the structure?
That wouldn't help, since the whole structure will still be only 8-bit
aligned.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] crypto: fix key alignment in tcrypt
2006-03-11 23:29 ` Andreas Schwab
@ 2006-03-11 23:48 ` Matt Mackall
2006-03-13 10:43 ` Herbert Xu
0 siblings, 1 reply; 5+ messages in thread
From: Matt Mackall @ 2006-03-11 23:48 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Atsushi Nemoto, linux-kernel, linux-crypto, herbert, akpm
On Sun, Mar 12, 2006 at 12:29:07AM +0100, Andreas Schwab wrote:
> Matt Mackall <mpm@selenic.com> writes:
>
> > On Wed, Mar 08, 2006 at 11:11:55PM +0900, Atsushi Nemoto wrote:
> >> Force 32-bit alignment on keys in tcrypt test vectors.
> >>
> >> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> >>
> >> diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
> >> index 733d07e..050f852 100644
> >> --- a/crypto/tcrypt.h
> >> +++ b/crypto/tcrypt.h
> >> @@ -31,7 +31,7 @@ struct hash_testvec {
> >> char digest[MAX_DIGEST_SIZE];
> >> unsigned char np;
> >> unsigned char tap[MAX_TAP];
> >> - char key[128]; /* only used with keyed hash algorithms */
> >> + char key[128] __attribute__((__aligned__(4))); /* only used with keyed hash algorithms */
> >> unsigned char ksize;
> >> };
> >>
> >> @@ -48,7 +48,7 @@ struct hmac_testvec {
> >> struct cipher_testvec {
> >> unsigned char fail;
> >> unsigned char wk; /* weak key flag */
> >> - char key[MAX_KEYLEN];
> >> + char key[MAX_KEYLEN] __attribute__((__aligned__(4)));
> >> unsigned char klen;
> >> char iv[MAX_IVLEN];
> >> char input[48];
> >
> > Wouldn't it be better to simply move this to the head of the structure?
>
> That wouldn't help, since the whole structure will still be only 8-bit
> aligned.
Ahh, hadn't noticed the struct was entirely populated by chars.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] crypto: fix key alignment in tcrypt
2006-03-11 23:48 ` Matt Mackall
@ 2006-03-13 10:43 ` Herbert Xu
0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2006-03-13 10:43 UTC (permalink / raw)
To: Matt Mackall
Cc: Andreas Schwab, Atsushi Nemoto, linux-kernel, linux-crypto, akpm
On Sat, Mar 11, 2006 at 05:48:41PM -0600, Matt Mackall wrote:
>
> > > Wouldn't it be better to simply move this to the head of the structure?
> >
> > That wouldn't help, since the whole structure will still be only 8-bit
> > aligned.
>
> Ahh, hadn't noticed the struct was entirely populated by chars.
Actually moving it to the head is good anyway because we may reduce the
amount of padding between vectors. On i386 however it is size-neutral
with respect to the vectors. However, it did save 45 bytes on the code
front.
I've applied the patch with the structure rearrangement so that the large
power-of-2 sized members come first.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-03-13 10:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-08 14:11 [PATCH] crypto: fix key alignment in tcrypt Atsushi Nemoto
2006-03-11 23:12 ` Matt Mackall
2006-03-11 23:29 ` Andreas Schwab
2006-03-11 23:48 ` Matt Mackall
2006-03-13 10:43 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox