XorPad() private static method

private static XorPad ( byte pad, int len, byte n ) : void
pad byte
len int
n byte
return void
コード例 #1
0
        public virtual void Init(ICipherParameters parameters)
        {
            this.digest.Reset();
            byte[] key = ((KeyParameter)parameters).GetKey();
            int    num = key.Length;

            if (num > this.blockLength)
            {
                this.digest.BlockUpdate(key, 0, num);
                this.digest.DoFinal(this.inputPad, 0);
                num = this.digestSize;
            }
            else
            {
                Array.Copy(key, 0, this.inputPad, 0, num);
            }
            Array.Clear(this.inputPad, num, this.blockLength - num);
            Array.Copy(this.inputPad, 0, this.outputBuf, 0, this.blockLength);
            HMac.XorPad(this.inputPad, this.blockLength, 54);
            HMac.XorPad(this.outputBuf, this.blockLength, 92);
            if (this.digest is IMemoable)
            {
                this.opadState = ((IMemoable)this.digest).Copy();
                ((IDigest)this.opadState).BlockUpdate(this.outputBuf, 0, this.blockLength);
            }
            this.digest.BlockUpdate(this.inputPad, 0, this.inputPad.Length);
            if (this.digest is IMemoable)
            {
                this.ipadState = ((IMemoable)this.digest).Copy();
            }
        }