Re: bit shifting.



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.



.



Relevant Pages

  • Re: Packages and returning errors
    ... > array intact. ... sub is_a_instance_method { ... my $class = shift; ... You need to fix the scope of $error by moving its declaration outside ...
    (comp.lang.perl.misc)
  • Re: Packages and returning errors
    ... The perldoc function guide says about shift (which is ... "Shifts the first value of the array off and returns it, ... If an array of values are passed to a sub, ... Back to my package (which I am currently thinking might be out of my depth, ...
    (comp.lang.perl.misc)
  • Re: MS SQL geek wants to jump ship, plz help on first Perl script
    ... Next step is the MEAT inside the loop. ... Then you don't understand shift(). ... automatically works on the @_ array (ie, ... # a lot of memory, coz it reads the whole arrary into memory first, ...
    (comp.lang.perl.misc)
  • Re: bit shifts by multiple bytes
    ... The last byte was added to the end, and then it was a matter of moving right to left across the array, using two bytes in a UInt16 at a time to shift. ... You have a function composed of two parts: how many whole bytes will you shift followed by how many remainder bits will you shift. ... I'd start by breaking your starting number into bytes and store each byte in the low order bits of an array of 16 bit words. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Shift em bits
    ... The language won't allow it. ... Shift operators only apply to integer ... you might find that you have defined an "8 uchar array" as your ... If you really are trying to write portable code (avoiding ASM for ...
    (comp.arch.embedded)

Quantcast