public class ASYM_ENCRYPT extends EncryptBase
NAKACK2
, so that most important
headers are encrypted as well, to prevent replay attacks.AUTH
.EncryptBase.Decrypter
Modifier and Type | Field and Description |
---|---|
protected Cipher |
asym_cipher |
protected boolean |
change_key_on_leave |
protected static short |
GMS_ID |
protected boolean |
is_key_server |
protected KeyPair |
key_pair |
protected Address |
key_server_addr |
protected long |
last_key_request |
protected boolean |
queue_up_msgs |
protected BlockingQueue<Message> |
up_queue |
asym_algorithm, asym_keylength, cipher_pool_size, decoding_ciphers, DEFAULT_SYM_ALGO, encoding_ciphers, encrypt_entire_message, key_map, local_addr, provider, secret_key, sign_msgs, sym_algorithm, sym_keylength, sym_version, use_adler, view
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
ASYM_ENCRYPT() |
Modifier and Type | Method and Description |
---|---|
Cipher |
asymCipher() |
protected void |
becomeKeyServer(Address tmpKeyServer,
boolean left_mbrs) |
protected SecretKey |
createSecretKey()
Initialise the symmetric key if none is supplied in a keystore
|
protected SecretKeySpec |
decodeKey(byte[] encodedKey) |
Object |
down(Event evt)
An event is to be sent down the stack.
|
protected void |
drainUpQueue() |
protected byte[] |
encryptSecretKey(SecretKey secret_key,
PublicKey public_key)
Encrypts the current secret key with the requester's public key (the requester will decrypt it with its private key)
|
protected PublicKey |
generatePubKey(byte[] encodedKey)
Used to reconstitute public key sent in byte form from peer
|
protected void |
handleNewKeyServer(Address newKeyServer,
boolean merge_view,
boolean left_mbrs)
If the keyserver changed, send a request for the secret key to the keyserver
|
protected void |
handleSecretKeyRequest(Message msg) |
protected void |
handleSecretKeyResponse(Message msg,
byte[] key_version) |
protected void |
handleUnknownVersion()
Called when the version shipped in the header can't be found
|
protected Object |
handleUpEvent(Message msg,
EncryptHeader hdr) |
protected void |
handleView(View v) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected void |
initKeyPair()
Generates the public/private key pair from the init params
|
KeyPair |
keyPair() |
Address |
keyServerAddr() |
ASYM_ENCRYPT |
keyServerAddr(Address key_srv) |
protected boolean |
keyServerChanged(Address newKeyServer) |
int |
numQueuedMessages() |
protected boolean |
process(Message msg)
Whether or not to process this received message
|
void |
sendKeyRequest() |
protected void |
sendKeyRequest(Address key_server)
send client's public key to server and request server's public key
|
protected void |
sendSecretKey(SecretKey secret_key,
PublicKey public_key,
Address source) |
protected void |
setKeys(SecretKey key,
byte[] version) |
protected static boolean |
skip(Message msg)
Checks if a message needs to be encrypted/decrypted.
|
void |
stop()
This method is called on a
Channel.disconnect() . |
Object |
up(Event evt)
An event was received from the layer below.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
_decrypt, adler, adler, asymAlgorithm, asymAlgorithm, asymKeylength, asymKeylength, code, computeChecksum, createChecksummer, createCipher, decryptChecksum, decryptMessage, encryptAndSend, encryptChecksum, encryptEntireMessage, encryptEntireMessage, getAlgorithm, handleEncryptedMessage, handleUpMessage, initSymCiphers, inView, localAddress, secretKey, secretKey, signMessages, signMessages, symAlgorithm, symAlgorithm, symKeylength, symKeylength, symVersion, symVersion, version
accept, afterCreationHook, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled
protected static final short GMS_ID
protected boolean change_key_on_leave
protected volatile Address key_server_addr
protected volatile boolean is_key_server
protected KeyPair key_pair
protected Cipher asym_cipher
protected volatile boolean queue_up_msgs
protected final BlockingQueue<Message> up_queue
protected volatile long last_key_request
public KeyPair keyPair()
public Cipher asymCipher()
public Address keyServerAddr()
public ASYM_ENCRYPT keyServerAddr(Address key_srv)
public int numQueuedMessages()
public void sendKeyRequest()
public void init() throws Exception
Protocol
init
in class EncryptBase
Exception
- Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exceptionpublic void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushedpublic Object down(Event evt)
Protocol
down_prot.down()
. In case of a GET_ADDRESS event (which tries to
retrieve the stack's address from one of the bottom layers), the layer may need to send
a new response event back up the stack using up_prot.up()
.down
in class EncryptBase
public Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.up
in class EncryptBase
public void up(MessageBatch batch)
Protocol
MessageBatch
. 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(org.jgroups.Message)
), and - if true - calls Protocol.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.getMatchingMessages(short,boolean)
), 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.up
in class EncryptBase
batch
- The message batchprotected static boolean skip(Message msg)
AUTH
protected Object handleUpEvent(Message msg, EncryptHeader hdr)
handleUpEvent
in class EncryptBase
protected boolean process(Message msg)
EncryptBase
process
in class EncryptBase
protected void handleSecretKeyRequest(Message msg)
protected void handleSecretKeyResponse(Message msg, byte[] key_version)
protected SecretKey createSecretKey() throws Exception
Exception
protected void initKeyPair() throws Exception
Exception
protected void handleView(View v)
handleView
in class EncryptBase
protected void becomeKeyServer(Address tmpKeyServer, boolean left_mbrs)
protected void handleNewKeyServer(Address newKeyServer, boolean merge_view, boolean left_mbrs)
protected boolean keyServerChanged(Address newKeyServer)
protected void sendSecretKey(SecretKey secret_key, PublicKey public_key, Address source) throws Exception
Exception
protected byte[] encryptSecretKey(SecretKey secret_key, PublicKey public_key) throws Exception
Exception
protected void sendKeyRequest(Address key_server)
protected SecretKeySpec decodeKey(byte[] encodedKey) throws Exception
Exception
protected void drainUpQueue()
protected void handleUnknownVersion()
EncryptBase
handleUnknownVersion
in class EncryptBase
protected PublicKey generatePubKey(byte[] encodedKey)
Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.