Exemple #1
0
void BlockOrientedCipherModeBase::ProcessData(byte *outString, const byte *inString, size_t length)
{
	unsigned int s = BlockSize();
	assert(length % s == 0);
	unsigned int alignment = m_cipher->BlockAlignment();
	bool inputAlignmentOk = !RequireAlignedInput() || IsAlignedOn(inString, alignment);

	if (IsAlignedOn(outString, alignment))
	{
		if (inputAlignmentOk)
			ProcessBlocks(outString, inString, length / s);
		else
		{
			memcpy(outString, inString, length);
			ProcessBlocks(outString, outString, length / s);
		}
	}
	else
	{
		while (length)
		{
			if (inputAlignmentOk)
				ProcessBlocks(m_buffer, inString, 1);
			else
			{
				memcpy(m_buffer, inString, s);
				ProcessBlocks(m_buffer, m_buffer, 1);
			}
			memcpy(outString, m_buffer, s);
			inString += s;
			outString += s;
			length -= s;
		}
	}
}
Exemple #2
0
void BlockOrientedCipherModeBase::ProcessData(byte *outString, const byte *inString, size_t length)
{
	if (!length)
		return;

	unsigned int s = BlockSize();
	assert(length % s == 0);

	if (!RequireAlignedInput() || IsAlignedOn(inString, m_cipher->BlockAlignment()))
		ProcessBlocks(outString, inString, length / s);
	else
	{
		do
		{
			memcpy(m_buffer, inString, s);
			ProcessBlocks(outString, m_buffer, 1);
			inString += s;
			outString += s;
			length -= s;
		} while (length > 0);
	}
}
int Page::LoadXmlPageFile()
{
  xmlNodePtr cur;
  xmlChar * value;
  wxFileName fullpath(file.GetFullPath());
  if(file.IsRelative()) {
	  fullpath.PrependDir(ws::curproj->GetProjPath());
  }
  doc = xmlParseFile((const char*)fullpath.GetFullPath().mb_str());
  if(doc == NULL)
    {
      std::cout << "Error parsing file " << (const char *)fullpath.GetFullPath().mb_str() << std::endl;
      return 0;
    }
  cur = xmlDocGetRootElement(doc);
  if(xmlStrcmp(cur->name, (const xmlChar *)"page") != 0)
    {
      xmlFreeDoc(doc);
      return 0;
    }
  cur = cur->children;
  while(cur != NULL)
    {
      if(!xmlStrcmp(cur->name, (const xmlChar *)"name"))
        {
          value = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
          wxString temp((const char*)value, wxConvUTF8);
          SetName(temp);
          std::cout << "Added name ..." << std::endl;
          xmlFree(value);
        }
      else if(!xmlStrcmp(cur->name, (const xmlChar *)"description"))
        {
          value = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
          wxString temp((const char*)value, wxConvUTF8);
          SetDescription(temp);
          std::cout << "Added description ..." << std::endl;
          xmlFree(value);
        }
      else if(!xmlStrcmp(cur->name, (const xmlChar *)"template"))
        {
          xmlChar *prop;
          if ((prop = xmlGetProp(cur, (const xmlChar*)"uri")) != NULL)
            {
              //do something
            }
          else
            {
              std::cout << "Couldn\'t find template" << std::endl;
            }
        }
      else if(!xmlStrcmp(cur->name, (const xmlChar *)"layout"))
        {
          xmlChar *prop;
          if ((prop = xmlGetProp(cur, (const xmlChar*)"uri")) != NULL)
            {
              //do something
            }
          else
            {
              std::cout << "Couldn\'t find layout" << std::endl;
            }
        }
      else if(!xmlStrcmp(cur->name,(const xmlChar *)"blocks"))
        {
          std::cout << "Processing blocks ..." << std::endl;
          ProcessBlocks(doc, cur);
        }
      cur = cur->next;
    }
  return 1;
};