Пример #1
0
AnonPrimitive::ANON_RESULT AnonHashSha1::anonymize (void* buf, unsigned int len)
{
	Sha1::SHA1_Init		(&sha);
	Sha1::SHA1_Update	(&sha, (unsigned char*) buf, len);
	Sha1::SHA1_Final	((unsigned char*) &digest, &sha);

	unsigned int remaining	= len;
	unsigned int pos		= 0;

	while (remaining != 0) {

		if (remaining >= SHA1_DIGLEN) {
				
			memcpy((unsigned char*) buf + pos, digest, SHA1_DIGLEN);
			remaining -= SHA1_DIGLEN;
			pos += SHA1_DIGLEN;

		} else {
			memcpy((unsigned char*) buf + pos, digest, remaining);
			remaining =  0;
			pos += remaining;
		}
		
	} // while (remaining != 0) 

	return ANON_RESULT (len);
}
Пример #2
0
AnonPrimitive::ANON_RESULT AnonHashHmacSha1::anonymize (void* buf, unsigned int len)
{
	HmacSha1::sha1_hmac ((uint8_t*)&digest, key, keylen, (uint8_t*)buf, len);

	unsigned int remaining	= len;
	unsigned int pos		= 0;

	while (remaining != 0) {

		if (remaining >= SHA1_DIGLEN) {
				
			memcpy		((unsigned char*) buf + pos, digest, SHA1_DIGLEN);
			remaining	-= SHA1_DIGLEN;
			pos			+= SHA1_DIGLEN;

		} else {

			memcpy		((unsigned char*) buf + pos, digest, remaining);
			remaining	=  0;
			pos			+= remaining;

		}
		
	} // while (remaining != 0) 

	return ANON_RESULT (len);
}
Пример #3
0
AnonPrimitive::ANON_RESULT AnonShuffle::anonymize_chain ( void* buf, unsigned int len ) const
{
  unsigned char* buf1 = reinterpret_cast<unsigned char*> ( buf );
  std::random_shuffle ( buf1, buf1+len );

  return ANON_RESULT ( len );
}
Пример #4
0
AnonPrimitive::ANON_RESULT AnonShuffle::anonymize_internal ( const void*const src_buff, void* dst_buff, unsigned int len ) const
{
  memcpy ( dst_buff, src_buff, len );

  unsigned char* buff = reinterpret_cast<unsigned char*> ( dst_buff );
  std::random_shuffle ( buff, buff+len );

  return ANON_RESULT ( len );
}