Exemplo n.º 1
0
        public DerBitString(int namedBits)
        {
            if (namedBits == 0)
            {
                mData    = new byte[0];
                mPadBits = 0;
                return;
            }
            int num  = BigInteger.BitLen(namedBits);
            int num2 = (num + 7) / 8;

            byte[] array = new byte[num2];
            num2--;
            for (int i = 0; i < num2; i++)
            {
                array[i]    = (byte)namedBits;
                namedBits >>= 8;
            }
            array[num2] = (byte)namedBits;
            int j;

            for (j = 0; (namedBits & (1 << j)) == 0; j++)
            {
            }
            mData    = array;
            mPadBits = j;
        }
Exemplo n.º 2
0
 public DerBitString(int namedBits)
 {
     if (namedBits == 0)
     {
         this.mData    = new byte[0];
         this.mPadBits = 0;
     }
     else
     {
         int    index  = (BigInteger.BitLen(namedBits) + 7) / 8;
         byte[] buffer = new byte[index];
         index--;
         for (int i = 0; i < index; i++)
         {
             buffer[i] = (byte)namedBits;
             namedBits = namedBits >> 8;
         }
         buffer[index] = (byte)namedBits;
         int num4 = 0;
         while ((namedBits & (((int)1) << num4)) == 0)
         {
             num4++;
         }
         this.mData    = buffer;
         this.mPadBits = num4;
     }
 }
Exemplo n.º 3
0
        public DerBitString(
            int namedBits)
        {
            if (namedBits == 0)
            {
                this.mData    = new byte[0];
                this.mPadBits = 0;
                return;
            }

            int bits  = BigInteger.BitLen(namedBits);
            int bytes = (bits + 7) / 8;

            Debug.Assert(0 < bytes && bytes <= 4);

            byte[] data = new byte[bytes];
            --bytes;

            for (int i = 0; i < bytes; i++)
            {
                data[i]     = (byte)namedBits;
                namedBits >>= 8;
            }

            Debug.Assert((namedBits & 0xFF) != 0);

            data[bytes] = (byte)namedBits;

            int padBits = 0;

            while ((namedBits & (1 << padBits)) == 0)
            {
                ++padBits;
            }

            Debug.Assert(padBits < 8);

            this.mData    = data;
            this.mPadBits = padBits;
        }