Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/snowcrypt/snowcrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


fshort, fint, flong = (">h", 2), (">i", 4), (">q", 8)
fuint, fulong = (">I", 4), (">Q", 8)


class Translator:
Expand All @@ -31,8 +32,8 @@ def next(self, format: tuple):
return data

def readAtomSize(self, inStream: BufferedReader) -> int:
atomLength = self.readOne(fint, inStream)
return atomLength if atomLength != 1 else self.readOne(flong, inStream)
atomLength = self.readOne(fuint, inStream)
return atomLength if atomLength != 1 else self.readOne(fulong, inStream)

def readOne(self, format: tuple, inStream: BufferedReader):
length = format[1]
Expand All @@ -49,7 +50,7 @@ def write(self, out: BufferedWriter) -> int:

def _decrypt_aavd(inStream: BufferedReader, key, iv, t: Translator):
# setup
length = t.next(fint)
length = t.next(fuint)
aes = newAES(key, MODE_CBC, iv=iv)

# for cipher padding, (up to) last 2 bytes are unencrypted
Expand Down Expand Up @@ -134,8 +135,8 @@ def mdat(
t.readOne(fint, inStream)
t.readOne(fint, inStream)
t.readOne(fint, inStream)
sum_block_length = t.readOne(fint, inStream)
block_count = t.readOne(fint, inStream)
sum_block_length = t.readOne(fuint, inStream)
block_count = t.readOne(fuint, inStream)

# next come the atom specific fields
# aavd has a list of sample sizes and then the samples.
Expand Down
Loading