PrivateKeyInfoFactory (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.util

## Class PrivateKeyInfoFactory

- java.lang.Object
- - org.bouncycastle.crypto.util.PrivateKeyInfoFactory

-     public class PrivateKeyInfoFactory
      extends java.lang.Object

  Factory to create ASN.1 private key info objects from lightweight private keys.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static PrivateKeyInfo` | `createPrivateKeyInfo(AsymmetricKeyParameter privateKey)` Create a PrivateKeyInfo representation of a private key.
    `static PrivateKeyInfo` | `createPrivateKeyInfo(AsymmetricKeyParameter privateKey, ASN1Set attributes)` Create a PrivateKeyInfo representation of a private key with attributes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### createPrivateKeyInfo

          public static PrivateKeyInfo createPrivateKeyInfo(AsymmetricKeyParameter privateKey)
                                                     throws java.io.IOException

      Create a PrivateKeyInfo representation of a private key.
      Parameters:
        `privateKey` - the key to be encoded into the info object.
      Returns:
        the appropriate PrivateKeyInfo
      Throws:
        `java.io.IOException` - on an error encoding the key

    - #### createPrivateKeyInfo

          public static PrivateKeyInfo createPrivateKeyInfo(AsymmetricKeyParameter privateKey,
                                                            ASN1Set attributes)
                                                     throws java.io.IOException

      Create a PrivateKeyInfo representation of a private key with attributes.
      Parameters:
        `privateKey` - the key to be encoded into the info object.
        `attributes` - the set of attributes to be included.
      Returns:
        the appropriate PrivateKeyInfo
      Throws:
        `java.io.IOException` - on an error encoding the key