Uploaded image for project: 'Commons JCS'
  1. Commons JCS
  2. JCS-230

UDPDiscoveryReceiver with EncryptingSerializer fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • jcs-3.1
    • jcs-3.2
    • TCP Lateral Cache
    • None

    Description

      Version jcs-3.1 introduced an option to use EncryptingSerializer instead of StandardSerializer.

      However when EncryptingSerializer  is configured for LTCP by :

      jcs.auxiliary.LTCP.serializer=org.apache.commons.jcs3.utils.serialization.EncryptingSerializer

      UDPDiscoveryReceiver throws an error when trying to serialize received message ( error bellow).

       

      Root cause of this error:

      calling deSerialize method in line 265 :

      serializer.deSerialize(byteBuffer.array(), null);

      byteBuffer.array() - returns byte[] which size is the full capacity of ByteBuffer not the size of recived message. 

       

       

      Apr 04, 2022 2:16:19 PM org.apache.commons.jcs3.utils.discovery.UDPDiscoveryReceiver 
      SEVERE: Error receiving multicast packet
      java.io.IOException: Error while decrypting
          at org.apache.commons.jcs3.utils.serialization.EncryptingSerializer.decrypt(EncryptingSerializer.java:209)
          at org.apache.commons.jcs3.utils.serialization.EncryptingSerializer.deSerialize(EncryptingSerializer.java:247)
          at org.apache.commons.jcs3.utils.discovery.UDPDiscoveryReceiver.run(UDPDiscoveryReceiver.java:265)
          at java.base/java.lang.Thread.run(Thread.java:834)
      Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
          at java.base/com.sun.crypto.provider.CipherCore.prepareInputBuffer(CipherCore.java:1005)
          at java.base/com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:848)
          at java.base/com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
          at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2202)
          at org.apache.commons.jcs3.utils.serialization.EncryptingSerializer.decrypt(EncryptingSerializer.java:203)
          ... 3 more

       

       

      Solution attached in patch.diff file.

      Attachments

        1. patch.diff
          1 kB
          Dorota Oeknigk-Urbanska
        2. unitTests.patch.diff
          5 kB
          Dorota Oeknigk-Urbanska

        Issue Links

          Activity

            People

              tv Thomas Vandahl
              dorkau Dorota Oeknigk-Urbanska
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: