comparison NaCl/crypto_verify/16.cs @ 77:b5e27116bd2a

NaCl: fixed MAC/hash verification code
author Ivo Smits <Ivo@UCIS.nl>
date Tue, 11 Feb 2014 17:45:33 +0100
parents c873e3dd73fe
children
comparison
equal deleted inserted replaced
76:b05350c24596 77:b5e27116bd2a
3 namespace UCIS.NaCl.crypto_verify { 3 namespace UCIS.NaCl.crypto_verify {
4 unsafe static class _16 { 4 unsafe static class _16 {
5 const int BYTES = 16; 5 const int BYTES = 16;
6 public static int crypto_verify(Byte* x, Byte* y) { 6 public static int crypto_verify(Byte* x, Byte* y) {
7 Int32 differentbits = 0; 7 Int32 differentbits = 0;
8 for (int i = 0; i < 15; i++) differentbits |= x[i] ^ y[i]; 8 for (int i = 0; i < 16; i++) differentbits |= x[i] ^ y[i];
9 return (1 & ((differentbits - 1) >> 8)) - 1; 9 return (1 & ((differentbits - 1) >> 8)) - 1;
10 } 10 }
11 } 11 }
12 } 12 }