Bouncy Castle Cryptography Library 1.86

org.bouncycastle.pqc.crypto.hqc
Class GFTest

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

public class GFTest
extends junit.framework.TestCase

Regression tests for HQC's GF(2^8) arithmetic.

GF used to be implemented with log/exp/inv/sqr lookup tables indexed by field elements, which leaked secret-derived values through the cache; it is now table-free and branch-free. These tests pin the arithmetic to the values the tables produced, so a future change cannot alter a result while the HQC known-answer tests happen to keep passing on the subset of inputs they exercise.

The expected values come from an independent construction: log and exp tables built here by iterating the generator X over GF(2)[X]/(X^8 + X^4 + X^3 + X^2 + 1), so the oracle takes a different computational route (discrete logs) from the implementation (carryless multiply and reduce). Field laws are checked as well, in case both sides were to be wrong the same way.


Constructor Summary
GFTest()
           
 
Method Summary
 void setUp()
           
 void testDivAgainstOracle()
           
 void testFieldLaws()
           
 void testInvAgainstOracle()
           
 void testMul3AgainstOracle()
          mul3 is exercised on a stride rather than all 16777216 triples, to keep the legacy Ant builds (which run this on a real JRE 1.3/1.4) quick; mul itself is covered exhaustively above and mul3 is defined in terms of it.
 void testMulAgainstOracle()
           
 void testOracleIsTheExpectedField()
          Guard the oracle itself: these are the opening entries of the classic GF(256) exp table for this field polynomial, and the cycle must close back on 1.
 void testSqrAgainstOracle()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

GFTest

public GFTest()
Method Detail

setUp

public void setUp()

testOracleIsTheExpectedField

public void testOracleIsTheExpectedField()
Guard the oracle itself: these are the opening entries of the classic GF(256) exp table for this field polynomial, and the cycle must close back on 1.


testMulAgainstOracle

public void testMulAgainstOracle()

testSqrAgainstOracle

public void testSqrAgainstOracle()

testInvAgainstOracle

public void testInvAgainstOracle()

testDivAgainstOracle

public void testDivAgainstOracle()

testMul3AgainstOracle

public void testMul3AgainstOracle()
mul3 is exercised on a stride rather than all 16777216 triples, to keep the legacy Ant builds (which run this on a real JRE 1.3/1.4) quick; mul itself is covered exhaustively above and mul3 is defined in terms of it.


testFieldLaws

public void testFieldLaws()

Bouncy Castle Cryptography Library 1.86