projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
This commit was manufactured by cvs2svn to create branch 'ec'.
[u/mdw/catacomb]
/
tea.c
diff --git
a/tea.c
b/tea.c
index
90d97cb
..
2043337
100644
(file)
--- a/
tea.c
+++ b/
tea.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: tea.c,v 1.
1 2000/07/15 13:44:31
mdw Exp $
+ * $Id: tea.c,v 1.
2 2000/07/29 09:56:47
mdw Exp $
*
* The Tiny Encryption Algorithm
*
*
* The Tiny Encryption Algorithm
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: tea.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: tea.c,v $
+ * Revision 1.2 2000/07/29 09:56:47 mdw
+ * Allow the number of rounds to be configured. This isn't exported
+ * through the gcipher interface, but it may be useful anyway.
+ *
* Revision 1.1 2000/07/15 13:44:31 mdw
* New ciphers.
*
* Revision 1.1 2000/07/15 13:44:31 mdw
* New ciphers.
*
@@
-76,8
+80,9
@@
void tea_init(tea_ctx *k, const void *buf, size_t sz)
p = kb;
}
p = kb;
}
- k->ka = LOAD32(p + 0); k->kb = LOAD32(p + 4);
- k->kc = LOAD32(p + 8); k->kd = LOAD32(p + 12);
+ k->ka = LOAD32(p + 0); k->kb = LOAD32(p + 4);
+ k->kc = LOAD32(p + 8); k->kd = LOAD32(p + 12);
+ k->r = 32;
if (p == kb)
BURN(kb);
if (p == kb)
BURN(kb);
@@
-103,7
+108,7
@@
void tea_eblk(const tea_ctx *k, const uint32 *s, uint32 *d)
uint32 n = 0;
unsigned i;
uint32 n = 0;
unsigned i;
- for (i = 0; i <
32
; i++) {
+ for (i = 0; i <
k->r
; i++) {
n += DELTA;
y = U32(y + (((z << 4) + ka) ^ (z + n) ^ ((z >> 5) + kb)));
z = U32(z + (((y << 4) + kc) ^ (y + n) ^ ((y >> 5) + kd)));
n += DELTA;
y = U32(y + (((z << 4) + ka) ^ (z + n) ^ ((z >> 5) + kb)));
z = U32(z + (((y << 4) + kc) ^ (y + n) ^ ((y >> 5) + kd)));
@@
-115,10
+120,10
@@
void tea_dblk(const tea_ctx *k, const uint32 *s, uint32 *d)
{
uint32 y = s[0], z = s[1];
uint32 ka = k->ka, kb = k->kb, kc = k->kc, kd = k->kd;
{
uint32 y = s[0], z = s[1];
uint32 ka = k->ka, kb = k->kb, kc = k->kc, kd = k->kd;
- uint32 n = DELTA
<< 5
;
+ uint32 n = DELTA
* k->r
;
unsigned i;
unsigned i;
- for (i = 0; i <
32
; i++) {
+ for (i = 0; i <
k->r
; i++) {
z = U32(z - (((y << 4) + kc) ^ (y + n) ^ ((y >> 5) + kd)));
y = U32(y - (((z << 4) + ka) ^ (z + n) ^ ((z >> 5) + kb)));
n -= DELTA;
z = U32(z - (((y << 4) + kc) ^ (y + n) ^ ((y >> 5) + kd)));
y = U32(y - (((z << 4) + ka) ^ (z + n) ^ ((z >> 5) + kb)));
n -= DELTA;