[OpenSEED-CVSlog] [Commit] openseed/src seed_ofb.c
Status: Beta
Brought to you by:
perky
|
From: Chang <pe...@us...> - 2001-11-16 06:13:33
|
perky 01/11/15 22:13:32
Modified: src seed_ofb.c
Log:
correct OFB encrypt IV handling
Revision Changes Path
1.3 +13 -15 openseed/src/seed_ofb.c
Index: seed_ofb.c
===================================================================
RCS file: /cvsroot/openseed/openseed/src/seed_ofb.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- seed_ofb.c 2001/11/16 04:37:11 1.2
+++ seed_ofb.c 2001/11/16 06:13:31 1.3
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: seed_ofb.c,v 1.2 2001/11/16 04:37:11 perky Exp $
+ * $Id: seed_ofb.c,v 1.3 2001/11/16 06:13:31 perky Exp $
*/
#include <stdlib.h>
@@ -40,44 +40,42 @@
seed_ofb_encrypt(const unsigned char *in, unsigned char *out, size_t length,
SEED_KEY_SCHEDULE ks, SEED_IV iv)
{
- const unsigned char *prev, *e_in=in+length;
+ const unsigned char *e_in=in+length;
+ unsigned char prev[SEED_BLOCK];
/* XXX: check block size */
- if (!iv) prev = NULLIV;
- else prev = iv;
+ if (!iv) { MOV_SEEDBLOCK(prev, NULLIV); }
+ else { MOV_SEEDBLOCK(prev, iv); }
for(; in < e_in; in += SEED_BLOCK, out += SEED_BLOCK) {
- seed_encrypt(out, in, ks);
- XOR_SEEDBLOCK(out, out, prev);
- prev = out;
+ seed_encrypt(prev, prev, ks);
+ XOR_SEEDBLOCK(out, prev, in);
}
if (iv) {
MOV_SEEDBLOCK(iv, prev);
}
- /* XXX: Padding ?? */
}
void
seed_ofb_decrypt(const unsigned char *in, unsigned char *out, size_t length,
SEED_KEY_SCHEDULE ks, SEED_IV iv)
{
- const unsigned char *prev, *e_in=in+length;
+ const unsigned char *e_in=in+length;
+ unsigned char prev[SEED_BLOCK];
/* XXX: check block size */
- if (!iv) prev = NULLIV;
- else prev = iv;
+ if (!iv) { MOV_SEEDBLOCK(prev, NULLIV); }
+ else { MOV_SEEDBLOCK(prev, iv); }
for(; in < e_in; in += SEED_BLOCK, out += SEED_BLOCK) {
- XOR_SEEDBLOCK(out, in, prev);
- seed_decrypt(out, out, ks);
- prev = in;
+ seed_encrypt(prev, prev, ks);
+ XOR_SEEDBLOCK(out, prev, in);
}
if (iv) {
MOV_SEEDBLOCK(iv, prev);
}
- /* XXX: Padding ?? */
}
/*
|