@@ -71,6 +71,7 @@ public void performTest()
71
71
72
72
verifyingSignatureWithMismatchedSaltSizeFails ();
73
73
verifyingOPSWithMismatchedSaltSizeFails ();
74
+ verifyingInlineSignatureWithSignatureSaltValueMismatchFails ();
74
75
}
75
76
76
77
private void verifyV6DirectKeySignatureTestVector ()
@@ -292,6 +293,59 @@ private void verifyingOPSWithMismatchedSaltSizeFails()
292
293
}
293
294
}
294
295
296
+ private void verifyingInlineSignatureWithSignatureSaltValueMismatchFails ()
297
+ throws IOException , PGPException
298
+ {
299
+ String ARMORED_MSG = "-----BEGIN PGP MESSAGE-----\n " +
300
+ "\n " +
301
+ "xEYGAQobIMcgFZRFzyKmYrqqNES9B0geVN5TZ6Wct6aUrITCuFyeyxhsTwYJppfk\n " +
302
+ "1S36bHIrDB8eJ8GKVnCPZSXsJ7rZrMkAyxR1AAAAAABIZWxsbywgV29ybGQhCsKY\n " +
303
+ "BgEbCgAAACkioQbLGGxPBgmml+TVLfpscisMHx4nwYpWcI9lJewnutmsyQWCZoJv\n " +
304
+ "WQAAAAAkFSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAItltzKi2NN+\n " +
305
+ "XNJISXQ0X0f4TppBoHbpmwc5YCTIv2+vDZPI+tjzXL9m2e1jrqqaUMEwQ+Zy8B+K\n " +
306
+ "LC4rA6Gh2gY=\n " +
307
+ "=KRD3\n " +
308
+ "-----END PGP MESSAGE-----" ;
309
+
310
+ ByteArrayInputStream bIn = new ByteArrayInputStream (ARMORED_KEY .getBytes (StandardCharsets .UTF_8 ));
311
+ ArmoredInputStream aIn = new ArmoredInputStream (bIn );
312
+ BCPGInputStream pIn = new BCPGInputStream (aIn );
313
+ PGPObjectFactory objFac = new BcPGPObjectFactory (pIn );
314
+ PGPSecretKeyRing secretKeys = (PGPSecretKeyRing ) objFac .nextObject ();
315
+ PGPPublicKey signingPubKey = secretKeys .getPublicKey ();
316
+
317
+ bIn = new ByteArrayInputStream (ARMORED_MSG .getBytes (StandardCharsets .UTF_8 ));
318
+ aIn = new ArmoredInputStream (bIn );
319
+ pIn = new BCPGInputStream (aIn );
320
+ objFac = new BcPGPObjectFactory (pIn );
321
+
322
+ PGPOnePassSignatureList opsList = (PGPOnePassSignatureList ) objFac .nextObject ();
323
+ PGPOnePassSignature ops = opsList .get (0 );
324
+ isEncodingEqual ("OPS salt MUST match our expectations." ,
325
+ Hex .decode ("C720159445CF22A662BAAA3444BD07481E54DE5367A59CB7A694AC84C2B85C9E" ),
326
+ ops .getSalt ());
327
+
328
+ ops .init (new BcPGPContentVerifierBuilderProvider (), signingPubKey );
329
+
330
+ PGPLiteralData lit = (PGPLiteralData ) objFac .nextObject ();
331
+ ByteArrayOutputStream plainOut = new ByteArrayOutputStream ();
332
+ Streams .pipeAll (lit .getDataStream (), plainOut );
333
+
334
+ ops .update (plainOut .toByteArray ());
335
+ PGPSignatureList sigList = (PGPSignatureList ) objFac .nextObject ();
336
+ PGPSignature sig = sigList .get (0 );
337
+
338
+ try
339
+ {
340
+ ops .verify (sig );
341
+ fail ("Verifying signature with mismatched salt MUST fail." );
342
+ }
343
+ catch (PGPException e )
344
+ {
345
+ // expected
346
+ }
347
+ }
348
+
295
349
public static void main (String [] args )
296
350
{
297
351
runTest (new PGPV6SignatureTest ());
0 commit comments