You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by "Duo Zhang (Jira)" <ji...@apache.org> on 2021/12/22 16:18:00 UTC

[jira] [Resolved] (HBASE-26613) The logic of the method incrementIV in Encryption class has problem

     [ https://issues.apache.org/jira/browse/HBASE-26613?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Duo Zhang resolved HBASE-26613.
-------------------------------
    Fix Version/s: 2.5.0
                   3.0.0-alpha-3
                   2.4.10
     Hadoop Flags: Reviewed
       Resolution: Fixed

Pushed to branch-2.4+.

Thanks [~xytss123]!

> The logic of the method incrementIV in Encryption class has problem
> -------------------------------------------------------------------
>
>                 Key: HBASE-26613
>                 URL: https://issues.apache.org/jira/browse/HBASE-26613
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Yutong Xiao
>            Assignee: Yutong Xiao
>            Priority: Major
>             Fix For: 2.5.0, 3.0.0-alpha-3, 2.4.10
>
>
> {code:java}
> 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);
>   }
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)