Skip to content

Commit d5ddf9f

Browse files
committed
Fix checkstyle issues
1 parent 78a8b45 commit d5ddf9f

File tree

5 files changed

+69
-30
lines changed

5 files changed

+69
-30
lines changed

pg/src/main/java/org/bouncycastle/bcpg/OnePassSignaturePacket.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public class OnePassSignaturePacket
6464
else if (version == VERSION_6)
6565
{
6666
int saltLen = in.read();
67-
if (saltLen < 0) {
67+
if (saltLen < 0)
68+
{
6869
throw new IOException("Version 6 OPS packet has invalid salt length.");
6970
}
7071
salt = new byte[saltLen];
@@ -168,7 +169,8 @@ public OnePassSignaturePacket(
168169
* Return the packet version.
169170
* @return version
170171
*/
171-
public int getVersion() {
172+
public int getVersion()
173+
{
172174
return version;
173175
}
174176

@@ -213,7 +215,8 @@ public long getKeyID()
213215
* Only for version 6 packets.
214216
* @return 32 bytes issuer fingerprint
215217
*/
216-
public byte[] getFingerprint() {
218+
public byte[] getFingerprint()
219+
{
217220
return Arrays.clone(fingerprint);
218221
}
219222

@@ -222,7 +225,8 @@ public byte[] getFingerprint() {
222225
* Only for version 6 packets.
223226
* @return salt
224227
*/
225-
public byte[] getSalt() {
228+
public byte[] getSalt()
229+
{
226230
return Arrays.clone(salt);
227231
}
228232

pg/src/main/java/org/bouncycastle/bcpg/SignaturePacket.java

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class SignaturePacket
4242
super(SIGNATURE);
4343

4444
version = in.read();
45-
switch (version) {
45+
switch (version)
46+
{
4647
case VERSION_2:
4748
case VERSION_3:
4849
parseV2_V3(in);
@@ -69,7 +70,8 @@ public class SignaturePacket
6970
* Version 3 packet format</a>
7071
*/
7172
private void parseV2_V3(BCPGInputStream in)
72-
throws IOException {
73+
throws IOException
74+
{
7375
int l = in.read(); // length l MUST be 5
7476

7577
signatureType = in.read();
@@ -97,7 +99,9 @@ private void parseV2_V3(BCPGInputStream in)
9799
* @see <a href="https://www.ietf.org/archive/id/draft-koch-librepgp-00.html#name-version-4-and-5-signature-p">
98100
* Version 5 packet format</a>
99101
*/
100-
private void parseV4_V5(BCPGInputStream in) throws IOException {
102+
private void parseV4_V5(BCPGInputStream in)
103+
throws IOException
104+
{
101105
signatureType = in.read();
102106
keyAlgorithm = in.read();
103107
hashAlgorithm = in.read();
@@ -121,7 +125,9 @@ private void parseV4_V5(BCPGInputStream in) throws IOException {
121125
* @see <a href="https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-version-4-and-6-signature-p">
122126
* Version 6 packet format</a>
123127
*/
124-
private void parseV6(BCPGInputStream in) throws IOException {
128+
private void parseV6(BCPGInputStream in)
129+
throws IOException
130+
{
125131
signatureType = in.read();
126132
keyAlgorithm = in.read();
127133
hashAlgorithm = in.read();
@@ -146,11 +152,16 @@ private void parseV6(BCPGInputStream in) throws IOException {
146152
* @param in input stream which skipped to after the hash algorithm octet
147153
* @throws IOException if the packet is malformed
148154
*/
149-
private void parseSubpackets(BCPGInputStream in) throws IOException {
155+
private void parseSubpackets(BCPGInputStream in)
156+
throws IOException
157+
{
150158
int hashedLength;
151-
if (version == 6) {
159+
if (version == 6)
160+
{
152161
hashedLength = StreamUtil.read4OctetLength(in);
153-
} else {
162+
}
163+
else
164+
{
154165
hashedLength = StreamUtil.read2OctetLength(in);
155166
}
156167
byte[] hashed = new byte[hashedLength];
@@ -188,9 +199,12 @@ else if (p instanceof SignatureCreationTime)
188199
}
189200

190201
int unhashedLength;
191-
if (version == VERSION_6) {
202+
if (version == VERSION_6)
203+
{
192204
unhashedLength = StreamUtil.read4OctetLength(in);
193-
} else {
205+
}
206+
else
207+
{
194208
unhashedLength = StreamUtil.read2OctetLength(in);
195209
}
196210
byte[] unhashed = new byte[unhashedLength];
@@ -228,7 +242,9 @@ else if (p instanceof SignatureCreationTime)
228242
* @param in input stream which skipped the head of the signature
229243
* @throws IOException if the packet is malformed
230244
*/
231-
private void parseSignature(BCPGInputStream in) throws IOException {
245+
private void parseSignature(BCPGInputStream in)
246+
throws IOException
247+
{
232248
switch (keyAlgorithm)
233249
{
234250
case RSA_GENERAL:
@@ -432,7 +448,8 @@ public byte[] getFingerPrint()
432448
* Only for v6 signatures.
433449
* @return salt
434450
*/
435-
public byte[] getSalt() {
451+
public byte[] getSalt()
452+
{
436453
return salt;
437454
}
438455

@@ -613,9 +630,12 @@ else if (version == VERSION_4 || version == VERSION_5 || version == VERSION_6)
613630

614631
byte[] data = sOut.toByteArray();
615632

616-
if (version == VERSION_6) {
633+
if (version == VERSION_6)
634+
{
617635
StreamUtil.write4OctetLength(pOut, data.length);
618-
} else {
636+
}
637+
else
638+
{
619639
StreamUtil.write2OctetLength(pOut, data.length);
620640
}
621641
pOut.write(data);
@@ -629,9 +649,12 @@ else if (version == VERSION_4 || version == VERSION_5 || version == VERSION_6)
629649

630650
data = sOut.toByteArray();
631651

632-
if (version == VERSION_6) {
652+
if (version == VERSION_6)
653+
{
633654
StreamUtil.write4OctetLength(pOut, data.length);
634-
} else {
655+
}
656+
else
657+
{
635658
StreamUtil.write2OctetLength(pOut, data.length);
636659
}
637660
pOut.write(data);
@@ -643,7 +666,8 @@ else if (version == VERSION_4 || version == VERSION_5 || version == VERSION_6)
643666

644667
pOut.write(fingerPrint);
645668

646-
if (version == VERSION_6) {
669+
if (version == VERSION_6)
670+
{
647671
pOut.write(salt.length);
648672
pOut.write(salt);
649673
}

pg/src/main/java/org/bouncycastle/bcpg/StreamUtil.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,36 @@ static void writeTime(BCPGOutputStream pOut, long time)
116116
}
117117

118118
static long readTime(BCPGInputStream in)
119-
throws IOException {
119+
throws IOException
120+
{
120121
return (((long)in.read() << 24) | ((long) in.read() << 16) | ((long) in.read() << 8) | in.read()) * 1000;
121122
}
122123

123124
static void write2OctetLength(OutputStream pOut, int len)
124-
throws IOException {
125+
throws IOException
126+
{
125127
pOut.write(len >> 8);
126128
pOut.write(len);
127129
}
128130

129131
static int read2OctetLength(InputStream in)
130-
throws IOException {
132+
throws IOException
133+
{
131134
return (in.read() << 8) | in.read();
132135
}
133136

134137
static void write4OctetLength(OutputStream pOut, int len)
135-
throws IOException {
138+
throws IOException
139+
{
136140
pOut.write(len >> 24);
137141
pOut.write(len >> 16);
138142
pOut.write(len >> 8);
139143
pOut.write(len);
140144
}
141145

142146
static int read4OctetLength(InputStream in)
143-
throws IOException {
147+
throws IOException
148+
{
144149
return (in.read() << 24) | (in.read() << 16) | (in.read() << 8) | in.read();
145150
}
146151

pg/src/main/java/org/bouncycastle/openpgp/PGPOnePassSignature.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public boolean verify(
9393
*
9494
* @return packet version
9595
*/
96-
public int getVersion() {
96+
public int getVersion()
97+
{
9798
return sigPack.getVersion();
9899
}
99100

@@ -113,7 +114,8 @@ public long getKeyID()
113114
* Only for {@link OnePassSignaturePacket#VERSION_6} packets.
114115
* @return fingerprint
115116
*/
116-
public byte[] getFingerprint() {
117+
public byte[] getFingerprint()
118+
{
117119
return sigPack.getFingerprint();
118120
}
119121

@@ -122,7 +124,8 @@ public byte[] getFingerprint() {
122124
* Only for {@link OnePassSignaturePacket#VERSION_6} packets.
123125
* @return salt
124126
*/
125-
public byte[] getSalt() {
127+
public byte[] getSalt()
128+
{
126129
return sigPack.getSalt();
127130
}
128131

pg/src/main/java/org/bouncycastle/openpgp/PGPSignatureGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,13 @@ else if (contentSigner.getKeyAlgorithm() == PublicKeyAlgorithmTags.Ed25519 ||
203203
fingerPrint[0] = digest[0];
204204
fingerPrint[1] = digest[1];
205205

206-
if (sigValues != null) {
206+
if (sigValues != null)
207+
{
207208
return new PGPSignature(new SignaturePacket(sigType, contentSigner.getKeyID(), contentSigner.getKeyAlgorithm(),
208209
contentSigner.getHashAlgorithm(), hPkts, unhPkts, fingerPrint, sigValues));
209-
} else {
210+
}
211+
else
212+
{
210213
// Ed25519, Ed448 use raw encoding instead of MPI
211214
return new PGPSignature(new SignaturePacket(4, sigType, contentSigner.getKeyID(), contentSigner.getKeyAlgorithm(),
212215
contentSigner.getHashAlgorithm(), hPkts, unhPkts, fingerPrint, contentSigner.getSignature()));

0 commit comments

Comments
 (0)