java - Rotate two longs -


i'm working on block cipher algorithm , requirements state 128 bit key state (stored big endian) needs shifted 25 bits right. key state must 2 longs. here's latest attempt @ figuring out. shifted both upper , lower halves of key right 25 bits, stored new values in new longs rotated keys left 39 bits. xor'd first new upper key second lower key , stored in upper half of key, , did same other 2 shifted keys stored in lower half of key. idea behind being needs have 25 shifted bits @ front of upper half of key.

long rotkeyupper = keyupper >> 25;  long rotkeylower = keylower >> 25; long rotkeyupper2 = keyupper << 39; long rotkeylower2 = keylower << 39; keyupper = rotkeyupper ^= rotkeylower2; keylower = rotkeyupper2 ^= rotkeylower; keyupper |= keylower; 

does make sense?

edit: yes did mean rotate. , clarify, "rotkeyupper" , "rotkeylower" longs store rotated bits - keyupper , keylower 2 longs actual key - sorry confusion.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -