Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/crypto/dist/ssh Reduce swap_bytes() to a non-alignment depen...
details: https://anonhg.NetBSD.org/src/rev/e16905615d7d
branches: trunk
changeset: 498422:e16905615d7d
user: simonb <simonb%NetBSD.org@localhost>
date: Mon Oct 23 11:40:55 2000 +0000
description:
Reduce swap_bytes() to a non-alignment dependent implementation - some
calls to swap_bytes() do indeed have non-aligned sources and destinations.
Fixes unaligned access problems on alpha and probably some of our other
architectures.
diffstat:
crypto/dist/ssh/cipher.c | 35 ++++++++++++++---------------------
1 files changed, 14 insertions(+), 21 deletions(-)
diffs (59 lines):
diff -r 737c3aa9a502 -r e16905615d7d crypto/dist/ssh/cipher.c
--- a/crypto/dist/ssh/cipher.c Mon Oct 23 11:32:30 2000 +0000
+++ b/crypto/dist/ssh/cipher.c Mon Oct 23 11:40:55 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cipher.c,v 1.1.1.1 2000/09/28 22:09:53 thorpej Exp $ */
+/* $NetBSD: cipher.c,v 1.2 2000/10/23 11:40:55 simonb Exp $ */
/*
* Author: Tatu Ylonen <ylo%cs.hut.fi@localhost>
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: cipher.c,v 1.1.1.1 2000/09/28 22:09:53 thorpej Exp $");
+__RCSID("$NetBSD: cipher.c,v 1.2 2000/10/23 11:40:55 simonb Exp $");
#endif
#include "includes.h"
@@ -113,28 +113,21 @@
* and after encryption/decryption. Thus the swap_bytes stuff (yuk).
*/
static void
-swap_bytes(const unsigned char *src, unsigned char *dst_, int n)
+swap_bytes(const unsigned char *src, unsigned char *dst, int n)
{
- /* dst must be properly aligned. */
- u_int32_t *dst = (u_int32_t *) dst_;
- union {
- u_int32_t i;
- char c[4];
- } t;
+ char c[4];
- /* Process 8 bytes every lap. */
- for (n = n / 8; n > 0; n--) {
- t.c[3] = *src++;
- t.c[2] = *src++;
- t.c[1] = *src++;
- t.c[0] = *src++;
- *dst++ = t.i;
+ /* Process 4 bytes every lap. */
+ for (n = n / 4; n > 0; n--) {
+ c[3] = *src++;
+ c[2] = *src++;
+ c[1] = *src++;
+ c[0] = *src++;
- t.c[3] = *src++;
- t.c[2] = *src++;
- t.c[1] = *src++;
- t.c[0] = *src++;
- *dst++ = t.i;
+ *dst++ = c[0];
+ *dst++ = c[1];
+ *dst++ = c[2];
+ *dst++ = c[3];
}
}
Home |
Main Index |
Thread Index |
Old Index