From 73e813f9ec37585a6b43791f1281eb0cdf43469f Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Tue, 29 May 2018 10:59:46 -0400 Subject: [PATCH] verify key size in Distance --- lbrynet/dht/distance.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lbrynet/dht/distance.py b/lbrynet/dht/distance.py index cda548db2..8945f8b30 100644 --- a/lbrynet/dht/distance.py +++ b/lbrynet/dht/distance.py @@ -1,3 +1,6 @@ +from lbrynet.dht import constants + + class Distance(object): """Calculate the XOR result between two string variables. @@ -6,6 +9,8 @@ class Distance(object): """ def __init__(self, key): + if len(key) != constants.key_bits / 8: + raise ValueError("invalid key length: %i", len(key)) self.key = key self.val_key_one = long(key.encode('hex'), 16)