applied Atheros1 commit for error handling around .encrypt
commit 8d7eceb18e
This commit is contained in:
parent
cad151a440
commit
0343c67b95
|
@ -3398,12 +3398,15 @@ class singleWorker(threading.Thread):
|
|||
fromaddress, 'payloadlengthextrabytes'))
|
||||
dataToEncrypt += '\x02' # message encoding type
|
||||
dataToEncrypt += encodeVarint(len(
|
||||
'Subject:' + subject + '\n' + 'Body:' + body)) # Type 2 is simple UTF-8 message encoding.
|
||||
'Subject:' + subject + '\n' + 'Body:' + body)) # Type 2 is simple UTF-8 message encoding per the documentation on the wiki.
|
||||
dataToEncrypt += 'Subject:' + subject + '\n' + 'Body:' + body
|
||||
signature = highlevelcrypto.sign(
|
||||
dataToEncrypt, privSigningKeyHex)
|
||||
dataToEncrypt += encodeVarint(len(signature))
|
||||
dataToEncrypt += signature
|
||||
# Encrypt the broadcast with the information contained in the broadcaster's address. Anyone who knows the address can generate
|
||||
# the private encryption key to decrypt the broadcast. This provides virtually no privacy; its purpose is to keep questionable
|
||||
# and illegal content from flowing through the Internet connections and being stored on the disk of 3rd parties.
|
||||
privEncryptionKey = hashlib.sha512(encodeVarint(
|
||||
addressVersionNumber) + encodeVarint(streamNumber) + ripe).digest()[:32]
|
||||
pubEncryptionKey = pointMult(privEncryptionKey)
|
||||
|
@ -3752,8 +3755,18 @@ class singleWorker(threading.Thread):
|
|||
payload += signature
|
||||
|
||||
# We have assembled the data that will be encrypted.
|
||||
encrypted = highlevelcrypto.encrypt(
|
||||
payload, "04" + pubEncryptionKeyBase256.encode('hex'))
|
||||
try:
|
||||
encrypted = highlevelcrypto.encrypt(payload,"04"+pubEncryptionKeyBase256.encode('hex'))
|
||||
except:
|
||||
shared.sqlLock.acquire()
|
||||
t = (ackdata,)
|
||||
shared.sqlSubmitQueue.put('''UPDATE sent SET status='badkey' WHERE ackdata=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata',(ackdata,'Problem: The recipient\'s encryption key is no good. Could not encrypt message. ' + unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8'))))
|
||||
continue
|
||||
encryptedPayload = embeddedTime + \
|
||||
encodeVarint(toStreamNumber) + encrypted
|
||||
target = 2 ** 64 / ((len(
|
||||
|
@ -3788,7 +3801,7 @@ class singleWorker(threading.Thread):
|
|||
shared.sqlLock.acquire()
|
||||
t = (ackdata,)
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET status='msgsent' WHERE ackdata=? AND (status='doingmsgpow' or status='forcepow') ''')
|
||||
'''UPDATE sent SET status='msgsent' WHERE ackdata=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
|
|
|
@ -484,6 +484,9 @@ class MyForm(QtGui.QMainWindow):
|
|||
elif status == 'toodifficult':
|
||||
statusText = _translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
|
||||
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
|
||||
elif status == 'badkey':
|
||||
statusText = QtGui.QApplication.translate("MainWindow", "Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(
|
||||
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
|
||||
elif status == 'forcepow':
|
||||
statusText = _translate(
|
||||
"MainWindow", "Forced difficulty override. Send should start soon.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user