I'm trying to recover file encrypted with an old pure python implementation of blowfish.
the old code relied on a single blofish.py file (Copyright (C) 2002 Michael Gilfix )
The old data are encrypted performing following operations:
cipher = Blowfish(self.masterKey)
cipher.initCTR()
cleanData = cipher.decryptCTR(encData)
That code don't initialize the nonce that is required in modern implementation of blowfish, so I was unable to port it to pycryptodome function
cipher = Blowfish.new(self.masterKey, Blowfish.MODE_CTR, nonce = ?????)
cleanData = cipher.decrypt(encData)
The only suggestion that I can find is inside the initCTR function where iv is set to 0 (even if CTR mode don't have IV)
def initCTR(self, iv=0):
"""Initializes CTR mode of the cypher"""
assert struct.calcsize("Q") == self.blocksize()
self.ctr_iv = iv
self._calcCTRBUF()
def _calcCTRBUF(self):
"""Calculates one block of CTR keystream"""
self.ctr_cks = self.encrypt(struct.pack("Q", self.ctr_iv)) # keystream block
self.ctr_iv += 1
self.ctr_pos = 0
can someone help me?