After some meddling with my code and finally getting ciphersaber-1 to work, i thought it would be fairly simple to implement version 2. According the the webpage, one just has to add another loop around the key mixing phase. Excerpts follow :
Code:
i = j = 0; /* i and j are unsigned chars, as are all bytes in state[] and state2[] */
do {
j = ( j + state[i] + state2[i] );
x = state[i];
state[i] = state[j];
state[j] = x;
i++;
} while (i);
The above works flawlessly on the test vectors on the site. Now, supposedly to use the improved version, one just needs to add a loop around they key mixing loop shown above.
Code:
/* n is a straight up integer */
i = j = 0;
while(n) {
do {
j = ( j + state[i] + state2[i] );
x = state[i];
state[i] = state[j];
state[j] = x;
i++;
} while (i);
n--;
}
However, the test vector, when decoded with the key "asdfg" and N=10 produces gibberish. Is there some flaw in the way I've set these loops up that I'm simply missing?
Ciphersaber Home page if this helps...
Thanks,
Spook