def _create_cbc_cipher(factory, **kwargs):
 cipher_state = factory._create_base_cipher(kwargs)
 iv = kwargs.pop('IV', None)
 IV = kwargs.pop('iv', None)
 if ((None, None) == (iv, IV)):
  iv = get_random_bytes(factory.block_size)
 if (iv is not None):
  if (IV is not None):
   raise TypeError("You must either use 'iv' or 'IV', not both")
 else:
  iv = IV
 if kwargs:
  raise TypeError(('Unknown parameters for CBC: %s' % str(kwargs)))
 return CbcMode(cipher_state, iv)

def _create_cbc_cipher ( factory , ** kwargs ) : cipher_state = factory . _create_base_cipher ( kwargs ) iv = kwargs . pop ( 'IV' , None ) IV = kwargs . pop ( 'iv' , None ) if ( ( None , None ) == ( iv , IV ) ) : iv = get_random_bytes ( factory . block_size ) if ( iv is not None ) : if ( IV is not None ) : raise TypeError ( "You must either use 'iv' or 'IV', not both" ) else : iv = IV if kwargs : raise TypeError ( ( 'Unknown parameters for CBC: %s' % str ( kwargs ) ) ) return CbcMode ( cipher_state , iv )
instantiate a cipher object that performs cbc encryption/decryption .