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

org.bouncycastle.asn1.DLExternal 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 to JDK 1.8.

There is a newer version: 1.79
Show newest version
package org.bouncycastle.asn1;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Class representing the Definite-Length-type External
 */
public class DLExternal
    extends ASN1External
{
    /**
     * Construct a Definite-Length EXTERNAL object, the input encoding vector must have exactly two elements on it.
     * 

* Acceptable input formats are: *

    *
  • {@link ASN1ObjectIdentifier} + data {@link DERTaggedObject} (direct reference form)
  • *
  • {@link ASN1Integer} + data {@link DERTaggedObject} (indirect reference form)
  • *
  • Anything but {@link DERTaggedObject} + data {@link DERTaggedObject} (data value form)
  • *
* * @throws IllegalArgumentException if input size is wrong, or */ public DLExternal(ASN1EncodableVector vector) { super(vector); } /** * Creates a new instance of DERExternal * See X.690 for more informations about the meaning of these parameters * @param directReference The direct reference or null if not set. * @param indirectReference The indirect reference or null if not set. * @param dataValueDescriptor The data value descriptor or null if not set. * @param externalData The external data in its encoded form. */ public DLExternal(ASN1ObjectIdentifier directReference, ASN1Integer indirectReference, ASN1Primitive dataValueDescriptor, DERTaggedObject externalData) { this(directReference, indirectReference, dataValueDescriptor, externalData.getTagNo(), externalData.toASN1Primitive()); } /** * Creates a new instance of Definite-Length External. * See X.690 for more informations about the meaning of these parameters * @param directReference The direct reference or null if not set. * @param indirectReference The indirect reference or null if not set. * @param dataValueDescriptor The data value descriptor or null if not set. * @param encoding The encoding to be used for the external data * @param externalData The external data */ public DLExternal(ASN1ObjectIdentifier directReference, ASN1Integer indirectReference, ASN1Primitive dataValueDescriptor, int encoding, ASN1Primitive externalData) { super(directReference, indirectReference, dataValueDescriptor, encoding, externalData); } ASN1Primitive toDLObject() { return this; } int encodedLength() throws IOException { return this.getEncoded().length; } /* (non-Javadoc) * @see org.bouncycastle.asn1.ASN1Primitive#encode(org.bouncycastle.asn1.DEROutputStream) */ void encode(ASN1OutputStream out, boolean withTag) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (directReference != null) { baos.write(directReference.getEncoded(ASN1Encoding.DL)); } if (indirectReference != null) { baos.write(indirectReference.getEncoded(ASN1Encoding.DL)); } if (dataValueDescriptor != null) { baos.write(dataValueDescriptor.getEncoded(ASN1Encoding.DL)); } ASN1TaggedObject obj = new DLTaggedObject(true, encoding, externalContent); baos.write(obj.getEncoded(ASN1Encoding.DL)); out.writeEncoded(withTag, BERTags.CONSTRUCTED, BERTags.EXTERNAL, baos.toByteArray()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy