Ejemplo n.º 1
0
static boost::shared_ptr<Cipher> NewAESCipher( const Interface &iface, int keyLen )
{
    if( keyLen <= 0 )
	keyLen = 192;

    keyLen = AESKeyRange.closest( keyLen );

    const EVP_CIPHER *blockCipher = 0;
    const EVP_CIPHER *streamCipher = 0;

    switch(keyLen)
    {
    case 128:
	blockCipher = EVP_aes_128_cbc();
	streamCipher = EVP_aes_128_cfb();
	break;

    case 192:
	blockCipher = EVP_aes_192_cbc();
	streamCipher = EVP_aes_192_cfb();
	break;

    case 256:
    default:
	blockCipher = EVP_aes_256_cbc();
	streamCipher = EVP_aes_256_cfb();
	break;
    }
    
    return boost::shared_ptr<Cipher>( new SSL_Cipher(iface, AESInterface, 
		blockCipher, streamCipher, keyLen / 8) );
}
Ejemplo n.º 2
0
static shared_ptr<Cipher> NewAesXtsCipher( const Interface &iface, int keyLen )
{
  if( keyLen <= 0 )
    keyLen = 256;

  keyLen = AesXtsKeyRange.closest( keyLen );

  const EVP_CIPHER *blockCipher = 0;

  switch(keyLen)
  {
    case 128:
      blockCipher = EVP_aes_128_xts();
      break;

    case 256:
    default:
      blockCipher = EVP_aes_256_xts();
      break;
  }

  // XTS uses 2 keys, so the key size is doubled here.
  // Eg XTS-AES-256 uses two 256 bit keys.
  return shared_ptr<Cipher>( new SSL_Cipher(iface, AesXtsInterface, 
                                            blockCipher, NULL, 2 * keyLen / 8) );
}
Ejemplo n.º 3
0
static std::shared_ptr<Cipher> NewBFCipher(const Interface &iface, int keyLen) {
  if (keyLen <= 0) keyLen = 160;

  keyLen = BFKeyRange.closest(keyLen);

  const EVP_CIPHER *blockCipher = EVP_bf_cbc();
  const EVP_CIPHER *streamCipher = EVP_bf_cfb();

  return std::shared_ptr<Cipher>(new SSL_Cipher(
      iface, BlowfishInterface, blockCipher, streamCipher, keyLen / 8));
}