java.lang.Object
net.i2p.router.KeyManager
Manages all router cryptographic key pairs including persistent storage of router keys and in-memory management of LeaseSet keys for secure communications.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classRead/Write the 4 files in keyBackup/ As of 0.9.4 this is run on-demand only, there's no need to periodically sync.Field Summary
Modifier and TypeFieldDescriptionprivate final RouterContextThe router context.private final Map<Hash, LeaseSetKeys> The lease set keys, by destination hash.private final LogLogger for the key manager.private PrivateKeyOur router's private key.private PublicKeyOur router's public key.private SigningPrivateKeyOur router's signing private key.private SigningPublicKeyOur router's signing public key.static final StringDefault keydir.static final StringPath to the private enc key file.static final StringPath to the private signing key file.static final StringPath to the public enc key file.static final StringPath to the public signing key file.static final StringProperty key for keydir.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptiongetKeys(Destination dest) The keys registered for a destination.Client session lease set keys.Router key.Router key.Router key.Router key.private voidQueue a background job to synchronize keys to disk.voidregisterKeys(Destination dest, SigningPrivateKey leaseRevocationPrivateKey, List<PrivateKey> endpointDecryptionKeys) Client with multiple keys.voidregisterKeys(Destination dest, SigningPrivateKey leaseRevocationPrivateKey, PrivateKey endpointDecryptionKey) Client with a single key.voidsetKeys(PublicKey key1, PrivateKey key2, SigningPublicKey key3, SigningPrivateKey key4) Configure the router's keys.unregisterKeys(Destination dest) Unregister keys for a destination, removing them from memory.
Field Details
_log
Logger for the key manager._context
The router context._privateKey
Our router's private key._publicKey
Our router's public key._signingPrivateKey
Our router's signing private key._signingPublicKey
Our router's signing public key._leaseSetKeys
The lease set keys, by destination hash.PROP_KEYDIR
DEFAULT_KEYDIR
KEYFILE_PRIVATE_ENC
Path to the private enc key file.- See Also:
KEYFILE_PUBLIC_ENC
Path to the public enc key file.- See Also:
KEYFILE_PRIVATE_SIGNING
Path to the private signing key file.- See Also:
KEYFILE_PUBLIC_SIGNING
Path to the public signing key file.- See Also:
Constructor Details
KeyManager
Create a key manager.- Parameters:
context- the router context
Method Details
setKeys
Configure the router's keys.- Parameters:
key1- the router's public encryption key, published to peers and clientskey2- the router's private encryption keykey3- the router's signing public key, which certifies the router's identitykey4- the router's signing private key
getPrivateKey
Router key.- Returns:
- will be null on error or before startup() or
setKeys(PublicKey, PrivateKey, SigningPublicKey, SigningPrivateKey)is called
getPublicKey
Router key.- Returns:
- will be null on error or before startup() or setKeys() is called
getSigningPrivateKey
Router key.- Returns:
- will be null on error or before startup() or setKeys() is called
getSigningPublicKey
Router key.- Returns:
- will be null on error or before startup() or setKeys() is called
registerKeys
public void registerKeys(Destination dest, SigningPrivateKey leaseRevocationPrivateKey, PrivateKey endpointDecryptionKey) Client with a single key.- Parameters:
dest- the destination these keys belong toleaseRevocationPrivateKey- unused, may be nullendpointDecryptionKey- the key that decrypts transport messages to the destination
registerKeys
public void registerKeys(Destination dest, SigningPrivateKey leaseRevocationPrivateKey, List<PrivateKey> endpointDecryptionKeys) Client with multiple keys.- Parameters:
dest- the destination these keys belong toleaseRevocationPrivateKey- unused, may be nullendpointDecryptionKeys- the keys that decrypt transport messages to the destination
queueWrite
private void queueWrite()Queue a background job to synchronize keys to disk. This method is called internally after key modifications.unregisterKeys
Unregister keys for a destination, removing them from memory. Does not delete backup files from disk.- Parameters:
dest- the destination whose keys should be unregistered- Returns:
- the LeaseSetKeys that were removed, or null if not found
getKeys
The keys registered for a destination.- Parameters:
dest- the destination to look up- Returns:
- the LeaseSetKeys for the destination, or null if not found
getKeys
Client session lease set keys.- Parameters:
dest- the hash of the destination to look up- Returns:
- the LeaseSetKeys registered for the destination, or null if there are none