summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/cfb_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des/cfb_enc.c')
-rw-r--r--src/lib/libcrypto/des/cfb_enc.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c
index 2600bdfc93..03cabb223c 100644
--- a/src/lib/libcrypto/des/cfb_enc.c
+++ b/src/lib/libcrypto/des/cfb_enc.c
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "e_os.h"
59#include "des_locl.h" 60#include "des_locl.h"
60 61
61/* The input and output are loaded in multiples of 8 bits. 62/* The input and output are loaded in multiples of 8 bits.
@@ -64,17 +65,15 @@
64 * the second. The second 12 bits will come from the 3rd and half the 4th 65 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte. 66 * byte.
66 */ 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 68/* 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. */ 69 * 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, 70void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
72 long length, DES_key_schedule *schedule, DES_cblock *ivec, 71 long length, DES_key_schedule *schedule, DES_cblock *ivec,
73 int enc) 72 int enc)
74 { 73 {
75 register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; 74 register DES_LONG d0,d1,v0,v1;
76 register unsigned long l=length; 75 register unsigned long l=length,n=(numbits+7)/8;
77 register int num=numbits; 76 register int num=numbits,i;
78 DES_LONG ti[2]; 77 DES_LONG ti[2];
79 unsigned char *iv; 78 unsigned char *iv;
80 unsigned char ovec[16]; 79 unsigned char ovec[16];
@@ -114,10 +113,10 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
114 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); 113 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
115 /* now the remaining bits */ 114 /* now the remaining bits */
116 if(num%8 != 0) 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; 118 ovec[i]<<=num%8;
120 ovec[n]|=ovec[n+1]>>(8-num%8); 119 ovec[i]|=ovec[i+1]>>(8-num%8);
121 } 120 }
122 iv=&ovec[0]; 121 iv=&ovec[0];
123 c2l(iv,v0); 122 c2l(iv,v0);
@@ -152,10 +151,10 @@ void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
152 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0)); 151 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
153 /* now the remaining bits */ 152 /* now the remaining bits */
154 if(num%8 != 0) 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; 156 ovec[i]<<=num%8;
158 ovec[n]|=ovec[n+1]>>(8-num%8); 157 ovec[i]|=ovec[i+1]>>(8-num%8);
159 } 158 }
160 iv=&ovec[0]; 159 iv=&ovec[0];
161 c2l(iv,v0); 160 c2l(iv,v0);