Ejemplo n.º 1
0
Archivo: hill.cpp Proyecto: MNAS/Labs
vector key::mult(vector p)
{
  vector c;
    for (int i=0; i<keySize(); ++i )
    {
        for ( int j=0; j<keySize(); j++ )
        {
            c.v[i]+=p.v[j]*arr[i][j];
        }
    }
    return c;
}
Ejemplo n.º 2
0
static int crypt_all(int *pcount, struct db_salt *salt)
{
	const int count = *pcount;
	int index = 0;

	if (any_cracked) {
		memset(cracked, 0, cracked_size);
		any_cracked = 0;
	}

#ifdef _OPENMP
#pragma omp parallel for
	for (index = 0; index < count; index++)
#endif
	{
		// allocate string2key buffer
		int res;
		int ks = keySize(cur_salt->cipher_algorithm);
		//int ds = digestSize(cur_salt->hash_algorithm);
		unsigned char keydata[64 * ((32 + 64 - 1) / 64)];

		cur_salt->s2kfun(saved_key[index], keydata, ks);
		res = check(keydata, ks);
		if (res) {
			cracked[index] = 1;
#ifdef _OPENMP
#pragma omp atomic
#endif
			any_cracked |= 1;
		}
	}

	return count;
}
Ejemplo n.º 3
0
void CipherKeyImpl::generateKey()
{
	ByteVec vec;

	getRandomBytes(vec, keySize());
	setKey(vec);
	
	getRandomBytes(vec, ivSize());
	setIV(vec);
}
Ejemplo n.º 4
0
Aes256::Aes256(BinData key):
  key_( std::move(key) ),
  iv_( generateRandomData( ivSize() ) ),
  td_(MCRYPT_RIJNDAEL_256, MCRYPT_CFB)
{
  if( key_.size()!=iv_.size() )
    throw std::runtime_error("key and IV size differ");

  assert( static_cast<size_t>(mcrypt_enc_get_key_size(td_.get()))==keySize() );
  assert( static_cast<size_t>(mcrypt_enc_get_iv_size(td_.get())) ==ivSize()  );

  int ret;
  if( (ret = mcrypt_generic_init(td_.get(), key_.data(), key_.size(), iv_.data())) < 0 )
    throw std::runtime_error( (Util::ErrStrm{}<<"mcrypt_generic_init(): "<<mcrypt_strerror(ret)).str().c_str() );
}
Ejemplo n.º 5
0
CipherKeyImpl::CipherKeyImpl(const std::string& name):
	_pCipher(0),
	_name(name),
	_key(),
	_iv()
{
	// dummy access to Cipherfactory so that the EVP lib is initilaized
	CipherFactory::defaultFactory();
	_pCipher = EVP_get_cipherbyname(name.c_str());

	if (!_pCipher)
		throw Poco::NotFoundException("Cipher " + name + " was not found");
	_key = ByteVec(keySize());
	_iv = ByteVec(ivSize());
	generateKey();
}
Ejemplo n.º 6
0
size_t Aes256::blockSize(void) const
{
  return keySize();
}