summaryrefslogtreecommitdiff
path: root/cbc.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2001-09-07 19:38:29 +0200
committerNiels Möller <nisse@lysator.liu.se>2001-09-07 19:38:29 +0200
commit97829771e9fa1317b2166f9d7a626212b355e5e0 (patch)
tree380760696c366b11b70c6f495fd8c6f3ca9da926 /cbc.c
parent4fc4077870fe97ce762e7d4bcb370d47c6eb7259 (diff)
downloadnettle-97829771e9fa1317b2166f9d7a626212b355e5e0.tar.gz
Work-in-progress.
Rev: src/nettle/Makefile.am:1.12 Rev: src/nettle/cbc.c:1.2 Rev: src/nettle/cbc.h:1.2
Diffstat (limited to 'cbc.c')
-rw-r--r--cbc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/cbc.c b/cbc.c
index 768ba1db..d12ed79a 100644
--- a/cbc.c
+++ b/cbc.c
@@ -25,7 +25,11 @@
#include "cbc.h"
+#include "memxor.h"
+
#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
void
cbc_encrypt(void *ctx, void (*f)(void *ctx,
@@ -40,7 +44,7 @@ cbc_encrypt(void *ctx, void (*f)(void *ctx,
for ( ; length; length -= block_size, src += block_size, dst += block_size)
{
memxor(iv, src, block_size);
- f(ctx, dst, src, block_size);
+ f(ctx, block_size, dst, src);
memcpy(iv, dst, block_size);
}
}
@@ -69,10 +73,21 @@ cbc_decrypt(void *ctx, void (*f)(void *ctx,
}
/* Decrypt in ECB mode */
- f(ctx, dst, src, length);
+ f(ctx, length, dst, src);
/* XOR the cryptotext, shifted one block */
memxor(dst, iv, block_size);
memxor(dst + block_size, src, length - block_size);
memcpy(iv, src + length - block_size, block_size);
}
+
+#include "des.h"
+static void foo(void)
+{
+ struct des_ctx ctx;
+ uint8_t iv[DES_BLOCK_SIZE];
+ uint8_t src[DES_BLOCK_SIZE];
+ uint8_t dst[DES_BLOCK_SIZE];
+
+ CBC_ENCRYPT(&ctx, des_encrypt, DES_BLOCK_SIZE, iv, DES_BLOCK_SIZE, dst, src);
+}