catch error from blob with invalid AES key size

This commit is contained in:
Jack Robison 2017-12-29 13:55:35 -05:00
parent 6385ab27c1
commit 2523afa266
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -1,5 +1,6 @@
import binascii import binascii
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer
from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor
from lbrynet.interfaces import IBlobHandler from lbrynet.interfaces import IBlobHandler
@ -14,7 +15,10 @@ class CryptBlobHandler(object):
######## IBlobHandler ######### ######## IBlobHandler #########
def handle_blob(self, blob, blob_info): def handle_blob(self, blob, blob_info):
blob_decryptor = StreamBlobDecryptor( try:
blob, self.key, binascii.unhexlify(blob_info.iv), blob_info.length) blob_decryptor = StreamBlobDecryptor(blob, self.key, binascii.unhexlify(blob_info.iv),
blob_info.length)
except ValueError as err:
return defer.fail(err)
d = blob_decryptor.decrypt(self.write_func) d = blob_decryptor.decrypt(self.write_func)
return d return d