@@ -121,7 +121,7 @@ public byte[] falsePositiveDecryptToMac(byte[] encryptionKeyBytes, byte[] macKey
121121 SecretKey macKey = new SecretKeySpec (macKeyBytes , "HmacSHA256" );
122122 Mac mac = Mac .getInstance ("HmacSHA256" );
123123 mac .init (macKey );
124- byte [] computedMac = mac .doFinal (ciphertext ); // False Positive
124+ byte [] computedMac = mac .doFinal (ciphertext ); // $ SPURIOUS: Alert[java/quantum/examples/bad-mac-order-decrypt-to-mac]
125125
126126 // Concatenate ciphertext and MAC
127127 byte [] output = new byte [ciphertext .length + computedMac .length ];
@@ -136,7 +136,7 @@ public byte[] falsePositiveDecryptToMac(byte[] encryptionKeyBytes, byte[] macKey
136136 * The function decrypts THEN computes the MAC on the plaintext.
137137 * It should have the MAC computed on the ciphertext first.
138138 */
139- public void decryptThenMac (byte [] encryptionKeyBytes , byte [] macKeyBytes , byte [] input ) throws Exception {
139+ public void decryptThenMac (byte [] encryptionKeyBytes , byte [] macKeyBytes , byte [] input ) throws Exception { // $ SPURIOUS: Source[java/quantum/examples/bad-mac-order-encrypt-plaintext-also-in-mac]
140140 // Split input into ciphertext and MAC
141141 int macLength = 32 ; // HMAC-SHA256 output length
142142 byte [] ciphertext = Arrays .copyOfRange (input , 0 , input .length - macLength );
@@ -149,7 +149,7 @@ public void decryptThenMac(byte[] encryptionKeyBytes, byte[] macKeyBytes, byte[]
149149 SecretKey macKey = new SecretKeySpec (macKeyBytes , "HmacSHA256" );
150150 Mac mac = Mac .getInstance ("HmacSHA256" );
151151 mac .init (macKey );
152- byte [] computedMac = mac .doFinal (ciphertext ); // $ Alert[java/quantum/examples/bad-mac-order-decrypt-then-mac], False positive for Plaintext reuse
152+ byte [] computedMac = mac .doFinal (ciphertext ); // $ Alert[java/quantum/examples/bad-mac-order-decrypt-then-mac] SPURIOUS: Alert[java/quantum/examples/bad-mac-order-encrypt-plaintext-also-in-mac]
153153
154154 if (!MessageDigest .isEqual (receivedMac , computedMac )) {
155155 throw new SecurityException ("MAC verification failed" );
0 commit comments