Skip to content

Commit

Permalink
Merge pull request #11 from gurnec/crypto-fixes
Browse files Browse the repository at this point in the history
Fix wallet creation bugs related to crypto
  • Loading branch information
jackjack-jj committed Sep 8, 2014
2 parents 069ef00 + 7c847c1 commit b52c955
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pywallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def SetIV(self, iv):
self.chIV = iv[0:16]

def Encrypt(self, data):
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).encrypt(data)[0:32]
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).encrypt(append_PKCS7_padding(data))

def Decrypt(self, data):
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
Expand Down Expand Up @@ -824,7 +824,7 @@ def SetIV(self, iv):
self.chIV = [ord(i) for i in iv]

def Encrypt(self, data):
mode, size, cypher = self.m.encrypt(data, self.cbc, self.chKey, self.sz, self.chIV)
mode, size, cypher = self.m.encrypt(append_PKCS7_padding(data), self.cbc, self.chKey, self.sz, self.chIV)
return ''.join(map(chr, cypher))

def Decrypt(self, data):
Expand Down Expand Up @@ -2246,10 +2246,10 @@ def merge_wallets(wadir, wa, wbdir, wb, wrdir, wr, passphrase_a, passphrase_b, p


if len(passphrase_r)>0:
NPP_salt=random_string(16).decode('hex')
NPP_salt=os.urandom(8)
NPP_rounds=int(50000+random.random()*20000)
NPP_method=0
NPP_MK=random_string(64).decode('hex')
NPP_MK=os.urandom(32)

crypter.SetKeyFromPassphrase(passphrase_r, NPP_salt, NPP_rounds, NPP_method)
NPP_EMK = crypter.Encrypt(NPP_MK)
Expand Down Expand Up @@ -4880,10 +4880,10 @@ def retrieve_last_pywallet_md5():
if passphraseRecov!="I don't want to put a password on the recovered wallet and I know what can be the consequences.":
db = open_wallet(db_env, recov_wallet_name, True)

NPP_salt=random_string(16).decode('hex')
NPP_salt=os.urandom(8)
NPP_rounds=int(50000+random.random()*20000)
NPP_method=0
NPP_MK=random_string(64).decode('hex')
NPP_MK=os.urandom(32)
crypter.SetKeyFromPassphrase(passphraseRecov, NPP_salt, NPP_rounds, NPP_method)
NPP_EMK = crypter.Encrypt(NPP_MK)
update_wallet(db, 'mkey', {
Expand Down

1 comment on commit b52c955

@jamesk123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it

Please sign in to comment.