public Signature(ASN1Sequence seq) {
    signatureAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
    signature = (DERBitString) seq.getObjectAt(1);

    if (seq.size() == 3) {
      certs = ASN1Sequence.getInstance((ASN1TaggedObject) seq.getObjectAt(2), true);
    }
  }
  public Request(ASN1Sequence seq) {
    reqCert = CertID.getInstance(seq.getObjectAt(0));

    if (seq.size() == 2) {
      singleRequestExtensions =
          X509Extensions.getInstance((ASN1TaggedObject) seq.getObjectAt(1), true);
    }
  }
  /**
   * Constructor from ASN1Sequence.
   *
   * <p>the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID,
   * Boolean, OctetString)
   */
  public X509Extensions(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement());

      if (s.size() == 3) {
        extensions.put(
            s.getObjectAt(0),
            new X509Extension(
                DERBoolean.getInstance(s.getObjectAt(1)),
                ASN1OctetString.getInstance(s.getObjectAt(2))));
      } else if (s.size() == 2) {
        extensions.put(
            s.getObjectAt(0),
            new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
      } else {
        throw new IllegalArgumentException("Bad sequence size: " + s.size());
      }

      ordering.addElement(s.getObjectAt(0));
    }
  }