Apache9 commented on a change in pull request #3968:
URL: https://github.com/apache/hbase/pull/3968#discussion_r772790543
##########
File path:
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/Encryption.java
##########
@@ -640,20 +640,17 @@ public static void incrementIv(byte[] iv) {
}
public static void incrementIv(byte[] iv, int v) {
+ // v should be > 0
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;
- }
+ int sum = 0;
+ for (int i = 0; i < length; i++) {
+ if (v <= 0) {
+ break;
}
- v--;
- } while (v > 0);
+ sum = v + iv[i];
Review comment:
What if iv[i] is negative here? In a first thought I think we should
consider each byte as unsigned?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]