Deleted Added
sdiff udiff text old ( 55009 ) new ( 62587 )
full compact
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
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.]
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 */
101#define NUM_WEAK_KEY 16
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
146#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
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));
227
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 }