RFC70 Note on Padding

0070 Note on Padding. S.D. Crocker. October 1970. (Format: TXT=12790 bytes) (Updated by RFC0228) (Status: UNKNOWN)

日本語訳
RFC一覧

参照

Network Working Group                                      S. Crocker
Request for Comments #70                                   UCLA
                                                           15 October 70

                           A Note on Padding

The padding on a message is a string of the form 10*.  For Hosts with
word lengths 16, 32, 48, etc., bits long, this string is necessarily in
the last word received from the Imp.  For Hosts with word lengths which
are not a multiple of 16 (but which are at least 16 bits long), the 1
bit will be in either the last word or the next to last word.  Of
course if the 1 bit is in the next to last word, the last word is all
zero.

An unpleasant coding task is discovering the bit position of the 1 bit
within its word.  One obvious technique is to repeatedly test the
low-order bit, shifting the word right one bit position if the
low-order bit is zero.  The following techniques are more pleasant.

Isolating the Low-Order Bit

Let W be a non-zero word, where the word length is n.  Then W is of the
form

            x....x10....0
            \__ __/\__ __/
               V      V
             n-k-1    k

where 0<=k p' =>
R(p) > R(p'), we obtain the following table of useful divisors for
p < 100.





                                                                [Page 4]

Network Working Group      A Note on Padding                      RFC 70


      p     R(p)                                p     R(p)

      1      1                                 29     28

      3      2                                 37     36

      5      4                                 53     52

      9      6                                 59     58

      11     10                                61     60

      13     12                                67     66

      19     18                                83     82

      25     20

Notice that 9 and 25 are useful divisors even though they generate only
6 and 20 remainders, respectively.

Determination of R(p)

If p is odd, the remainders

           0
      mod(2 ,p)
           1
      mod(2 ,p)

           .
           .
           .
                                                               t
will be between 1 and p-1 inclusive.  At some power of 2, say 2 , there
                                                       k    t
will be a repeated remainder, so that for some k < t, 2  = 2  mod p.
       t+1    k+1
Since 2    = 2    mod p
       t+2    k+2
and   2    = 2    mod p

           .
           .
           .
          etc.
                                          0    t-1
all of the distinct remainders occur for 2 ...2   .  Therefore, R(p)=t.



                                                                [Page 5]

Network Working Group      A Note on Padding                      RFC 70


Next we show that

      R(p)
     2     = 1 mod p
                      R(p)    k
We already know that 2     = 2  mod p

for some 0<=k=q,
          k       q      k-q
     mod(2 ,p) = 2 *mod(2   ,p').



                                                                [Page 6]

Network Working Group      A Note on Padding                      RFC 70


From this we can see that the sequence of remainders will have an
                             q-1
initial segment of 1, 2, ...2    of length q, and repeating segments of

length R(p').  Therefore, R(p) = q+R(p').  Since we normally expect

     R(p) ~ p,

even p generally will not be useful.

I don't know of a direct way of choosing a p for a given n, but the
previous table was generated from the following Fortran program run
under the SEX system at UCLA.



            0
                    CALL IASSGN('OC ',56)
            1       FORMAT(I3,I5)
                    M=0
                    DO 100 K=1,100,2
                    K=1
                    L=0
            20      L=L+1
                    N=MOD(2*N,K)
                    IF(N.GT.1) GO TO 20
                    IF(L.LE.M) GO TO 100
                    M=L
                    WRITE(56,1)K,L
            100     CONTINUE
                    STOP
                    END

      Fortran program to computer useful divisors

In the program, K takes on trial values of p, N takes on the values of
the successive remainders, L counts up to R(p), and M remembers the
previous largest R(p).  Execution is quite speedy.













                                                                [Page 7]

Network Working Group      A Note on Padding                      RFC 70


Results from Number Theory

The quantity referred to above as R(p) is usually written Ord 2 and is
                                                             p
read "the order of 2 mod p".  The maximum value of Ord 2 is given by
                                                      p
Euler's phi-function, sometimes called the totient.  The totient of a

positive integer p is the number of integers less than p which are

relatively prime to p.  The totient is easy to compute from a

representation of p as a product of primes:

               n      n        n
     Let p = p  1 * p  2 ... p  k
              1      2        k

where the p  are distinct primes.  Then
           i
                          k -1               k -1                 k -1
     phi(p) = (p - 1) * p  1   * (p - 1) * p  2   ... (p - 1) * p  k
                1        1         2        2           k        k

If p is prime, the totient of p is simply

     phi(p) = p-1.

If p is not prime, the totient is smaller.

If a is relatively prime to p, then Euler's generalization of Fermat's
theorem states

      phi(m)
     a       = 1 mod p.

It is this theorem which places an upper bound Ord 2, because Ord 2 is
                                                  p              p
the smallest value such that

      Ord 2
     2   p  = 1 mod p

Moreover it is always true that phi(p) is divisible by Ord 2.
                                                          p






                                                                [Page 8]

Network Working Group      A Note on Padding                      RFC 70


Acknowledgements

Bob Kahn read an early draft and made many comments which improved the
exposition.  Alex Hurwitz assured me that a search technique is
necessary to compute R(p), and supplied the names for the quantities
and theorems I uncovered.


       [ This RFC was put into machine readable form for entry ]
       [ into the online RFC archives by Guillaume Lahaye and  ] 
                          [ John Hewes 6/97 ]








































                                                                [Page 9]

一覧

 RFC 1〜100  RFC 1401〜1500  RFC 2801〜2900  RFC 4201〜4300 
 RFC 101〜200  RFC 1501〜1600  RFC 2901〜3000  RFC 4301〜4400 
 RFC 201〜300  RFC 1601〜1700  RFC 3001〜3100  RFC 4401〜4500 
 RFC 301〜400  RFC 1701〜1800  RFC 3101〜3200  RFC 4501〜4600 
 RFC 401〜500  RFC 1801〜1900  RFC 3201〜3300  RFC 4601〜4700 
 RFC 501〜600  RFC 1901〜2000  RFC 3301〜3400  RFC 4701〜4800 
 RFC 601〜700  RFC 2001〜2100  RFC 3401〜3500  RFC 4801〜4900 
 RFC 701〜800  RFC 2101〜2200  RFC 3501〜3600  RFC 4901〜5000 
 RFC 801〜900  RFC 2201〜2300  RFC 3601〜3700  RFC 5001〜5100 
 RFC 901〜1000  RFC 2301〜2400  RFC 3701〜3800  RFC 5101〜5200 
 RFC 1001〜1100  RFC 2401〜2500  RFC 3801〜3900  RFC 5201〜5300 
 RFC 1101〜1200  RFC 2501〜2600  RFC 3901〜4000  RFC 5301〜5400 
 RFC 1201〜1300  RFC 2601〜2700  RFC 4001〜4100  RFC 5401〜5500 
 RFC 1301〜1400  RFC 2701〜2800  RFC 4101〜4200 

スポンサーリンク

merge

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る