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


C++ copy_mem函数代码示例

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


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

示例1: BOTAN_ARG_CHECK

/*
* Modified key schedule used for bcrypt password hashing
*/
void Blowfish::salted_set_key(const uint8_t key[], size_t length,
                              const uint8_t salt[], size_t salt_length,
                              size_t workfactor)
   {
   BOTAN_ARG_CHECK(salt_length > 0 && salt_length % 4 == 0,
                   "Invalid salt length for Blowfish salted key schedule");

   if(length > 72)
      {
      // Truncate longer passwords to the 72 char bcrypt limit
      length = 72;
      }

   m_P.resize(18);
   copy_mem(m_P.data(), P_INIT, 18);

   m_S.resize(1024);
   copy_mem(m_S.data(), S_INIT, 1024);
   key_expansion(key, length, salt, salt_length);

   if(workfactor > 0)
      {
      const size_t rounds = static_cast<size_t>(1) << workfactor;

      for(size_t r = 0; r != rounds; ++r)
         {
         key_expansion(key, length, nullptr, 0);
         key_expansion(salt, salt_length, nullptr, 0);
         }
      }
   }
开发者ID:webmaster128,项目名称:botan,代码行数:34,代码来源:blowfish.cpp

示例2: while

/*
* Convert some data from Base64
*/
void Base64_Decoder::write(const byte input[], size_t length)
   {
   while(length)
      {
      size_t to_copy = std::min<size_t>(length, m_in.size() - m_position);
      if(to_copy == 0)
         {
         m_in.resize(m_in.size()*2);
         m_out.resize(m_out.size()*2);
         }
      copy_mem(&m_in[m_position], input, to_copy);
      m_position += to_copy;

      size_t consumed = 0;
      size_t written = base64_decode(m_out.data(),
                                     reinterpret_cast<const char*>(m_in.data()),
                                     m_position,
                                     consumed,
                                     false,
                                     m_checking != FULL_CHECK);

      send(m_out, written);

      if(consumed != m_position)
         {
         copy_mem(m_in.data(), m_in.data() + consumed, m_position - consumed);
         m_position = m_position - consumed;
         }
      else
         m_position = 0;

      length -= to_copy;
      input += to_copy;
      }
   }
开发者ID:Andrew-He,项目名称:botan,代码行数:38,代码来源:b64_filt.cpp

示例3: snd_udp

void
snd_udp(struct TCB *tp, unsigned char far *data, int count)
{
	if (IP_STUB(tp)->transport != IPPROTO_UDP) {
		snd_raw_ip(tp, data, count);	// RAW_IP_Packet
	} else {
		statistics.udpOutDatagrams++;

		//rprintf("[udp send %d, %d byte]", tp -tcb, count);
		copy_mem(_DS, (unsigned)IP_S, _DS, (unsigned)IP_STUB(tp), IP_PLEN);
		UDP_S->source = tp->local_port;
		UDP_S->length = htons(count + UDP_HLEN);
		UDP_S->destination = tp->remote_port;

		copy_mem(_DS, (unsigned)UDP_S + UDP_PLEN, FP_SEG(data), FP_OFF(data), count);
		statistics.UDP_snd_bytes += count;
		IP_S->time_to_live = 0;
		IP_S->checksum = UDP_S->length;
		UDP_S->checksum = 0;
		UDP_S->checksum = checksum(&(IP_S->time_to_live), PSEUDO_HLEN + UDP_HLEN + count);
		snd_ip(IP_S, UDP_HLEN + count);
		//print_packet(IP_S, UDP_HLEN + count);
	}
	clean_udp_tx_buffer(tp);
}
开发者ID:barmi,项目名称:tcpip,代码行数:25,代码来源:UDP.C

示例4: BOTAN_ARG_CHECK

