|
@@ -1,6 +1,7 @@
|
|
import itertools
|
|
import itertools
|
|
import pathlib
|
|
import pathlib
|
|
import typing
|
|
import typing
|
|
|
|
+import warnings
|
|
|
|
|
|
import numpy
|
|
import numpy
|
|
import pandas
|
|
import pandas
|
|
@@ -46,8 +47,21 @@ def split_pgp_file(
|
|
bundle = pgpdump.BinaryData(bundle_bytes)
|
|
bundle = pgpdump.BinaryData(bundle_bytes)
|
|
remaining_bytes = bundle.data
|
|
remaining_bytes = bundle.data
|
|
for packet in bundle.packets():
|
|
for packet in bundle.packets():
|
|
- prefix, remaining_bytes = remaining_bytes.split(packet.data, maxsplit=1)
|
|
|
|
-
|
|
|
|
|
|
+ try:
|
|
|
|
+ prefix, remaining_bytes = remaining_bytes.split(packet.data, maxsplit=1)
|
|
|
|
+ except ValueError:
|
|
|
|
+ assert len(packet.data) > 596 # actual threshold might be higher
|
|
|
|
+ split_index = 2 ** 9
|
|
|
|
+ prefix, remaining_bytes = remaining_bytes.split(
|
|
|
|
+ packet.data[:split_index], maxsplit=1
|
|
|
|
+ )
|
|
|
|
+ separator, remaining_bytes = remaining_bytes.split(
|
|
|
|
+ packet.data[split_index:], maxsplit=1
|
|
|
|
+ )
|
|
|
|
+ assert sum(separator) == len(packet.data) - split_index
|
|
|
|
+ warnings.warn(
|
|
|
|
+ "ignoring separator; output of join_pgp_packets will be invalid"
|
|
|
|
+ )
|
|
yield prefix
|
|
yield prefix
|
|
yield packet
|
|
yield packet
|
|
assert not remaining_bytes
|
|
assert not remaining_bytes
|