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


C++ ConstBufferPtr类代码示例

本文整理汇总了C++中ConstBufferPtr的典型用法代码示例。如果您正苦于以下问题:C++ ConstBufferPtr类的具体用法?C++ ConstBufferPtr怎么用?C++ ConstBufferPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: EncryptNew

	void VolumeHeader::EncryptNew (const BufferPtr &newHeaderBuffer, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf)
	{
		if (newHeaderBuffer.Size() != HeaderSize || newSalt.Size() != SaltSize)
			throw ParameterIncorrect (SRC_POS);

		shared_ptr <EncryptionMode> mode = EA->GetMode()->GetNew();
		shared_ptr <EncryptionAlgorithm> ea = EA->GetNew();

		if (typeid (*mode) == typeid (EncryptionModeXTS))
		{
			mode->SetKey (newHeaderKey.GetRange (EA->GetKeySize(), EA->GetKeySize()));
			ea->SetKey (newHeaderKey.GetRange (0, ea->GetKeySize()));
		}
		else
		{
			mode->SetKey (newHeaderKey.GetRange (0, mode->GetKeySize()));
			ea->SetKey (newHeaderKey.GetRange (LegacyEncryptionModeKeyAreaSize, ea->GetKeySize()));
		}

		ea->SetMode (mode);

		newHeaderBuffer.CopyFrom (newSalt);

		BufferPtr headerData = newHeaderBuffer.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize);
		Serialize (headerData);
		ea->Encrypt (headerData);

		if (newPkcs5Kdf)
			Pkcs5 = newPkcs5Kdf;
	}
开发者ID:AB9IL,项目名称:VeraCrypt,代码行数:30,代码来源:VolumeHeader.cpp

示例2: DeserializeEntryAt

	T VolumeHeader::DeserializeEntryAt (const ConstBufferPtr &header, const size_t &offset) const
	{
		if (offset > header.Size())
			throw ParameterIncorrect (SRC_POS);

		return Endian::Big (*reinterpret_cast<const T *> (header.Get() + offset));
	}
开发者ID:AB9IL,项目名称:VeraCrypt,代码行数:7,代码来源:VolumeHeader.cpp

示例3: Block

bool
Block::fromBuffer(const ConstBufferPtr& wire, size_t offset, Block& block)
{
  Buffer::const_iterator tempBegin = wire->begin() + offset;

  uint32_t type;
  bool isOk = Tlv::readType(tempBegin, wire->end(), type);
  if (!isOk)
    return false;

  uint64_t length;
  isOk = Tlv::readVarNumber(tempBegin, wire->end(), length);
  if (!isOk)
    return false;

  if (length > static_cast<uint64_t>(wire->end() - tempBegin))
    {
      return false;
    }

  block = Block(wire, type,
                wire->begin() + offset, tempBegin + length,
                tempBegin, tempBegin + length);

  return true;
}
开发者ID:PatrickGuo,项目名称:ndn-cxx-master,代码行数:26,代码来源:block.cpp

示例4: CopyFrom

	void BufferPtr::CopyFrom (const ConstBufferPtr &bufferPtr) const
	{
		if (bufferPtr.Size() > DataSize)
			throw ParameterTooLarge (SRC_POS);

		Memory::Copy (DataPtr, bufferPtr.Get(), bufferPtr.Size());
	}
开发者ID:ggielly,项目名称:GostCrypt_Windows_1.0,代码行数:7,代码来源:Buffer.cpp

示例5: update