/*
* Modified key schedule used for bcrypt password hashing
*/
void Blowfish::eks_key_schedule(const uint8_t key[], size_t length,
                                const uint8_t salt[16], size_t workfactor)
   {

   /*
   * On a 2.8 GHz Core-i7, workfactor == 18 takes about 25 seconds to
   * hash a password. This seems like a reasonable upper bound for the
   * time being.
   * Bcrypt allows up to work factor 31 (2^31 iterations)
   */
   BOTAN_ARG_CHECK(workfactor >= 4 && workfactor <= 18,
                   "Invalid bcrypt work factor");

   if(length > 72)
      {
      // Truncate longer passwords to the 72 char bcrypt limit
      length = 72;
      }

   m_P.resize(18);
   copy_mem(m_P.data(), P_INIT, 18);

   m_S.resize(1024);
   copy_mem(m_S.data(), S_INIT, 1024);
   key_expansion(key, length, salt);

   const uint8_t null_salt[16] = { 0 };
   const size_t rounds = static_cast<size_t>(1) << workfactor;

   for(size_t r = 0; r != rounds; ++r)
      {
      key_expansion(key, length, null_salt);
      key_expansion(salt, 16, null_salt);
      }
   }
开发者ID:evpo,项目名称:EncryptPad,代码行数:38,代码来源:blowfish.cpp

示例5: cipher

size_t CBC_Decryption::process(uint8_t buf[], size_t sz)
   {
   const size_t BS = cipher().block_size();

   BOTAN_ASSERT(sz % BS == 0, "Input is full blocks");
   size_t blocks = sz / BS;

   while(blocks)
      {
      const size_t to_proc = std::min(BS * blocks, m_tempbuf.size());

      cipher().decrypt_n(buf, m_tempbuf.data(), to_proc / BS);

      xor_buf(m_tempbuf.data(), state_ptr(), BS);
      xor_buf(&m_tempbuf[BS], buf, to_proc - BS);
      copy_mem(state_ptr(), buf + (to_proc - BS), BS);

      copy_mem(buf, m_tempbuf.data(), to_proc);

      buf += to_proc;
      blocks -= to_proc / BS;
      }

   return sz;
   }
开发者ID:fxdupont,项目名称:botan,代码行数:25,代码来源:cbc.cpp

示例6: while

/*
* Convert some data from hex format
*/
void Hex_Decoder::write(const byte input[], size_t length)
   {
   while(length)
      {
      size_t to_copy = std::min<size_t>(length, in.size() - position);
      copy_mem(&in[position], input, to_copy);
      position += to_copy;

      size_t consumed = 0;
      size_t written = hex_decode(out.data(),
                                  reinterpret_cast<const char*>(in.data()),
                                  position,
                                  consumed,
                                  checking != FULL_CHECK);

      send(out, written);

      if(consumed != position)
         {
         copy_mem(in.data(), in.data() + consumed, position - consumed);
         position = position - consumed;
         }
      else
         position = 0;

      length -= to_copy;
      input += to_copy;
      }
   }
开发者ID:Kampbell,项目名称:botan,代码行数:32,代码来源:hex_filt.cpp

示例7: copy_mem

/*
* Blowfish Key Schedule
*/
void Blowfish::key_schedule(const uint8_t key[], size_t length)
   {
   m_P.resize(18);
   copy_mem(m_P.data(), P_INIT, 18);

   m_S.resize(1024);
   copy_mem(m_S.data(), S_INIT, 1024);

   key_expansion(key, length, nullptr, 0);
   }
开发者ID:webmaster128,项目名称:botan,代码行数:13,代码来源:blowfish.cpp

示例8: aont_unpackage

