Module x509_public_key

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

Description

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

Data Types

public_key()

public_key() = public_key:rsa_public_key() | public_key:ec_public_key()

spki()

spki() = #'SubjectPublicKeyInfo'{} | #'OTPSubjectPublicKeyInfo'{} | #'CertificationRequestInfo_subjectPKInfo'{}

to_der_opts()

to_der_opts() = [{wrap, boolean()}]

to_pem_opts()

to_pem_opts() = [{wrap, boolean()}]

Function Index

derive/1derives the public key from the given RSA or EC private key.
from_der/1attempts to parse a public key in DER (binary) format Unwraps a SubjectPublicKeyInfo style container, if present.
from_pem/1attempts to parse a public key in PEM format Expects the input string to include at least one PEM entry of "PUBLIC KEY" or "RSA PUBLIC KEY".
to_der/1converts a public key to SubjectPublicKeyInfo in DER (binary) format.
to_der/2converts a public key to DER (binary) format When the 'wrap' flag is set to 'true' (the default), the public key is wrapped in a SubjectPublicKeyInfo container.
to_pem/1converts a public key to SubjectPublicKeyInfo in PEM format.
to_pem/2converts a public key to PEM format If the public key is an EC public key, or if the the 'wrap' flag is set to 'true' (the default), the public key is wrapped in a SubjectPublicKeyInfo container.
unwrap/1extracts a public key from a SubjectPublicKeyInfo style container Supports the same container structures as 'wrap/2'.
wrap/1wraps a public key in a SubjectPublicKeyInfo container.
wrap/2wraps a public key in a SubjectPublicKeyInfo (or similar) container The following container types are supported: * 'SubjectPublicKeyInfo' - standard X.509 structure for storing public keys * 'OTPSubjectPublicKeyInfo' - Erlang/OTP record variant of 'SubjectPublicKeyInfo', for use in the 'OTPCertificate' record * 'CertificationRequestInfo_subjectPKInfo' - for use in a PKCS#10 CertificationRequest (CSR).

Function Details

derive/1

derive(X1::x509_private_key:private_key()) -> public_key()

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

from_der/1

from_der(DER::binary()) -> {ok, public_key()} | {error, malformed}

attempts to parse a public key in DER (binary) format Unwraps a SubjectPublicKeyInfo style container, if present. Returns an 'ok' tuple in case of success, or an 'error' tuple in case of failure. Possible error reasons are: * 'malformed' - the data could not be decoded as a public key

from_pem/1

from_pem(PEM::binary()) -> {ok, public_key()} | {error, not_found | malformed}

attempts to parse a public key in PEM format Expects the input string to include at least one PEM entry of "PUBLIC KEY" or "RSA PUBLIC KEY". Unwraps a SubjectPublicKeyInfo style container, if present. Returns an 'ok' tuple in case of success, or an 'error' tuple in case of failure. Possible error reasons are: * 'not_found' - no PEM entry of a supported PUBLIC KEY type was found * 'malformed' - the entry could not be decoded as a public key

to_der/1

to_der(PublicKey::public_key()) -> binary()

converts a public key to SubjectPublicKeyInfo in DER (binary) format

to_der/2

to_der(PublicKey::public_key(), Opts::to_der_opts()) -> binary()

converts a public key to DER (binary) format When the 'wrap' flag is set to 'true' (the default), the public key is wrapped in a SubjectPublicKeyInfo container. If the flag is set to 'false', the raw public key is encoded.

to_pem/1

to_pem(PublicKey::public_key()) -> binary()

converts a public key to SubjectPublicKeyInfo in PEM format

to_pem/2

to_pem(PublicKey::public_key(), Opts::to_pem_opts()) -> binary()

converts a public key to PEM format If the public key is an EC public key, or if the the 'wrap' flag is set to 'true' (the default), the public key is wrapped in a SubjectPublicKeyInfo container. For an RSA public keys only, if the flag is set to 'false', the raw public key is encoded.

unwrap/1

unwrap(X1::spki()) -> public_key()

extracts a public key from a SubjectPublicKeyInfo style container Supports the same container structures as 'wrap/2'.

wrap/1

wrap(PublicKey::public_key()) -> #'SubjectPublicKeyInfo'{}

wraps a public key in a SubjectPublicKeyInfo container

wrap/2

wrap(PublicKey::public_key(), X2::'SubjectPublicKeyInfo') -> #'SubjectPublicKeyInfo'{}

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 * 'OTPSubjectPublicKeyInfo' - Erlang/OTP record variant of 'SubjectPublicKeyInfo', for use in the 'OTPCertificate' record * 'CertificationRequestInfo_subjectPKInfo' - for use in a PKCS#10 CertificationRequest (CSR)


Generated by EDoc