X509 v0.1.0 X509.PublicKey View Source

Functions for deriving, reading and writing RSA and EC public keys.

Link to this section Summary

Types

SubjectPublicKeyInfo container

t()

RSA or EC public key

Functions

Derives the public key from the given RSA or EC private key

Attempts to parse a public key in DER (binary) format. Unwraps a SubjectPublicKeyInfo style container, if present

Attempts to parse a public key in PEM format. Unwraps a SubjectPublicKeyInfo style container, if present

Converts a public key to DER (binary) format

Converts a public key to PEM format

Extracts a public key from a SubjectPublicKeyInfo style container

Wraps a public key in a SubjectPublicKeyInfo (or similar) container

Link to this section Types

Link to this type spki() View Source
spki() ::
  X509.ASN.record(:subject_public_key_info)
  | X509.ASN.record(:otp_subject_public_key_info)
  | X509.ASN.record(:certification_request_subject_pk_info)

SubjectPublicKeyInfo container

Link to this section Functions

Derives the public key from the given RSA or EC private key.

Link to this function from_der(der) View Source
from_der(binary()) :: t() | nil

Attempts to parse a public key in DER (binary) format. Unwraps a SubjectPublicKeyInfo style container, if present.

If the data cannot be parsed as a supported public key type, nil is returned.

Link to this function from_pem(pem) View Source
from_pem(String.t()) :: t() | nil

Attempts to parse a public key in PEM format. Unwraps a SubjectPublicKeyInfo style container, if present.

If the data cannot be parsed as a supported public key type, nil is returned.

Link to this function to_der(public_key, opts \\ []) View Source
to_der(t(), Keyword.t()) :: binary()

Converts a public key to DER (binary) format.

Options:

  • :wrap - Wrap the private key in a SubjectPublicKeyInfo container (default: false)
Link to this function to_pem(public_key, opts \\ []) View Source
to_pem(t(), Keyword.t()) :: String.t()

Converts a public key to PEM format.

Options:

  • :wrap - Wrap the private key in a SubjectPublicKeyInfo container; for RSA public keys this defaults to false, but for EC public keys this option is ignored and the key is always exported in SubjectPublicKeyInfo format

Extracts a public key from a SubjectPublicKeyInfo style container.

Supports the same container structures as wrap/2.

Link to this function wrap(public_key, wrapper \\ :SubjectPublicKeyInfo) View Source

Wraps a public key in a SubjectPublicKeyInfo (or similar) container.

The following container types are supported:

  • :SubjectPublicKeyInfo - standard X.509 structure for storing public keys (default)
  • :OTPSubjectPublicKeyInfo - Erlang/OTP record variant of :SubjectPublicKeyInfo, for use in the :OTPCertificate record
  • :CertificationRequestInfo_subjectPKInfo - for use in a PKCS#10 CertificationRequest (CSR)