Deleted Added
sdiff udiff text old ( 55009 ) new ( 62587 )
full compact
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.]
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 */
100#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
145#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));
226
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 }