void aont_unpackage(BlockCipher* cipher,
                    const byte input[], size_t input_len,
                    byte output[])
   {
   const size_t BLOCK_SIZE = cipher->block_size();

   if(!cipher->valid_keylength(BLOCK_SIZE))
      throw Invalid_Argument("AONT::unpackage: Invalid cipher");

   if(input_len < BLOCK_SIZE)
      throw Invalid_Argument("AONT::unpackage: Input too short");

   // The all-zero string which is used both as the CTR IV and as K0
   const std::string all_zeros(BLOCK_SIZE*2, '0');

   cipher->set_key(SymmetricKey(all_zeros));

   SecureVector<byte> package_key(BLOCK_SIZE);
   SecureVector<byte> buf(BLOCK_SIZE);

   // Copy the package key (masked with the block hashes)
   copy_mem(&package_key[0],
            input + (input_len - BLOCK_SIZE),
            BLOCK_SIZE);

   const size_t blocks = ((input_len - 1) / BLOCK_SIZE);

   // XOR the blocks into the package key bits
   for(size_t i = 0; i != blocks; ++i)
      {
      const size_t left = std::min<size_t>(BLOCK_SIZE,
                                           input_len - BLOCK_SIZE * (i+1));

      zeroise(buf);
      copy_mem(&buf[0], input + (BLOCK_SIZE * i), left);

      for(size_t j = 0; j != sizeof(i); ++j)
         buf[BLOCK_SIZE - 1 - j] ^= get_byte(sizeof(i)-1-j, i);

      cipher->encrypt(buf);

      xor_buf(&package_key[0], buf, BLOCK_SIZE);
      }

   Pipe pipe(new StreamCipher_Filter(new CTR_BE(cipher), package_key));

   pipe.process_msg(input, input_len - BLOCK_SIZE);

   pipe.read(output, pipe.remaining());
   }
开发者ID:BenjaminSchiborr,项目名称:safe,代码行数:50,代码来源:package.cpp

示例9: sysbrk

/**
 * @brief Clone all memory for a module
 *
 * @param modld -
 *
 * <long-description>
 *
 * @return <ReturnValue>
 */
InsLibModlDesc *InsLibCloneModule(InsLibModlDesc *modld)
{
	InsLibModlDesc *modld_clone = NULL;
	int sz;

	if (modld) {
		modld_clone = (InsLibModlDesc *) sysbrk(sizeof(InsLibModlDesc));
		if (!modld_clone) {
			//pseterr(ENOMEM);
			printk("InsLib: not enough memory for modld_clone\n");
			return NULL;
		}
		copy_mem((void *) modld_clone, (void *) modld,
			 sizeof(InsLibModlDesc));

		if (modld->BusType == InsLibBusTypeCARRIER) {
			modld_clone->ModuleAddress =
				InsLibCloneCar(modld->ModuleAddress);
		}
		else if (modld->BusType == InsLibBusTypeVME) {
			modld_clone->ModuleAddress =
				InsLibCloneVme(modld->ModuleAddress);
		}
		else if ((modld->BusType == InsLibBusTypePMC)
			 ||  (modld->BusType == InsLibBusTypePCI)) {
			modld_clone->ModuleAddress =
				InsLibClonePci(modld->ModuleAddress);
		}

		if (modld->Extra) {
			sz = strlen(modld_clone->Extra) +1;
			modld_clone->Extra = (char *) sysbrk(sz);
			if (modld_clone->Extra)
				copy_mem((void *) modld_clone->Extra,
					 (void *) modld->Extra, sz);
		}

		if (modld->Isr) {
			modld_clone->Isr = (InsLibIntrDesc *)
				sysbrk(sizeof(InsLibIntrDesc));
			if (modld_clone->Isr)
				copy_mem((void *) modld_clone->Isr,
					 (void *)modld->Isr,
					 sizeof(InsLibIntrDesc));
		}
		modld_clone->Next = InsLibCloneModule(modld->Next);
		return modld_clone;
	}
	return NULL;
}
开发者ID:GSI-CS-CO,项目名称:kernel_modules,代码行数:59,代码来源:libinstkernel.c

示例10: force_le

