PKI-Lite - v1.0.5
    Preparing search index...

    Represents a private key in PKCS#8 format.

    PrivateKeyInfo is the standard format for encoding private keys as defined in PKCS#8. It includes the algorithm identifier, the private key material, and optional attributes. This format is algorithm-agnostic and can represent RSA, ECDSA, EdDSA, and other types of private keys.

    PrivateKeyInfo ::= SEQUENCE {
         version                 Version,
         privateKeyAlgorithm     AlgorithmIdentifier,
         privateKey              OCTET STRING,
         attributes          [0] IMPLICIT Attributes OPTIONAL
    }
    
    // Create a private key info structure
    const privateKeyInfo = new PrivateKeyInfo({
    algorithm: new AlgorithmIdentifier({
    algorithm: OIDs.rsaEncryption
    }),
    privateKey: rsaPrivateKeyBytes
    })

    // Load from PEM
    const pem = '-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----'
    const keyInfo = PrivateKeyInfo.fromPem(pem)

    // Extract the actual private key
    const rsaKey = keyInfo.extractRSAPrivateKey()

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Algorithm identifier specifying the private key algorithm and parameters.

    attributes?: Attribute[]

    Optional attributes providing additional key metadata.

    privateKey: OctetString

    The private key material as an OCTET STRING. The format of this data depends on the algorithm.

    version: number

    Version number (usually 0 for PKCS#8 v1).

    Accessors

    • get pemHeader(): string

      Gets the PEM header name for this object type. Converts the class name to uppercase for use in PEM encoding.

      Returns string

    • get pkiType(): string

      Gets the PKI type name for this object (typically the class name). Used for PEM headers and debugging output.

      Returns string

    Methods

    • Compares this PKI object with another for equality. Two objects are considered equal if their DER encodings are identical.

      Parameters

      • other: PkiBase<any>

        The other PKI object to compare with

      Returns boolean

      true if the objects are equal, false otherwise

    • Returns a human-readable string representation of this object. By default, returns the same as toString(), but subclasses can override for more user-friendly output.

      Returns string

      A human-readable string representation