Bouncy Castle Cryptography Library 1.85

org.bouncycastle.pqc.crypto.mayo
Class MayoRetryTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.bouncycastle.pqc.crypto.mayo.MayoRetryTest
All Implemented Interfaces:
junit.framework.Test

public class MayoRetryTest
extends junit.framework.TestCase

Regression test for the retry path in MayoSigner.generateSignature(byte[]).

The retry loop accumulates three buffers (, , ) with mulAdd-style (accumulate-into) calls. All three are allocated once before the loop, so on a retry they must be re-zeroed. The reference C implementation (MAYO-C ) declares inside the function as }, i.e. fresh per attempt, while memsets and the target on failure.

The Java port hoisted 's allocation out of the loop. Without clearing on retry, the second attempt computes (stale data carried over), corrupting the signature. The KAT vectors never trigger a retry, so this is invisible to the KAT battery.

This test forces exactly one retry by overriding to fail the first attempt, then asserts the produced signature still verifies.


Constructor Summary
MayoRetryTest()
           
 
Method Summary
 void testRetryProducesValidSignature()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MayoRetryTest

public MayoRetryTest()
Method Detail

testRetryProducesValidSignature

public void testRetryProducesValidSignature()
                                     throws java.lang.Exception
Throws:
java.lang.Exception

Bouncy Castle Cryptography Library 1.85