Beispiel #1
0
        public virtual int randomInt()
        {
            int num;

            lock (random)
            {
                int expressionStack_19_0 = random.nextInt();
                goto Label_0019;
                expressionStack_19_0 = num;
Label_0019:
                num = expressionStack_19_0;
            }
            return(num);
        }
Beispiel #2
0
        /**
         * add the pad bytes to the passed in block, returning the
         * number of bytes added.
         */
        public int addPadding(
            byte[]  inBytes,
            int inOff)
        {
            byte code = (byte)(inBytes.Length - inOff);

            while (inOff < (inBytes.Length - 1))
            {
                inBytes[inOff] = (byte)random.nextInt();
                inOff++;
            }

            inBytes[inOff] = code;

            return(code);
        }
Beispiel #3
0
        private byte[] encodeBlock(
            byte[]  inBytes,
            int inOff,
            int inLen)
        //throws InvalidCipherTextException
        {
            byte[] block = new byte[engine.getInputBlockSize()];

            if (forPrivateKey)
            {
                block[0] = 0x01;                                        // type code 1

                for (int i = 1; i != block.Length - inLen - 1; i++)
                {
                    block[i] = (byte)0xFF;
                }
            }
            else
            {
                random.nextBytes(block);                                // random fill

                block[0] = 0x02;                                        // type code 2

                //
                // a zero byte marks the end of the padding, so all
                // the pad bytes must be non-zero.
                //
                for (int i = 1; i != block.Length - inLen - 1; i++)
                {
                    while (block[i] == 0)
                    {
                        block[i] = (byte)random.nextInt();
                    }
                }
            }

            block[block.Length - inLen - 1] = 0x00;                   // mark the end of the padding
            Array.Copy(inBytes, inOff, block, block.Length - inLen, inLen);

            return(engine.processBlock(block, 0, block.Length));
        }
Beispiel #4
0
        /**
         * add the pad bytes to the passed in block, returning the
         * number of bytes added.
         */
        public int addPadding(
            byte[]  inBytes,
            int inOff)
        {
            byte code = (byte)(inBytes.Length - inOff);

            while (inOff < inBytes.Length - 1)
            {
                if (random == null)
                {
                    inBytes[inOff] = 0;
                }
                else
                {
                    inBytes[inOff] = (byte)random.nextInt();
                }
                inOff++;
            }

            inBytes[inOff] = code;

            return(code);
        }