]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/des/cfb64ede.c
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
14 * The input and output encrypted as though 64bit cfb mode is being used.
15 * The extra state information to record how much of the 64bit block we have
16 * used is contained in *num;
19 void DES_ede3_cfb64_encrypt(const unsigned char *in
, unsigned char *out
,
20 long length
, DES_key_schedule
*ks1
,
21 DES_key_schedule
*ks2
, DES_key_schedule
*ks3
,
22 DES_cblock
*ivec
, int *num
, int enc
)
24 register DES_LONG v0
, v1
;
25 register long l
= length
;
26 register int n
= *num
;
28 unsigned char *iv
, c
, cc
;
39 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
61 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
77 v0
= v1
= ti
[0] = ti
[1] = c
= cc
= 0;
82 * This is compatible with the single key CFB-r for DES, even thought that's
86 void DES_ede3_cfb_encrypt(const unsigned char *in
, unsigned char *out
,
87 int numbits
, long length
, DES_key_schedule
*ks1
,
88 DES_key_schedule
*ks2
, DES_key_schedule
*ks3
,
89 DES_cblock
*ivec
, int enc
)
91 register DES_LONG d0
, d1
, v0
, v1
;
92 register unsigned long l
= length
, n
= ((unsigned int)numbits
+ 7) / 8;
93 register int num
= numbits
, i
;
96 unsigned char ovec
[16];
108 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
113 l2cn(d0
, d1
, out
, n
);
116 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under
122 } else if (num
== 64) {
131 /* shift ovec left most of the bits... */
132 memmove(ovec
, ovec
+ num
/ 8, 8 + (num
% 8 ? 1 : 0));
133 /* now the remaining bits */
135 for (i
= 0; i
< 8; ++i
) {
137 ovec
[i
] |= ovec
[i
+ 1] >> (8 - num
% 8);
149 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
153 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under
159 } else if (num
== 64) {
168 /* shift ovec left most of the bits... */
169 memmove(ovec
, ovec
+ num
/ 8, 8 + (num
% 8 ? 1 : 0));
170 /* now the remaining bits */
172 for (i
= 0; i
< 8; ++i
) {
174 ovec
[i
] |= ovec
[i
+ 1] >> (8 - num
% 8);
182 l2cn(d0
, d1
, out
, n
);
189 v0
= v1
= d0
= d1
= ti
[0] = ti
[1] = 0;