org.bouncycastle.crypto.agreement.test.JPAKEPrimeOrderGroupTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk14 Show documentation
Show all versions of bcprov-jdk14 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.4.
package org.bouncycastle.crypto.agreement.test;
import java.math.BigInteger;
import junit.framework.TestCase;
import org.bouncycastle.crypto.CryptoException;
import org.bouncycastle.crypto.agreement.jpake.JPAKEPrimeOrderGroup;
public class JPAKEPrimeOrderGroupTest
extends TestCase
{
public void testConstruction()
throws CryptoException
{
// p-1 not evenly divisible by q
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(7), BigInteger.valueOf(5), BigInteger.valueOf(6));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// g < 2
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(11), BigInteger.valueOf(5), BigInteger.valueOf(1));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// g > p-1
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(11), BigInteger.valueOf(5), BigInteger.valueOf(11));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// g^q mod p not equal 1
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(11), BigInteger.valueOf(5), BigInteger.valueOf(6));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// p not prime
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(15), BigInteger.valueOf(2), BigInteger.valueOf(4));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// q not prime
try
{
new JPAKEPrimeOrderGroup(BigInteger.valueOf(7), BigInteger.valueOf(6), BigInteger.valueOf(3));
fail();
}
catch (IllegalArgumentException e)
{
// pass
}
// should succeed
new JPAKEPrimeOrderGroup(BigInteger.valueOf(7), BigInteger.valueOf(3), BigInteger.valueOf(4));
}
}