def create_NewLength(length, partial=False): """Create a NewLength instance. :Parameters: - `length`: integer octet count of corresponding packet body - `partial`: optional True or False (default False), whether or not this is a partial length :Returns: `OpenPGP.packet.NewLength` instance """ if length < 192: return NewLength(chr(length)) elif 192 <= length < 8383: return NewLength(STN.int2doubleoct(length)) elif length <= 4294967295: # five oct header return NewLength('\xff' + STN.int2quadoct(length)) else: raise PGPFormatError("Subpacket value exceeded maximum size.")
def testD2Sanity(self): """strnum: double octet inversion (int2doubleoct/doubleoct2int)""" for o in self.good_double_octs: self.assertEqual(o[0], doubleoct2int(int2doubleoct(o[0])))
def testB4IntTranslation(self): """strnum: int2doubleoct output""" for v in self.good_double_octs: self.assertEqual(v[1], int2doubleoct(v[0]))