From b3df024323bf853f798396dd5cad5f8360bcbede Mon Sep 17 00:00:00 2001 From: mw Date: Mon, 27 Aug 2018 15:38:41 +1000 Subject: [PATCH] Fixed immediate redeclaration of values and added spotbugs files. --- .../pqc/crypto/gmss/GMSSLeaf.java | 12 +-- spotbugs.gradle | 68 +++++++++++++++ spotbugs/excludefilter.xml | 84 +++++++++++++++++++ spotbugs_settings.gradle | 3 + 4 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 spotbugs.gradle create mode 100644 spotbugs/excludefilter.xml create mode 100644 spotbugs_settings.gradle diff --git a/core/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSLeaf.java b/core/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSLeaf.java index 6823ce3f1e..8cbfe8d565 100644 --- a/core/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSLeaf.java +++ b/core/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSLeaf.java @@ -112,7 +112,7 @@ public GMSSLeaf(Digest digest, byte[][] otsIndex, int[] numLeafs) * The constructor precomputes some needed variables for distributed leaf * calculation * - * @param digest an array of strings, containing the digest of the used hash + * @param digest an array of strings, containing the digest of the used hash * function and PRNG and the digest of the corresponding * provider * @param w the winterniz parameter of that tree the leaf is computed @@ -231,7 +231,7 @@ GMSSLeaf nextLeaf() */ private void updateLeafCalc() { - byte[] buf = new byte[messDigestOTS.getDigestSize()]; + byte[] buf = new byte[messDigestOTS.getDigestSize()]; // steps times do // TODO: this really needs to be looked at, the 10000 has been added as @@ -273,7 +273,7 @@ else if (i == 0 || j == two_power_w - 1) } } - throw new IllegalStateException("unable to updateLeaf in steps: " + steps + " " + i + " " + j); + throw new IllegalStateException("unable to updateLeaf in steps: " + steps + " " + i + " " + j); } /** @@ -292,7 +292,7 @@ public byte[] getLeaf() * * @param intValue an integer * @return The least integer greater or equal to the logarithm to the base 2 - * of intValue + * of intValue */ private int getLog(int intValue) { @@ -315,10 +315,6 @@ public byte[][] getStatByte() { byte[][] statByte = new byte[4][]; - statByte[0] = new byte[mdsize]; - statByte[1] = new byte[mdsize]; - statByte[2] = new byte[mdsize * keysize]; - statByte[3] = new byte[mdsize]; statByte[0] = privateKeyOTS; statByte[1] = seed; statByte[2] = concHashs; diff --git a/spotbugs.gradle b/spotbugs.gradle new file mode 100644 index 0000000000..7392a9acc7 --- /dev/null +++ b/spotbugs.gradle @@ -0,0 +1,68 @@ +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + + dependencies { + classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.2" + classpath "net.saliman:gradle-cobertura-plugin:2.2.8" + } + +} + + + + +allprojects { + apply plugin: 'java' + apply plugin: "com.github.spotbugs" + apply plugin: 'net.saliman.cobertura' + + repositories { + mavenCentral() + } + + dependencies { + + } + + compileJava { + options.debug = true + } + + spotbugs { + toolVersion = '3.1.6' + } + + tasks.withType(com.github.spotbugs.SpotBugsTask) { + reports { + xml.enabled = false + html.enabled = true + } + } + + spotbugs { + excludeFilter = file("${rootDir}/spotbugs/excludeFilter.xml"); + } + +} + +test { + exclude('**/*') +} + +subprojects { + apply plugin: 'eclipse' + sourceCompatibility = 1.5 + targetCompatibility = 1.5 +} + + + + + + + + diff --git a/spotbugs/excludefilter.xml b/spotbugs/excludefilter.xml new file mode 100644 index 0000000000..eb888cf17f --- /dev/null +++ b/spotbugs/excludefilter.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spotbugs_settings.gradle b/spotbugs_settings.gradle new file mode 100644 index 0000000000..c7e4590fe3 --- /dev/null +++ b/spotbugs_settings.gradle @@ -0,0 +1,3 @@ +include "core","mail","pg","pkix","prov","tls" + +rootProject.buildFileName = 'spotbugs.gradle' \ No newline at end of file