INNER CODE UNIT · C#

HMAC_LENGTH

sdrapkin/SecurityDriven.Inferno · EtM_CBC.cs:19

		static readonly int HMAC_LENGTH = _hmacFactory().HashSize / 8;
		static readonly int CONTEXT_TWEAK_LENGTH = Math.Max(ENC_KEY_LENGTH - AES_IV_LENGTH, 0);
		static readonly int CONTEXT_BUFFER_LENGTH = CONTEXT_TWEAK_LENGTH + AES_IV_LENGTH;

		static readonly ThreadLocal<byte[]> _iv = new ThreadLocal<byte[]>(() => new byte[AES_IV_LENGTH]);
		static readonly ThreadLocal<byte[]> _contextBuffer = new ThreadLocal<byte[]>(() => new byte[CONTEXT_BUFFER_LENGTH]);
		static readonly ThreadLocal<byte[]> _encKey = new ThreadLocal<byte[]>(() => new byte[ENC_KEY_LENGTH]);
		static readonly ThreadLocal<byte[]> _macKey = new ThreadLocal<byte[]>(() => new byte[MAC_KEY_LENGTH]);
		static readonly ThreadLocal<byte[]> _sessionKey = new ThreadLocal<byte[]>(() => new byte[HMAC_LENGTH]);

		public static int CalculateCiphertextLength(ArraySegment<byte> plaintext)
		{
			int finalBlockLength = plaintext.Count - (plaintext.Count & (-Cipher.AesConstants.AES_BLOCK_SIZE));
			int paddingLength = AES_IV_LENGTH - finalBlockLength;
			return CONTEXT_BUFFER_LENGTH + plaintext.Count + paddingLength + MAC_LENGTH;
		}

		static void ValidateAes(Aes aes) // detect & fix any Mode/Padding deviation

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…