Digest<Hash>&
Digest<Hash>::operator<<(Digest<Hash>& src)
{
  ConstBufferPtr buffer = src.computeDigest();
  update(buffer->get(), buffer->size());

  return *this;
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:8,代码来源:digest.cpp

示例6: WriteAt

void File::WriteAt (const ConstBufferPtr &buffer, uint64 position) const
{
    if_debug (ValidateState());

#ifdef TC_TRACE_FILE_OPERATIONS
    TraceFileOperation (FileHandle, Path, true, buffer.Size(), position);
#endif
    throw_sys_sub_if (pwrite (FileHandle, buffer, buffer.Size(), position) != (ssize_t) buffer.Size(), wstring (Path));
}
开发者ID:Clockwork-Sphinx,项目名称:VeraCrypt,代码行数:9,代码来源:File.cpp

示例7: PasswordEmpty

bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
{
    if (password.Size() < 1)
        throw PasswordEmpty (SRC_POS);

    ConstBufferPtr salt (encryptedData.GetRange (SaltOffset, SaltSize));
    SecureBuffer header (EncryptedHeaderDataSize);
    SecureBuffer headerKey (GetLargestSerializedKeySize());

    foreach (shared_ptr <Pkcs5Kdf> pkcs5, keyDerivationFunctions)
    {
        pkcs5->DeriveKey (headerKey, password, salt);

        foreach (shared_ptr <EncryptionMode> mode, encryptionModes)
        {
            if (typeid (*mode) != typeid (EncryptionModeXTS))
                mode->SetKey (headerKey.GetRange (0, mode->GetKeySize()));

            foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms)
            {
                if (!ea->IsModeSupported (mode))
                    continue;

                /*
                printf("trying %ls, %ls, %ls\n", pkcs5->GetName().c_str(),
                							mode->GetName().c_str(),
                							ea->GetName().c_str()
                							);
                							*/


                if (typeid (*mode) == typeid (EncryptionModeXTS))
                {
                    ea->SetKey (headerKey.GetRange (0, ea->GetKeySize()));

                    mode = mode->GetNew();
                    mode->SetKey (headerKey.GetRange (ea->GetKeySize(), ea->GetKeySize()));
                }
                else
                {
                    ea->SetKey (headerKey.GetRange (LegacyEncryptionModeKeyAreaSize, ea->GetKeySize()));
                }

                ea->SetMode (mode);

                header.CopyFrom (encryptedData.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize));
                ea->Decrypt (header);

                if (Deserialize (header, ea, mode))
                {
                    EA = ea;
                    Pkcs5 = pkcs5;
                    return true;
                }
            }
        }
    }
开发者ID:gdbelvin,项目名称:truecrypt-file-carve,代码行数:57,代码来源:VolumeHeader.cpp

示例8: StringSource

