private boolean isAlgIdEqual(AlgorithmIdentifier id1, AlgorithmIdentifier id2) {
    if (!id1.getAlgorithm().equals(id2.getAlgorithm())) {
      return false;
    }

    if (id1.getParameters() == null) {
      if (id2.getParameters() != null && !id2.getParameters().equals(DERNull.INSTANCE)) {
        return false;
      }

      return true;
    }

    if (id2.getParameters() == null) {
      if (id1.getParameters() != null && !id1.getParameters().equals(DERNull.INSTANCE)) {
        return false;
      }

      return true;
    }

    return id1.getParameters().equals(id2.getParameters());
  }
  /**
   * @deprecated use PrivateKeyInfo.getInstance()
   * @param seq
   */
  public PrivateKeyInfo(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    BigInteger version = ((ASN1Integer) e.nextElement()).getValue();
    if (version.intValue() != 0) {
      throw new IllegalArgumentException("wrong version for private key info");
    }

    algId = AlgorithmIdentifier.getInstance(e.nextElement());
    privKey = ASN1OctetString.getInstance(e.nextElement());

    if (e.hasMoreElements()) {
      attributes = ASN1Set.getInstance((ASN1TaggedObject) e.nextElement(), false);
    }
  }