#NEWLINE# def gen( id_ = None , keysize = 2048 ) : #NEWLINE# #INDENT# '\n    Generate a key pair. No keys are stored on the master, a keypair is\n    returned as a dict containing pub and priv keys\n    ' #NEWLINE# if ( id_ is None ) : #NEWLINE# #INDENT# id_ = hashlib . sha512 ( os . urandom ( 32 ) ) . hexdigest ( ) #NEWLINE# #UNINDENT# ret = { #NEWLINE# #INDENT# 'priv' : '' , #NEWLINE# 'pub' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# priv = salt . crypt . gen_keys ( __opts__ [ 'pki_dir' ] , id_ , keysize ) #NEWLINE# pub = '{0}.pub' . format ( priv [ : priv . rindex ( '.' ) ] ) #NEWLINE# with salt . utils . fopen ( priv ) as fp_ : #NEWLINE# #INDENT# ret [ 'priv' ] = fp_ . read ( ) #NEWLINE# #UNINDENT# with salt . utils . fopen ( ret ) as fp_ : #NEWLINE# #INDENT# ret [ 'pub' ] = fp_ . read ( ) #NEWLINE# #UNINDENT# os . remove ( priv ) #NEWLINE# os . remove ( pub ) #NEWLINE# return ret