Implementation of SHA-3 based on following KeccakNISTInterface.c from http://keccak.noekeon.org/
Following the naming conventions used in the C source code to enable easy review of the implementation.
Наследование: IDigest
Пример #1
0
 private void KeccakPermutation(byte[] state)
 {
     ulong[] stateAsWords = new ulong[state.Length / 8];
     Sha3Digest.FromBytesToWords(stateAsWords, state);
     this.KeccakPermutationOnWords(stateAsWords);
     Sha3Digest.FromWordsToBytes(state, stateAsWords);
 }
Пример #2
0
 private void KeccakPermutationOnWords(ulong[] state)
 {
     for (int i = 0; i < 24; i++)
     {
         this.Theta(state);
         this.Rho(state);
         this.Pi(state);
         this.Chi(state);
         Sha3Digest.Iota(state, i);
     }
 }
Пример #3
0
 private void CopyIn(Sha3Digest source)
 {
     Array.Copy(source.state, 0, this.state, 0, source.state.Length);
     Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
     this.rate                      = source.rate;
     this.bitsInQueue               = source.bitsInQueue;
     this.fixedOutputLength         = source.fixedOutputLength;
     this.squeezing                 = source.squeezing;
     this.bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
     this.chunk                     = Arrays.Clone(source.chunk);
     this.oneByte                   = Arrays.Clone(source.oneByte);
 }
Пример #4
0
 public Sha3Digest(Sha3Digest source) : base(source)
 {
 }
Пример #5
0
		private void CopyIn(Sha3Digest source)
		{
            Array.Copy(source.state, 0, this.state, 0, source.state.Length);
            Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
            this.rate = source.rate;
            this.bitsInQueue = source.bitsInQueue;
            this.fixedOutputLength = source.fixedOutputLength;
            this.squeezing = source.squeezing;
            this.bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
            this.chunk = Arrays.Clone(source.chunk);
            this.oneByte = Arrays.Clone(source.oneByte);
        }
Пример #6
0
        public Sha3Digest(Sha3Digest source)
        {
			CopyIn(source);
		}
Пример #7
0
        public void Reset(IMemoable other)
        {
            Sha3Digest d = (Sha3Digest)other;

            CopyIn(d);
        }
Пример #8
0
 public Sha3Digest(Sha3Digest source)
 {
     CopyIn(source);
 }
Пример #9
0
 public Sha3Digest(Sha3Digest source)
     : base(source)
 {
 }
Пример #10
0
        public void Reset(IMemoable other)
        {
            Sha3Digest source = (Sha3Digest)other;

            this.CopyIn(source);
        }
Пример #11
0
 public Sha3Digest(Sha3Digest source)
 {
     this.CopyIn(source);
 }