Switch to edit mode.
Name(s): parse_packet1: {d} = args
2: bl = $math_utils:BLfromInt(d[1])
3: if (bl[$ - 7] != 1)
4: raise(E_INVARG, "Invalid packet header!")
5: endif
6: ptype = this.packet_types[$math_utils:IntfromBL(bl[$ - 5..$ - 2])]
7: plen_bytes = $math_utils:IntfromBL(bl[$ - 1..$])
8: if (bl[$ - 6] == 0)
9: if (plen_bytes == 0)
10: plen = d[2]
11: pdata = d[3..plen + 2]
12: elseif (plen_bytes == 1)
13: plen = d[2] * 256 + d[3]
14: pdata = d[4..plen + 3]
15: elseif (plen_bytes == 3)
16: plen = ((d[2] * 256 + d[3]) * 256 + d[4]) * 256 + d[5]
17: pdata = d[6..plen + 5]
18: endif
19: else
20: if (d[2] < 192)
21: plen = d[2]
22: plen_bytes = 0
23: pdata = d[3..plen + 2]
24: elseif (d[2] < 224)
25: plen = (d[2] - 192) * 256 + d[3] + 192
26: pdata = d[4..plen + 3]
27: plen_bytes = 1
28: elseif (d[2] < 255)
29: raise(E_INVARG, "Partial length headers not working")
30: "Partial length code here"
31: else
32: plen = ((d[3] * 256 + d[4]) * 256 + d[5]) * 256 + d[6]
33: pdata = d[7..plen + 6]
34: plen_bytes = 4
35: endif
36: endif
37: if (ptype == "Public Key Packet" || ptype == "Public Subkey Packet")
38: r = this:parse_packet_public_key(pdata)
39: elseif (ptype == "Signature Packet")
40: r = this:parse_packet_signature(pdata)
41: elseif (ptype == "User ID Packet")
42: r = this:parse_packet_user_id(pdata)
43: else
44: r = pdata
45: endif
46: return {ptype, plen + plen_bytes + 2, r}
47: "Last modified by manta (#7165) on Tue Feb 20 20:16:57 2001 MST."