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:48 UTC

[commons-codec] branch master updated (8e1652ab -> a79f0464)

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

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


    from 8e1652ab Update Javadoc for Java 8
     new 94f2d802 Fix PMD violation
     new a79f0464 Fix PMD violations

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/commons/codec/digest/Blake3.java    | 51 +++++++++++-----------
 1 file changed, 26 insertions(+), 25 deletions(-)


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

Posted by gg...@apache.org.
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) {


[commons-codec] 02/02: Fix PMD violations

Posted by gg...@apache.org.
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 a79f046459b8a2061a4d38f53e99418af5afa36a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 4 11:49:38 2023 -0400

    Fix PMD violations
---
 .../org/apache/commons/codec/digest/Blake3.java    | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 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 b0c8fd5c..7af24a4e 100644
--- a/src/main/java/org/apache/commons/codec/digest/Blake3.java
+++ b/src/main/java/org/apache/commons/codec/digest/Blake3.java
@@ -364,7 +364,7 @@ public final class Blake3 {
         private final int blockLength;
         private final int flags;
 
-        Output(
+        private Output(
                 final int[] inputChainingValue, final int[] blockWords, final long counter, final int blockLength,
                 final int flags) {
             this.inputChainingValue = inputChainingValue;
@@ -374,12 +374,12 @@ public final class Blake3 {
             this.flags = flags;
         }
 
-        int[] chainingValue() {
+        private int[] chainingValue() {
             return Arrays
                     .copyOf(compress(inputChainingValue, blockWords, blockLength, counter, flags), CHAINING_VALUE_INTS);
         }
 
-        void rootOutputBytes(final byte[] out, int offset, int length) {
+        private void rootOutputBytes(final byte[] out, int offset, int length) {
             int outputBlockCounter = 0;
             while (length > 0) {
                 int chunkLength = Math.min(OUT_LEN * 2, length);
@@ -406,21 +406,21 @@ public final class Blake3 {
         private int blockLength;
         private int blocksCompressed;
 
-        ChunkState(final int[] key, final long chunkCounter, final int flags) {
+        private ChunkState(final int[] key, final long chunkCounter, final int flags) {
             chainingValue = key;
             this.chunkCounter = chunkCounter;
             this.flags = flags;
         }
 
-        int length() {
+        private int length() {
             return BLOCK_LEN * blocksCompressed + blockLength;
         }
 
-        int startFlag() {
+        private int startFlag() {
             return blocksCompressed == 0 ? CHUNK_START : 0;
         }
 
-        void update(final byte[] input, int offset, int length) {
+        private void update(final byte[] input, int offset, int length) {
             while (length > 0) {
                 if (blockLength == BLOCK_LEN) {
                     // If the block buffer is full, compress it and clear it. More
@@ -443,7 +443,7 @@ public final class Blake3 {
             }
         }
 
-        Output output() {
+        private Output output() {
             final int[] blockWords = unpackInts(block, BLOCK_INTS);
             final int outputFlags = flags | startFlag() | CHUNK_END;
             return new Output(chainingValue, blockWords, chunkCounter, blockLength, outputFlags);
@@ -461,13 +461,13 @@ public final class Blake3 {
         private int stackLen;
         private ChunkState state;
 
-        EngineState(final int[] key, final int flags) {
+        private EngineState(final int[] key, final int flags) {
             this.key = key;
             this.flags = flags;
             state = new ChunkState(key, 0, flags);
         }
 
-        void inputData(final byte[] in, int offset, int length) {
+        private void inputData(final byte[] in, int offset, int length) {
             while (length > 0) {
                 // If the current chunk is complete, finalize it and reset the
                 // chunk state. More input is coming, so this chunk is not ROOT.
@@ -487,7 +487,7 @@ public final class Blake3 {
             }
         }
 
-        void outputHash(final byte[] out, final int offset, final int length) {
+        private void outputHash(final byte[] out, final int offset, final int length) {
             // Starting with the Output from the current chunk, compute all the
             // parent chaining values along the right edge of the tree, until we
             // have the root Output.
@@ -500,7 +500,7 @@ public final class Blake3 {
             output.rootOutputBytes(out, offset, length);
         }
 
-        void reset() {
+        private void reset() {
             stackLen = 0;
             Arrays.fill(cvStack, null);
             state = new ChunkState(key, 0, flags);