def create_private_key(path=None, text=False, bits=2048, passphrase=None, cipher='aes_128_cbc', verbose=True):
 if ((not path) and (not text)):
  raise salt.exceptions.SaltInvocationError('Either path or text must be specified.')
 if (path and text):
  raise salt.exceptions.SaltInvocationError('Either path or text must be specified, not both.')
 if verbose:
  _callback_func = M2Crypto.RSA.keygen_callback
 else:
  _callback_func = _keygen_callback
 rsa = M2Crypto.RSA.gen_key(bits, M2Crypto.m2.RSA_F4, _callback_func)
 bio = M2Crypto.BIO.MemoryBuffer()
 if (passphrase is None):
  cipher = None
 rsa.save_key_bio(bio, cipher=cipher, callback=_passphrase_callback(passphrase))
 if path:
  return write_pem(text=bio.read_all(), path=path, pem_type='RSA PRIVATE KEY')
 else:
  return bio.read_all()

def create_private_key ( path = None , text = False , bits = 2048 , passphrase = None , cipher = 'aes_128_cbc' , verbose = True ) : if ( ( not path ) and ( not text ) ) : raise salt . exceptions . SaltInvocationError ( 'Either path or text must be specified.' ) if ( path and text ) : raise salt . exceptions . SaltInvocationError ( 'Either path or text must be specified, not both.' ) if verbose : _callback_func = M2Crypto . RSA . keygen_callback else : _callback_func = _keygen_callback rsa = M2Crypto . RSA . gen_key ( bits , M2Crypto . m2 . RSA_F4 , _callback_func ) bio = M2Crypto . BIO . MemoryBuffer ( ) if ( passphrase is None ) : cipher = None rsa . save_key_bio ( bio , cipher = cipher , callback = _passphrase_callback ( passphrase ) ) if path : return write_pem ( text = bio . read_all ( ) , path = path , pem_type = 'RSA PRIVATE KEY' ) else : return bio . read_all ( )
creates a private key in pem format .