Esempio n. 1
0
def store_public_key( config, key_type, object_id, key_data ):
   """
   Store a public key for a given object of a given type.
   """
   key_data_pem = key_data.exportKey()
   key_path = conf.object_key_path( config, key_type, object_id, public=True )
   return write_key( key_path, key_data_pem )
Esempio n. 2
0
def store_public_key(config, key_type, object_id, key_data):
    """
    Store a public key for a given object of a given type.
    """
    key_data_pem = key_data.exportKey()
    key_path = conf.object_key_path(config, key_type, object_id, public=True)
    return write_key(key_path, key_data_pem)
Esempio n. 3
0
def store_private_key(config, key_type, object_id, key_data, overwrite=False):
    """
    Store a private key for a given object of a given type.
    """
    key_data_pem = key_data.exportKey()
    assert key_data.has_private(), "Not a private key"
    key_path = conf.object_key_path(config, key_type, object_id, public=False)
    return write_key(key_path, key_data_pem, overwrite=overwrite)
Esempio n. 4
0
def store_private_key( config, key_type, object_id, key_data, overwrite=False ):
   """
   Store a private key for a given object of a given type.
   """
   key_data_pem = key_data.exportKey()
   assert key_data.has_private(), "Not a private key"
   key_path = conf.object_key_path( config, key_type, object_id, public=False )
   return write_key( key_path, key_data_pem, overwrite=overwrite )
Esempio n. 5
0
def warn_key_change(config):
    """
    return a warning string the user that the MS's public key has changed, and exit.
    """
    return """
SECURE VERIFICATION FAILURE!

It's possible that someone is impersonating your Syndicate, to get you to leak sensitive data!
If you are certain this is not the case, you should remove the offending public key.

Offending public key path:  %s
""" % conf.object_key_path(config, "syndicate", make_ms_url(config['syndicate_host'], config['syndicate_port'], config['no_tls']).strip("https://"), public=True)
Esempio n. 6
0
def warn_key_change(config):
    """
    return a warning string the user that the MS's public key has changed, and exit.
    """
    return """
SECURE VERIFICATION FAILURE!

It's possible that someone is impersonating your Syndicate, to get you to leak sensitive data!
If you are certain this is not the case, you should remove the offending public key.

Offending public key path:  %s
""" % conf.object_key_path(
        config,
        "syndicate",
        make_ms_url(config['syndicate_host'], config['syndicate_port'],
                    config['no_tls']).strip("https://"),
        public=True)
Esempio n. 7
0
def erase_key(config, key_type, object_id, public=False):
    """
    Erase a key for a given object of a given type.
    """
    key_path = conf.object_key_path(config, key_type, object_id, public=public)
    return secure_erase_key(key_path)
Esempio n. 8
0
def load_private_key(config, key_type, object_id):
    """
    Load a private key of the given type for the given object.
    """
    key_path = conf.object_key_path(config, key_type, object_id, public=False)
    return read_private_key(key_path)
Esempio n. 9
0
def load_public_key(config, key_type, object_id):
    """
    Load a public key of the given type for the given object.
    """
    key_path = conf.object_key_path(config, key_type, object_id, public=True)
    return read_public_key(key_path)
Esempio n. 10
0
def erase_key( config, key_type, object_id, public=False ):
   """
   Erase a key for a given object of a given type.
   """
   key_path = conf.object_key_path( config, key_type, object_id, public=public )
   return secure_erase_key( key_path )
Esempio n. 11
0
def load_private_key( config, key_type, object_id ):
   """
   Load a private key of the given type for the given object.
   """
   key_path = conf.object_key_path( config, key_type, object_id, public=False )
   return read_private_key( key_path )
Esempio n. 12
0
def load_public_key( config, key_type, object_id ):
   """
   Load a public key of the given type for the given object.
   """
   key_path = conf.object_key_path( config, key_type, object_id, public=True )
   return read_public_key( key_path )
Esempio n. 13
0
def store_private_key( config, key_type, object_id, key_data ):
   """
   Store a private key for a given object of a given type.
   """
   key_path = conf.object_key_path( config, key_type, object_id, public=False )
   return write_key( key_path, key_data )