- AE8FE58A8F92689212F3CCDB9A30A530CD19B0CE5AD7AEECDF5EEE1C6C9505AE56DF43A3132CA534D0BDB745D469CDBCE7F2A51EF30900259DADA9E894288827+ 0646687DE5D54FD0278B8265786D9E5BB65492DC81F323249B57C129D5293CF605F384B13354379D970AAF04C1757866529320F2B0D8226F64A0F269398DE6CBblatta/lib/infosec.py(24 . 6)(24 . 10)
143 MESSAGE_PACKET_FORMAT = "<q32s32s32s324s"
144 MAX_MESSAGE_LENGTH = 428
145 MAX_BOUNCES = 3
146 STALE_PACKET = 0
147 DUPLICATE_PACKET = 1
148 MALFORMED_PACKET = 2
149 INVALID_SIGNATURE = 3
150
151 class Infosec(object):
152 def __init__(self, server=None):
(110 . 15)(114 . 14)
154 black_packet_bytes, signature_bytes = struct.unpack(BLACK_PACKET_FORMAT, black_packet)
155 except:
156 self.server.print_error("Discarding malformed black packet from %s" % peer.get_key())
157 return None
158 return { "error_code": MALFORMED_PACKET }
159
160 # check signature
161
162 signature_check_bytes = hmac.new(signing_key, black_packet_bytes, hashlib.sha384).digest()
163
164 if(signature_check_bytes != signature_bytes):
165 self.server.print_debug("rejected black packet with bad signature for %s: %s" % (peer.get_key(), base64.b64encode(signature_check_bytes)))
166 return None
167 return { "error_code": INVALID_SIGNATURE }
168
169 # try to decrypt black packet
170
(137 . 12)(140 . 10)
172 # check timestamp
173
174 if(int_ts not in self._ts_range()):
175 self.server.print_debug("rejected message with timestamp out of range")
176 return None
177 return { "error_code": STALE_PACKET }
178
179 if(self.server.recent.has(int_ts)):
180 self.server.print_debug("rejected known message: %d" % int_ts)
181 return None
182 return { "error_code": DUPLICATE_PACKET }
183 else:
184 self.server.recent.insert(int_ts)
185
(175 . 7)(176 . 8)
187 "bounces": bounces,
188 "self_chain": self_chain,
189 "net_chain": net_chain,
190 "self_chain_valid": self_chain_valid }
191 "self_chain_valid": self_chain_valid,
192 "error_code": None}
193
194 def _pad(self, text, size):
195 return text.ljust(size)