projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9810d74
)
Use secure arena for memory allocation. Rearrange setiv slightly.
author
mdw
<mdw>
Sat, 17 Jun 2000 10:50:39 +0000
(10:50 +0000)
committer
mdw
<mdw>
Sat, 17 Jun 2000 10:50:39 +0000
(10:50 +0000)
cfb-def.h
patch
|
blob
|
blame
|
history
diff --git
a/cfb-def.h
b/cfb-def.h
index
85d95db
..
bb3757c
100644
(file)
--- a/
cfb-def.h
+++ b/
cfb-def.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: cfb-def.h,v 1.
1 1999/12/10 23:16
:39 mdw Exp $
+ * $Id: cfb-def.h,v 1.
2 2000/06/17 10:50
:39 mdw Exp $
*
* Definitions for ciphertext feedback mode
*
*
* Definitions for ciphertext feedback mode
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: cfb-def.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: cfb-def.h,v $
+ * Revision 1.2 2000/06/17 10:50:39 mdw
+ * Use secure arena for memory allocation. Rearrange setiv slightly.
+ *
* Revision 1.1 1999/12/10 23:16:39 mdw
* Split mode macros into interface and implementation.
*
* Revision 1.1 1999/12/10 23:16:39 mdw
* Split mode macros into interface and implementation.
*
@@
-49,6
+52,10
@@
#include <mLib/bits.h>
#include <mLib/sub.h>
#include <mLib/bits.h>
#include <mLib/sub.h>
+#ifndef CATACOMB_ARENA_H
+# include "arena.h"
+#endif
+
#ifndef CATACOMB_BLKC_H
# include "blkc.h"
#endif
#ifndef CATACOMB_BLKC_H
# include "blkc.h"
#endif
@@
-61,6
+68,10
@@
# include "paranoia.h"
#endif
# include "paranoia.h"
#endif
+#ifndef CATACOMB_PARANOIA_H
+# include "paranoia.h"
+#endif
+
/*----- Macros ------------------------------------------------------------*/
/* --- @CFB_DEF@ --- *
/*----- Macros ------------------------------------------------------------*/
/* --- @CFB_DEF@ --- *
@@
-88,8
+99,8
@@
void pre##_cfbgetiv(const pre##_cfbctx *ctx, void *iv) \
{ \
octet *p = iv; \
void pre##_cfbgetiv(const pre##_cfbctx *ctx, void *iv) \
{ \
octet *p = iv; \
-
int off = ctx->off;
\
-
int rest = PRE##_BLKSZ - off;
\
+
unsigned off = ctx->off;
\
+
unsigned rest = PRE##_BLKSZ - off;
\
memcpy(p, ctx->iv + off, rest); \
memcpy(p + rest, ctx->iv, off); \
} \
memcpy(p, ctx->iv + off, rest); \
memcpy(p + rest, ctx->iv, off); \
} \
@@
-106,11
+117,8
@@
void pre##_cfbgetiv(const pre##_cfbctx *ctx, void *iv) \
\
void pre##_cfbsetiv(pre##_cfbctx *ctx, const void *iv) \
{ \
\
void pre##_cfbsetiv(pre##_cfbctx *ctx, const void *iv) \
{ \
- uint32 niv[PRE##_BLKSZ / 4]; \
- BLKC_LOAD(PRE, niv, iv); \
- pre##_eblk(&ctx->ctx, niv, niv); \
- BLKC_STORE(PRE, ctx->iv, niv); \
- ctx->off = 0; \
+ memcpy(ctx->iv, iv, PRE##_BLKSZ); \
+ ctx->off = PRE##_BLKSZ; \
} \
\
/* --- @pre_cfbbdry@ --- * \
} \
\
/* --- @pre_cfbbdry@ --- * \
@@
-125,10
+133,12
@@
void pre##_cfbsetiv(pre##_cfbctx *ctx, const void *iv) \
\
void pre##_cfbbdry(pre##_cfbctx *ctx) \
{ \
\
void pre##_cfbbdry(pre##_cfbctx *ctx) \
{ \
- octet iv[PRE##_BLKSZ]; \
- pre##_cfbgetiv(ctx, iv); \
- pre##_cfbsetiv(ctx, iv); \
- BURN(iv); \
+ uint32 niv[PRE##_BLKSZ / 4]; \
+ BLKC_LOAD(PRE, niv, ctx->iv); \
+ pre##_eblk(&ctx->ctx, niv, niv); \
+ BLKC_STORE(PRE, ctx->iv, niv); \
+ ctx->off = PRE##_BLKSZ; \
+ BURN(niv); \
} \
\
/* --- @pre_cfbsetkey@ --- * \
} \
\
/* --- @pre_cfbsetkey@ --- * \
@@
-144,6
+154,7
@@
void pre##_cfbbdry(pre##_cfbctx *ctx) \
void pre##_cfbsetkey(pre##_cfbctx *ctx, const pre##_ctx *k) \
{ \
ctx->ctx = *k; \
void pre##_cfbsetkey(pre##_cfbctx *ctx, const pre##_ctx *k) \
{ \
ctx->ctx = *k; \
+ ctx->off = PRE##_BLKSZ; \
} \
\
/* --- @pre_cfbinit@ --- * \
} \
\
/* --- @pre_cfbinit@ --- * \
@@
-191,7
+202,7
@@
void pre##_cfbencrypt(pre##_cfbctx *ctx, \
{ \
const octet *s = src; \
octet *d = dest; \
{ \
const octet *s = src; \
octet *d = dest; \
-
int off = ctx->off;
\
+
unsigned off = ctx->off;
\
\
/* --- Empty blocks are trivial --- */ \
\
\
/* --- Empty blocks are trivial --- */ \
\
@@
-248,7
+259,7
@@
void pre##_cfbencrypt(pre##_cfbctx *ctx, \
return; \
} \
\
return; \
} \
\
-/* --- @pre_cfb
en
crypt@ --- * \
+/* --- @pre_cfb
de
crypt@ --- * \
* \
* Arguments: @pre_cfbctx *ctx@ = pointer to CFB context block \
* @const void *src@ = pointer to source data \
* \
* Arguments: @pre_cfbctx *ctx@ = pointer to CFB context block \
* @const void *src@ = pointer to source data \
@@
-268,7
+279,7
@@
void pre##_cfbdecrypt(pre##_cfbctx *ctx, \
{ \
const octet *s = src; \
octet *d = dest; \
{ \
const octet *s = src; \
octet *d = dest; \
-
int off = ctx->off;
\
+
unsigned off = ctx->off;
\
\
/* --- Empty blocks are trivial --- */ \
\
\
/* --- Empty blocks are trivial --- */ \
\
@@
-340,7
+351,7
@@
typedef struct gctx { \
\
static gcipher *ginit(const void *k, size_t sz) \
{ \
\
static gcipher *ginit(const void *k, size_t sz) \
{ \
- gctx *g =
CREATE(gctx);
\
+ gctx *g =
S_CREATE(gctx);
\
g->c.ops = &gops; \
pre##_cfbinit(&g->k, k, sz, 0); \
return (&g->c); \
g->c.ops = &gops; \
pre##_cfbinit(&g->k, k, sz, 0); \
return (&g->c); \
@@
-361,7
+372,8
@@
static void gdecrypt(gcipher *c, const void *s, void *t, size_t sz) \
static void gdestroy(gcipher *c) \
{ \
gctx *g = (gctx *)c; \
static void gdestroy(gcipher *c) \
{ \
gctx *g = (gctx *)c; \
- DESTROY(g); \
+ BURN(*g); \
+ S_DESTROY(g); \
} \
\
static void gsetiv(gcipher *c, const void *iv) \
} \
\
static void gsetiv(gcipher *c, const void *iv) \
@@
-377,12
+389,12
@@
static void gbdry(gcipher *c) \
} \
\
static const gcipher_ops gops = { \
} \
\
static const gcipher_ops gops = { \
- &pre##_cfb
.b,
\
-
gencrypt, gdecrypt, gdestroy, gsetiv, gbdry
\
+ &pre##_cfb
,
\
+
gencrypt, gdecrypt, gdestroy, gsetiv, gbdry
\
}; \
\
const gccipher pre##_cfb = { \
}; \
\
const gccipher pre##_cfb = { \
-
{ #pre "-cfb", PRE##_KEYSZ, PRE##_BLKSZ },
\
+
#pre "-cfb", pre##_keysz, PRE##_BLKSZ,
\
ginit \
}; \
\
ginit \
}; \
\