Search Results

Search found 1 results on 1 pages for 'masseyc'.

Page 1/1 | 1 

  • implementing cryptographic algorithms, specifically the key expansion part

    - by masseyc
    Hey, recently I picked up a copy of Applied Cryptography by Bruce Schneier and it's been a good read. I now understand how several algorithms outlined in the book work, and I'd like to start implementing a few of them in C. One thing that many of the algorithms have in common is dividing an x-bit key, into several smaller y-bit keys. For example, blowfish's key, X, is 64-bits, but you are required to break it up into two 32-bit halves; Xl and Xr. This is where I'm getting stuck. I'm fairly decent with C, but I'm not the strongest when it comes to bitwise operators and the like. After some help on IRC, I managed to come up with these two macros: #define splitup(a, b, c) {b = a >> 32; c = a & 0xffffffff; } #define combine(a, b, c) {a = (c << 32) | a;} Where a is 64 bits and b and c are 32 bits. However, the compiler warns me about the fact that I'm shifting a 32 bit variable by 32 bits. My questions are these: what's bad about shifting a 32-bit variable 32 bits? I'm guessing it's undefined, but these macros do seem to be working. Also, would you suggest I go about this another way? As I said, I'm fairly familiar with C, but bitwise operators and the like still give me a headache.

    Read the article

1