Score:1

Rivest Cipher 6 (RC6) Key Scheduler

us flag

I am trying to understand the Key Scheduler used in RC6 and I have a total of 3 questions. The RC6 Wikipedia page says that the only difference between the RC5 and RC6 key scheduler is that more words are produced from the key in RC6. In my application, I am using w=32bits, r=20rounds and b=16bytes.

My first question is are these are two separate for loops or is the second for loop that iterates from s-1 to v inside the first for loop that iterates from 1 to 2r+3? My second question is why are we setting A=B=i=j=0 and is this command and the v=3xmax{c,2r+4} inside the first for loop?

The RC6 paper also supplies this pseudo code:


Input: User-supplied b byte key preloaded into the c-word array L[0... c - 1]

Number r of rounds

Output: w-bit round keys S[0... 2r + 3]

Procedure: S[0] = Pw

for i = 1 to 2r + 3 do:
S[i] = S[i - 1] + Qw
A = B = i = j = 0
v = 3 x max{c,2r+4}

for s = 1 to v do:
{
A = S[i] = (S[i] + A + B)<<<3
B = L[j] = (L[j] + A + B)<<<(A + B)
i = (i + 1)mod(2r + 4)
j = (j + 1)modc
}

My third question is on how to preload the word array L with my 16byte key. The RC5 paper says:

The first algorithmic step of key expansion is to copy the secret key K[0...b-1] into an array L[0...c-1] of c=b/u words where u= w/8 is the number of bytes/word. This operation is done in a natural manner using u consecutive key bytes of K to fill up each successive word in L, low-order byte to high-order byte. Any unfilled byte positions of L are zeroed.

And the pseudo code for this operation is:

for i=b-1 downto 0 do:
    L[i/u] = (L[i/u]<<<8)+K[i];

To elaborate on my third question, if i is going from 15 down to 0, and my u = 32/8=4, how can I use a decimal to index L? For example, when i is 15 we have L[15/4]=(L[15/4]<<<8 + K[i]);

Score:2
ru flag
  1. The loops are disjoint. In other words, the first loop completes and then the second loop starts.

  2. A=B=i=j=0 are explicitly initialised to zero as in many languages failing to specify an initial value can lead to unspecified behaviour (e.g. setting the variables to random values lying in old memory). This initialisation and the initialisation of v occur outside of the loops.

  3. The expression i/u should be interpreted as C-like integer arithmetic that returns an integer value (in this case by taking floor). Thus in your example L[15/4]=L[3].

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.