Deleted Added
full compact
cfb_enc.c (120631) cfb_enc.c (127128)
1/* crypto/des/cfb_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

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

51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
1/* crypto/des/cfb_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

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

51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "e_os.h"
59#include "des_locl.h"
60
61/* The input and output are loaded in multiples of 8 bits.
62 * What this means is that if you hame numbits=12 and length=2
63 * the first 12 bits will be retrieved from the first byte and half
64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte.
66 */
60#include "des_locl.h"
61
62/* The input and output are loaded in multiples of 8 bits.
63 * What this means is that if you hame numbits=12 and length=2
64 * the first 12 bits will be retrieved from the first byte and half
65 * the second. The second 12 bits will come from the 3rd and half the 4th
66 * byte.
67 */
67/* WARNING WARNING: this uses in and out in 8-byte chunks regardless of
68 * length */
69/* Until Aug 1 2003 this function did not correctly implement CFB-r, so it
70 * will not be compatible with any encryption prior to that date. Ben. */
71void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
72 long length, DES_key_schedule *schedule, DES_cblock *ivec,
73 int enc)
74 {
68/* Until Aug 1 2003 this function did not correctly implement CFB-r, so it
69 * will not be compatible with any encryption prior to that date. Ben. */
70void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
71 long length, DES_key_schedule *schedule, DES_cblock *ivec,
72 int enc)
73 {
75 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
76 register unsigned long l=length;
77 register int num=numbits;
74 register DES_LONG d0,d1,v0,v1;
75 register unsigned long l=length,n=(numbits+7)/8;
76 register int num=numbits,i;
78 DES_LONG ti[2];
79 unsigned char *iv;
80 unsigned char ovec[16];
81
82 if (num > 64) return;
83 iv = &(*ivec)[0];
84 c2l(iv,v0);
85 c2l(iv,v1);

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

109 l2c(v0,iv);
110 l2c(v1,iv);
111 l2c(d0,iv);
112 l2c(d1,iv);
113 /* shift ovec left most of the bits... */
114 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
115 /* now the remaining bits */
116 if(num%8 != 0)
77 DES_LONG ti[2];
78 unsigned char *iv;
79 unsigned char ovec[16];
80
81 if (num > 64) return;
82 iv = &(*ivec)[0];
83 c2l(iv,v0);
84 c2l(iv,v1);

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

108 l2c(v0,iv);
109 l2c(v1,iv);
110 l2c(d0,iv);
111 l2c(d1,iv);
112 /* shift ovec left most of the bits... */
113 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
114 /* now the remaining bits */
115 if(num%8 != 0)
117 for(n=0 ; n < 8 ; ++n)
116 for(i=0 ; i < 8 ; ++i)
118 {
117 {
119 ovec[n]<<=num%8;
120 ovec[n]|=ovec[n+1]>>(8-num%8);
118 ovec[i]<<=num%8;
119 ovec[i]|=ovec[i+1]>>(8-num%8);
121 }
122 iv=&ovec[0];
123 c2l(iv,v0);
124 c2l(iv,v1);
125 }
126 }
127 }
128 else

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

147 l2c(v0,iv);
148 l2c(v1,iv);
149 l2c(d0,iv);
150 l2c(d1,iv);
151 /* shift ovec left most of the bits... */
152 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
153 /* now the remaining bits */
154 if(num%8 != 0)
120 }
121 iv=&ovec[0];
122 c2l(iv,v0);
123 c2l(iv,v1);
124 }
125 }
126 }
127 else

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

146 l2c(v0,iv);
147 l2c(v1,iv);
148 l2c(d0,iv);
149 l2c(d1,iv);
150 /* shift ovec left most of the bits... */
151 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
152 /* now the remaining bits */
153 if(num%8 != 0)
155 for(n=0 ; n < 8 ; ++n)
154 for(i=0 ; i < 8 ; ++i)
156 {
155 {
157 ovec[n]<<=num%8;
158 ovec[n]|=ovec[n+1]>>(8-num%8);
156 ovec[i]<<=num%8;
157 ovec[i]|=ovec[i+1]>>(8-num%8);
159 }
160 iv=&ovec[0];
161 c2l(iv,v0);
162 c2l(iv,v1);
163 }
164 d0^=ti[0];
165 d1^=ti[1];
166 l2cn(d0,d1,out,n);
167 out+=n;
168 }
169 }
170 iv = &(*ivec)[0];
171 l2c(v0,iv);
172 l2c(v1,iv);
173 v0=v1=d0=d1=ti[0]=ti[1]=0;
174 }
175
158 }
159 iv=&ovec[0];
160 c2l(iv,v0);
161 c2l(iv,v1);
162 }
163 d0^=ti[0];
164 d1^=ti[1];
165 l2cn(d0,d1,out,n);
166 out+=n;
167 }
168 }
169 iv = &(*ivec)[0];
170 l2c(v0,iv);
171 l2c(v1,iv);
172 v0=v1=d0=d1=ti[0]=ti[1]=0;
173 }
174