Ejemplo n.º 1
0
        protected override int DecryptBlock(byte[] inBuf, int inOff, int length, byte[] outBuf, int outOff)
        {
            byte[] dec;

            if (fpeParameters.Radix > 256)
            {
                if ((length & 1) != 0)
                {
                    throw new ArgumentException("input must be an even number of bytes for a wide radix");
                }

                ushort[] u16In  = Pack.BE_To_UInt16(inBuf, inOff, length);
                ushort[] u16Out = SP80038G.DecryptFF1w(baseCipher, fpeParameters.Radix, fpeParameters.GetTweak(),
                                                       u16In, 0, u16In.Length);
                dec = Pack.UInt16_To_BE(u16Out, 0, u16Out.Length);
            }
            else
            {
                dec = SP80038G.DecryptFF1(baseCipher, fpeParameters.Radix, fpeParameters.GetTweak(), inBuf, inOff, length);
            }

            Array.Copy(dec, 0, outBuf, outOff, length);

            return(length);
        }
Ejemplo n.º 2
0
        protected static ushort[] toShortArray(byte[] buf)
        {
            if ((buf.Length & 1) != 0)
            {
                throw new ArgumentException("data must be an even number of bytes for a wide radix");
            }

            ushort[] rv = new ushort[buf.Length / 2];

            for (int i = 0; i != rv.Length; i++)
            {
                rv[i] = Pack.BE_To_UInt16(buf, i * 2);
            }

            return(rv);
        }