org.bouncycastle.asn1.test.PopLinkWitnessV2Test Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on 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.5 to JDK 1.8. Note: this package includes the NTRU encryption algorithms.
The newest version!
package org.bouncycastle.asn1.test;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmc.PopLinkWitnessV2;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.test.SimpleTest;
public class PopLinkWitnessV2Test
extends SimpleTest
{
public static void main(String[] args)
{
runTest(new PopLinkWitnessV2Test());
}
public String getName()
{
return "PopLinkWitnessV2Test";
}
public void performTest()
throws Exception
{
// Object identifiers real but not correct in this context.
PopLinkWitnessV2 popLinkWitnessV2 = new PopLinkWitnessV2(
new AlgorithmIdentifier(PKCSObjectIdentifiers.bagtypes, new ASN1Integer(10L)),
new AlgorithmIdentifier(PKCSObjectIdentifiers.crlTypes, new ASN1Integer(12L)),
"cats".getBytes()
);
byte[] b = popLinkWitnessV2.getEncoded();
PopLinkWitnessV2 popLinkWitnessV2Result = PopLinkWitnessV2.getInstance(b);
isEquals(popLinkWitnessV2, popLinkWitnessV2Result);
try
{
PopLinkWitnessV2.getInstance(new DERSequence());
fail("Length must be 3");
}
catch (Throwable t)
{
isEquals(t.getClass(), IllegalArgumentException.class);
}
}
}