void Streebog::compress_64(const uint64_t M[], bool last_block)
   {
   uint64_t N = force_le(last_block ? 0ULL : m_count);

   uint64_t hN[8];
   uint64_t A[8];

   copy_mem(hN, m_h.data(), 8);
   hN[0] ^= N;
   lps(hN);

   copy_mem(A, hN, 8);

   for(size_t i = 0; i != 8; ++i)
      {
      hN[i] ^= M[i];
      }

   for(size_t i = 0; i < 12; ++i)
      {
      for(size_t j = 0; j != 8; ++j)
         A[j] ^= force_le(STREEBOG_C[i][j]);
      lps(A);

      lps(hN);
      for(size_t j = 0; j != 8; ++j)
         hN[j] ^= A[j];
      }

   for(size_t i = 0; i != 8; ++i)
      {
      m_h[i] ^= hN[i] ^ M[i];
      }

   if(!last_block)
      {
      uint64_t carry = 0;
      for(int i = 0; i < 8; i++)
         {
         const uint64_t m = force_le(M[i]);
         const uint64_t hi = force_le(m_S[i]);
         const uint64_t t = hi + m;

         m_S[i] = force_le(t + carry);
         carry = (t < hi ? 1 : 0) | (t < m ? 1 : 0);
         }
      }
   }
开发者ID:mgierlings,项目名称:botan,代码行数:48,代码来源:streebog.cpp

示例11: copy_mem

/*
* Read from a memory buffer
*/
size_t DataSource_Memory::read(byte out[], size_t length)
   {
   size_t got = std::min<size_t>(source.size() - offset, length);
   copy_mem(out, &source[offset], got);
   offset += got;
   return got;
   }
开发者ID:Stautob,项目名称:botan,代码行数:10,代码来源:data_src.cpp

示例12: encrypt

/*
* Encrypt in XTS mode
*/
void XTS_Encryption::write(const byte input[], u32bit length)
   {
   const u32bit BLOCK_SIZE = cipher->BLOCK_SIZE;

   u32bit copied = std::min(buffer.size() - position, length);
   buffer.copy(position, input, copied);
   length -= copied;
   input += copied;
   position += copied;

   if(length == 0) return;

   encrypt(buffer);
   if(length > BLOCK_SIZE)
      {
      encrypt(buffer + BLOCK_SIZE);
      while(length > buffer.size())
         {
         encrypt(input);
         length -= BLOCK_SIZE;
         input += BLOCK_SIZE;
         }
      position = 0;
      }
   else
      {
      copy_mem(buffer.begin(), buffer + BLOCK_SIZE, BLOCK_SIZE);
      position = BLOCK_SIZE;
      }
   buffer.copy(position, input, length);
   position += length;
   }
开发者ID:Amaterasu27,项目名称:miktex,代码行数:35,代码来源:xts.cpp

示例13: copy_fhead_common

void copy_fhead_common(Fli_head *sh, Fli_head *dh)
{
	/* copys all but magic, filesize, or user lock fields between 
	 * two fli headers */
	copy_mem(OPTR(sh,sizeof(Chunk_id)), OPTR(dh,sizeof(Chunk_id)),
			  FLIH_COMMONSIZE - sizeof(Chunk_id));
}
开发者ID:AnimatorPro,项目名称:Animator-Pro,代码行数:7,代码来源:WRITEFLX.C

示例14: read

 u32bit read(byte output[], u32bit length)
    {
    u32bit copied = std::min(length, end - start);
    copy_mem(output, buffer + start, copied);
    start += copied;
    return copied;
    }
开发者ID:Amaterasu27,项目名称:miktex,代码行数:7,代码来源:secqueue.cpp

示例15: write

 size_t write(const uint8_t input[], size_t length)
 {
     size_t copied = std::min<size_t>(length, m_buffer.size() - m_end);
     copy_mem(m_buffer.data() + m_end, input, copied);
     m_end += copied;
     return copied;
 }
开发者ID:randombit,项目名称:botan,代码行数:7,代码来源:secqueue.cpp


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