Deleted Added
full compact
des_setkey.c (55009) des_setkey.c (62587)
1/* $FreeBSD: head/sys/crypto/des/des_setkey.c 62587 2000-07-04 16:35:15Z itojun $ */
2/* $KAME: des_setkey.c,v 1.3 2000/03/27 04:36:33 sumikawa Exp $ */
3
1/* crypto/des/set_key.c */
2/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
3 * All rights reserved.
4 *
5 * This file is part of an SSL implementation written
6 * by Eric Young (eay@mincom.oz.au).
7 * The implementation was written so as to conform with Netscapes SSL
8 * specification. This library and applications are

--- 29 unchanged lines hidden (view full) ---

38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * The licence and distribution terms for any publically available version or
43 * derivative of this code cannot be changed. i.e. this code cannot simply be
44 * copied and put under another distribution licence
45 * [including the GNU Public Licence.]
4/* crypto/des/set_key.c */
5/* Copyright (C) 1995-1996 Eric Young (eay@mincom.oz.au)
6 * All rights reserved.
7 *
8 * This file is part of an SSL implementation written
9 * by Eric Young (eay@mincom.oz.au).
10 * The implementation was written so as to conform with Netscapes SSL
11 * specification. This library and applications are

--- 29 unchanged lines hidden (view full) ---

41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 *
45 * The licence and distribution terms for any publically available version or
46 * derivative of this code cannot be changed. i.e. this code cannot simply be
47 * copied and put under another distribution licence
48 * [including the GNU Public Licence.]
46 *
47 * $FreeBSD: head/sys/crypto/des/des_setkey.c 55009 1999-12-22 19:13:38Z shin $
48 */
49
50/* set_key.c v 1.4 eay 24/9/91
51 * 1.4 Speed up by 400% :-)
52 * 1.3 added register declarations.
53 * 1.2 unrolled make_key_sched a bit more
54 * 1.1 added norm_expand_bits
55 * 1.0 First working version

--- 36 unchanged lines hidden (view full) ---

92 * %A D.W. Davies
93 * %A W.L. Price
94 * %T Security for Computer Networks
95 * %I John Wiley & Sons
96 * %D 1984
97 * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference
98 * (and actual cblock values).
99 */
49 */
50
51/* set_key.c v 1.4 eay 24/9/91
52 * 1.4 Speed up by 400% :-)
53 * 1.3 added register declarations.
54 * 1.2 unrolled make_key_sched a bit more
55 * 1.1 added norm_expand_bits
56 * 1.0 First working version

--- 36 unchanged lines hidden (view full) ---

93 * %A D.W. Davies
94 * %A W.L. Price
95 * %T Security for Computer Networks
96 * %I John Wiley & Sons
97 * %D 1984
98 * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference
99 * (and actual cblock values).
100 */
100#define NUM_WEAK_KEY 16
101#define NUM_WEAK_KEY 16
101static des_cblock weak_keys[NUM_WEAK_KEY]={
102 /* weak keys */
103 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
104 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
105 {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F},
106 {0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0},
107 /* semi-weak keys */
108 {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE},

--- 28 unchanged lines hidden (view full) ---

137
138/* NOW DEFINED IN des_local.h
139 * See ecb_encrypt.c for a pseudo description of these macros.
140 * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
141 * (b)^=(t),\
142 * (a)=((a)^((t)<<(n))))
143 */
144
102static des_cblock weak_keys[NUM_WEAK_KEY]={
103 /* weak keys */
104 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
105 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
106 {0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F},
107 {0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0},
108 /* semi-weak keys */
109 {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE},

--- 28 unchanged lines hidden (view full) ---

138
139/* NOW DEFINED IN des_local.h
140 * See ecb_encrypt.c for a pseudo description of these macros.
141 * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
142 * (b)^=(t),\
143 * (a)=((a)^((t)<<(n))))
144 */
145
145#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
146#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
146 (a)=(a)^(t)^(t>>(16-(n))))
147
148/* return 0 if key parity is odd (correct),
149 * return -1 if key parity error,
150 * return -2 if illegal weak key.
151 */
152int des_set_key(key, schedule)
153des_cblock (*key);

--- 64 unchanged lines hidden (view full) ---

218 t= des_skb[4][ (d )&0x3f ]|
219 des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]|
220 des_skb[6][ (d>>15L)&0x3f ]|
221 des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)];
222
223 /* table contained 0213 4657 */
224 *(k++)=((t<<16L)|(s&0x0000ffffL))&0xffffffffL;
225 s= ((s>>16L)|(t&0xffff0000L));
147 (a)=(a)^(t)^(t>>(16-(n))))
148
149/* return 0 if key parity is odd (correct),
150 * return -1 if key parity error,
151 * return -2 if illegal weak key.
152 */
153int des_set_key(key, schedule)
154des_cblock (*key);

--- 64 unchanged lines hidden (view full) ---

219 t= des_skb[4][ (d )&0x3f ]|
220 des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]|
221 des_skb[6][ (d>>15L)&0x3f ]|
222 des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)];
223
224 /* table contained 0213 4657 */
225 *(k++)=((t<<16L)|(s&0x0000ffffL))&0xffffffffL;
226 s= ((s>>16L)|(t&0xffff0000L));
226
227
227 s=(s<<4L)|(s>>28L);
228 *(k++)=s&0xffffffffL;
229 }
230 return(0);
231 }
232
233int des_key_sched(key, schedule)
234des_cblock (*key);
235des_key_schedule schedule;
236 {
237 return(des_set_key(key,schedule));
238 }
228 s=(s<<4L)|(s>>28L);
229 *(k++)=s&0xffffffffL;
230 }
231 return(0);
232 }
233
234int des_key_sched(key, schedule)
235des_cblock (*key);
236des_key_schedule schedule;
237 {
238 return(des_set_key(key,schedule));
239 }