- dtucker@cvs.openbsd.org 2013/06/03 00:03:18
[mac.c] force the MAC output to be 64-bit aligned so umac won't see unaligned accesses on strict-alignment architectures. bz#2101, patch from tomas.kuthan at oracle.com, ok djm@
This commit is contained in:
parent
ea8342c248
commit
4ac66af091
|
@ -17,6 +17,11 @@
|
||||||
[clientloop.h clientloop.c mux.c]
|
[clientloop.h clientloop.c mux.c]
|
||||||
No need for the mux cleanup callback to be visible so restore it to static
|
No need for the mux cleanup callback to be visible so restore it to static
|
||||||
and call it through the detach_user function pointer. ok djm@
|
and call it through the detach_user function pointer. ok djm@
|
||||||
|
- dtucker@cvs.openbsd.org 2013/06/03 00:03:18
|
||||||
|
[mac.c]
|
||||||
|
force the MAC output to be 64-bit aligned so umac won't see unaligned
|
||||||
|
accesses on strict-alignment architectures. bz#2101, patch from
|
||||||
|
tomas.kuthan at oracle.com, ok djm@
|
||||||
|
|
||||||
20130602
|
20130602
|
||||||
- (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy
|
- (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy
|
||||||
|
|
19
mac.c
19
mac.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: mac.c,v 1.23 2013/05/17 00:13:13 djm Exp $ */
|
/* $OpenBSD: mac.c,v 1.24 2013/06/03 00:03:18 dtucker Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
* Copyright (c) 2001 Markus Friedl. All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -174,12 +174,15 @@ mac_init(Mac *mac)
|
||||||
u_char *
|
u_char *
|
||||||
mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
|
mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
|
||||||
{
|
{
|
||||||
static u_char m[EVP_MAX_MD_SIZE];
|
static union {
|
||||||
|
u_char m[EVP_MAX_MD_SIZE];
|
||||||
|
u_int64_t for_align;
|
||||||
|
} u;
|
||||||
u_char b[4], nonce[8];
|
u_char b[4], nonce[8];
|
||||||
|
|
||||||
if (mac->mac_len > sizeof(m))
|
if (mac->mac_len > sizeof(u))
|
||||||
fatal("mac_compute: mac too long %u %lu",
|
fatal("mac_compute: mac too long %u %lu",
|
||||||
mac->mac_len, (u_long)sizeof(m));
|
mac->mac_len, (u_long)sizeof(u));
|
||||||
|
|
||||||
switch (mac->type) {
|
switch (mac->type) {
|
||||||
case SSH_EVP:
|
case SSH_EVP:
|
||||||
|
@ -188,22 +191,22 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
|
||||||
HMAC_Init(&mac->evp_ctx, NULL, 0, NULL);
|
HMAC_Init(&mac->evp_ctx, NULL, 0, NULL);
|
||||||
HMAC_Update(&mac->evp_ctx, b, sizeof(b));
|
HMAC_Update(&mac->evp_ctx, b, sizeof(b));
|
||||||
HMAC_Update(&mac->evp_ctx, data, datalen);
|
HMAC_Update(&mac->evp_ctx, data, datalen);
|
||||||
HMAC_Final(&mac->evp_ctx, m, NULL);
|
HMAC_Final(&mac->evp_ctx, u.m, NULL);
|
||||||
break;
|
break;
|
||||||
case SSH_UMAC:
|
case SSH_UMAC:
|
||||||
put_u64(nonce, seqno);
|
put_u64(nonce, seqno);
|
||||||
umac_update(mac->umac_ctx, data, datalen);
|
umac_update(mac->umac_ctx, data, datalen);
|
||||||
umac_final(mac->umac_ctx, m, nonce);
|
umac_final(mac->umac_ctx, u.m, nonce);
|
||||||
break;
|
break;
|
||||||
case SSH_UMAC128:
|
case SSH_UMAC128:
|
||||||
put_u64(nonce, seqno);
|
put_u64(nonce, seqno);
|
||||||
umac128_update(mac->umac_ctx, data, datalen);
|
umac128_update(mac->umac_ctx, data, datalen);
|
||||||
umac128_final(mac->umac_ctx, m, nonce);
|
umac128_final(mac->umac_ctx, u.m, nonce);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatal("mac_compute: unknown MAC type");
|
fatal("mac_compute: unknown MAC type");
|
||||||
}
|
}
|
||||||
return (m);
|
return (u.m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue