예제 #1
0
  /**
   * Produce an object suitable for an ASN1OutputStream.
   *
   * <pre>
   * KeyTransRecipientInfo ::= SEQUENCE {
   *     version CMSVersion,  -- always set to 0 or 2
   *     rid RecipientIdentifier,
   *     keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
   *     encryptedKey EncryptedKey
   * }
   * </pre>
   */
  public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(version);
    v.add(rid);
    v.add(keyEncryptionAlgorithm);
    v.add(encryptedKey);

    return new DERSequence(v);
  }
예제 #2
0
  /**
   *
   *
   * <pre>
   * PKIMessage ::= SEQUENCE {
   *                  header           PKIHeader,
   *                  body             PKIBody,
   *                  protection   [0] PKIProtection OPTIONAL,
   *                  extraCerts   [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate
   *                                                                     OPTIONAL
   * }
   * </pre>
   *
   * @return a basic ASN.1 object representation.
   */
  public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();

    v.add(header);
    v.add(body);

    addOptional(v, 0, protection);
    addOptional(v, 1, extraCerts);

    return new DERSequence(v);
  }
예제 #3
0
 /**
  * Creates a new PKIMessage.
  *
  * @param header message header
  * @param body message body
  * @param protection message protection (may be null)
  * @param extraCerts extra certificates (may be null)
  */
 public PKIMessage(
     PKIHeader header, PKIBody body, DERBitString protection, CMPCertificate[] extraCerts) {
   this.header = header;
   this.body = body;
   this.protection = protection;
   if (extraCerts != null) {
     ASN1EncodableVector v = new ASN1EncodableVector();
     for (int i = 0; i < extraCerts.length; i++) {
       v.add(extraCerts[i]);
     }
     this.extraCerts = new DERSequence(v);
   }
 }
예제 #4
0
 private void addOptional(ASN1EncodableVector v, int tagNo, ASN1Encodable obj) {
   if (obj != null) {
     v.add(new DERTaggedObject(true, tagNo, obj));
   }
 }