INNER CODE UNIT · C#

cipherLength

sdrapkin/SecurityDriven.Inferno · EtM_CBC.cs:114

			int cipherLength = ciphertext.Count - CONTEXT_BUFFER_LENGTH - MAC_LENGTH;
			if (cipherLength < Cipher.AesConstants.AES_BLOCK_SIZE) { outputSegment = null; return; }
			int fullBlockLength = cipherLength - AES_IV_LENGTH;
			byte[] finalBlock = null;
			try
			{
				var iv = _iv.Value;
				var encKey = _encKey.Value;
				var macKey = _macKey.Value;
				var sessionKey = _sessionKey.Value;

				Kdf.SP800_108_Ctr.DeriveKey(hmacFactory: _hmacFactory, key: masterKey, label: salt, context: new ArraySegment<byte>(ciphertext.Array, ciphertext.Offset, CONTEXT_BUFFER_LENGTH), derivedOutput: sessionKey.AsArraySegment(), counter: counter);
				Utils.BlockCopy(sessionKey, 0, macKey, 0, MAC_KEY_LENGTH);

				using (var hmac = _hmacFactory())
				{
					hmac.Key = macKey;
					hmac.TransformBlock(ciphertext.Array, ciphertext.Offset + CONTEXT_TWEAK_LENGTH, AES_IV_LENGTH + cipherLength, null, 0);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…