org.bouncycastle.oer.its.ItsUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcutil-lts8on Show documentation
Show all versions of bcutil-lts8on Show documentation
The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls. This jar contains APIs for Java 8 and later.
The newest version!
package org.bouncycastle.oer.its;
import java.util.List;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.util.Arrays;
public class ItsUtils
{
/**
*
* OCTET STRING (SIZE(n))
*
*/
public static byte[] octetStringFixed(byte[] octets, int n)
{
if (octets.length != n)
{
throw new IllegalArgumentException("octet string out of range");
}
return octets;
}
/**
*
* OCTET STRING (SIZE(1..32))
*
*/
public static byte[] octetStringFixed(byte[] octets)
{
if (octets.length < 1 || octets.length > 32)
{
throw new IllegalArgumentException("octet string out of range");
}
return Arrays.clone(octets);
}
public static ASN1Sequence toSequence(List objs)
{
return new DERSequence((ASN1Encodable[])objs.toArray(new ASN1Encodable[0]));
}
public static ASN1Sequence toSequence(ASN1Encodable... objs)
{
return new DERSequence(objs);
}
}