Skip to content

Commit b3df024

Browse files
committed
Fixed immediate redeclaration of values and added spotbugs files.
1 parent df98e3e commit b3df024

File tree

4 files changed

+159
-8
lines changed

4 files changed

+159
-8
lines changed

Diff for: core/src/main/java/org/bouncycastle/pqc/crypto/gmss/GMSSLeaf.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public GMSSLeaf(Digest digest, byte[][] otsIndex, int[] numLeafs)
112112
* The constructor precomputes some needed variables for distributed leaf
113113
* calculation
114114
*
115-
* @param digest an array of strings, containing the digest of the used hash
115+
* @param digest an array of strings, containing the digest of the used hash
116116
* function and PRNG and the digest of the corresponding
117117
* provider
118118
* @param w the winterniz parameter of that tree the leaf is computed
@@ -231,7 +231,7 @@ GMSSLeaf nextLeaf()
231231
*/
232232
private void updateLeafCalc()
233233
{
234-
byte[] buf = new byte[messDigestOTS.getDigestSize()];
234+
byte[] buf = new byte[messDigestOTS.getDigestSize()];
235235

236236
// steps times do
237237
// 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)
273273
}
274274
}
275275

276-
throw new IllegalStateException("unable to updateLeaf in steps: " + steps + " " + i + " " + j);
276+
throw new IllegalStateException("unable to updateLeaf in steps: " + steps + " " + i + " " + j);
277277
}
278278

279279
/**
@@ -292,7 +292,7 @@ public byte[] getLeaf()
292292
*
293293
* @param intValue an integer
294294
* @return The least integer greater or equal to the logarithm to the base 2
295-
* of <code>intValue</code>
295+
* of <code>intValue</code>
296296
*/
297297
private int getLog(int intValue)
298298
{
@@ -315,10 +315,6 @@ public byte[][] getStatByte()
315315
{
316316

317317
byte[][] statByte = new byte[4][];
318-
statByte[0] = new byte[mdsize];
319-
statByte[1] = new byte[mdsize];
320-
statByte[2] = new byte[mdsize * keysize];
321-
statByte[3] = new byte[mdsize];
322318
statByte[0] = privateKeyOTS;
323319
statByte[1] = seed;
324320
statByte[2] = concHashs;

Diff for: spotbugs.gradle

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
8+
dependencies {
9+
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.2"
10+
classpath "net.saliman:gradle-cobertura-plugin:2.2.8"
11+
}
12+
13+
}
14+
15+
16+
17+
18+
allprojects {
19+
apply plugin: 'java'
20+
apply plugin: "com.github.spotbugs"
21+
apply plugin: 'net.saliman.cobertura'
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
dependencies {
28+
29+
}
30+
31+
compileJava {
32+
options.debug = true
33+
}
34+
35+
spotbugs {
36+
toolVersion = '3.1.6'
37+
}
38+
39+
tasks.withType(com.github.spotbugs.SpotBugsTask) {
40+
reports {
41+
xml.enabled = false
42+
html.enabled = true
43+
}
44+
}
45+
46+
spotbugs {
47+
excludeFilter = file("${rootDir}/spotbugs/excludeFilter.xml");
48+
}
49+
50+
}
51+
52+
test {
53+
exclude('**/*')
54+
}
55+
56+
subprojects {
57+
apply plugin: 'eclipse'
58+
sourceCompatibility = 1.5
59+
targetCompatibility = 1.5
60+
}
61+
62+
63+
64+
65+
66+
67+
68+

Diff for: spotbugs/excludefilter.xml

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<FindBugsFilter>
4+
<Match>
5+
<!-- clone calls copy constructor -->
6+
<Class name="org.bouncycastle.jcajce.PKIXCertStoreSelector"/>
7+
<Method name="clone"/>
8+
<Bug code="CN"/>
9+
</Match>
10+
11+
<Match>
12+
<!-- $$ Needs review, clone returns this, need reason. -->
13+
<Class name="org.bouncycastle.jcajce.PKIXCRLStoreSelector"/>
14+
<Method name="clone"/>
15+
<Bug code="CN"/>
16+
</Match>
17+
18+
<Match>
19+
<!-- $$ Needs review, clone returns this, need reason. -->
20+
<Class name="org.bouncycastle.jcajce.PKIXExtendedParameters"/>
21+
<Method name="clone"/>
22+
<Bug code="CN"/>
23+
</Match>
24+
25+
<Match>
26+
<!-- $$ Needs review, clone returns this, need reason. -->
27+
<Class name="org.bouncycastle.jcajce.PKIXExtendedBuilderParameters"/>
28+
<Method name="clone"/>
29+
<Bug code="CN"/>
30+
</Match>
31+
32+
<Match>
33+
<Class name="org.bouncycastle.asn1.x500.X500Name"/>
34+
<Method name="equals"/>
35+
</Match>
36+
37+
38+
<Match>
39+
40+
<!-- Per: FI_FINALIZER_ONLY_NULLS_FIELDS: Finalizer only nulls fields
41+
This finalizer does nothing except null out fields.
42+
This is completely pointless, and requires that the object be garbage collected, finalized, and then garbage collected again.
43+
You should just remove the finalize method.
44+
-->
45+
46+
<Class name="org.bouncycastle.crypto.general.ElGamalPrivateKeyParameters"/>
47+
<Method name="finalize"/>
48+
<Bug code="FI"/>
49+
</Match>
50+
51+
52+
<Match>
53+
<!-- Nm: The class name org.bouncycastle.util.Iterable shadows the simple name of implemented interface java.lang.Iterable -->
54+
<!-- Suggests a rename but I fear that may break some peoples code. -->
55+
<Class name="org.bouncycastle.util.Iterable"/>
56+
</Match>
57+
58+
59+
<!-- Fixed: Added close in finally block to org.bouncycastle.asn1.ASN1Primitive.fromByteArray(byte[]) -->
60+
<!--- Fixed: Added close in finally block to: org.bouncycastle.jcajce.provider.ProvJKS$JKSKeyStoreSpi.engineLoad(InputStream, char[]) -->
61+
<!-- Added try / finally close blocks to streams. org.bouncycastle.jcajce.provider ProvPKCS12 -->
62+
63+
<!-- Added transient to fields in BouncyCastleFipsProvider -->
64+
65+
66+
<Match>
67+
<!-- Complaining about a transient 'this' -->
68+
69+
<Class name="org.bouncycastle.jcajce.provider.ProvRandom$1$1"/>
70+
<Class name="org.bouncycastle.jcajce.provider.ProvRandom$2$1"/>
71+
</Match>
72+
73+
74+
<!-- removed unnecessary condition statement from org.bouncycastle.asn1.ASN1ApplicationSpecific.replaceTagNumber(int, byte[]) @212 -->
75+
<!-- commented out if statement as it cannot fire: org.bouncycastle.crypto.fips.BaseKDFBytesGenerator.generateBytes(byte[], int, int) @87 -->
76+
77+
<Match>
78+
<Class name="org.bouncycastle.asn1.ASN1OctetString"/>
79+
<Method name="getOctets()"/>
80+
</Match>
81+
82+
83+
</FindBugsFilter>
84+

Diff for: spotbugs_settings.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include "core","mail","pg","pkix","prov","tls"
2+
3+
rootProject.buildFileName = 'spotbugs.gradle'

0 commit comments

Comments
 (0)