Skip to content

Commit 4a90a4b

Browse files
committed
Merge branch 'akbar1214-fix-message-drop-issue'
2 parents 4a1d606 + a86f1a1 commit 4a90a4b

6 files changed

Lines changed: 11 additions & 30 deletions

File tree

src/org/jgroups/protocols/ASYM_ENCRYPT.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,12 @@ protected void initKeyPair() throws Exception {
551551

552552
protected void createNewKey(String message) {
553553
try {
554+
// cache the previous group key before overwriting it, so that messages still in flight (encrypted with
555+
// the old key) can be decrypted after the rotation
556+
cacheGroupKey(secret_key, sym_version);
554557
this.secret_key=createSecretKey();
555558
initSymCiphers(sym_algorithm, secret_key);
556559
log.debug("%s: created new group key (version: %s) %s", local_addr, Util.byteArrayToHexString(sym_version), message);
557-
cacheGroupKey(sym_version);
558560
}
559561
catch(Exception ex) {
560562
log.error("%s: failed creating group key and initializing ciphers: %s", local_addr, ex);
@@ -570,17 +572,19 @@ protected synchronized void installSharedGroupKey(Address sender, SecretKey key,
570572
}
571573
log.debug("%s: installing group key received from %s (version: %s)",
572574
local_addr, sender != null? sender : "key exchange protocol", Util.byteArrayToHexString(version));
575+
// cache the previous group key before overwriting it, so that messages still in flight (encrypted with
576+
// the old key) can be decrypted after the key change
577+
cacheGroupKey(secret_key, sym_version);
573578
secret_key=key;
574579
initSymCiphers(sym_algorithm, key);
575580
sym_version=version;
576-
cacheGroupKey(version);
577581
}
578582

579-
/** Cache the current shared key to decrypt messages encrypted with the old shared group key */
580-
protected void cacheGroupKey(byte[] version) throws Exception {
581-
// put the previous key into the map
582-
if(secret_key != null)
583-
key_map.putIfAbsent(new AsciiString(version), secret_key);
583+
/** Caches a group key (key, version) so that messages encrypted with a previous group key can still be decrypted
584+
* after a key rotation */
585+
protected void cacheGroupKey(Key key, byte[] version) {
586+
if(key != null && version != null)
587+
key_map.putIfAbsent(new AsciiString(version), key);
584588
}
585589

586590
/** Encrypts the current secret key with the requester's public key (the requester will decrypt it with its private key) */

tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_LeaveTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public class ASYM_ENCRYPT_LeaveTest extends BaseLeaveTest {
2929
super.destroy();
3030
}
3131

32-
/** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads,
33-
* which makes the testsuite fail!!! */
34-
public void dummy() {}
35-
36-
3732
/** Creates a channel with a config similar to ./conf/asym-ssl.xml */
3833
protected JChannel create(String name) throws Exception {
3934
return new JChannel(

tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_Test.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ public class ASYM_ENCRYPT_Test extends EncryptTest {
4848
super.destroy();
4949
}
5050

51-
/** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads,
52-
* which makes the testsuite fail!!! */
53-
public void dummy() {}
54-
5551

5652

5753
/** Verifies that a non-member (non-coord) cannot send a JOIN-RSP to a member */

tests/junit-functional/org/jgroups/protocols/ASYM_ENCRYPT_TestKeyExchange.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ public class ASYM_ENCRYPT_TestKeyExchange extends ASYM_ENCRYPT_Test {
1313

1414
@Override protected boolean useExternalKeyExchange() {return true;}
1515

16-
/** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads,
17-
* which makes the testsuite fail!!! */
18-
public void dummy() {}
19-
20-
2116
@AfterMethod
2217
protected void destroy() {
2318
super.destroy();

tests/junit-functional/org/jgroups/protocols/SYM_ENCRYPT_Test.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ public class SYM_ENCRYPT_Test extends EncryptTest {
3333
super.destroy();
3434
}
3535

36-
/** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads,
37-
* which makes the testsuite fail!!! */
38-
public void dummy() {}
39-
40-
4136
@Override protected JChannel create(String name, Consumer<List<Protocol>> c) throws Exception {
4237
// Verify that the SecureRandom instance can be customized
4338
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");

tests/junit-functional/org/jgroups/tests/LeaveTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ public class LeaveTest extends BaseLeaveTest {
2222
super.destroy();
2323
}
2424

25-
/** For some obscure TestNG reasons, this method is needed. Remove it and all tests are executed in separate threads,
26-
* which makes the testsuite fail!!! */
27-
public void dummy() {}
28-
2925
protected JChannel create(String name) throws Exception {
3026
return new JChannel(
3127
new SHARED_LOOPBACK(),

0 commit comments

Comments
 (0)