projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement efficient reduction for pleasant-looking primes.
[u/mdw/catacomb]
/
xtea.c
diff --git
a/xtea.c
b/xtea.c
index
1d65c4d
..
32702fe
100644
(file)
--- a/
xtea.c
+++ b/
xtea.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: xtea.c,v 1.
1 2000/07/15 13:44:31
mdw Exp $
+ * $Id: xtea.c,v 1.
2 2000/07/29 09:56:47
mdw Exp $
*
* The Extended Tiny Encryption Algorithm
*
*
* The Extended Tiny Encryption Algorithm
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: xtea.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: xtea.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 xtea_init(xtea_ctx *k, const void *buf, size_t sz)
p = kb;
}
p = kb;
}
- k->k[0] = LOAD32(p + 0); k->k[1] = LOAD32(p + 4);
- k->k[2] = LOAD32(p + 8); k->k[3] = LOAD32(p + 12);
+ k->k[0] = LOAD32(p + 0); k->k[1] = LOAD32(p + 4);
+ k->k[2] = LOAD32(p + 8); k->k[3] = LOAD32(p + 12);
+ k->r = 32;
if (p == kb)
BURN(kb);
if (p == kb)
BURN(kb);
@@
-102,7
+107,7
@@
void xtea_eblk(const xtea_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++) {
y = U32(y + ((((z << 4) ^ (z >> 5)) + z) ^ (n + k->k[n & 3])));
n += DELTA;
z = U32(z + ((((y << 4) ^ (y >> 5)) + y) ^ (n + k->k[(n >> 11) & 3])));
y = U32(y + ((((z << 4) ^ (z >> 5)) + z) ^ (n + k->k[n & 3])));
n += DELTA;
z = U32(z + ((((y << 4) ^ (y >> 5)) + y) ^ (n + k->k[(n >> 11) & 3])));
@@
-113,10
+118,10
@@
void xtea_eblk(const xtea_ctx *k, const uint32 *s, uint32 *d)
void xtea_dblk(const xtea_ctx *k, const uint32 *s, uint32 *d)
{
uint32 y = s[0], z = s[1];
void xtea_dblk(const xtea_ctx *k, const uint32 *s, uint32 *d)
{
uint32 y = s[0], z = s[1];
- 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) ^ (y >> 5)) + y) ^ (n + k->k[(n >> 11) & 3])));
n -= DELTA;
y = U32(y - ((((z << 4) ^ (z >> 5)) + z) ^ (n + k->k[n & 3])));
z = U32(z - ((((y << 4) ^ (y >> 5)) + y) ^ (n + k->k[(n >> 11) & 3])));
n -= DELTA;
y = U32(y - ((((z << 4) ^ (z >> 5)) + z) ^ (n + k->k[n & 3])));