private V1AxCryptDataStream CreateEncryptedDataStream(Stream inputStream, long cipherTextLength) { if (_reader.CurrentItemType != AxCryptItemType.Data) { throw new InvalidOperationException("An attempt to create an encrypted data stream was made when the reader is not positioned at the data."); } _reader.SetEndOfStream(); _expectedTotalHmacLength = _hmacStream.Position + cipherTextLength; V1AxCryptDataStream encryptedDataStream = new V1AxCryptDataStream(inputStream, _hmacStream, cipherTextLength); return(encryptedDataStream); }