You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/04 15:49:49 UTC

[commons-codec] 01/02: Fix PMD violation

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit 94f2d80288335fdbb1b42a06fb5a98896ba43aac
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 4 11:44:52 2023 -0400

    Fix PMD violation
---
 .../org/apache/commons/codec/digest/Blake3.java    | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/digest/Blake3.java b/src/main/java/org/apache/commons/codec/digest/Blake3.java
index 24956a65..b0c8fd5c 100644
--- a/src/main/java/org/apache/commons/codec/digest/Blake3.java
+++ b/src/main/java/org/apache/commons/codec/digest/Blake3.java
@@ -74,6 +74,7 @@ import java.util.Objects;
  * @since 1.16
  */
 public final class Blake3 {
+
     private static final int BLOCK_LEN = 64;
     private static final int BLOCK_INTS = BLOCK_LEN / Integer.BYTES;
     private static final int KEY_LEN = 32;
@@ -95,6 +96,19 @@ public final class Blake3 {
     private static final int DERIVE_KEY_CONTEXT = 1 << 5;
     private static final int DERIVE_KEY_MATERIAL = 1 << 6;
 
+    /**
+     * Pre-permuted for all 7 rounds; the second row (2,6,3,...) indicates the base permutation.
+     */
+    private static final byte[][] MSG_SCHEDULE = {
+            { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
+            { 2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8 },
+            { 3, 4, 10, 12, 13, 2, 7, 14, 6, 5, 9, 0, 11, 15, 8, 1 },
+            { 10, 7, 12, 9, 14, 3, 13, 15, 4, 0, 11, 2, 5, 8, 1, 6 },
+            { 12, 13, 9, 11, 15, 10, 14, 8, 7, 2, 5, 3, 0, 1, 6, 4 },
+            { 9, 14, 11, 5, 8, 12, 15, 1, 13, 3, 0, 10, 2, 6, 4, 7 },
+            { 11, 15, 5, 0, 1, 9, 8, 6, 14, 10, 2, 12, 3, 4, 7, 13 }
+    };
+
     private final EngineState engineState;
 
     private Blake3(final int[] key, final int flags) {
@@ -307,19 +321,6 @@ public final class Blake3 {
         g(state, 3, 4, 9, 14, msg[schedule[14]], msg[schedule[15]]);
     }
 
-    /**
-     * Pre-permuted for all 7 rounds; the second row (2,6,3,...) indicates the base permutation.
-     */
-    private static final byte[][] MSG_SCHEDULE = {
-            { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
-            { 2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8 },
-            { 3, 4, 10, 12, 13, 2, 7, 14, 6, 5, 9, 0, 11, 15, 8, 1 },
-            { 10, 7, 12, 9, 14, 3, 13, 15, 4, 0, 11, 2, 5, 8, 1, 6 },
-            { 12, 13, 9, 11, 15, 10, 14, 8, 7, 2, 5, 3, 0, 1, 6, 4 },
-            { 9, 14, 11, 5, 8, 12, 15, 1, 13, 3, 0, 10, 2, 6, 4, 7 },
-            { 11, 15, 5, 0, 1, 9, 8, 6, 14, 10, 2, 12, 3, 4, 7, 13 }
-    };
-
     private static int[] compress(
             final int[] chainingValue, final int[] blockWords, final int blockLength, final long counter,
             final int flags) {