From d1450169fbddaa567f2fb50d4ed870a060875dc9 Mon Sep 17 00:00:00 2001 From: David Hook Date: Mon, 22 Feb 2021 13:18:52 +1100 Subject: [PATCH] early JVM compatibility, minor refactoring --- .../bouncycastle/crypto/digests/Kangaroo.java | 18 +++++++++--------- .../crypto/test/RegressionTest.java | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/bouncycastle/crypto/digests/Kangaroo.java b/core/src/main/java/org/bouncycastle/crypto/digests/Kangaroo.java index f9d5610e1a..adf68c342d 100644 --- a/core/src/main/java/org/bouncycastle/crypto/digests/Kangaroo.java +++ b/core/src/main/java/org/bouncycastle/crypto/digests/Kangaroo.java @@ -1,16 +1,16 @@ package org.bouncycastle.crypto.digests; import org.bouncycastle.crypto.CipherParameters; -import org.bouncycastle.crypto.Digest; +import org.bouncycastle.crypto.ExtendedDigest; import org.bouncycastle.crypto.Xof; import org.bouncycastle.util.Arrays; +import org.bouncycastle.util.Bytes; import org.bouncycastle.util.Pack; /** * Kangaroo. */ -public abstract class Kangaroo - implements Digest +public final class Kangaroo { /** * Default digest length. @@ -42,7 +42,7 @@ public KangarooTwelve(final int pLength) public String getAlgorithmName() { - return getClass().getSimpleName(); + return "KangarooTwelve"; } } @@ -71,7 +71,7 @@ public MarsupilamiFourteen(final int pLength) public String getAlgorithmName() { - return getClass().getSimpleName(); + return "MarsupilamiFourteen"; } } @@ -171,8 +171,8 @@ public KangarooParameters build() /** * The Kangaroo Base. */ - public abstract static class KangarooBase - implements Digest, Xof + abstract static class KangarooBase + implements ExtendedDigest, Xof { /** * Block Size. @@ -561,7 +561,7 @@ private static byte[] lengthEncode(final long strLen) if (v != 0) { n = 1; - while ((v >>= Byte.SIZE) != 0) + while ((v >>= Bytes.SIZE) != 0) { n++; } @@ -574,7 +574,7 @@ private static byte[] lengthEncode(final long strLen) /* Encode the length */ for (int i = 0; i < n; i++) { - b[i] = (byte) (strLen >> (Byte.SIZE * (n - i - 1))); + b[i] = (byte) (strLen >> (Bytes.SIZE * (n - i - 1))); } /* Return the encoded length */ diff --git a/core/src/test/java/org/bouncycastle/crypto/test/RegressionTest.java b/core/src/test/java/org/bouncycastle/crypto/test/RegressionTest.java index e34b8d6645..8e5176fba4 100644 --- a/core/src/test/java/org/bouncycastle/crypto/test/RegressionTest.java +++ b/core/src/test/java/org/bouncycastle/crypto/test/RegressionTest.java @@ -177,7 +177,8 @@ public class RegressionTest new KMACTest(), new SipHash128Test(), new GCMSIVTest(), - new Blake3Test() + new Blake3Test(), + new KangarooTest() }; public static void main(String[] args)