fix wallet creation bugs related to crypto
* fix encryption when using PyCrypto or SlowAES * use os.urandom wherever cryptographically secure rnd #s are required
This commit is contained in:
parent
069ef00443
commit
7c847c18fa
12
pywallet.py
12
pywallet.py
@ -742,7 +742,7 @@ class Crypter_pycrypto( object ):
|
|||||||
self.chIV = iv[0:16]
|
self.chIV = iv[0:16]
|
||||||
|
|
||||||
def Encrypt(self, data):
|
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):
|
def Decrypt(self, data):
|
||||||
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
|
return AES.new(self.chKey,AES.MODE_CBC,self.chIV).decrypt(data)[0:32]
|
||||||
@ -824,7 +824,7 @@ class Crypter_pure(object):
|
|||||||
self.chIV = [ord(i) for i in iv]
|
self.chIV = [ord(i) for i in iv]
|
||||||
|
|
||||||
def Encrypt(self, data):
|
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))
|
return ''.join(map(chr, cypher))
|
||||||
|
|
||||||
def Decrypt(self, data):
|
def Decrypt(self, data):
|
||||||
@ -2246,10 +2246,10 @@ def merge_wallets(wadir, wa, wbdir, wb, wrdir, wr, passphrase_a, passphrase_b, p
|
|||||||
|
|
||||||
|
|
||||||
if len(passphrase_r)>0:
|
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_rounds=int(50000+random.random()*20000)
|
||||||
NPP_method=0
|
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)
|
crypter.SetKeyFromPassphrase(passphrase_r, NPP_salt, NPP_rounds, NPP_method)
|
||||||
NPP_EMK = crypter.Encrypt(NPP_MK)
|
NPP_EMK = crypter.Encrypt(NPP_MK)
|
||||||
@ -4880,10 +4880,10 @@ if __name__ == '__main__':
|
|||||||
if passphraseRecov!="I don't want to put a password on the recovered wallet and I know what can be the consequences.":
|
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)
|
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_rounds=int(50000+random.random()*20000)
|
||||||
NPP_method=0
|
NPP_method=0
|
||||||
NPP_MK=random_string(64).decode('hex')
|
NPP_MK=os.urandom(32)
|
||||||
crypter.SetKeyFromPassphrase(passphraseRecov, NPP_salt, NPP_rounds, NPP_method)
|
crypter.SetKeyFromPassphrase(passphraseRecov, NPP_salt, NPP_rounds, NPP_method)
|
||||||
NPP_EMK = crypter.Encrypt(NPP_MK)
|
NPP_EMK = crypter.Encrypt(NPP_MK)
|
||||||
update_wallet(db, 'mkey', {
|
update_wallet(db, 'mkey', {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user