- djm@cvs.openbsd.org 2013/07/20 01:43:46

[umac.c]
     use a union to ensure correct alignment; ok deraadt
This commit is contained in:
Damien Miller 2013-07-20 13:22:13 +10:00
parent 85b45e0918
commit 32ecfa0f79
2 changed files with 12 additions and 7 deletions

View File

@ -6,6 +6,9 @@
add ssh-agent(1) support to sshd(8); allows encrypted hostkeys, add ssh-agent(1) support to sshd(8); allows encrypted hostkeys,
or hostkeys on smartcards; most of the work by Zev Weiss; bz #1974 or hostkeys on smartcards; most of the work by Zev Weiss; bz #1974
ok djm@ ok djm@
- djm@cvs.openbsd.org 2013/07/20 01:43:46
[umac.c]
use a union to ensure correct alignment; ok deraadt
20130718 20130718
- (djm) OpenBSD CVS Sync - (djm) OpenBSD CVS Sync

16
umac.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: umac.c,v 1.5 2013/05/17 00:13:14 djm Exp $ */ /* $OpenBSD: umac.c,v 1.6 2013/07/20 01:43:46 djm Exp $ */
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* *
* umac.c -- C Implementation UMAC Message Authentication * umac.c -- C Implementation UMAC Message Authentication
@ -254,19 +254,21 @@ static void pdf_gen_xor(pdf_ctx *pc, UINT8 nonce[8], UINT8 buf[8])
#elif (UMAC_OUTPUT_LEN > 8) #elif (UMAC_OUTPUT_LEN > 8)
#define LOW_BIT_MASK 0 #define LOW_BIT_MASK 0
#endif #endif
union {
UINT8 tmp_nonce_lo[4]; UINT8 tmp_nonce_lo[4];
UINT32 align;
} t;
#if LOW_BIT_MASK != 0 #if LOW_BIT_MASK != 0
int ndx = nonce[7] & LOW_BIT_MASK; int ndx = nonce[7] & LOW_BIT_MASK;
#endif #endif
*(UINT32 *)tmp_nonce_lo = ((UINT32 *)nonce)[1]; *(UINT32 *)t.tmp_nonce_lo = ((UINT32 *)nonce)[1];
tmp_nonce_lo[3] &= ~LOW_BIT_MASK; /* zero last bit */ t.tmp_nonce_lo[3] &= ~LOW_BIT_MASK; /* zero last bit */
if ( (((UINT32 *)tmp_nonce_lo)[0] != ((UINT32 *)pc->nonce)[1]) || if ( (((UINT32 *)t.tmp_nonce_lo)[0] != ((UINT32 *)pc->nonce)[1]) ||
(((UINT32 *)nonce)[0] != ((UINT32 *)pc->nonce)[0]) ) (((UINT32 *)nonce)[0] != ((UINT32 *)pc->nonce)[0]) )
{ {
((UINT32 *)pc->nonce)[0] = ((UINT32 *)nonce)[0]; ((UINT32 *)pc->nonce)[0] = ((UINT32 *)nonce)[0];
((UINT32 *)pc->nonce)[1] = ((UINT32 *)tmp_nonce_lo)[0]; ((UINT32 *)pc->nonce)[1] = ((UINT32 *)t.tmp_nonce_lo)[0];
aes_encryption(pc->nonce, pc->cache, pc->prf_key); aes_encryption(pc->nonce, pc->cache, pc->prf_key);
} }