[rc5] Blocks

Wes Shull wshull at scicom.com
Mon Oct 27 22:08:50 EST 1997


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I sent this to the list earlier, but never saw it...  I'm thinking 
maybe I sent it from another email address and the list is too 
spamproof for its own good.  If you've already seen this, my 
apologies.

Someone asked:

<<Another thing is (for those who have read the paper) that the 
algorithm has a + operation. It sais is the modulo-2^w addition. What 
is this? How can I implement this in C?>>

At 08:21 PM 10/24/97 -0500, Tim Charron wrote:

<<This is an exclusive or operation.  In C, it's denoted by the ^ 
character.>>

I think he was asking about just plain '+', wondering what they 
meant by "addition mod 2^w".

'w' is the first parameter in the specification of a particular 
version of RC5--you say RC5-w/r/b.  It specifies the number of bits 
in each word processed by the algorithm (it actually does a block at 
a time, which is two words).  2^w would be the smallest number you 
*can't* represent in w bits (you can represent 0..(2^w)-1 in w bits, 
for example 0..(2^8)-1 = 0..255 in 8 bits)

Basically, the modulus is just the remainder of integer division.  
So, for example, 37 div 5 = 7 [for you C guys that don't know Pascal, 

"div" is just integer division; it will return an int like (int) 37 / 

(int) 5 would, but reads more clearly], and 37 mod 5 [C: 37 % 5] = 2 
[= 37 - ((37 div 5) * 5)]

Anyway, the result of all this is that A mod B will always be in the 
range [0..B-1].  So doing addition mod 2^w ensures that result of the 

addition will always fit in w bits.

An implementation note:  in the case of A mod 2^w, what you're 
effectively doing is only taking the w low-order bits of the result.  

So you're just ignoring any carry (overflow) that the addition 
generates on a 32-bit machine.  Simple enough.

I hope I haven't muddled the issue further by adding too many 
details; I have an unfortunate tendency toward excessive 
elaboration...

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBNFVXQc6PmyPzIEKpEQIVxQCgtmqp9D0fN6xJVGyMVo5oAj0yqGwAoM1s
U2qD6SNEPwupBW2rpx0CBwnn
=q6RL
-----END PGP SIGNATURE-----

-- 
Wes Shull * wes at kuoi.asui.uidaho.edu * Prince William County, Virginia, USA
Radio Amateur (KC7QCY) * Porsche 928 Fan * Ford Festiva Owner * cat lover
----
To unsubscribe, send email to majordomo at llamas.net with 'unsubscribe rc5' in the body.



More information about the rc5 mailing list