@@ -60,9 +60,7 @@ def crypt(self, data, direction):
60
60
Performs actual encryption/decryption of data
61
61
depending on the direction. The data is broken
62
62
up into 8 byte chunks for the ciphering
63
- process. If the data does not align on 8 byte
64
- chunks, then null padding is added. This is
65
- removed upon decryption.
63
+ process. Data must be aligned on 8 byte chunks.
66
64
67
65
def cipher(self, xl, xr, direction):
68
66
Encrypts a 64-bit block of data where xl is
@@ -439,12 +437,8 @@ def __round_func(self, xl):
439
437
return int (f )
440
438
441
439
def crypt (self , data , direction ):
442
- # Pad the data if need be so it has 8 byte chunks
443
- align = len (data ) % 8
444
- if align != 0 :
445
- padding = '\x00 ' * (8 - align )
446
- data += padding
447
-
440
+ # Data must be padded
441
+ assert len (data ) % 8 == 0
448
442
result = ''
449
443
for i in range (0 , len (data ), 8 ):
450
444
# Use big endianess since that's what everyone else uses
@@ -457,10 +451,6 @@ def crypt(self, data, direction):
457
451
(xr >> 24 ) & 0xFF , (xr >> 16 ) & 0xFF , (xr >> 8 ) & 0xFF , xr & 0xFF
458
452
)
459
453
result += '' .join (map (chr , chunk ))
460
-
461
- # Strip the padding if we decrypted
462
- if direction == self .DECRYPT :
463
- result = result .rstrip ('\x00 ' )
464
454
return result
465
455
466
456
def encrypt (self , data ):
0 commit comments