org.bouncycastle.asn1.test.IdentityProofV2Test 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.7. Note: this package includes the IDEA and NTRU encryption algorithms.
package org.bouncycastle.asn1.test;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.cmc.IdentityProofV2;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.util.test.SimpleTest;
public class IdentityProofV2Test
extends SimpleTest
{
public static void main(String[] args)
{
runTest(new IdentityProofV2Test());
}
public String getName()
{
return "IdentityProofV2";
}
public void performTest()
throws Exception
{
IdentityProofV2 proofV2 = new IdentityProofV2(
new AlgorithmIdentifier(PKCSObjectIdentifiers.encryptionAlgorithm, new ASN1Integer(10L)),
new AlgorithmIdentifier(PKCSObjectIdentifiers.bagtypes, new ASN1Integer(10L)),
"Cats".getBytes()
);
byte[] b = proofV2.getEncoded();
IdentityProofV2 proofV2Res = IdentityProofV2.getInstance(b);
isEquals("proofAldID", proofV2.getProofAlgID(), proofV2Res.getProofAlgID());
isEquals("macAlgId", proofV2.getMacAlgId(), proofV2Res.getMacAlgId());
isTrue("witness", areEqual(proofV2.getWitness(), proofV2Res.getWitness()));
try
{
IdentityProofV2.getInstance(new DERSequence(new ASN1Encodable[0]));
fail("Sequence must be length of 3");
}
catch (Throwable t)
{
isEquals("Exception incorrect", t.getClass(), IllegalArgumentException.class);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy