Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding IV support to SYM_ENCRYPT and ASYM_ENCRYPT protocols (JGRP-2386). #441

Merged
merged 1 commit into from Oct 4, 2019

Conversation

nsawadsky
Copy link

This change allows JGroups to support symmetric encryption algorithms that require an initialization vector (IV). An important example is "AES/CBC/PKCS5Padding" which uses the CBC cipher mode.

The main changes that were required are as follows:

  • Added a sym_iv_length field to Encrypt. This must be set to a non-zero value when using a cipher mode that requires an IV.
  • Added an iv field to the EncryptHeader (which may be null if the cipher mode does not require an IV).
  • Since the IV is passed when the Cipher is initialized and the IV is created per-message, cipher initialization is now deferred until the message is being encrypted/decrypted.
  • Since the key is passed to the Cipher.init() method and init() is deferred, we now store the Key rather than the Cipher in the key_map field of Encrypt.
  • DH_KEY_EXCHANGE is mostly unchanged. So it does not support using an IV-based cipher to encrypt the shared symmetric key. This seems okay as a fresh DH session key is generated for each key exchange, so the ciphertext will always be different. This saves us having to add an iv field to the DhHeader.
  • All the SYM_ENCRYPT and ASYM_ENCRYPT tests have been extended with subclasses that run the same tests using "AES/CBC/PKCS5Padding".

@belaban
Copy link
Owner

belaban commented Oct 4, 2019

LGTM. The 'encrypt' task passed fine, now running the entire testsuite... stay tuned.

@belaban
Copy link
Owner

belaban commented Oct 4, 2019

@nsawadsky Do you think a small addition to the manual might make sense?

@belaban belaban merged commit 59690b8 into belaban:master Oct 4, 2019
@belaban
Copy link
Owner

belaban commented Oct 4, 2019

@nsawadsky Thanks for your contribution!

@nsawadsky
Copy link
Author

Thanks Bela! I will open another pull request for the manual updates.

@nsawadsky nsawadsky deleted the iv-support branch October 4, 2019 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants