package cn.anicert.secure.access.crypto.util;

import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;

import java.io.IOException;

/**
 * @Description
 * @Date 2024/5/30 17:18
 * @Author yourongbin
 **/
public class ASN1Util {
    public static ASN1Object checkAndGetASN1Object(byte[] in)
            throws IllegalArgumentException
    {
        ASN1InputStream din = null;
        ASN1Primitive pkcs;
        try
        {
            din = new ASN1InputStream(in);
            pkcs = din.readObject();
        } catch (IOException var11) {
            throw new IllegalArgumentException("failed to construct sequence from byte[]:" + var11.getMessage());
        } finally {
            if (din != null) {
                try {
                    din.close();
                } catch (Exception var10) {
                    var10.printStackTrace();
                }
            }
        }
        return pkcs;
    }
}
