Org.BouncyCastle.Crypto.Modes.SicBlockCipher.ProcessBlock C# (CSharp) Method

ProcessBlock() public method

public ProcessBlock ( byte input, int inOff, byte output, int outOff ) : int
input byte
inOff int
output byte
outOff int
return int
		public int ProcessBlock(
			byte[]	input,
			int		inOff,
			byte[]	output,
			int		outOff)
		{
			cipher.ProcessBlock(counter, 0, counterOut, 0);

			//
			// XOR the counterOut with the plaintext producing the cipher text
			//
			for (int i = 0; i < counterOut.Length; i++)
			{
				output[outOff + i] = (byte)(counterOut[i] ^ input[inOff + i]);
			}

			// Increment the counter
			int j = counter.Length;
			while (--j >= 0 && ++counter[j] == 0)
			{
			}

			return counter.Length;
		}

Usage Example

示例#1
0
        public virtual int DoFinal(
            byte[]  outBytes,
            int outOff)
        {
            InitCipher();

            int extra = bufOff;

            byte[] tmp = new byte[bufBlock.Length];

            bufOff = 0;

            if (forEncryption)
            {
                Check.OutputLength(outBytes, outOff, extra + macSize, "Output buffer too short");

                cipher.ProcessBlock(bufBlock, 0, tmp, 0);

                Array.Copy(tmp, 0, outBytes, outOff, extra);

                mac.BlockUpdate(tmp, 0, extra);

                CalculateMac();

                Array.Copy(macBlock, 0, outBytes, outOff + extra, macSize);

                Reset(false);

                return(extra + macSize);
            }
            else
            {
                if (extra < macSize)
                {
                    throw new InvalidCipherTextException("data too short");
                }

                Check.OutputLength(outBytes, outOff, extra - macSize, "Output buffer too short");

                if (extra > macSize)
                {
                    mac.BlockUpdate(bufBlock, 0, extra - macSize);

                    cipher.ProcessBlock(bufBlock, 0, tmp, 0);

                    Array.Copy(tmp, 0, outBytes, outOff, extra - macSize);
                }

                CalculateMac();

                if (!VerifyMac(bufBlock, extra - macSize))
                {
                    throw new InvalidCipherTextException("mac check in EAX failed");
                }

                Reset(false);

                return(extra - macSize);
            }
        }
All Usage Examples Of Org.BouncyCastle.Crypto.Modes.SicBlockCipher::ProcessBlock