summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2013-06-06 08:12:37 +1000
committerDarren Tucker <dtucker@zip.com.au>2013-06-06 08:12:37 +1000
commit4ac66af091cf6db5a42c18e43738ca9c41e338e5 (patch)
tree541bce15520b26aa1a16e28ccbe4ab1d50349449
parentea8342c248ad6c0a4fe1a70de133f954973bd2b2 (diff)
- 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@
-rw-r--r--ChangeLog5
-rw-r--r--mac.c19
2 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 40b15c144..5aa24bd4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,11 @@
17 [clientloop.h clientloop.c mux.c] 17 [clientloop.h clientloop.c mux.c]
18 No need for the mux cleanup callback to be visible so restore it to static 18 No need for the mux cleanup callback to be visible so restore it to static
19 and call it through the detach_user function pointer. ok djm@ 19 and call it through the detach_user function pointer. ok djm@
20 - dtucker@cvs.openbsd.org 2013/06/03 00:03:18
21 [mac.c]
22 force the MAC output to be 64-bit aligned so umac won't see unaligned
23 accesses on strict-alignment architectures. bz#2101, patch from
24 tomas.kuthan at oracle.com, ok djm@
20 25
2120130602 2620130602
22 - (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy 27 - (tim) [Makefile.in] Make Solaris, UnixWare, & OpenServer linkers happy
diff --git a/mac.c b/mac.c
index 907e19781..c4dfb501d 100644
--- a/mac.c
+++ b/mac.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mac.c,v 1.23 2013/05/17 00:13:13 djm Exp $ */ 1/* $OpenBSD: mac.c,v 1.24 2013/06/03 00:03:18 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -174,12 +174,15 @@ mac_init(Mac *mac)
174u_char * 174u_char *
175mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen) 175mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
176{ 176{
177 static u_char m[EVP_MAX_MD_SIZE]; 177 static union {
178 u_char m[EVP_MAX_MD_SIZE];
179 u_int64_t for_align;
180 } u;
178 u_char b[4], nonce[8]; 181 u_char b[4], nonce[8];
179 182
180 if (mac->mac_len > sizeof(m)) 183 if (mac->mac_len > sizeof(u))
181 fatal("mac_compute: mac too long %u %lu", 184 fatal("mac_compute: mac too long %u %lu",
182 mac->mac_len, (u_long)sizeof(m)); 185 mac->mac_len, (u_long)sizeof(u));
183 186
184 switch (mac->type) { 187 switch (mac->type) {
185 case SSH_EVP: 188 case SSH_EVP:
@@ -188,22 +191,22 @@ mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
188 HMAC_Init(&mac->evp_ctx, NULL, 0, NULL); 191 HMAC_Init(&mac->evp_ctx, NULL, 0, NULL);
189 HMAC_Update(&mac->evp_ctx, b, sizeof(b)); 192 HMAC_Update(&mac->evp_ctx, b, sizeof(b));
190 HMAC_Update(&mac->evp_ctx, data, datalen); 193 HMAC_Update(&mac->evp_ctx, data, datalen);
191 HMAC_Final(&mac->evp_ctx, m, NULL); 194 HMAC_Final(&mac->evp_ctx, u.m, NULL);
192 break; 195 break;
193 case SSH_UMAC: 196 case SSH_UMAC:
194 put_u64(nonce, seqno); 197 put_u64(nonce, seqno);
195 umac_update(mac->umac_ctx, data, datalen); 198 umac_update(mac->umac_ctx, data, datalen);
196 umac_final(mac->umac_ctx, m, nonce); 199 umac_final(mac->umac_ctx, u.m, nonce);
197 break; 200 break;
198 case SSH_UMAC128: 201 case SSH_UMAC128:
199 put_u64(nonce, seqno); 202 put_u64(nonce, seqno);
200 umac128_update(mac->umac_ctx, data, datalen); 203 umac128_update(mac->umac_ctx, data, datalen);
201 umac128_final(mac->umac_ctx, m, nonce); 204 umac128_final(mac->umac_ctx, u.m, nonce);
202 break; 205 break;
203 default: 206 default:
204 fatal("mac_compute: unknown MAC type"); 207 fatal("mac_compute: unknown MAC type");
205 } 208 }
206 return (m); 209 return (u.m);
207} 210}
208 211
209void 212void