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

org.bouncycastle.its.asn1.SequenceOfOctetString 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.4.

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

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.util.Arrays;

/**
 *  
 *     SequenceOfOctetString ::= SEQUENCE (SIZE(0..MAX)) OF OCTET STRING (SIZE(0..MAX))
 * 
*/ public class SequenceOfOctetString extends ASN1Object { private byte[][] octetStrings; private SequenceOfOctetString(ASN1Sequence seq) { this.octetStrings = toByteArrays(seq); } public static SequenceOfOctetString getInstance(Object o) { if (o instanceof SequenceOfOctetString) { return (SequenceOfOctetString)o; } else if (o != null) { return new SequenceOfOctetString(ASN1Sequence.getInstance(o)); } return null; } public int size() { return octetStrings.length; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); for (int i = 0; i != octetStrings.length; i++) { v.add(new DEROctetString(Arrays.clone(octetStrings[i]))); } return new DERSequence(v); } static byte[][] toByteArrays(ASN1Sequence seq) { byte[][] octetStrings = new byte[seq.size()][]; for (int i = 0; i != seq.size(); i++) { octetStrings[i] = ASN1OctetString.getInstance(seq.getObjectAt(i)).getOctets(); } return octetStrings; } }



© 2015 - 2024 Weber Informatics LLC | Privacy Policy