std::ostream&
operator<<(std::ostream& os, Digest<Hash>& digest)
{
  using namespace CryptoPP;

  std::string output;
  ConstBufferPtr buffer = digest.computeDigest();
  StringSource(buffer->buf(), buffer->size(), true, new HexEncoder(new FileSink(os)));

  return os;
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:11,代码来源:digest.cpp

示例9: SetKey

	void EncryptionAlgorithm::SetKey (const ConstBufferPtr &key)
	{
		if (Ciphers.size() < 1)
			throw NotInitialized (SRC_POS);

		if (GetKeySize() != key.Size())
			throw ParameterIncorrect (SRC_POS);

		size_t keyOffset = 0;
		foreach_ref (Cipher &c, Ciphers)
		{
			c.SetKey (key.GetRange (keyOffset, c.GetKeySize()));
			keyOffset += c.GetKeySize();
		}
开发者ID:josejamilena,项目名称:veracrypt,代码行数:14,代码来源:EncryptionAlgorithm.cpp

示例10: ParameterIncorrect

	uint64 MemoryStream::Read (const BufferPtr &buffer)
	{
		if (Data.size() == 0)
			throw ParameterIncorrect (SRC_POS);

		ConstBufferPtr streamBuf (*this);
		size_t len = buffer.Size();
		if (streamBuf.Size() - ReadPosition < len)
			len = streamBuf.Size() - ReadPosition;

		BufferPtr(buffer).CopyFrom (streamBuf.GetRange (ReadPosition, len));
		ReadPosition += len;
		return len;
	}
开发者ID:ggielly,项目名称:GostCrypt_Windows_1.0,代码行数:14,代码来源:MemoryStream.cpp

示例11:

std::ostream& operator << ( std::ostream& os, const ICommand& command )
{
    ConstBufferPtr buffer = command.getBuffer();
    if( buffer )
        os << lunchbox::disableFlush << "command< type "
           << uint32_t( command.getType( )) << " cmd " << command.getCommand()
           << " size " << command.getSize() << '/' << buffer->getSize() << '/'
           << buffer->getMaxSize() << " from " << command.getNode() << " to "
           << command.getLocalNode() << " >" << lunchbox::enableFlush;
    else
        os << "command< empty >";

    if( command._impl->func.isValid( ))
        os << ' ' << command._impl->func << std::endl;
    return os;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例12: SetKey

	void EncryptionModeLRW::SetKey (const ConstBufferPtr &key)
	{
		if (key.Size() != 16)
			throw ParameterIncorrect (SRC_POS);

		if (!KeySet)
			GfContext.Allocate (sizeof (GfCtx));

		if (!Gf64TabInit ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
			throw bad_alloc();

		if (!Gf128Tab64Init ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
			throw bad_alloc();

		Key.CopyFrom (key);
		KeySet = true;
	}
开发者ID:BlueBlock,项目名称:truecrypt,代码行数:17,代码来源:EncryptionModeLRW.cpp

示例13: Block

Component
Component::fromImplicitSha256Digest(const ConstBufferPtr& digest)
{
    if (digest->size() != crypto::SHA256_DIGEST_SIZE)
        BOOST_THROW_EXCEPTION(Error("Cannot create ImplicitSha256DigestComponent (input digest must be " +
                                    to_string(crypto::SHA256_DIGEST_SIZE) + " octets)"));

    return Block(tlv::ImplicitSha256DigestComponent, digest);
}
开发者ID:dashings,项目名称:ndn-cxx,代码行数:9,代码来源:name-component.cpp

示例14: Serialize

	void Serializer::Serialize (const string &name, const ConstBufferPtr &data)
	{
		SerializeString (name);

		uint64 size = data.Size();
		Serialize (size);

		DataStream->Write (data);
	}
开发者ID:4nt1m0n,项目名称:truecrypt,代码行数:9,代码来源:Serializer.cpp

示例15: faceStatus

void
MulticastDiscovery::registerHubDiscoveryPrefix(const ConstBufferPtr& buffer)
{
  std::vector<uint64_t> multicastFaces;

  size_t offset = 0;
  while (offset < buffer->size()) {
    bool isOk = false;
    Block block;
    std::tie(isOk, block) = Block::fromBuffer(buffer, offset);
    if (!isOk) {
      std::cerr << "ERROR: cannot decode FaceStatus TLV" << std::endl;
      break;
    }

    offset += block.size();

    nfd::FaceStatus faceStatus(block);

    ndn::util::FaceUri uri(faceStatus.getRemoteUri());
    if (uri.getScheme() == "udp4") {
      namespace ip = boost::asio::ip;
      boost::system::error_code ec;
      ip::address address = ip::address::from_string(uri.getHost(), ec);

      if (!ec && address.is_multicast()) {
        multicastFaces.push_back(faceStatus.getFaceId());
      }
      else
        continue;
    }
  }

  if (multicastFaces.empty()) {
    m_nextStageOnFailure("No multicast faces available, skipping multicast discovery stage");
  }
  else {
    nfd::ControlParameters parameters;
    parameters
      .setName(LOCALHOP_HUB_DISCOVERY_PREFIX)
      .setCost(1)
      .setExpirationPeriod(time::seconds(30));

    nRequestedRegs = multicastFaces.size();
    nFinishedRegs = 0;

    for (const auto& face : multicastFaces) {
      parameters.setFaceId(face);
      m_controller.start<nfd::RibRegisterCommand>(parameters,
                                                  bind(&MulticastDiscovery::onRegisterSuccess,
                                                       this),
                                                  bind(&MulticastDiscovery::onRegisterFailure,
                                                       this, _1, _2));
    }
  }
}
开发者ID:MobinRanjbar,项目名称:NFD,代码行数:56,代码来源:multicast-discovery.cpp


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