@_restore_ownership
def create_key(key_type='RSA', key_length=1024, name_real='Autogenerated Key', name_comment='Generated by SaltStack', name_email=None, subkey_type=None, subkey_length=None, expire_date=None, use_passphrase=False, user=None, gnupghome=None):
 ret = {'res': True, 'fingerprint': '', 'message': ''}
 create_params = {'key_type': key_type, 'key_length': key_length, 'name_real': name_real, 'name_comment': name_comment}
 gpg = _create_gpg(user, gnupghome)
 if name_email:
  create_params['name_email'] = name_email
 if subkey_type:
  create_params['subkey_type'] = subkey_type
 if subkey_length:
  create_params['subkey_length'] = subkey_length
 if expire_date:
  create_params['expire_date'] = expire_date
 if use_passphrase:
  gpg_passphrase = __salt__['pillar.get']('gpg_passphrase')
  if (not gpg_passphrase):
   ret['res'] = False
   ret['message'] = 'gpg_passphrase not available in pillar.'
   return ret
  else:
   create_params['passphrase'] = gpg_passphrase
 input_data = gpg.gen_key_input(**create_params)
 key = gpg.gen_key(input_data)
 if key.fingerprint:
  ret['fingerprint'] = key.fingerprint
  ret['message'] = 'GPG key pair successfully generated.'
 else:
  ret['res'] = False
  ret['message'] = 'Unable to generate GPG key pair.'
 return ret

@ _restore_ownership def create_key ( key_type = 'RSA' , key_length = 1024 , name_real = 'Autogenerated Key' , name_comment = 'Generated by SaltStack' , name_email = None , subkey_type = None , subkey_length = None , expire_date = None , use_passphrase = False , user = None , gnupghome = None ) : ret = { 'res' : True , 'fingerprint' : '' , 'message' : '' } create_params = { 'key_type' : key_type , 'key_length' : key_length , 'name_real' : name_real , 'name_comment' : name_comment } gpg = _create_gpg ( user , gnupghome ) if name_email : create_params [ 'name_email' ] = name_email if subkey_type : create_params [ 'subkey_type' ] = subkey_type if subkey_length : create_params [ 'subkey_length' ] = subkey_length if expire_date : create_params [ 'expire_date' ] = expire_date if use_passphrase : gpg_passphrase = __salt__ [ 'pillar.get' ] ( 'gpg_passphrase' ) if ( not gpg_passphrase ) : ret [ 'res' ] = False ret [ 'message' ] = 'gpg_passphrase not available in pillar.' return ret else : create_params [ 'passphrase' ] = gpg_passphrase input_data = gpg . gen_key_input ( ** create_params ) key = gpg . gen_key ( input_data ) if key . fingerprint : ret [ 'fingerprint' ] = key . fingerprint ret [ 'message' ] = 'GPG key pair successfully generated.' else : ret [ 'res' ] = False ret [ 'message' ] = 'Unable to generate GPG key pair.' return ret
creates a master key .