code: public DERObject toASN1Object()
      {
          ASN1EncodableVector v = new ASN1EncodableVector();
  
          v.add(new DERInteger(0));
          v.add(algId);
          v.add(new DEROctetString(privKey));
  
          if (attributes != null)
          {
              v.add(new DERTaggedObject(false, 0, attributes));
          }
  
          return new DERSequence(v);
      }
docs: write out an RSA private key with it's asscociated information
  as described in PKCS8.
  <pre>
  PrivateKeyInfo ::= SEQUENCE {
  version Version,
  privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
  privateKey PrivateKey,
  attributes [0] IMPLICIT Attributes OPTIONAL
  }
  Version ::= INTEGER {v1(0)} (v1,...)
  
  PrivateKey ::= OCTET STRING
  
  Attributes ::= SET OF Attribute
  </pre>