@@ -14,7 +14,9 @@ public class OnePassSignaturePacketTest
1414{
1515
1616 // Parse v6 OPS packet and compare its values to a known-good test vector
17- private void testParseV6OnePassSignaturePacket () throws IOException {
17+ private void testParseV6OnePassSignaturePacket ()
18+ throws IOException
19+ {
1820 // Version 6 OnePassSignature packet
1921 // extracted from https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-sample-inline-signed-messag
2022 byte [] encOPS = Hex .decode ("c44606010a1b2076495f50218890f7f5e2ee3c1822514f70500f551d86e5c921e404e34a53fbaccb186c4f0609a697e4d52dfa6c722b0c1f1e27c18a56708f6525ec27bad9acc901" );
@@ -48,7 +50,9 @@ private void testParseV6OnePassSignaturePacket() throws IOException {
4850 isEncodingEqual ("OPS Packet encoding mismatch" , encOPS , bOut .toByteArray ());
4951 }
5052
51- private void roundtripV3Packet () throws IOException {
53+ private void roundtripV3Packet ()
54+ throws IOException
55+ {
5256 OnePassSignaturePacket before = new OnePassSignaturePacket (
5357 PGPSignature .BINARY_DOCUMENT ,
5458 HashAlgorithmTags .SHA256 ,
@@ -73,7 +77,8 @@ private void roundtripV3Packet() throws IOException {
7377 isNull ("OPS v3 MUST NOT have salt" ,
7478 before .getSalt ());
7579
76- for (boolean newTypeIdFormat : new boolean [] {true , false }) {
80+ for (boolean newTypeIdFormat : new boolean [] {true , false })
81+ {
7782 // round-trip the packet by encoding and decoding it
7883 ByteArrayOutputStream bOut = new ByteArrayOutputStream ();
7984 BCPGOutputStream pOut = new BCPGOutputStream (bOut , newTypeIdFormat );
@@ -105,7 +110,9 @@ private void roundtripV3Packet() throws IOException {
105110 }
106111 }
107112
108- private void roundtripV6Packet () throws IOException {
113+ private void roundtripV6Packet ()
114+ throws IOException
115+ {
109116 byte [] salt = new byte [32 ];
110117 byte [] fingerprint = Hex .decode ("CB186C4F0609A697E4D52DFA6C722B0C1F1E27C18A56708F6525EC27BAD9ACC9" );
111118 long keyID = ((fingerprint [0 ] & 0xffL ) << 56 ) |
@@ -143,7 +150,8 @@ private void roundtripV6Packet() throws IOException {
143150 isTrue ("non-nested OPS is expected to be containing" ,
144151 before .isContaining ());
145152
146- for (boolean newTypeIdFormat : new boolean [] {true , false }) {
153+ for (boolean newTypeIdFormat : new boolean [] {true , false })
154+ {
147155 // round-trip the packet by encoding and decoding it
148156 ByteArrayOutputStream bOut = new ByteArrayOutputStream ();
149157 BCPGOutputStream pOut = new BCPGOutputStream (bOut , newTypeIdFormat );
@@ -174,7 +182,9 @@ private void roundtripV6Packet() throws IOException {
174182 }
175183 }
176184
177- private void roundtripV6PacketWithZeroLengthSalt () throws IOException {
185+ private void roundtripV6PacketWithZeroLengthSalt ()
186+ throws IOException
187+ {
178188 byte [] salt = new byte [0 ];
179189 byte [] fingerprint = Hex .decode ("CB186C4F0609A697E4D52DFA6C722B0C1F1E27C18A56708F6525EC27BAD9ACC9" );
180190
@@ -189,7 +199,8 @@ private void roundtripV6PacketWithZeroLengthSalt() throws IOException {
189199 isEncodingEqual ("Salt mismatch" ,
190200 salt , before .getSalt ());
191201
192- for (boolean newTypeIdFormat : new boolean [] {true , false }) {
202+ for (boolean newTypeIdFormat : new boolean [] {true , false })
203+ {
193204 // round-trip the packet by encoding and decoding it
194205 ByteArrayOutputStream bOut = new ByteArrayOutputStream ();
195206 BCPGOutputStream pOut = new BCPGOutputStream (bOut , newTypeIdFormat );
@@ -218,24 +229,31 @@ private void roundtripV6PacketWithZeroLengthSalt() throws IOException {
218229 }
219230 }
220231
221- private void parsingOfPacketWithUnknownVersionFails () {
232+ private void parsingOfPacketWithUnknownVersionFails ()
233+ {
222234 // Version 0x99 OnePassSignature packet
223235 byte [] encOPS = Hex .decode ("c44699010a1b2076495f50218890f7f5e2ee3c1822514f70500f551d86e5c921e404e34a53fbaccb186c4f0609a697e4d52dfa6c722b0c1f1e27c18a56708f6525ec27bad9acc901" );
224236
225237 ByteArrayInputStream bIn = new ByteArrayInputStream (encOPS );
226238 BCPGInputStream pIn = new BCPGInputStream (bIn );
227239
228- try {
240+ try
241+ {
229242 pIn .readPacket ();
230243 fail ("Expected UnsupportedPacketVersionException" );
231- } catch (IOException e ) {
244+ }
245+ catch (IOException e )
246+ {
232247 fail ("Expected UnsupportedPacketVersionException" , e );
233- } catch (UnsupportedPacketVersionException e ) {
248+ }
249+ catch (UnsupportedPacketVersionException e )
250+ {
234251 // expected
235252 }
236253 }
237254
238- private void parsingOfPacketWithTruncatedFingerprintFails () {
255+ private void parsingOfPacketWithTruncatedFingerprintFails ()
256+ {
239257 // Version 6 OnePassSignature packet with truncated fingerprint field (20 bytes instead of 32)
240258 // This error would happen, if a v6 OPS packet was generated with a v4 fingerprint.
241259 // extracted from https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-13.html#name-sample-inline-signed-messag
@@ -244,21 +262,27 @@ private void parsingOfPacketWithTruncatedFingerprintFails() {
244262 ByteArrayInputStream bIn = new ByteArrayInputStream (encOPS );
245263 BCPGInputStream pIn = new BCPGInputStream (bIn );
246264
247- try {
265+ try
266+ {
248267 pIn .readPacket ();
249268 fail ("Expected IOException" );
250- } catch (IOException e ) {
269+ }
270+ catch (IOException e )
271+ {
251272 // expected
252273 }
253274 }
254275
255276 @ Override
256- public String getName () {
277+ public String getName ()
278+ {
257279 return "OnePassSignaturePacketTest" ;
258280 }
259281
260282 @ Override
261- public void performTest () throws Exception {
283+ public void performTest ()
284+ throws Exception
285+ {
262286 testParseV6OnePassSignaturePacket ();
263287 roundtripV3Packet ();
264288 roundtripV6Packet ();
@@ -267,7 +291,8 @@ public void performTest() throws Exception {
267291 roundtripV6PacketWithZeroLengthSalt ();
268292 }
269293
270- public static void main (String [] args ) {
294+ public static void main (String [] args )
295+ {
271296 runTest (new OnePassSignaturePacketTest ());
272297 }
273298}
0 commit comments