Здравствуйте. помогите очень срочно!!! с питоном не работал, но очень надо подробно понять что делает предложенный ниже фрагмент алгоритма. если можно с подробным описанием generateRoundkeys80 и generateRoundkeys128. СПАСИБО!
def generateRoundkeys80(key,rounds):
“”“Generate the roundkeys for a 80-bit key
Input:
key: the key as a 80-bit integer
rounds: the number of rounds as an integer
Output: list of 64-bit roundkeys as integers”“”
roundkeys =
for i in xrange(1,rounds+1): # (K1 … K32)
# rawkey: used in comments to show what happens at bitlevel
# rawKey
roundkeys.append(key >>16)
#1. Shift
#rawKey+rawKey
key = ((key & (2**19-1)) << 61) + (key >> 19)
#2. SBox
#rawKey = S(rawKey)
key = (Sbox << 76)+(key & (2**76-1))
#3. Salt
#rawKey ^ i
key ^= i << 15
return roundkeys
def generateRoundkeys128(key,rounds):
“”“Generate the roundkeys for a 128-bit key
Input:
key: the key as a 128-bit integer
rounds: the number of rounds as an integer
Output: list of 64-bit roundkeys as integers”“”
roundkeys =
for i in xrange(1,rounds+1): # (K1 … K32)
# rawkey: used in comments to show what happens at bitlevel
roundkeys.append(key >>64)
#1. Shift
key = ((key & (2**67-1)) << 61) + (key >> 67)
#2. SBox
key = (Sbox << 124)+(Sbox << 120)+(key & (2**120-1))
#3. Salt
#rawKey ^ i
key ^= i << 62
return roundkeys
def addRoundKey(state,roundkey):
return state ^ roundkey