projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use unsigned integer rather than enum for flags.
[u/mdw/catacomb]
/
idea.c
diff --git
a/idea.c
b/idea.c
index
cde3af4
..
c0a1d07
100644
(file)
--- a/
idea.c
+++ b/
idea.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: idea.c,v 1.
3 2000/07/02 18:24:39
mdw Exp $
+ * $Id: idea.c,v 1.
4 2000/07/15 17:47:58
mdw Exp $
*
* Implementation of the IDEA cipher
*
*
* Implementation of the IDEA cipher
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: idea.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: idea.c,v $
+ * Revision 1.4 2000/07/15 17:47:58 mdw
+ * Fix bug in decryption key scheduling.
+ *
* Revision 1.3 2000/07/02 18:24:39 mdw
* Use a new multiplication function from an Ascom white paper to resist
* timing attacks.
* Revision 1.3 2000/07/02 18:24:39 mdw
* Use a new multiplication function from an Ascom white paper to resist
* timing attacks.
@@
-75,13
+78,16
@@
static uint16 inv(uint16 n)
{
uint32 m = 0x10001;
uint32 a = 1, b = 0;
{
uint32 m = 0x10001;
uint32 a = 1, b = 0;
+ uint32 nn = n;
+ if (!nn)
+ nn = 0x10000;
for (;;) {
uint32 q, r, t;
for (;;) {
uint32 q, r, t;
- if (!(r = m % n))
+ if (!(r = m % n
n
))
break;
break;
- q = m / n;
- m = n
;
n = r;
+ q = m / n
n
;
+ m = n
n; n
n = r;
t = a; a = b - q * a; b = t;
}
if (a > MASK16)
t = a; a = b - q * a; b = t;
}
if (a > MASK16)
@@
-255,8
+261,8
@@
void idea_init(idea_ctx *k, const void *buf, size_t sz)
ROUND(_k, _a, _b, _c, _d); \
ROUND(_k, _a, _c, _b, _d); \
MIX (_k, _a, _c, _b, _d); \
ROUND(_k, _a, _b, _c, _d); \
ROUND(_k, _a, _c, _b, _d); \
MIX (_k, _a, _c, _b, _d); \
- c = (
U16(_a) << 16) | U16(_c);
\
- d = (
U16(_b) << 16) | U16(_d);
\
+ c = (
(uint32)U16(_a) << 16) | (uint32)U16(_c);
\
+ d = (
(uint32)U16(_b) << 16) | (uint32)U16(_d);
\
} while (0)
#define DBLK(k, a, b) EBLK((k), (a), (b))
} while (0)
#define DBLK(k, a, b) EBLK((k), (a), (b))