Database Reference
In-Depth Information
End
B = B-S [1];
A = A-S [0];
4.5.6.3 RC5 Key Expansion
Key expansion expands the user's secret
key,
K,
to fill the expanded key array
S,
which makes
S
similar to an
array of
t
= 2(
r
+ 1) random binary words. Two magic constants,
P
w
and
Q
w
,
are used in this process. These constants are defined as
(
)
(
)
w
P
=
dd
e
−
22
(4.3)
w
(
(
)
)
w
Q
=
dd
φ −
12
(4.4)
w
where
e
= 2.718281828459....(base of natural logarithms)
ϕ = 1.618033988749....(golden ratio)
and
Odd
(
x
) is the odd integer nearest to
x
For
w
= 16 and 32, these constants are given in hexadecimals:
P
16
=
b
7
e
1;
Q
16
= 9
e
37
P
32
=
b
7
e
15163;
Q
32
= 9
e
3779
b
9
The expansion begins by copying the secret key
K
[0…
b
- 1] into an
array
L
[0…
c
- 1] that has c = ⎡
b
/
u
⎤ words, where
u
=
w
/8 is the num-
ber of bytes per word.
u
consecutive key bytes of
K
are used to fill up
each successive word in
L
in a low-order to high-order byte manner.
All unfilled byte positions of
L
are zeroed.
To initialize the array
S,
we follow these steps:
S [0] = P
w
;
For i = 1 to t-1 do
S [i] = S [i-1] + Q
w
;
End
The last step is to mix the user secret key in three passes over the
arrays
S
and
L
as follows:
i = j = 0;
A = B = 0;
Do 3*max (t, c) times:
Search WWH ::
Custom Search