Example #1
0
        private byte[] ComputeAuthTag(byte[] aad, byte[] iv, byte[] cipherText, byte[] hmacKey)
        {
            byte[] al        = Arrays.LongToBytes(aad.Length * 8);
            byte[] hmacInput = Arrays.Concat(aad, iv, cipherText, al);

            byte[] hmac = hashAlgorithm.Sign(hmacInput, hmacKey);

            return(Arrays.FirstHalf(hmac));
        }
Example #2
0
 public static byte[] Xor(byte[] left, long right)
 {
     Ensure.BitSize(left, 64, "Arrays.Xor(byte[], long) expects array size to be 8 bytes, but was {0}", new object[] { (int)left.Length });
     return(Arrays.LongToBytes(Arrays.BytesToLong(left) ^ right));
 }
 private byte[] ComputeAuthTag(byte[] aad, byte[] iv, byte[] cipherText, byte[] hmacKey)
 {
     byte[] bytes    = Arrays.LongToBytes((long)((int)aad.Length * 8));
     byte[] numArray = Arrays.Concat(new byte[][] { aad, iv, cipherText, bytes });
     return(Arrays.FirstHalf(this.hashAlgorithm.Sign(numArray, hmacKey)));
 }
Example #4
0
 public static byte[] SixtyFourBitLength(byte[] aad)
 {
     return(Arrays.LongToBytes((long)((int)aad.Length * 8)));
 }