public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(func);
    v.add(scheme);

    return new DERSequence(v);
  }
Example #2
0
  /**
   * Produce an object suitable for an ASN1OutputStream.
   *
   * <pre>
   * Request         ::=     SEQUENCE {
   *     reqCert                     CertID,
   *     singleRequestExtensions     [0] EXPLICIT Extensions OPTIONAL }
   * </pre>
   */
  public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(reqCert);

    if (singleRequestExtensions != null) {
      v.add(new DERTaggedObject(true, 0, singleRequestExtensions));
    }

    return new DERSequence(v);
  }
  /**
   * Produce an object suitable for an ASN1OutputStream.
   *
   * <pre>
   * Signature       ::=     SEQUENCE {
   *     signatureAlgorithm      AlgorithmIdentifier,
   *     signature               BIT STRING,
   *     certs               [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL}
   * </pre>
   */
  public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(signatureAlgorithm);
    v.add(signature);

    if (certs != null) {
      v.add(new DERTaggedObject(true, 0, certs));
    }

    return new DERSequence(v);
  }
  /**
   *
   *
   * <pre>
   *     Extensions        ::=   SEQUENCE SIZE (1..MAX) OF Extension
   *
   *     Extension         ::=   SEQUENCE {
   *        extnId            EXTENSION.&amp;id ({ExtensionSet}),
   *        critical          BOOLEAN DEFAULT FALSE,
   *        extnValue         OCTET STRING }
   * </pre>
   */
  public DERObject toASN1Object() {
    ASN1EncodableVector vec = new ASN1EncodableVector();
    Enumeration e = ordering.elements();

    while (e.hasMoreElements()) {
      DERObjectIdentifier oid = (DERObjectIdentifier) e.nextElement();
      X509Extension ext = (X509Extension) extensions.get(oid);
      ASN1EncodableVector v = new ASN1EncodableVector();

      v.add(oid);

      if (ext.isCritical()) {
        v.add(new DERBoolean(true));
      }

      v.add(ext.getValue());

      vec.add(new DERSequence(v));
    }

    return new DERSequence(vec);
  }