public void Update(byte input) { if (this.bufOff == this.buf.Length) { byte[] array = new byte[this.buf.Length]; Array.Copy(this.buf, 0, array, 0, this.mac.Length); if (this.firstStep) { this.firstStep = false; } else { array = Gost28147Mac.CM5func(this.buf, 0, this.mac); } this.gost28147MacFunc(this.workingKey, array, 0, this.mac, 0); this.bufOff = 0; } this.buf[this.bufOff++] = input; }
public int DoFinal(byte[] output, int outOff) { while (this.bufOff < 8) { this.buf[this.bufOff++] = 0; } byte[] array = new byte[this.buf.Length]; Array.Copy(this.buf, 0, array, 0, this.mac.Length); if (this.firstStep) { this.firstStep = false; } else { array = Gost28147Mac.CM5func(this.buf, 0, this.mac); } this.gost28147MacFunc(this.workingKey, array, 0, this.mac, 0); Array.Copy(this.mac, this.mac.Length / 2 - 4, output, outOff, 4); this.Reset(); return(4); }
public void BlockUpdate(byte[] input, int inOff, int len) { if (len < 0) { throw new ArgumentException("Can't have a negative input length!"); } int num = 8 - this.bufOff; if (len > num) { Array.Copy(input, inOff, this.buf, this.bufOff, num); byte[] array = new byte[this.buf.Length]; Array.Copy(this.buf, 0, array, 0, this.mac.Length); if (this.firstStep) { this.firstStep = false; } else { array = Gost28147Mac.CM5func(this.buf, 0, this.mac); } this.gost28147MacFunc(this.workingKey, array, 0, this.mac, 0); this.bufOff = 0; len -= num; inOff += num; while (len > 8) { array = Gost28147Mac.CM5func(input, inOff, this.mac); this.gost28147MacFunc(this.workingKey, array, 0, this.mac, 0); len -= 8; inOff += 8; } } Array.Copy(input, inOff, this.buf, this.bufOff, len); this.bufOff += len; }