All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.test.PopLinkWitnessV2Test Maven / Gradle / Ivy

Go to download

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 and up.

There is a newer version: 1.70
Show 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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy