Mercurial > hg > ucis.core
comparison NaCl/crypto_verify/32.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 _32 { | 4 unsafe static class _32 { |
5 const int BYTES = 32; | 5 const int BYTES = 32; |
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 < 31; i++) differentbits |= x[i] ^ y[i]; | 8 for (int i = 0; i < 32; 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 } |