forked from LBRYCommunity/lbry-sdk
22 lines
663 B
Python
22 lines
663 B
Python
import binascii
|
|
from twisted.internet import defer
|
|
from lbrynet.blob.CryptBlob import StreamBlobDecryptor
|
|
|
|
|
|
class CryptBlobHandler:
|
|
#implements(IBlobHandler)
|
|
|
|
def __init__(self, key, write_func):
|
|
self.key = key
|
|
self.write_func = write_func
|
|
|
|
######## IBlobHandler #########
|
|
|
|
def handle_blob(self, blob, blob_info):
|
|
try:
|
|
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)
|
|
return d
|