コード例 #1
0
  /**
   * Returns the ASN.1 encoding of this object.
   *
   * @returns the ASN.1 encoding.
   * @throws IOException if error occurs when constructing its ASN.1 encoding.
   */
  public byte[] getEncoded() throws IOException {
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);

    dOut.writeObject(infoObj);
    dOut.close();

    return bOut.toByteArray();
  }
コード例 #2
0
  private AlgorithmParameters getParameters() throws NoSuchAlgorithmException {
    AlgorithmParameters ap = AlgorithmParameters.getInstance(this.getAlgName());
    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    DEROutputStream dOut = new DEROutputStream(bOut);

    try {
      dOut.writeObject(infoObj.getEncryptionAlgorithm().getParameters());
      dOut.close();

      ap.init(bOut.toByteArray());
    } catch (IOException e) {
      throw new NoSuchAlgorithmException("unable to parse parameters");
    }

    return ap;
  }