|
@@ -28,8 +28,14 @@ def numpy_array_from_file(
|
|
|
def split_pgp_file(
|
|
|
path: pathlib.Path,
|
|
|
) -> typing.Iterator[typing.Union[bytearray, pgpdump.packet.Packet]]:
|
|
|
-
|
|
|
- bundle = pgpdump.BinaryData(path.read_bytes())
|
|
|
+ """
|
|
|
+ https://datatracker.ietf.org/doc/html/rfc4880
|
|
|
+ """
|
|
|
+ bundle_bytes = path.read_bytes()
|
|
|
+ if bundle_bytes.startswith(b"-----BEGIN"):
|
|
|
+ bundle = pgpdump.AsciiData(bundle_bytes)
|
|
|
+ else:
|
|
|
+ bundle = pgpdump.BinaryData(bundle_bytes)
|
|
|
remaining_bytes = bundle.data
|
|
|
for packet in bundle.packets():
|
|
|
prefix, remaining_bytes = remaining_bytes.split(packet.data, maxsplit=1)
|