1 import os, random, struct
2 from zope.interface import implements
3 from twisted.internet import defer
4 from twisted.internet.interfaces import IPullProducer
5 from twisted.python import failure
6 from twisted.application import service
7 from twisted.web.error import Error as WebError
8 from foolscap.api import flushEventualQueue, fireEventually
9 from allmydata import uri, client
10 from allmydata.introducer.server import IntroducerNode
11 from allmydata.interfaces import IMutableFileNode, IImmutableFileNode,\
12 NotEnoughSharesError, ICheckable, \
13 IMutableUploadable, SDMF_VERSION, \
15 from allmydata.check_results import CheckResults, CheckAndRepairResults, \
16 DeepCheckResults, DeepCheckAndRepairResults
17 from allmydata.storage_client import StubServer
18 from allmydata.mutable.layout import unpack_header
19 from allmydata.mutable.publish import MutableData
20 from allmydata.storage.mutable import MutableShareFile
21 from allmydata.util import hashutil, log, fileutil, pollmixin
22 from allmydata.util.assertutil import precondition
23 from allmydata.util.consumer import download_to_data
24 from allmydata.stats import StatsGathererService
25 from allmydata.key_generator import KeyGeneratorService
26 import allmydata.test.common_util as testutil
27 from allmydata import immutable
29 TEST_RSA_KEY_SIZE = 522
31 def flush_but_dont_ignore(res):
32 d = flushEventualQueue()
39 implements(IPullProducer)
40 def resumeProducing(self):
43 class FakeCHKFileNode:
44 """I provide IImmutableFileNode, but all of my data is stored in a
45 class-level dictionary."""
46 implements(IImmutableFileNode)
48 def __init__(self, filecap, all_contents):
49 precondition(isinstance(filecap, (uri.CHKFileURI, uri.LiteralFileURI)), filecap)
50 self.all_contents = all_contents
52 self.storage_index = self.my_uri.get_storage_index()
55 return self.my_uri.to_string()
56 def get_write_uri(self):
58 def get_readonly_uri(self):
59 return self.my_uri.to_string()
62 def get_verify_cap(self):
63 return self.my_uri.get_verify_cap()
64 def get_repair_cap(self):
65 return self.my_uri.get_verify_cap()
66 def get_storage_index(self):
67 return self.storage_index
69 def check(self, monitor, verify=False, add_lease=False):
70 s = StubServer("\x00"*20)
71 r = CheckResults(self.my_uri, self.storage_index,
72 healthy=True, recoverable=True,
73 needs_rebalancing=False,
74 count_shares_needed=3,
75 count_shares_expected=10,
77 count_good_share_hosts=10,
78 count_recoverable_versions=1,
79 count_unrecoverable_versions=0,
80 servers_responding=[s],
83 list_corrupt_shares=[],
84 count_corrupt_shares=0,
85 list_incompatible_shares=[],
86 count_incompatible_shares=0,
91 return defer.succeed(r)
92 def check_and_repair(self, monitor, verify=False, add_lease=False):
93 d = self.check(verify)
95 r = CheckAndRepairResults(self.storage_index)
96 r.pre_repair_results = r.post_repair_results = cr
101 def is_mutable(self):
103 def is_readonly(self):
105 def is_unknown(self):
107 def is_allowed_in_immutable_directory(self):
109 def raise_error(self):
113 if isinstance(self.my_uri, uri.LiteralFileURI):
114 return self.my_uri.get_size()
116 data = self.all_contents[self.my_uri.to_string()]
118 raise NotEnoughSharesError(le, 0, 3)
120 def get_current_size(self):
121 return defer.succeed(self.get_size())
123 def read(self, consumer, offset=0, size=None):
124 # we don't bother to call registerProducer/unregisterProducer,
125 # because it's a hassle to write a dummy Producer that does the right
126 # thing (we have to make sure that DummyProducer.resumeProducing
127 # writes the data into the consumer immediately, otherwise it will
130 d = defer.succeed(None)
131 d.addCallback(self._read, consumer, offset, size)
134 def _read(self, ignored, consumer, offset, size):
135 if isinstance(self.my_uri, uri.LiteralFileURI):
136 data = self.my_uri.data
138 if self.my_uri.to_string() not in self.all_contents:
139 raise NotEnoughSharesError(None, 0, 3)
140 data = self.all_contents[self.my_uri.to_string()]
146 consumer.write(data[start:end])
150 def get_best_readable_version(self):
151 return defer.succeed(self)
154 def download_to_data(self):
155 return download_to_data(self)
158 download_best_version = download_to_data
161 def get_size_of_best_version(self):
162 return defer.succeed(self.get_size)
165 def make_chk_file_cap(size):
166 return uri.CHKFileURI(key=os.urandom(16),
167 uri_extension_hash=os.urandom(32),
171 def make_chk_file_uri(size):
172 return make_chk_file_cap(size).to_string()
174 def create_chk_filenode(contents, all_contents):
175 filecap = make_chk_file_cap(len(contents))
176 n = FakeCHKFileNode(filecap, all_contents)
177 all_contents[filecap.to_string()] = contents
181 class FakeMutableFileNode:
182 """I provide IMutableFileNode, but all of my data is stored in a
183 class-level dictionary."""
185 implements(IMutableFileNode, ICheckable)
186 MUTABLE_SIZELIMIT = 10000
188 def __init__(self, storage_broker, secret_holder,
189 default_encoding_parameters, history, all_contents):
190 self.all_contents = all_contents
191 self.file_types = {} # storage index => MDMF_VERSION or SDMF_VERSION
192 self.init_from_cap(make_mutable_file_cap())
193 self._k = default_encoding_parameters['k']
194 self._segsize = default_encoding_parameters['max_segment_size']
195 def create(self, contents, key_generator=None, keysize=None,
196 version=SDMF_VERSION):
197 if version == MDMF_VERSION and \
198 isinstance(self.my_uri, (uri.ReadonlySSKFileURI,
199 uri.WriteableSSKFileURI)):
200 self.init_from_cap(make_mdmf_mutable_file_cap())
201 self.file_types[self.storage_index] = version
202 initial_contents = self._get_initial_contents(contents)
203 data = initial_contents.read(initial_contents.get_size())
205 self.all_contents[self.storage_index] = data
206 return defer.succeed(self)
207 def _get_initial_contents(self, contents):
209 return MutableData("")
211 if IMutableUploadable.providedBy(contents):
214 assert callable(contents), "%s should be callable, not %s" % \
215 (contents, type(contents))
216 return contents(self)
217 def init_from_cap(self, filecap):
218 assert isinstance(filecap, (uri.WriteableSSKFileURI,
219 uri.ReadonlySSKFileURI,
220 uri.WriteableMDMFFileURI,
221 uri.ReadonlyMDMFFileURI))
222 self.my_uri = filecap
223 self.storage_index = self.my_uri.get_storage_index()
224 if isinstance(filecap, (uri.WriteableMDMFFileURI,
225 uri.ReadonlyMDMFFileURI)):
226 self.file_types[self.storage_index] = MDMF_VERSION
229 self.file_types[self.storage_index] = SDMF_VERSION
234 def get_readcap(self):
235 return self.my_uri.get_readonly()
237 return self.my_uri.to_string()
238 def get_write_uri(self):
239 if self.is_readonly():
241 return self.my_uri.to_string()
242 def get_readonly(self):
243 return self.my_uri.get_readonly()
244 def get_readonly_uri(self):
245 return self.my_uri.get_readonly().to_string()
246 def get_verify_cap(self):
247 return self.my_uri.get_verify_cap()
248 def get_repair_cap(self):
249 if self.my_uri.is_readonly():
252 def is_readonly(self):
253 return self.my_uri.is_readonly()
254 def is_mutable(self):
255 return self.my_uri.is_mutable()
256 def is_unknown(self):
258 def is_allowed_in_immutable_directory(self):
259 return not self.my_uri.is_mutable()
260 def raise_error(self):
262 def get_writekey(self):
265 return len(self.all_contents[self.storage_index])
266 def get_current_size(self):
267 return self.get_size_of_best_version()
268 def get_size_of_best_version(self):
269 return defer.succeed(len(self.all_contents[self.storage_index]))
271 def get_storage_index(self):
272 return self.storage_index
274 def get_servermap(self, mode):
275 return defer.succeed(None)
277 def get_version(self):
278 assert self.storage_index in self.file_types
279 return self.file_types[self.storage_index]
281 def check(self, monitor, verify=False, add_lease=False):
282 s = StubServer("\x00"*20)
283 r = CheckResults(self.my_uri, self.storage_index,
284 healthy=True, recoverable=True,
285 needs_rebalancing=False,
286 count_shares_needed=3,
287 count_shares_expected=10,
288 count_shares_good=10,
289 count_good_share_hosts=10,
290 count_recoverable_versions=1,
291 count_unrecoverable_versions=0,
292 servers_responding=[s],
293 sharemap={"seq1-abcd-sh0": [s]},
294 count_wrong_shares=0,
295 list_corrupt_shares=[],
296 count_corrupt_shares=0,
297 list_incompatible_shares=[],
298 count_incompatible_shares=0,
303 return defer.succeed(r)
305 def check_and_repair(self, monitor, verify=False, add_lease=False):
306 d = self.check(verify)
308 r = CheckAndRepairResults(self.storage_index)
309 r.pre_repair_results = r.post_repair_results = cr
314 def deep_check(self, verify=False, add_lease=False):
315 d = self.check(verify)
317 dr = DeepCheckResults(self.storage_index)
323 def deep_check_and_repair(self, verify=False, add_lease=False):
324 d = self.check_and_repair(verify)
326 dr = DeepCheckAndRepairResults(self.storage_index)
332 def download_best_version(self):
333 return defer.succeed(self._download_best_version())
336 def _download_best_version(self, ignored=None):
337 if isinstance(self.my_uri, uri.LiteralFileURI):
338 return self.my_uri.data
339 if self.storage_index not in self.all_contents:
340 raise NotEnoughSharesError(None, 0, 3)
341 return self.all_contents[self.storage_index]
344 def overwrite(self, new_contents):
345 assert not self.is_readonly()
346 new_data = new_contents.read(new_contents.get_size())
347 new_data = "".join(new_data)
348 self.all_contents[self.storage_index] = new_data
349 return defer.succeed(None)
350 def modify(self, modifier):
351 # this does not implement FileTooLargeError, but the real one does
352 return defer.maybeDeferred(self._modify, modifier)
353 def _modify(self, modifier):
354 assert not self.is_readonly()
355 old_contents = self.all_contents[self.storage_index]
356 new_data = modifier(old_contents, None, True)
357 self.all_contents[self.storage_index] = new_data
360 # As actually implemented, MutableFilenode and MutableFileVersion
361 # are distinct. However, nothing in the webapi uses (yet) that
362 # distinction -- it just uses the unified download interface
363 # provided by get_best_readable_version and read. When we start
364 # doing cooler things like LDMF, we will want to revise this code to
365 # be less simplistic.
366 def get_best_readable_version(self):
367 return defer.succeed(self)
370 def get_best_mutable_version(self):
371 return defer.succeed(self)
373 # Ditto for this, which is an implementation of IWriteable.
374 # XXX: Declare that the same is implemented.
375 def update(self, data, offset):
376 assert not self.is_readonly()
377 def modifier(old, servermap, first_time):
378 new = old[:offset] + "".join(data.read(data.get_size()))
379 new += old[len(new):]
381 return self.modify(modifier)
384 def read(self, consumer, offset=0, size=None):
385 data = self._download_best_version()
387 data = data[offset:offset+size]
389 return defer.succeed(consumer)
392 def make_mutable_file_cap():
393 return uri.WriteableSSKFileURI(writekey=os.urandom(16),
394 fingerprint=os.urandom(32))
396 def make_mdmf_mutable_file_cap():
397 return uri.WriteableMDMFFileURI(writekey=os.urandom(16),
398 fingerprint=os.urandom(32))
400 def make_mutable_file_uri(mdmf=False):
402 uri = make_mdmf_mutable_file_cap()
404 uri = make_mutable_file_cap()
406 return uri.to_string()
408 def make_verifier_uri():
409 return uri.SSKVerifierURI(storage_index=os.urandom(16),
410 fingerprint=os.urandom(32)).to_string()
412 def create_mutable_filenode(contents, mdmf=False, all_contents=None):
413 # XXX: All of these arguments are kind of stupid.
415 cap = make_mdmf_mutable_file_cap()
417 cap = make_mutable_file_cap()
420 encoding_params['k'] = 3
421 encoding_params['max_segment_size'] = 128*1024
423 filenode = FakeMutableFileNode(None, None, encoding_params, None,
425 filenode.init_from_cap(cap)
427 filenode.create(MutableData(contents), version=MDMF_VERSION)
429 filenode.create(MutableData(contents), version=SDMF_VERSION)
433 class LoggingServiceParent(service.MultiService):
434 def log(self, *args, **kwargs):
435 return log.msg(*args, **kwargs)
437 class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
439 # SystemTestMixin tests tend to be a lot of work, and we have a few
440 # buildslaves that are pretty slow, and every once in a while these tests
441 # run up against the default 120 second timeout. So increase the default
442 # timeout. Individual test cases can override this, of course.
446 self.sparent = service.MultiService()
447 self.sparent.startService()
449 self.stats_gatherer = None
450 self.stats_gatherer_furl = None
451 self.key_generator_svc = None
452 self.key_generator_furl = None
455 log.msg("shutting down SystemTest services")
456 d = self.sparent.stopService()
457 d.addBoth(flush_but_dont_ignore)
460 def getdir(self, subdir):
461 return os.path.join(self.basedir, subdir)
463 def add_service(self, s):
464 s.setServiceParent(self.sparent)
467 def set_up_nodes(self, NUMCLIENTS=5,
468 use_stats_gatherer=False, use_key_generator=False):
469 self.numclients = NUMCLIENTS
470 iv_dir = self.getdir("introducer")
471 if not os.path.isdir(iv_dir):
472 fileutil.make_dirs(iv_dir)
473 fileutil.write(os.path.join(iv_dir, 'tahoe.cfg'), \
475 "web.port = tcp:0:interface=127.0.0.1\n")
476 if SYSTEM_TEST_CERTS:
477 os.mkdir(os.path.join(iv_dir, "private"))
478 f = open(os.path.join(iv_dir, "private", "node.pem"), "w")
479 f.write(SYSTEM_TEST_CERTS[0])
481 iv = IntroducerNode(basedir=iv_dir)
482 self.introducer = self.add_service(iv)
483 d = self.introducer.when_tub_ready()
484 d.addCallback(self._get_introducer_web)
485 if use_stats_gatherer:
486 d.addCallback(self._set_up_stats_gatherer)
487 if use_key_generator:
488 d.addCallback(self._set_up_key_generator)
489 d.addCallback(self._set_up_nodes_2)
490 if use_stats_gatherer:
491 d.addCallback(self._grab_stats)
494 def _get_introducer_web(self, res):
495 f = open(os.path.join(self.getdir("introducer"), "node.url"), "r")
496 self.introweb_url = f.read().strip()
499 def _set_up_stats_gatherer(self, res):
500 statsdir = self.getdir("stats_gatherer")
501 fileutil.make_dirs(statsdir)
502 self.stats_gatherer_svc = StatsGathererService(statsdir)
503 self.stats_gatherer = self.stats_gatherer_svc.stats_gatherer
504 self.add_service(self.stats_gatherer_svc)
507 sgf = os.path.join(statsdir, 'stats_gatherer.furl')
508 def check_for_furl():
509 return os.path.exists(sgf)
510 d.addCallback(lambda junk: self.poll(check_for_furl, timeout=30))
512 self.stats_gatherer_furl = file(sgf, 'rb').read().strip()
513 d.addCallback(get_furl)
516 def _set_up_key_generator(self, res):
517 kgsdir = self.getdir("key_generator")
518 fileutil.make_dirs(kgsdir)
520 self.key_generator_svc = KeyGeneratorService(kgsdir,
522 default_key_size=TEST_RSA_KEY_SIZE)
523 self.key_generator_svc.key_generator.pool_size = 4
524 self.key_generator_svc.key_generator.pool_refresh_delay = 60
525 self.add_service(self.key_generator_svc)
528 def check_for_furl():
529 return os.path.exists(os.path.join(kgsdir, 'key_generator.furl'))
530 d.addCallback(lambda junk: self.poll(check_for_furl, timeout=30))
532 kgf = os.path.join(kgsdir, 'key_generator.furl')
533 self.key_generator_furl = file(kgf, 'rb').read().strip()
534 d.addCallback(get_furl)
537 def _set_up_nodes_2(self, res):
539 self.introducer_furl = q.introducer_url
542 for i in range(self.numclients):
543 basedir = self.getdir("client%d" % i)
544 basedirs.append(basedir)
545 fileutil.make_dirs(os.path.join(basedir, "private"))
546 if len(SYSTEM_TEST_CERTS) > (i+1):
547 f = open(os.path.join(basedir, "private", "node.pem"), "w")
548 f.write(SYSTEM_TEST_CERTS[i+1])
551 config = "[client]\n"
552 config += "introducer.furl = %s\n" % self.introducer_furl
553 if self.stats_gatherer_furl:
554 config += "stats_gatherer.furl = %s\n" % self.stats_gatherer_furl
557 # clients[0] runs a webserver and a helper, no key_generator
559 config += "web.port = tcp:0:interface=127.0.0.1\n"
560 config += "timeout.keepalive = 600\n"
561 config += "[helper]\n"
562 config += "enabled = True\n"
564 # clients[3] runs a webserver and uses a helper, uses
566 if self.key_generator_furl:
567 config += "key_generator.furl = %s\n" % self.key_generator_furl
569 config += "web.port = tcp:0:interface=127.0.0.1\n"
570 config += "timeout.disconnect = 1800\n"
572 fileutil.write(os.path.join(basedir, 'tahoe.cfg'), config)
574 # give subclasses a chance to append lines to the node's tahoe.cfg
575 # files before they are launched.
576 self._set_up_nodes_extra_config()
578 # start clients[0], wait for it's tub to be ready (at which point it
579 # will have registered the helper furl).
580 c = self.add_service(client.Client(basedir=basedirs[0]))
581 self.clients.append(c)
582 c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
583 d = c.when_tub_ready()
585 f = open(os.path.join(basedirs[0],"private","helper.furl"), "r")
586 helper_furl = f.read()
588 self.helper_furl = helper_furl
589 if self.numclients >= 4:
590 f = open(os.path.join(basedirs[3], 'tahoe.cfg'), 'ab+')
593 "helper.furl = %s\n" % helper_furl)
596 # this starts the rest of the clients
597 for i in range(1, self.numclients):
598 c = self.add_service(client.Client(basedir=basedirs[i]))
599 self.clients.append(c)
600 c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
602 return self.wait_for_connections()
603 d.addCallback(_ready)
606 # now find out where the web port was
607 self.webish_url = self.clients[0].getServiceNamed("webish").getURL()
608 if self.numclients >=4:
609 # and the helper-using webport
610 self.helper_webish_url = self.clients[3].getServiceNamed("webish").getURL()
611 d.addCallback(_connected)
614 def _set_up_nodes_extra_config(self):
615 # for overriding by subclasses
618 def _grab_stats(self, res):
619 d = self.stats_gatherer.poll()
622 def bounce_client(self, num):
623 c = self.clients[num]
624 d = c.disownServiceParent()
625 # I think windows requires a moment to let the connection really stop
626 # and the port number made available for re-use. TODO: examine the
627 # behavior, see if this is really the problem, see if we can do
628 # better than blindly waiting for a second.
629 d.addCallback(self.stall, 1.0)
631 new_c = client.Client(basedir=self.getdir("client%d" % num))
632 self.clients[num] = new_c
633 new_c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
634 self.add_service(new_c)
635 return new_c.when_tub_ready()
636 d.addCallback(_stopped)
637 d.addCallback(lambda res: self.wait_for_connections())
638 def _maybe_get_webport(res):
640 # now find out where the web port was
641 self.webish_url = self.clients[0].getServiceNamed("webish").getURL()
642 d.addCallback(_maybe_get_webport)
645 def add_extra_node(self, client_num, helper_furl=None,
646 add_to_sparent=False):
647 # usually this node is *not* parented to our self.sparent, so we can
648 # shut it down separately from the rest, to exercise the
649 # connection-lost code
650 basedir = self.getdir("client%d" % client_num)
651 if not os.path.isdir(basedir):
652 fileutil.make_dirs(basedir)
653 config = "[client]\n"
654 config += "introducer.furl = %s\n" % self.introducer_furl
656 config += "helper.furl = %s\n" % helper_furl
657 fileutil.write(os.path.join(basedir, 'tahoe.cfg'), config)
659 c = client.Client(basedir=basedir)
660 self.clients.append(c)
661 c.set_default_mutable_keysize(TEST_RSA_KEY_SIZE)
664 c.setServiceParent(self.sparent)
667 d = self.wait_for_connections()
668 d.addCallback(lambda res: c)
671 def _check_connections(self):
672 for c in self.clients:
673 if not c.connected_to_introducer():
675 sb = c.get_storage_broker()
676 if len(sb.get_connected_servers()) != self.numclients:
678 up = c.getServiceNamed("uploader")
679 if up._helper_furl and not up._helper:
683 def wait_for_connections(self, ignored=None):
684 return self.poll(self._check_connections, timeout=200)
687 # our system test uses the same Tub certificates each time, to avoid the
688 # overhead of key generation
689 SYSTEM_TEST_CERTS = [
690 """-----BEGIN CERTIFICATE-----
691 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
692 aW5neTAeFw0wODA3MjUyMjQyMDVaFw0wOTA3MjUyMjQyMDVaMBcxFTATBgNVBAMU
693 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxHCWajrR
694 2h/iurw8k93m8WUdE3xypJiiAITw7GkKlKbCLD+dEce2MXwVVYca0n/MZZsj89Cu
695 Ko0lLjksMseoSDoj98i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BthZ
713 WqU1XZVGg2KooISsxIsCQQD1PS7//xHLumBb0jnpL7n6W8gmiTyzblT+0otaCisP
714 fN6rTlwV1o8VsOUAz0rmKO5RArCbkmb01WtMgPCDBYkk
715 -----END RSA PRIVATE KEY-----
717 """-----BEGIN CERTIFICATE-----
718 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
719 aW5neTAeFw0wODA3MjUyMjQyMDVaFw0wOTA3MjUyMjQyMDVaMBcxFTATBgNVBAMU
720 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAs9CALdmW
721 kJ6r0KPSLdGCA8rzQKxWayrMckT22ZtbRv3aw6VA96dWclpY+T2maV0LrAzmMSL8
722 n61ydJHM33iYDOyWbwHWN45XCjY/e20PL54XUl/DmbBHEhQVQLIfCldcRcnWEfoO
723 iOhDJfWpDO1dmP/aOYLdkZCZvBtPAfyUqRcCAwEAATANBgkqhkiG9w0BAQQFAAOB
724 gQAN9eaCREkzzk4yPIaWYkWHg3Igs1vnOR/iDw3OjyxO/xJFP2lkA2WtrwL2RTRq
725 dxA8gwdPyrWgdiZElwZH8mzTJ4OdUXLSMclLOg9kvH6gtSvhLztfEDwDP1wRhikh
726 OeWWu2GIC+uqFCI1ftoGgU+aIa6yrHswf66rrQvBSSvJPQ==
727 -----END CERTIFICATE-----
728 -----BEGIN RSA PRIVATE KEY-----
729 MIICXQIBAAKBgQCz0IAt2ZaQnqvQo9It0YIDyvNArFZrKsxyRPbZm1tG/drDpUD3
730 p1ZyWlj5PaZpXQusDOYxIvyfrXJ0kczfeJgM7JZvAdY3jlcKNj97bQ8vnhdSX8OZ
731 sEcSFBVAsh8KV1xFydYR+g6I6EMl9akM7V2Y/9o5gt2RkJm8G08B/JSpFwIDAQAB
732 AoGBAIUy5zCPpSP+FeJY6CG+t6Pdm/IFd4KtUoM3KPCrT6M3+uzApm6Ny9Crsor2
733 qyYTocjSSVaOxzn1fvpw4qWLrH1veUf8ozMs8Z0VuPHD1GYUGjOXaBPXb5o1fQL9
734 h7pS5/HrDDPN6wwDNTsxRf/fP58CnfwQUhwdoxcx8TnVmDQxAkEA6N3jBXt/Lh0z
735 UbXHhv3QBOcqLZA2I4tY7wQzvUvKvVmCJoW1tfhBdYQWeQv0jzjL5PzrrNY8hC4l
736 8+sFM3h5TwJBAMWtbFIEZfRSG1JhHK3evYHDTZnr/j+CdoWuhzP5RkjkIKsiLEH7
737 2ZhA7CdFQLZF14oXy+g1uVCzzfB2WELtUbkCQQDKrb1XWzrBlzbAipfkXWs9qTmj
738 uJ32Z+V6+0xRGPOXxJ0sDDqw7CeFMfchWg98zLFiV+SEZV78qPHtkAPR3ayvAkB+
739 hUMhM4N13t9x2IoclsXAOhp++9bdG0l0woHyuAdOPATUw6iECwf4NQVxFRgYEZek
740 4Ro3Y7taddrHn1dabr6xAkAic47OoLOROYLpljmJJO0eRe3Z5IFe+0D2LfhAW3LQ
741 JU+oGq5pCjfnoaDElRRZn0+GmunnWeQEYKoflTi/lI9d
742 -----END RSA PRIVATE KEY-----
744 """-----BEGIN CERTIFICATE-----
745 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
746 aW5neTAeFw0wODA3MjUyMjQyMDZaFw0wOTA3MjUyMjQyMDZaMBcxFTATBgNVBAMU
747 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsxG7LTrz
748 DF+9wegOR/BRJhjSumPUbYQnNAUKtPraFsGjAJILP44AHdnHt1MONLgTeX1ynapo
749 q6O/q5cdKtBB7uEh7FpkLCCwpZt/m0y79cynn8AmWoQVgl8oS0567UmPeJnTzFPv
750 dmT5dlaQALeX5YGceAsEvhmAsdOMttaor38CAwEAATANBgkqhkiG9w0BAQQFAAOB
751 gQA345rxotfvh2kfgrmRzAyGewVBV4r23Go30GSZir8X2GoH3qKNwO4SekAohuSw
752 AiXzLUbwIdSRSqaLFxSC7Duqc9eIeFDAWjeEmpfFLBNiw3K8SLA00QrHCUXnECTD
753 b/Kk6OGuvPOiuuONVjEuEcRdCH3/Li30D0AhJaMynjhQJQ==
754 -----END CERTIFICATE-----
755 -----BEGIN RSA PRIVATE KEY-----
756 MIICXQIBAAKBgQCzEbstOvMMX73B6A5H8FEmGNK6Y9RthCc0BQq0+toWwaMAkgs/
757 jgAd2ce3Uw40uBN5fXKdqmiro7+rlx0q0EHu4SHsWmQsILClm3+bTLv1zKefwCZa
758 hBWCXyhLTnrtSY94mdPMU+92ZPl2VpAAt5flgZx4CwS+GYCx04y21qivfwIDAQAB
759 AoGBAIlhFg/aRPL+VM9539LzHN60dp8GzceDdqwjHhbAySZiQlLCuJx2rcI4/U65
760 CpIJku9G/fLV9N2RkA/trDPXeGyqCTJfnNzyZcvvMscRMFqSGyc21Y0a+GS8bIxt
761 1R2B18epSVMsWSWWMypeEgsfv29LV7oSWG8UKaqQ9+0h63DhAkEA4i2L/rori/Fb
762 wpIBfA+xbXL/GmWR7xPW+3nG3LdLQpVzxz4rIsmtO9hIXzvYpcufQbwgVACyMmRf
763 TMABeSDM7wJBAMquEdTaVXjGfH0EJ7z95Ys2rYTiCXjBfyEOi6RXXReqV9SXNKlN
764 aKsO22zYecpkAjY1EdUdXWP/mNVEybjpZnECQQCcuh0JPS5RwcTo9c2rjyBOjGIz
765 g3B1b5UIG2FurmCrWe6pgO3ZJFEzZ/L2cvz0Hj5UCa2JKBZTDvRutZoPumfnAkAb
766 nSW+y1Rz1Q8m9Ub4v9rjYbq4bRd/RVWtyk6KQIDldYbr5wH8wxgsniSVKtVFFuUa
767 P5bDY3HS6wMGo42cTOhxAkAcdweQSQ3j7mfc5vh71HeAC1v/VAKGehGOUdeEIQNl
768 Sb2WuzpZkbfsrVzW6MdlgY6eE7ufRswhDPLWPC8MP0d1
769 -----END RSA PRIVATE KEY-----
771 """-----BEGIN CERTIFICATE-----
772 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af/W3hqGihiqN2kL3PIIYcxSRWiyNlYXjElsR
790 2sllBTe3AkEA0jcMHVThwKt1+Ce5VcE7N6hFfbsgISTjfJ+Q3K2NkvJkmtE8ZRX5
791 XprssnPN8owkfF5yuKbcSZL3uvaaSGN9IQJAfTVnN9wwOXQwHhDSbDt9/KRBCnum
792 n+gHqDrKLaVJHOJ9SZf8eLswoww5c+UqtkYxmtlwie61Tp+9BXQosilQ4wJBAIZ1
793 XVNZmriBM4jR59L5MOZtxF0ilu98R+HLsn3kqLyIPF9mXCoQPxwLHkEan213xFKk
794 mt6PJDIPRlOZLqAEuuECQFQMCrn0VUwPg8E40pxMwgMETvVflPs/oZK1Iu+b7+WY
795 vBptAyhMu31fHQFnJpiUOyHqSZnOZyEn1Qu2lszNvUg=
796 -----END RSA PRIVATE KEY-----
798 """-----BEGIN CERTIFICATE-----
799 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
800 aW5neTAeFw0wODA3MjUyMjQyMDZaFw0wOTA3MjUyMjQyMDZaMBcxFTATBgNVBAMU
801 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnjiOwipn
802 jigDuNMfNG/tBJhPwYUHhSbQdvrTubhsxw1oOq5XpNqUwRtC8hktOKM3hghyqExP
803 62EOi0aJBkRhtwtPSLBCINptArZLfkog/nTIqVv4eLEzJ19nTi/llHHWKcgA6XTI
804 sU/snUhGlySA3RpETvXqIJTauQRZz0kToSUCAwEAATANBgkqhkiG9w0BAQQFAAOB
805 gQCQ+u/CsX5WC5m0cLrpyIS6qZa62lrB3mj9H1aIQhisT5kRsMz3FJ1aOaS8zPRz
806 w0jhyRmamCcSsWf5WK539iOtsXbKMdAyjNtkQO3g+fnsLgmznAjjst24jfr+XU59
807 0amiy1U6TY93gtEBZHtiLldPdUMsTuFbBlqbcMBQ50x9rA==
808 -----END CERTIFICATE-----
809 -----BEGIN RSA PRIVATE KEY-----
810 MIICXAIBAAKBgQCeOI7CKmeOKAO40x80b+0EmE/BhQeFJtB2+tO5uGzHDWg6rlek
811 2pTBG0LyGS04ozeGCHKoTE/rYQ6LRokGRGG3C09IsEIg2m0Ctkt+SiD+dMipW/h4
812 sTMnX2dOL+WUcdYpyADpdMixT+ydSEaXJIDdGkRO9eoglNq5BFnPSROhJQIDAQAB
813 AoGAAPrst3s3xQOucjismtCOsVaYN+SxFTwWUoZfRWlFEz6cBLELzfOktEWM9p79
814 TrqEH4px22UNobGqO2amdql5yXwEFVhYQkRB8uDA8uVaqpL8NLWTGPRXxZ2DSU+n
815 7/FLf/TWT3ti/ZtXaPVRj6E2/Mq9AVEVOjUYzkNjM02OxcECQQDKEqmPbdZq2URU
816 7RbUxkq5aTp8nzAgbpUsgBGQ9PDAymhj60BDEP0q28Ssa7tU70pRnQ3AZs9txgmL
817 kK2g97FNAkEAyHH9cIb6qXOAJPIr/xamFGr5uuYw9TJPz/hfVkVimW/aZnBB+e6Q
818 oALJBDKJWeYPzdNbouJYg8MeU0qWdZ5DOQJADUk+1sxc/bd9U6wnBSRog1pU2x7I
819 VkmPC1b8ULCaJ8LnLDKqjf5O9wNuIfwPXB1DoKwX3F+mIcyUkhWYJO5EPQJAUj5D
820 KMqZSrGzYHVlC/M1Daee88rDR7fu+3wDUhiCDkbQq7tftrbl7GF4LRq3NIWq8l7I
821 eJq6isWiSbaO6Y+YMQJBAJFBpVhlY5Px2BX5+Hsfq6dSP3sVVc0eHkdsoZFFxq37
822 fksL/q2vlPczvBihgcxt+UzW/UrNkelOuX3i57PDvFs=
823 -----END RSA PRIVATE KEY-----
825 """-----BEGIN CERTIFICATE-----
826 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
827 aW5neTAeFw0wODA3MjUyMjQyMDZaFw0wOTA3MjUyMjQyMDZaMBcxFTATBgNVBAMU
828 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsCQuudDF
829 zgmY5tDpT0TkUo8fpJ5JcvgCkLFpSDD8REpXhLFkHWhTmTj3CAxfv4lA3sQzHZxe
830 4S9YCb5c/VTbFEdgwc/wlxMmJiz2jYghdmWPBb8pBEk31YihIhC+u4kex6gJBH5y
831 ixiZ3PPRRMaOBBo+ZfM50XIyWbFOOM/7FwcCAwEAATANBgkqhkiG9w0BAQQFAAOB
832 gQB4cFURaiiUx6n8eS4j4Vxrii5PtsaNEI4acANFSYknGd0xTP4vnmoivNmo5fWE
833 Q4hYtGezNu4a9MnNhcQmI20KzXmvhLJtkwWCgGOVJtMem8hDWXSALV1Ih8hmVkGS
834 CI1elfr9eyguunGp9eMMQfKhWH52WHFA0NYa0Kpv5BY33A==
835 -----END CERTIFICATE-----
836 -----BEGIN RSA PRIVATE KEY-----
837 MIICWwIBAAKBgQCwJC650MXOCZjm0OlPRORSjx+knkly+AKQsWlIMPxESleEsWQd
838 aFOZOPcIDF+/iUDexDMdnF7hL1gJvlz9VNsUR2DBz/CXEyYmLPaNiCF2ZY8FvykE
839 STfViKEiEL67iR7HqAkEfnKLGJnc89FExo4EGj5l8znRcjJZsU44z/sXBwIDAQAB
840 AoGABA7xXKqoxBSIh1js5zypHhXaHsre2l1Igdj0mgs25MPpvE7yBZNvyan8Vx0h
841 36Hj8r4Gh3og3YNfvem67sNTwNwONY0ep+Xho/3vG0jFATGduSXdcT04DusgZNqg
842 UJqW75cqxrD6o/nya5wUoN9NL5pcd5AgVMdOYvJGbrwQuaECQQDiCs/5dsUkUkeC
843 Tlur1wh0wJpW4Y2ctO3ncRdnAoAA9y8dELHXMqwKE4HtlyzHY7Bxds/BDh373EVK
844 rsdl+v9JAkEAx3xTmsOQvWa1tf/O30sdItVpGogKDvYqkLCNthUzPaL85BWB03E2
845 xunHcVVlqAOE5tFuw0/UEyEkOaGlNTJTzwJAPIVel9FoCUiKYuYt/z1swy3KZRaw
846 /tMmm4AZHvh5Y0jLcYHFy/OCQpRkhkOitqQHWunPyEXKW2PnnY5cTv68GQJAHG7H
847 B88KCUTjb25nkQIGxBlA4swzCtDhXkAb4rEA3a8mdmfuWjHPyeg2ShwO4jSmM7P0
848 Iph1NMjLff9hKcTjlwJARpItOFkYEdtSODC7FMm7KRKQnNB27gFAizsOYWD4D2b7
849 w1FTEZ/kSA9wSNhyNGt7dgUo6zFhm2u973HBCUb3dg==
850 -----END RSA PRIVATE KEY-----
852 """-----BEGIN CERTIFICATE-----
853 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
854 aW5neTAeFw0wODA3MjUyMjQ3NThaFw0wOTA3MjUyMjQ3NThaMBcxFTATBgNVBAMU
855 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvhTRj1dA
856 NOfse/UBeTfMekZKxZHsNPr+qBYaveWAHDded/BMyMgaMV2n6HQdiDaRjJkzjHCF
857 3xBtpIJeEGUqfrF0ob8BIZXy3qk68eX/0CVUbgmjSBN44ahlo63NshyXmZtEAkRV
858 VE/+cRKw3N2wtuTed5xwfNcL6dg4KTOEYEkCAwEAATANBgkqhkiG9w0BAQQFAAOB
859 gQCN+CLuVwLeWjSdVbdizYyrOVckqtwiIHG9BbGMlcIdm0qpvD7V7/sN2csk5LaT
860 BNiHi1t5628/4UHqqodYmFw8ri8ItFwB+MmTJi11CX6dIP9OUhS0qO8Z/BKtot7H
861 j04oNwl+WqZZfHIYwTIEL0HBn60nOvCQPDtnWG2BhpUxMA==
862 -----END CERTIFICATE-----
863 -----BEGIN RSA PRIVATE KEY-----
864 MIICXQIBAAKBgQC+FNGPV0A05+x79QF5N8x6RkrFkew0+v6oFhq95YAcN1538EzI
865 yBoxXafodB2INpGMmTOMcIXfEG2kgl4QZSp+sXShvwEhlfLeqTrx5f/QJVRuCaNI
866 E3jhqGWjrc2yHJeZm0QCRFVUT/5xErDc3bC25N53nH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VtKpII1o/5z7Jo292JYy8CAwEAATANBgkqhkiG9w0BAQQFAAOB
886 gQA0PYMA07wo9kEH4fv9TCfo+zz42Px6lUxrQBPxBvDiGYhk2kME/wX0IcoZPKTV
887 WyBGmDAYWvFaHWbrbbTOfzlLWfYrDD913hCi9cO8iF8oBqRjIlkKcxAoe7vVg5Az
888 ydVcrY+zqULJovWwyNmH1QNIQfMat0rj7fylwjiS1y/YsA==
889 -----END CERTIFICATE-----
890 -----BEGIN RSA PRIVATE KEY-----
891 MIICXAIBAAKBgQC0qHHqwQCOfodZzpPaSXCU+fSq7Ie0BMjDxXd7M/jq/qDatFLt
892 1PLCjgZM/i9fnyX6wL3P0l6qFDWtZLAwrgWacMxkK7sBU7ugwheld1LPuXRuAKc2
893 O9umQDak59sHVnyiPyJ5t98nfcgPkN2SYLOphW0qkgjWj/nPsmjb3YljLwIDAQAB
894 AoGAU4CYRv22mCZ7wVLunDLdyr5ODMMPZnHfqj2XoGbBYz0WdIBs5GlNXAfxeZzz
895 oKsbDvAPzANcphh5RxAHMDj/dT8rZOez+eJrs1GEV+crl1T9p83iUkAuOJFtgUgf
896 TtQBL9vHaj7DfvCEXcBPmN/teDFmAAOyUNbtuhTkRa3PbuECQQDwaqZ45Kr0natH
897 V312dqlf9ms8I6e873pAu+RvA3BAWczk65eGcRjEBxVpTvNEcYKFrV8O5ZYtolrr
898 VJl97AfdAkEAwF4w4KJ32fLPVoPnrYlgLw86NejMpAkixblm8cn51avPQmwbtahb
899 BZUuca22IpgDpjeEk5SpEMixKe/UjzxMewJBALy4q2cY8U3F+u6sshLtAPYQZIs3
900 3fNE9W2dUKsIQvRwyZMlkLN7UhqHCPq6e+HNTM0MlCMIfAPkf4Rdy4N6ZY0CQCKE
901 BAMaQ6TwgzFDw5sIjiCDe+9WUPmRxhJyHL1/fvtOs4Z4fVRP290ZklbFU2vLmMQH
902 LBuKzfb7+4XJyXrV1+cCQBqfPFQQZLr5UgccABYQ2jnWVbJPISJ5h2b0cwXt+pz/
903 8ODEYLjqWr9K8dtbgwdpzwbkaGhQYpyvsguMvNPMohs=
904 -----END RSA PRIVATE KEY-----
906 """-----BEGIN CERTIFICATE-----
907 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
908 aW5neTAeFw0wODA3MjUyMjQ3NThaFw0wOTA3MjUyMjQ3NThaMBcxFTATBgNVBAMU
909 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAnBfNHycn
910 5RnYzDN4EWTk2q1BBxA6ZYtlG1WPkj5iKeaYKzUk58zBL7mNOA0ucq+yTwh9C4IC
911 EutWPaKBSKY5XI+Rdebh+Efq+urtOLgfJHlfcCraEx7hYN+tqqMVgEgnO/MqIsn1
912 I1Fvnp89mSYbQ9tmvhSH4Hm+nbeK6iL2tIsCAwEAATANBgkqhkiG9w0BAQQFAAOB
913 gQBt9zxfsKWoyyV764rRb6XThuTDMNSDaVofqePEWjudAbDu6tp0pHcrL0XpIrnT
914 3iPgD47pdlwQNbGJ7xXwZu2QTOq+Lv62E6PCL8FljDVoYqR3WwJFFUigNvBT2Zzu
915 Pxx7KUfOlm/M4XUSMu31sNJ0kQniBwpkW43YmHVNFb/R7g==
916 -----END CERTIFICATE-----
917 -----BEGIN RSA PRIVATE KEY-----
918 MIICXQIBAAKBgQCcF80fJyflGdjMM3gRZOTarUEHEDpli2UbVY+SPmIp5pgrNSTn
919 zMEvuY04DS5yr7JPCH0LggIS61Y9ooFIpjlcj5F15uH4R+r66u04uB8keV9wKtoT
920 HuFg362qoxWASCc78yoiyfUjUW+enz2ZJhtD22a+FIfgeb6dt4rqIva0iwIDAQAB
921 AoGBAIHstcnWd7iUeQYPWUNxLaRvTY8pjNH04yWLZEOgNWkXDVX5mExw++RTmB4t
922 qpm/cLWkJSEtB7jjthb7ao0j/t2ljqfr6kAbClDv3zByAEDhOu8xB/5ne6Ioo+k2
923 dygC+GcVcobhv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3fPl2ZgDYQ
942 ZzsWAZvTNXd/eme0SgOzD10rfntA6ZIgJTWHx3E0RkdwKw==
943 -----END CERTIFICATE-----
944 -----BEGIN RSA PRIVATE KEY-----
945 MIICXQIBAAKBgQDiact/7HQJYoMo/k8tnzu3ZF5IMT8nlCgjlWETRtdpqF2E+tBM
946 LbC86lP432fMSkj0BKH96NWRgaVzTec0pEvvPJUzVTIZ24TCxGywUyp/ImEjWn5W
947 bEMxY2mV7HuYgCF4B2yQ+PenCLYI/hUgyM6PfrwBe9ci0/N4J8CFiERVowIDAQAB
948 AoGAQYTl+8XcKl8Un4dAOG6M5FwqIHAH25c3Klzu85obehrbvUCriG/sZi7VT/6u
949 VeLlS6APlJ+NNgczbrOLhaNJyYzjICSt8BI96PldFUzCEkVlgE+29pO7RNoZmDYB
950 dSGyIDrWdVYfdzpir6kC0KDcrpA16Sc+/bK6Q8ALLRpC7QECQQD7F7fhIQ03CKSk
951 lS4mgDuBQrB/52jXgBumtjp71ANNeaWR6+06KDPTLysM+olsh97Q7YOGORbrBnBg
952 Y2HPnOgjAkEA5taZaMfdFa8V1SPcX7mgCLykYIujqss0AmauZN/24oLdNE8HtTBF
953 OLaxE6PnQ0JWfx9KGIy3E0V3aFk5FWb0gQJBAO4KFEaXgOG1jfCBhNj3JHJseMso
954 5Nm4F366r0MJQYBHXNGzqphB2K/Svat2MKX1QSUspk2u/a0d05dtYCLki6UCQHWS
955 sChyQ+UbfF9HGKOZBC3vBzo1ZXNEdIUUj5bJjBHq3YgbCK38nAU66A482TmkvDGb
956 Wj4OzeB+7Ua0yyJfggECQQDVlAa8HqdAcrbEwI/YfPydFsavBJ0KtcIGK2owQ+dk
957 dhlDnpXDud/AtX4Ft2LaquQ15fteRrYjjwI9SFGytjtp
958 -----END RSA PRIVATE KEY-----
960 """-----BEGIN CERTIFICATE-----
961 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
962 aW5neTAeFw0wODA3MjUyMjQ3NThaFw0wOTA3MjUyMjQ3NThaMBcxFTATBgNVBAMU
963 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAueLfowPT
964 kXXtHeU2FZSz2mJhHmjqeyI1oMoyyggonccx65vMxaRfljnz2dOjVVYpCOn/LrdP
965 wVxHO8KNDsmQeWPRjnnBa2dFqqOnp/8gEJFJBW7K/gI9se6o+xe9QIWBq6d/fKVR
966 BURJe5TycLogzZuxQn1xHHILa3XleYuHAbMCAwEAATANBgkqhkiG9w0BAQQFAAOB
967 gQBEC1lfC3XK0galQC96B7faLpnQmhn5lX2FUUoFIQQtBTetoE+gTqnLSOIZcOK4
968 pkT3YvxUvgOV0LOLClryo2IknMMGWRSAcXtVUBBLRHVTSSuVUyyLr5kdRU7B4E+l
969 OU0j8Md/dzlkm//K1bzLyUaPq204ofH8su2IEX4b3IGmAQ==
970 -----END CERTIFICATE-----
971 -----BEGIN RSA PRIVATE KEY-----
972 MIICWwIBAAKBgQC54t+jA9ORde0d5TYVlLPaYmEeaOp7IjWgyjLKCCidxzHrm8zF
973 pF+WOfPZ06NVVikI6f8ut0/BXEc7wo0OyZB5Y9GOecFrZ0Wqo6en/yAQkUkFbsr+
974 Aj2x7qj7F71AhYGrp398pVEFREl7lPJwuiDNm7FCfXEccgtrdeV5i4cBswIDAQAB
975 AoGAO4PnJHNaLs16AMNdgKVevEIZZDolMQ1v7C4w+ryH/JRFaHE2q+UH8bpWV9zK
976 A82VT9RTrqpkb71S1VBiB2UDyz263XdAI/N2HcIVMmfKb72oV4gCI1KOv4DfFwZv
977 tVVcIdVEDBOZ2TgqK4opGOgWMDqgIAl2z3PbsIoNylZHEJECQQDtQeJFhEJGH4Qz
978 BGpdND0j2nnnJyhOFHJqikJNdul3uBwmxTK8FPEUUH/rtpyUan3VMOyDx3kX4OQg
979 GDNSb32rAkEAyJIZIJ0EMRHVedyWsfqR0zTGKRQ+qsc3sCfyUhFksWms9jsSS0DT
980 tVeTdC3F6EIAdpKOGhSyfBTU4jxwbFc0GQJADI4L9znEeAl66Wg2aLA2/Aq3oK/F
981 xjv2wgSG9apxOFCZzMNqp+FD0Jth6YtEReZMuldYbLDFi6nu6HPfY2Fa+QJAdpm1
982 lAxk6yMxiZK/5VRWoH6HYske2Vtd+aNVbePtF992ME/z3F3kEkpL3hom+dT1cyfs
983 MU3l0Ot8ip7Ul6vlGQJAegNzpcfl2GFSdWQMxQ+nN3woKnPqpR1M3jgnqvo7L4Xe
984 JW3vRxvfdrUuzdlvZ/Pbsu/vOd+cuIa4h0yD5q3N+g==
985 -----END RSA PRIVATE KEY-----
987 """-----BEGIN CERTIFICATE-----
988 MIIBnjCCAQcCAgCEMA0GCSqGSIb3DQEBBAUAMBcxFTATBgNVBAMUDG5ld3BiX3Ro
989 aW5neTAeFw0wODA3MjUyMjQ3NThaFw0wOTA3MjUyMjQ3NThaMBcxFTATBgNVBAMU
990 DG5ld3BiX3RoaW5neTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAruBhwk+J
991 XdlwfKXXN8K+43JyEYCV7Fp7ZiES4t4AEJuQuBqJVMxpzeZzu2t/vVb59ThaxxtY
992 NGD3Xy6Og5dTv//ztWng8P7HwwvfbrUICU6zo6JAhg7kfaNa116krCYOkC/cdJWt
993 o5W+zsDmI1jUVGH0D73h29atc1gn6wLpAsMCAwEAATANBgkqhkiG9w0BAQQFAAOB
994 gQAEJ/ITGJ9lK/rk0yHcenW8SHsaSTlZMuJ4yEiIgrJ2t71Rd6mtCC/ljx9USvvK
995 bF500whTiZlnWgKi02boBEKa44z/DytF6pljeNPefBQSqZyUByGEb/8Mn58Idyls
996 q4/d9iKXMPvbpQdcesOzgOffFZevLQSWyPRaIdYBOOiYUA==
997 -----END CERTIFICATE-----
998 -----BEGIN RSA PRIVATE KEY-----
999 MIICXQIBAAKBgQCu4GHCT4ld2XB8pdc3wr7jcnIRgJXsWntmIRLi3gAQm5C4GolU
1000 zGnN5nO7a3+9Vvn1OFrHG1g0YPdfLo6Dl1O///O1aeDw/sfDC99utQgJTrOjokCG
1001 DuR9o1rXXqSsJg6QL9x0la2jlb7OwOYjWNRUYfQPveHb1q1zWCfrAukCwwIDAQAB
1002 AoGAcZAXC/dYrlBpIxkTRQu7qLqGZuVI9t7fabgqqpceFargdR4Odrn0L5jrKRer
1003 MYrM8bjyAoC4a/NYUUBLnhrkcCQWO9q5fSQuFKFVWHY53SM63Qdqk8Y9Fmy/h/4c
1004 UtwZ5BWkUWItvnTMgb9bFcvSiIhEcNQauypnMpgNknopu7kCQQDlSQT10LkX2IGT
1005 bTUhPcManx92gucaKsPONKq2mP+1sIciThevRTZWZsxyIuoBBY43NcKKi8NlZCtj
1006 hhSbtzYdAkEAw0B93CXfso8g2QIMj/HJJz/wNTLtg+rriXp6jh5HWe6lKWRVrce+
1007 1w8Qz6OI/ZP6xuQ9HNeZxJ/W6rZPW6BGXwJAHcTuRPA1p/fvUvHh7Q/0zfcNAbkb
1008 QlV9GL/TzmNtB+0EjpqvDo2g8XTlZIhN85YCEf8D5DMjSn3H+GMHN/SArQJBAJlW
1009 MIGPjNoh5V4Hae4xqBOW9wIQeM880rUo5s5toQNTk4mqLk9Hquwh/MXUXGUora08
1010 2XGpMC1midXSTwhaGmkCQQCdivptFEYl33PrVbxY9nzHynpp4Mi89vQF0cjCmaYY
1011 N8L+bvLd4BU9g6hRS8b59lQ6GNjryx2bUnCVtLcey4Jd
1012 -----END RSA PRIVATE KEY-----
1016 # To disable the pre-computed tub certs, uncomment this line.
1017 #SYSTEM_TEST_CERTS = []
1019 TEST_DATA="\x02"*(immutable.upload.Uploader.URI_LIT_SIZE_THRESHOLD+1)
1021 class ShouldFailMixin:
1022 def shouldFail(self, expected_failure, which, substring,
1023 callable, *args, **kwargs):
1024 """Assert that a function call raises some exception. This is a
1025 Deferred-friendly version of TestCase.assertRaises() .
1027 Suppose you want to verify the following function:
1029 def broken(a, b, c):
1031 raise TypeError('a must not be negative')
1032 return defer.succeed(b+c)
1035 d = self.shouldFail(TypeError, 'test name',
1036 'a must not be negative',
1037 broken, -4, 5, c=12)
1038 in your test method. The 'test name' string will be included in the
1039 error message, if any, because Deferred chains frequently make it
1040 difficult to tell which assertion was tripped.
1042 The substring= argument, if not None, must appear in the 'repr'
1043 of the message wrapped by this Failure, or the test will fail.
1046 assert substring is None or isinstance(substring, str)
1047 d = defer.maybeDeferred(callable, *args, **kwargs)
1049 if isinstance(res, failure.Failure):
1050 res.trap(expected_failure)
1052 message = repr(res.value.args[0])
1053 self.failUnless(substring in message,
1054 "%s: substring '%s' not in '%s'"
1055 % (which, substring, message))
1057 self.fail("%s was supposed to raise %s, not get '%s'" %
1058 (which, expected_failure, res))
1062 class WebErrorMixin:
1063 def explain_web_error(self, f):
1064 # an error on the server side causes the client-side getPage() to
1065 # return a failure(t.web.error.Error), and its str() doesn't show the
1066 # response body, which is where the useful information lives. Attach
1067 # this method as an errback handler, and it will reveal the hidden
1070 print "Web Error:", f.value, ":", f.value.response
1073 def _shouldHTTPError(self, res, which, validator):
1074 if isinstance(res, failure.Failure):
1076 return validator(res)
1078 self.fail("%s was supposed to Error, not get '%s'" % (which, res))
1080 def shouldHTTPError(self, which,
1081 code=None, substring=None, response_substring=None,
1082 callable=None, *args, **kwargs):
1083 # returns a Deferred with the response body
1084 assert substring is None or isinstance(substring, str)
1087 if code is not None:
1088 self.failUnlessEqual(f.value.status, str(code), which)
1090 code_string = str(f)
1091 self.failUnless(substring in code_string,
1092 "%s: substring '%s' not in '%s'"
1093 % (which, substring, code_string))
1094 response_body = f.value.response
1095 if response_substring:
1096 self.failUnless(response_substring in response_body,
1097 "%s: response substring '%s' not in '%s'"
1098 % (which, response_substring, response_body))
1099 return response_body
1100 d = defer.maybeDeferred(callable, *args, **kwargs)
1101 d.addBoth(self._shouldHTTPError, which, _validate)
1104 class ErrorMixin(WebErrorMixin):
1105 def explain_error(self, f):
1106 if f.check(defer.FirstError):
1107 print "First Error:", f.value.subFailure
1110 def corrupt_field(data, offset, size, debug=False):
1111 if random.random() < 0.5:
1112 newdata = testutil.flip_one_bit(data, offset, size)
1114 log.msg("testing: corrupting offset %d, size %d flipping one bit orig: %r, newdata: %r" % (offset, size, data[offset:offset+size], newdata[offset:offset+size]))
1117 newval = testutil.insecurerandstr(size)
1119 log.msg("testing: corrupting offset %d, size %d randomizing field, orig: %r, newval: %r" % (offset, size, data[offset:offset+size], newval))
1120 return data[:offset]+newval+data[offset+size:]
1122 def _corrupt_nothing(data, debug=False):
1123 """Leave the data pristine. """
1126 def _corrupt_file_version_number(data, debug=False):
1127 """Scramble the file data -- the share file version number have one bit
1128 flipped or else will be changed to a random value."""
1129 return corrupt_field(data, 0x00, 4)
1131 def _corrupt_size_of_file_data(data, debug=False):
1132 """Scramble the file data -- the field showing the size of the share data
1133 within the file will be set to one smaller."""
1134 return corrupt_field(data, 0x04, 4)
1136 def _corrupt_sharedata_version_number(data, debug=False):
1137 """Scramble the file data -- the share data version number will have one
1138 bit flipped or else will be changed to a random value, but not 1 or 2."""
1139 return corrupt_field(data, 0x0c, 4)
1140 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1141 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1142 newsharevernum = sharevernum
1143 while newsharevernum in (1, 2):
1144 newsharevernum = random.randrange(0, 2**32)
1145 newsharevernumbytes = struct.pack(">L", newsharevernum)
1146 return data[:0x0c] + newsharevernumbytes + data[0x0c+4:]
1148 def _corrupt_sharedata_version_number_to_plausible_version(data, debug=False):
1149 """Scramble the file data -- the share data version number will be
1150 changed to 2 if it is 1 or else to 1 if it is 2."""
1151 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1152 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1153 if sharevernum == 1:
1157 newsharevernumbytes = struct.pack(">L", newsharevernum)
1158 return data[:0x0c] + newsharevernumbytes + data[0x0c+4:]
1160 def _corrupt_segment_size(data, debug=False):
1161 """Scramble the file data -- the field showing the size of the segment
1162 will have one bit flipped or else be changed to a random value."""
1163 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1164 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1165 if sharevernum == 1:
1166 return corrupt_field(data, 0x0c+0x04, 4, debug=False)
1168 return corrupt_field(data, 0x0c+0x04, 8, debug=False)
1170 def _corrupt_size_of_sharedata(data, debug=False):
1171 """Scramble the file data -- the field showing the size of the data
1172 within the share data will have one bit flipped or else will be changed
1173 to a random value."""
1174 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1175 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1176 if sharevernum == 1:
1177 return corrupt_field(data, 0x0c+0x08, 4)
1179 return corrupt_field(data, 0x0c+0x0c, 8)
1181 def _corrupt_offset_of_sharedata(data, debug=False):
1182 """Scramble the file data -- the field showing the offset of the data
1183 within the share data will have one bit flipped or else be changed to a
1185 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1186 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1187 if sharevernum == 1:
1188 return corrupt_field(data, 0x0c+0x0c, 4)
1190 return corrupt_field(data, 0x0c+0x14, 8)
1192 def _corrupt_offset_of_ciphertext_hash_tree(data, debug=False):
1193 """Scramble the file data -- the field showing the offset of the
1194 ciphertext hash tree within the share data will have one bit flipped or
1195 else be changed to a random value.
1197 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1198 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1199 if sharevernum == 1:
1200 return corrupt_field(data, 0x0c+0x14, 4, debug=False)
1202 return corrupt_field(data, 0x0c+0x24, 8, debug=False)
1204 def _corrupt_offset_of_block_hashes(data, debug=False):
1205 """Scramble the file data -- the field showing the offset of the block
1206 hash tree within the share data will have one bit flipped or else will be
1207 changed to a random value."""
1208 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1209 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1210 if sharevernum == 1:
1211 return corrupt_field(data, 0x0c+0x18, 4)
1213 return corrupt_field(data, 0x0c+0x2c, 8)
1215 def _corrupt_offset_of_block_hashes_to_truncate_crypttext_hashes(data, debug=False):
1216 """Scramble the file data -- the field showing the offset of the block
1217 hash tree within the share data will have a multiple of hash size
1218 subtracted from it, thus causing the downloader to download an incomplete
1219 crypttext hash tree."""
1220 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1221 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1222 if sharevernum == 1:
1223 curval = struct.unpack(">L", data[0x0c+0x18:0x0c+0x18+4])[0]
1224 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)/2))*hashutil.CRYPTO_VAL_SIZE
1225 newvalstr = struct.pack(">L", newval)
1226 return data[:0x0c+0x18]+newvalstr+data[0x0c+0x18+4:]
1228 curval = struct.unpack(">Q", data[0x0c+0x2c:0x0c+0x2c+8])[0]
1229 newval = random.randrange(0, max(1, (curval/hashutil.CRYPTO_VAL_SIZE)/2))*hashutil.CRYPTO_VAL_SIZE
1230 newvalstr = struct.pack(">Q", newval)
1231 return data[:0x0c+0x2c]+newvalstr+data[0x0c+0x2c+8:]
1233 def _corrupt_offset_of_share_hashes(data, debug=False):
1234 """Scramble the file data -- the field showing the offset of the share
1235 hash tree within the share data will have one bit flipped or else will be
1236 changed to a random value."""
1237 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1238 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1239 if sharevernum == 1:
1240 return corrupt_field(data, 0x0c+0x1c, 4)
1242 return corrupt_field(data, 0x0c+0x34, 8)
1244 def _corrupt_offset_of_uri_extension(data, debug=False):
1245 """Scramble the file data -- the field showing the offset of the uri
1246 extension will have one bit flipped or else will be changed to a random
1248 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1249 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1250 if sharevernum == 1:
1251 return corrupt_field(data, 0x0c+0x20, 4)
1253 return corrupt_field(data, 0x0c+0x3c, 8)
1255 def _corrupt_offset_of_uri_extension_to_force_short_read(data, debug=False):
1256 """Scramble the file data -- the field showing the offset of the uri
1257 extension will be set to the size of the file minus 3. This means when
1258 the client tries to read the length field from that location it will get
1259 a short read -- the result string will be only 3 bytes long, not the 4 or
1260 8 bytes necessary to do a successful struct.unpack."""
1261 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1262 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1263 # The "-0x0c" in here is to skip the server-side header in the share
1264 # file, which the client doesn't see when seeking and reading.
1265 if sharevernum == 1:
1267 log.msg("testing: corrupting offset %d, size %d, changing %d to %d (len(data) == %d)" % (0x2c, 4, struct.unpack(">L", data[0x2c:0x2c+4])[0], len(data)-0x0c-3, len(data)))
1268 return data[:0x2c] + struct.pack(">L", len(data)-0x0c-3) + data[0x2c+4:]
1271 log.msg("testing: corrupting offset %d, size %d, changing %d to %d (len(data) == %d)" % (0x48, 8, struct.unpack(">Q", data[0x48:0x48+8])[0], len(data)-0x0c-3, len(data)))
1272 return data[:0x48] + struct.pack(">Q", len(data)-0x0c-3) + data[0x48+8:]
1274 def _corrupt_mutable_share_data(data, debug=False):
1276 assert prefix == MutableShareFile.MAGIC, "This function is designed to corrupt mutable shares of v1, and the magic number doesn't look right: %r vs %r" % (prefix, MutableShareFile.MAGIC)
1277 data_offset = MutableShareFile.DATA_OFFSET
1278 sharetype = data[data_offset:data_offset+1]
1279 assert sharetype == "\x00", "non-SDMF mutable shares not supported"
1280 (version, ig_seqnum, ig_roothash, ig_IV, ig_k, ig_N, ig_segsize,
1281 ig_datalen, offsets) = unpack_header(data[data_offset:])
1282 assert version == 0, "this function only handles v0 SDMF files"
1283 start = data_offset + offsets["share_data"]
1284 length = data_offset + offsets["enc_privkey"] - start
1285 return corrupt_field(data, start, length)
1287 def _corrupt_share_data(data, debug=False):
1288 """Scramble the file data -- the field containing the share data itself
1289 will have one bit flipped or else will be changed to a random value."""
1290 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1291 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways, not v%d." % sharevernum
1292 if sharevernum == 1:
1293 sharedatasize = struct.unpack(">L", data[0x0c+0x08:0x0c+0x08+4])[0]
1295 return corrupt_field(data, 0x0c+0x24, sharedatasize)
1297 sharedatasize = struct.unpack(">Q", data[0x0c+0x08:0x0c+0x0c+8])[0]
1299 return corrupt_field(data, 0x0c+0x44, sharedatasize)
1301 def _corrupt_share_data_last_byte(data, debug=False):
1302 """Scramble the file data -- flip all bits of the last byte."""
1303 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1304 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways, not v%d." % sharevernum
1305 if sharevernum == 1:
1306 sharedatasize = struct.unpack(">L", data[0x0c+0x08:0x0c+0x08+4])[0]
1307 offset = 0x0c+0x24+sharedatasize-1
1309 sharedatasize = struct.unpack(">Q", data[0x0c+0x08:0x0c+0x0c+8])[0]
1310 offset = 0x0c+0x44+sharedatasize-1
1312 newdata = data[:offset] + chr(ord(data[offset])^0xFF) + data[offset+1:]
1314 log.msg("testing: flipping all bits of byte at offset %d: %r, newdata: %r" % (offset, data[offset], newdata[offset]))
1317 def _corrupt_crypttext_hash_tree(data, debug=False):
1318 """Scramble the file data -- the field containing the crypttext hash tree
1319 will have one bit flipped or else will be changed to a random value.
1321 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1322 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1323 if sharevernum == 1:
1324 crypttexthashtreeoffset = struct.unpack(">L", data[0x0c+0x14:0x0c+0x14+4])[0]
1325 blockhashesoffset = struct.unpack(">L", data[0x0c+0x18:0x0c+0x18+4])[0]
1327 crypttexthashtreeoffset = struct.unpack(">Q", data[0x0c+0x24:0x0c+0x24+8])[0]
1328 blockhashesoffset = struct.unpack(">Q", data[0x0c+0x2c:0x0c+0x2c+8])[0]
1330 return corrupt_field(data, 0x0c+crypttexthashtreeoffset, blockhashesoffset-crypttexthashtreeoffset, debug=debug)
1332 def _corrupt_crypttext_hash_tree_byte_x221(data, debug=False):
1333 """Scramble the file data -- the byte at offset 0x221 will have its 7th
1336 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1337 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1339 log.msg("original data: %r" % (data,))
1340 return data[:0x0c+0x221] + chr(ord(data[0x0c+0x221])^0x02) + data[0x0c+0x2210+1:]
1342 def _corrupt_block_hashes(data, debug=False):
1343 """Scramble the file data -- the field containing the block hash tree
1344 will have one bit flipped or else will be changed to a random value.
1346 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1347 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1348 if sharevernum == 1:
1349 blockhashesoffset = struct.unpack(">L", data[0x0c+0x18:0x0c+0x18+4])[0]
1350 sharehashesoffset = struct.unpack(">L", data[0x0c+0x1c:0x0c+0x1c+4])[0]
1352 blockhashesoffset = struct.unpack(">Q", data[0x0c+0x2c:0x0c+0x2c+8])[0]
1353 sharehashesoffset = struct.unpack(">Q", data[0x0c+0x34:0x0c+0x34+8])[0]
1355 return corrupt_field(data, 0x0c+blockhashesoffset, sharehashesoffset-blockhashesoffset)
1357 def _corrupt_share_hashes(data, debug=False):
1358 """Scramble the file data -- the field containing the share hash chain
1359 will have one bit flipped or else will be changed to a random value.
1361 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1362 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1363 if sharevernum == 1:
1364 sharehashesoffset = struct.unpack(">L", data[0x0c+0x1c:0x0c+0x1c+4])[0]
1365 uriextoffset = struct.unpack(">L", data[0x0c+0x20:0x0c+0x20+4])[0]
1367 sharehashesoffset = struct.unpack(">Q", data[0x0c+0x34:0x0c+0x34+8])[0]
1368 uriextoffset = struct.unpack(">Q", data[0x0c+0x3c:0x0c+0x3c+8])[0]
1370 return corrupt_field(data, 0x0c+sharehashesoffset, uriextoffset-sharehashesoffset)
1372 def _corrupt_length_of_uri_extension(data, debug=False):
1373 """Scramble the file data -- the field showing the length of the uri
1374 extension will have one bit flipped or else will be changed to a random
1376 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1377 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1378 if sharevernum == 1:
1379 uriextoffset = struct.unpack(">L", data[0x0c+0x20:0x0c+0x20+4])[0]
1380 return corrupt_field(data, uriextoffset, 4)
1382 uriextoffset = struct.unpack(">Q", data[0x0c+0x3c:0x0c+0x3c+8])[0]
1383 return corrupt_field(data, 0x0c+uriextoffset, 8)
1385 def _corrupt_uri_extension(data, debug=False):
1386 """Scramble the file data -- the field containing the uri extension will
1387 have one bit flipped or else will be changed to a random value."""
1388 sharevernum = struct.unpack(">L", data[0x0c:0x0c+4])[0]
1389 assert sharevernum in (1, 2), "This test is designed to corrupt immutable shares of v1 or v2 in specific ways."
1390 if sharevernum == 1:
1391 uriextoffset = struct.unpack(">L", data[0x0c+0x20:0x0c+0x20+4])[0]
1392 uriextlen = struct.unpack(">L", data[0x0c+uriextoffset:0x0c+uriextoffset+4])[0]
1394 uriextoffset = struct.unpack(">Q", data[0x0c+0x3c:0x0c+0x3c+8])[0]
1395 uriextlen = struct.unpack(">Q", data[0x0c+uriextoffset:0x0c+uriextoffset+8])[0]
1397 return corrupt_field(data, 0x0c+uriextoffset, uriextlen)