next up previous contents
Next: Generation of random numbers Up: PGP Previous: The Web of Trust

Multi-precision integers

 

RSA arithmetic involves a lot of multi-precision integers, often having hundreds of bits of precision. PGP always stores the MSB (most significant byte) first in external data to allow exchange of data files between different processor architectures. PGP externally stores a multi-precision integer (MPI) with a 16-bit prefix that gives the number of significant bits in the integer that follows. The integer that follows this bit-count field is stored in the usual byte order, with the MSB padded with zero bits if the bit-count is not a multiple of 8. The bit-count always specifies the exact number of significant bits. For example, the integer value 5 would be stored as these three bytes:

    00 03 05
An MPI with a value of zero is simply stored with the 16-bit bit-count prefix field containing a 0, with no value bytes following it.



Asgaut Eng
Wed Apr 10 14:07:30 MET DST 1996