MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / MPI

Class MPI

pgpy/packet/types.py:241–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240
241class MPI(long):
242 def __new__(cls, num):
243 mpi = num
244
245 if isinstance(num, (bytes, bytearray)):
246 if isinstance(num, bytes): # pragma: no cover
247 num = bytearray(num)
248
249 fl = ((MPIs.bytes_to_int(num[:2]) + 7) // 8)
250 del num[:2]
251
252 mpi = MPIs.bytes_to_int(num[:fl])
253 del num[:fl]
254
255 return super(MPI, cls).__new__(cls, mpi)
256
257 def byte_length(self):
258 return ((self.bit_length() + 7) // 8)
259
260 def to_mpibytes(self):
261 return MPIs.int_to_bytes(self.bit_length(), 2) + MPIs.int_to_bytes(self, self.byte_length())
262
263 def __len__(self):
264 return self.byte_length() + 2
265
266
267class MPIs(Field):

Callers 15

__init__Method · 0.85
parseMethod · 0.85
from_signerMethod · 0.85
from_signerMethod · 0.85
parseMethod · 0.85
from_signerMethod · 0.85
from_signerMethod · 0.85
__init__Method · 0.85
parseMethod · 0.85
parseMethod · 0.85
parseMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected