summaryrefslogtreecommitdiff
path: root/cbc.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2001-09-09 00:28:18 +0200
committerNiels Möller <nisse@lysator.liu.se>2001-09-09 00:28:18 +0200
commit250c4c17021014f9baea92d357d75a063eb3ff66 (patch)
treebdd358d079feabdf23a6fb58a1e16525c19642ee /cbc.h
parent7e12e96ec6601dd5f20f498e38126499c99f8705 (diff)
downloadnettle-250c4c17021014f9baea92d357d75a063eb3ff66.tar.gz
* cbc.h (CBC_CTX): New macro.
(CBC_ENCRYPT): New macro. (CBC_DECRYPT): New macro. Rev: src/nettle/cbc.h:1.3
Diffstat (limited to 'cbc.h')
-rw-r--r--cbc.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/cbc.h b/cbc.h
index 2bf72e7c..dba52fdd 100644
--- a/cbc.h
+++ b/cbc.h
@@ -46,11 +46,44 @@ cbc_decrypt(void *ctx, void (*f)(void *ctx,
unsigned length, uint8_t *dst,
const uint8_t *src);
+#define CBC_CTX(type, size) \
+{ type ctx; uint8_t iv[size]; }
+
+#define CBC_SET_IV(ctx, data) \
+memcpy((ctx)->iv, (data), sizeof((ctx)->iv))
+
+#if 0
+#define CBC_ENCRYPT(self, f, length, dst, src) \
+do { if (0) (f)(&(self)->ctx, 0, NULL, NULL); \
+ cbc_encrypt((void *) &(self)->ctx, \
+ (void (*)(void *, unsigned, uint8_t *, const uint8_t *)) (f), \
+ sizeof((self)->iv), (self)->iv, \
+ (length), (dst), (src)); \
+} while (0)
+#endif
+
+#define CBC_ENCRYPT(self, f, length, dst, src) \
+(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
+ : cbc_encrypt((void *) &(self)->ctx, \
+ (void (*)(void *, unsigned, uint8_t *, const uint8_t *)) (f), \
+ sizeof((self)->iv), (self)->iv, \
+ (length), (dst), (src)))
+
+#define CBC_DECRYPT(self, f, length, dst, src) \
+(0 ? ((f)(&(self)->ctx, 0, NULL, NULL)) \
+ : cbc_decrypt((void *) &(self)->ctx, \
+ (void (*)(void *, unsigned, uint8_t *, const uint8_t *)) (f), \
+ sizeof((self)->iv), (self)->iv, \
+ (length), (dst), (src)))
+
+#if 0
/* Type safer variants */
-#define CBC_ENCRYPT(ctx, f, b, iv, l, dst, src) \
+#define CBC_ENCRYPT2(ctx, f, b, iv, l, dst, src) \
(0 ? ((f)((ctx),0,NULL,NULL)) \
: cbc_encrypt((void *)(ctx), \
- ((*)(void *, unsigned, uint8_t *, const uint8_t *)) (f), \
+ (void (*)(void *, unsigned, uint8_t *, const uint8_t *)) (f), \
(b), (iv), (l), (dst), (src)))
+#endif
+
#endif /* NETTLE_CBC_H_INCLUDED */