Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-26613

The logic of the method incrementIV in Encryption class has problem

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      public static void incrementIv(byte[] iv, int v) {
          int length = iv.length;
          boolean carry = true;
          // TODO: Optimize for v > 1, e.g. 16, 32
          do {
            for (int i = 0; i < length; i++) {
              if (carry) {
                iv[i] = (byte) ((iv[i] + 1) & 0xFF);
                carry = 0 == iv[i];
              } else {
                break;
              }
            }
            v--;
          } while (v > 0);
        }
      

      The carry flag is outside the while loop and the inner loop check the carry value is true, so that when it was set to false, it will make the rest iterations busy spinning.
      And the logic becomes whatever the v is, the IV will be incremented by (1 or 2). As the description in todo, this function should support increment value > 1. So that this is not what we expect I think.

      Attachments

        Issue Links

          Activity

            People

              xytss123 Yutong Xiao
              xytss123 Yutong Xiao
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: