]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/des/cfb64ede.c
82e9a378378d4746491cb12a499ba1397b45909c
2 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
13 * The input and output encrypted as though 64bit cfb mode is being used.
14 * The extra state information to record how much of the 64bit block we have
15 * used is contained in *num;
18 void DES_ede3_cfb64_encrypt(const unsigned char *in
, unsigned char *out
,
19 long length
, DES_key_schedule
*ks1
,
20 DES_key_schedule
*ks2
, DES_key_schedule
*ks3
,
21 DES_cblock
*ivec
, int *num
, int enc
)
23 register DES_LONG v0
, v1
;
24 register long l
= length
;
25 register int n
= *num
;
27 unsigned char *iv
, c
, cc
;
38 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
60 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
76 v0
= v1
= ti
[0] = ti
[1] = c
= cc
= 0;
81 * This is compatible with the single key CFB-r for DES, even thought that's
85 void DES_ede3_cfb_encrypt(const unsigned char *in
, unsigned char *out
,
86 int numbits
, long length
, DES_key_schedule
*ks1
,
87 DES_key_schedule
*ks2
, DES_key_schedule
*ks3
,
88 DES_cblock
*ivec
, int enc
)
90 register DES_LONG d0
, d1
, v0
, v1
;
91 register unsigned long l
= length
, n
= ((unsigned int)numbits
+ 7) / 8;
92 register int num
= numbits
, i
;
95 unsigned char ovec
[16];
107 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
112 l2cn(d0
, d1
, out
, n
);
115 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under
121 } else if (num
== 64) {
130 /* shift ovec left most of the bits... */
131 memmove(ovec
, ovec
+ num
/ 8, 8 + (num
% 8 ? 1 : 0));
132 /* now the remaining bits */
134 for (i
= 0; i
< 8; ++i
) {
136 ovec
[i
] |= ovec
[i
+ 1] >> (8 - num
% 8);
148 DES_encrypt3(ti
, ks1
, ks2
, ks3
);
152 * 30-08-94 - eay - changed because l>>32 and l<<32 are bad under
158 } else if (num
== 64) {
167 /* shift ovec left most of the bits... */
168 memmove(ovec
, ovec
+ num
/ 8, 8 + (num
% 8 ? 1 : 0));
169 /* now the remaining bits */
171 for (i
= 0; i
< 8; ++i
) {
173 ovec
[i
] |= ovec
[i
+ 1] >> (8 - num
% 8);
181 l2cn(d0
, d1
, out
, n
);
188 v0
= v1
= d0
= d1
= ti
[0] = ti
[1] = 0;