当前位置: 首页>>代码示例>>C++>>正文


C++ shared_ptr::AllowsRandomAccess方法代码示例

本文整理汇总了C++中std::shared_ptr::AllowsRandomAccess方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AllowsRandomAccess方法的具体用法?C++ shared_ptr::AllowsRandomAccess怎么用?C++ shared_ptr::AllowsRandomAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::shared_ptr的用法示例。


在下文中一共展示了shared_ptr::AllowsRandomAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

bool     FileVEILOperationsImpl::StreamStartsWithCmsHeader(std::shared_ptr<IDataReader> stream, std::shared_ptr<ICmsHeaderBase>& pVal)
{
	tscrypto::tsCryptoData contents;
	std::shared_ptr<ICmsHeaderBase> header;
	std::shared_ptr<tsmod::IObject> iunk;
	int len;
	int headerLen = 0;
	int64_t fileLength;

	if (stream == NULL)
		return false;

	fileLength = stream->DataLength();

	if (fileLength > 20480)
		len = 20480;
	else
		len = (int)fileLength;

	stream->ReadData(len, contents);
	if (contents.size() != (uint32_t)len)
	{
		return false;
	}
	if (!ExtractHeaderFromStream(contents.c_str(), len, &headerLen, iunk) ||
		!(header = std::dynamic_pointer_cast<ICmsHeader>(iunk)) ||
		headerLen == 0)
	{
		return false;
	}

	if (stream->AllowsRandomAccess())
	{
		stream->GoToPosition(headerLen);
	}

	pVal = header;
	return true;
}
开发者ID:TecSec,项目名称:OpenVEIL,代码行数:39,代码来源:FileOperations.cpp

示例2: EncryptSignStream

bool FileVEILOperationsImpl::EncryptSignStream(std::shared_ptr<IDataReader> inputData, std::shared_ptr<IDataWriter> outputData, std::shared_ptr<ICmsHeader> Header, CompressionType comp, TS_ALG_ID algorithm,
	TS_ALG_ID hashAlgorithm, bool SignHeader, bool bindData, CMSFileFormatIds DataFormat, bool randomIvec, SymmetricPaddingType paddingType, int blockSize)
{
	TSDECLARE_FUNCTIONExt(true);

	std::shared_ptr<ICmsHeaderBase> header2;
	std::shared_ptr<ICmsHeader> header7;
	std::shared_ptr<IKeyGenCallback> callback;
	int64_t fileSize = 0;

	if (Header == NULL)
	{
		LogError("The CKM Header is missing.");
		return TSRETURN_ERROR(("Bad Header"), false);
	}

	if (!Header->DuplicateHeader(header2))
	{
		LogError("The specified CKM Header is incomplete or invalid.");
		return TSRETURN_ERROR(("Bad Header"), false);
	}
	if (!(header7 = std::dynamic_pointer_cast<ICmsHeader>(header2)))
	{
		LogError("The specified CKM Header is incomplete or invalid.");
		return TSRETURN_ERROR(("Bad Header"), false);
	}

	//
	// Now get the length of the source file
	//
	if (inputData->AllowsRandomAccess())
		fileSize = inputData->DataLength();
	else
		fileSize = -1;

	if (!PrepareHeader(header7, comp, algorithm, hashAlgorithm, SignHeader, bindData, DataFormat, randomIvec, paddingType, blockSize, fileSize))
	{
		LogError("The specified CKM Header could not be prepared for key generation.");
		return TSRETURN_ERROR(("Bad Header"), false);
	}

	//	CkmDevOnly << "Header after prepare" << endl << indent << TSHeaderToString(header7) << endl << outdent;

#ifdef HAVE_BSTR
	// TODO:  Implement Linux mime support here - libmagic
	{
		tscrypto::tsCryptoData tmp;
		CryptoUtf16 tmpBstr(inputData->DataName());
		LPWSTR mime = NULL;

		if (inputData->PeekData(4096, tmp))
		{
			if (FindMimeFromData(NULL, tmpBstr.c_str(), tmp.rawData(), (DWORD)tmp.size(), NULL, 3 /*FMFD_ENABLEMIMESNIFFING | FMFD_URLASFILENAME*/, &mime, 0) >= 0)
			{
				if (mime != NULL && mime[0] != 0)
				{
					header7->SetMimeType(CryptoUtf16(mime).toUtf8());
				}
			}
		}
	}
#endif // HAVE_BSTR

	std::shared_ptr<ICryptoHelper> helper;

	if (!m_session && header7->NeedsSession())
	{
		if (!!m_sessionCallback)
		{
			if (!(m_sessionCallback->GetSessionForHeader(true, header2, 0, m_session)))
			{
				LogError("No session.");
				return TSRETURN_ERROR(("Returns ~~"), false);
			}
		}
	}

	if (!m_session)
	{
		LogError("Unable to retrieve the cryptographic helper object from the CKM Runtime.");
		return TSRETURN_ERROR(("Returns ~~"), false);
	}
	else
	{
		if (!(helper = CreateCryptoHelper(m_session)))
		{
			LogError("Unable to generate the working key and encrypted data - Unable to create the helper.");
			return TSRETURN_ERROR(("Unable to generate the working key and encrypted data."), false);
		}
	}

	helper->SetOperationStatusCallback(m_status);
	helper->SetTaskInformation(m_currentTask, m_taskCount);
	if (!!m_keyGenCallback)
		helper->SetKeyGenCallback(m_keyGenCallback);

	if (!header7->SetDataName(inputData->DataName().c_str()))
	{
		LOG(DebugInfo1, "WARNING:  Unable to save the original file name.  Continuing to process the file.\n");
	}
//.........这里部分代码省略.........
开发者ID:TecSec,项目名称:OpenVEIL,代码行数:101,代码来源:FileOperations.cpp


注:本文中的std::shared_ptr::AllowsRandomAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。