Re: bit shifting.
- From: Oleg Khovayko <"[my_last_name]"@gmail.com>
- Date: Sun, 26 Oct 2008 02:27:51 GMT
And what next?
What do you want to say?
Yes, cyclic shift is reversible operation, we know.
About your code -- it contains syntax and logical errors,
for example, twice used label "case 1" in the switch operator.
Also, your strange code (including switch) for compute "b"
can be substituted by easy and compact single line:
b = -k[i] & 7;
And, thereafter, you can shift your data:
for(j = 0; j < 4; j++)
x[j] <<= b; // Mean ROL
Oleg H.
Antony Clements wrote:
I've read about a few systems that use x amount of static bit shifts within their P-box(s), DES for example uses one or two circular left bit shifts per subkey. Since my key is always the same length as the data, there is no need for permutations of the subkeys. So instead i'm using the bit shift within the plaintext block itself as opposed to a master key..
I'm toying with the idea of b being a variable based on the key as opposed to being a fixed value. All shifts are circular left shifts.
Here is what I mean, I hope it's clear to everyone.
Given that each 512-bit block always uses 512 bits of key.
i is a counter, start with i==0.
j is a counter, start with j==0
b is the bit rotation value. Valid values of b are 0,...,7.
k is an array of 16 elements. Start with k==0.
x is an array of 4 elements. Start with x==0
p is an array of 16 elements. Start with p==0.
Split the 512-bit key block into sixteen 32-bit subkeys. Place each subkey into the array k().
Split the 512-bit plaintext block into sixteen 32-bit subblocks. Place each subblock into the array p().
Split p(i) into 4 bytes. Place each byte in x().
b = k(i) % 256
b = b % 8
switch(b)
{
case 1:
b = 7
break;
case 2:
b = 6
break;
case 3:
b = 5
break;
case 4:
b = 4
break;
case 5:
b = 3
break;
case 6:
b = 2
break;
case 1:
b = 1
break;
default:
b=0
break;
}
for(j=0; j < 4; J++)
{
x(j) = ((x(j) << b;
}
This is fully reversable by omitting the switch statement and respective code.
- Follow-Ups:
- Re: bit shifting.
- From: Antony Clements
- Re: bit shifting.
- References:
- bit shifting.
- From: Antony Clements
- bit shifting.
- Prev by Date: bit shifting.
- Next by Date: Re: bit shifting.
- Previous by thread: bit shifting.
- Next by thread: Re: bit shifting.
- Index(es):
Relevant Pages
|