Tue Apr 14 10:11:28 2009 UTC ()
Fix sign-compare issues


(lukem)
diff -r1.7 -r1.8 src/usr.bin/bdes/bdes.c

cvs diff -r1.7 -r1.8 src/usr.bin/bdes/bdes.c (expand / switch to unified diff)

--- src/usr.bin/bdes/bdes.c 2008/07/21 14:19:21 1.7
+++ src/usr.bin/bdes/bdes.c 2009/04/14 10:11:28 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bdes.c,v 1.7 2008/07/21 14:19:21 lukem Exp $ */ 1/* $NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Matt Bishop of Dartmouth College. 8 * Matt Bishop of Dartmouth College.
9 * 9 *
10 * The United States Government has rights in this work pursuant 10 * The United States Government has rights in this work pursuant
11 * to contract no. NAG 2-680 between the National Aeronautics and 11 * to contract no. NAG 2-680 between the National Aeronautics and
12 * Space Administration and Dartmouth College. 12 * Space Administration and Dartmouth College.
13 * 13 *
14 * Redistribution and use in source and binary forms, with or without 14 * Redistribution and use in source and binary forms, with or without
@@ -36,27 +36,27 @@ @@ -36,27 +36,27 @@
36 * SUCH DAMAGE. 36 * SUCH DAMAGE.
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#ifndef lint 40#ifndef lint
41__COPYRIGHT("@(#) Copyright (c) 1991, 1993\ 41__COPYRIGHT("@(#) Copyright (c) 1991, 1993\
42 The Regents of the University of California. All rights reserved."); 42 The Regents of the University of California. All rights reserved.");
43#endif /* not lint */ 43#endif /* not lint */
44 44
45#ifndef lint 45#ifndef lint
46#if 0 46#if 0
47static char sccsid[] = "@(#)bdes.c 8.1 (Berkeley) 6/6/93"; 47static char sccsid[] = "@(#)bdes.c 8.1 (Berkeley) 6/6/93";
48#else 48#else
49__RCSID("$NetBSD: bdes.c,v 1.7 2008/07/21 14:19:21 lukem Exp $"); 49__RCSID("$NetBSD: bdes.c,v 1.8 2009/04/14 10:11:28 lukem Exp $");
50#endif 50#endif
51#endif /* not lint */ 51#endif /* not lint */
52 52
53/* 53/*
54 * BDES -- DES encryption package for Berkeley Software Distribution 4.4 54 * BDES -- DES encryption package for Berkeley Software Distribution 4.4
55 * options: 55 * options:
56 * -a key is in ASCII 56 * -a key is in ASCII
57 * -b use ECB (electronic code book) mode 57 * -b use ECB (electronic code book) mode
58 * -d invert (decrypt) input 58 * -d invert (decrypt) input
59 * -f b use b-bit CFB (cipher feedback) mode 59 * -f b use b-bit CFB (cipher feedback) mode
60 * -F b use b-bit CFB (cipher feedback) alternative mode 60 * -F b use b-bit CFB (cipher feedback) alternative mode
61 * -k key use key as the cryptographic key 61 * -k key use key as the cryptographic key
62 * -m b generate a MAC of length b 62 * -m b generate a MAC of length b
@@ -114,27 +114,27 @@ __RCSID("$NetBSD: bdes.c,v 1.7 2008/07/2 @@ -114,27 +114,27 @@ __RCSID("$NetBSD: bdes.c,v 1.7 2008/07/2
114 char bits1[64]; /* bits of message */ \ 114 char bits1[64]; /* bits of message */ \
115 expand(buf, bits1); \ 115 expand(buf, bits1); \
116 if (encrypt(bits1, inverse)) \ 116 if (encrypt(bits1, inverse)) \
117 bdes_err(0, "encrypt"); \ 117 bdes_err(0, "encrypt"); \
118 compress(bits1, buf); \ 118 compress(bits1, buf); \
119 } 119 }
120#endif 120#endif
121 121
122/* 122/*
123 * this does an error-checking write 123 * this does an error-checking write
124 */ 124 */
125#define READ(buf, n) fread(buf, sizeof(char), n, stdin) 125#define READ(buf, n) fread(buf, sizeof(char), n, stdin)
126#define WRITE(buf,n) \ 126#define WRITE(buf,n) \
127 if (fwrite(buf, sizeof(char), n, stdout) != n) \ 127 if (fwrite(buf, sizeof(char), n, stdout) != (size_t)n) \
128 bdes_err(bn, NULL); 128 bdes_err(bn, NULL);
129 129
130/* 130/*
131 * some things to make references easier 131 * some things to make references easier
132 */ 132 */
133typedef char Desbuf[8]; 133typedef char Desbuf[8];
134#define CHAR(x,i) (x[i]) 134#define CHAR(x,i) (x[i])
135#define UCHAR(x,i) (x[i]) 135#define UCHAR(x,i) (x[i])
136#define BUFFER(x) (x) 136#define BUFFER(x) (x)
137#define UBUFFER(x) (x) 137#define UBUFFER(x) (x)
138 138
139/* 139/*
140 * global variables and related macros 140 * global variables and related macros