Class DH_KEY_EXCHANGE
- All Implemented Interfaces:
Lifecycle
Diffie-Hellman is used between a member and a key server (the coordinator) to obtain a session key (only known to the key server and the joiner) which is used by the key server to encrypt the shared secret symmetric (group) key and by the requester to decrypt the group key it gets in the response of the key server.
Note that this implementation is not immune against man-in-the-middle attacks.
- Since:
- 4.0.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PublicKeyThe public key used for the Diffie-Hellman key exchange to obtain the session key (used to encrypt the keyserver's secret key)protected static final KeyFactoryprotected KeyAgreementDiffie-Hellman protocol engineprotected static final KeyPairGeneratorprotected longTime (ms) when the last key request was sent, prevents too many requestsprotected Stringprotected intprotected longFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfetchSecretKeyFrom(Address target) Needs to fetch the secret key from a given destination (usually the key server).Returns the address of the server, e.g.protected voidhandle(DH_KEY_EXCHANGE.DhHeader hdr, Address sender) protected voidhandleSecretKeyRequest(PublicKey dh_public_key, Address sender) protected voidhandleSecretKeyResponse(PublicKey dh_public_key, byte[] encrypted_secret_key, byte[] version, Address sender) protected SecretKeyhash(byte[] key) voidinit()Called after a protocol has been created and before the protocol is started.protected static StringA single message was received.voidup(MessageBatch batch) Sends up a multiple messages in aMessageBatch.Methods inherited from class org.jgroups.protocols.KeyExchange
down, findProtocolAbove, getSecretKeyFromAbove, handleView, requiredUpServices, setSecretKeyAboveMethods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, resetStatistics, resetStats, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop, toString, up
-
Field Details
-
secret_key_algorithm
-
secret_key_length
protected int secret_key_length -
timeout
protected long timeout -
key_agreement
Diffie-Hellman protocol engine -
dh_key
The public key used for the Diffie-Hellman key exchange to obtain the session key (used to encrypt the keyserver's secret key) -
last_key_request
protected long last_key_requestTime (ms) when the last key request was sent, prevents too many requests -
key_pair_gen
-
dh_key_factory
-
-
Constructor Details
-
DH_KEY_EXCHANGE
public DH_KEY_EXCHANGE()
-
-
Method Details
-
init
Description copied from class:ProtocolCalled after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent. -
fetchSecretKeyFrom
Description copied from class:KeyExchangeNeeds to fetch the secret key from a given destination (usually the key server). When received, the secret key (and version) needs to be installed in a protocol above usingKeyExchange.setSecretKeyAbove(Tuple).- Specified by:
fetchSecretKeyFromin classKeyExchange- Parameters:
target- The member from which to fetch the secret key- Throws:
NoSuchAlgorithmExceptionInvalidKeyException
-
getServerLocation
Description copied from class:KeyExchangeReturns the address of the server, e.g. server socket (if any)- Specified by:
getServerLocationin classKeyExchange
-
up
Description copied from class:ProtocolA single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up. -
up
Description copied from class:ProtocolSends up a multiple messages in aMessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.The default processing below sends messages up the stack individually, based on a matching criteria (calling
Protocol.accept(Message)), and - if true - callsProtocol.up(org.jgroups.Event)for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done. -
handle
-
handleSecretKeyRequest
- Throws:
Exception
-
handleSecretKeyResponse
protected void handleSecretKeyResponse(PublicKey dh_public_key, byte[] encrypted_secret_key, byte[] version, Address sender) throws Exception - Throws:
Exception
-
hash
- Throws:
Exception
-
print16
-