This module provides functions to handle public key infrastructure from RFC 5280 - X.509 certificates and some parts of the PKCS-standard.
All records used in this manual
are generated from asn1 specifications
and are documented in the User's Guide. See
Use the following include directive to get access to the records and constant macros described here and in the User's Guide.
-include_lib("public_key/include/public_key.hrl").
Data Types
boolean() = true | false
string = [bytes()]
pki_asn1_type() = 'Certificate' | 'RSAPrivateKey'| 'RSAPublicKey'
'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | 'SubjectPublicKeyInfo'
pem_entry () = {pki_asn1_type(), binary() %% DER or encrypted DER
not_encrypted | {"DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)}}.
rsa_public_key() = #'RSAPublicKey'{}
rsa_private_key() = #'RSAPrivateKey'{}
dsa_public_key() = {integer(), #'Dss-Parms'{}}
rsa_private_key() = #'RSAPrivateKey'{}
dsa_private_key() = #'DSAPrivateKey'{}
public_crypt_options() = [{rsa_pad, rsa_padding()}].
rsa_padding() = 'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding'
| 'rsa_no_padding'
rsa_digest_type() = 'md5' | 'sha'
dss_digest_type() = 'none' | 'sha'
ssh_file() = openssh_public_key | rfc4716_public_key |
known_hosts | auth_keys
Public key decryption using the private key.
Public key decryption using the public key.
Decodes a public key asn1 der encoded entity.
Encodes a public key entity with asn1 DER encoding.
Decode PEM binary data and return entries as asn1 der encoded entities.
Creates a PEM binary
Decodes a pem entry. pem_decode/1 returns a list of pem entries. Note that if the pem entry is of type 'SubjectPublickeyInfo' it will be further decoded to an rsa_public_key() or dsa_public_key().
Creates a pem entry that can be feed to pem_encode/1.
Public key encryption using the private key.
Public key encryption using the public key.
Decodes an asn1 der encoded pkix certificate. The otp option will use the customized asn1 specification OTP-PKIX.asn1 for decoding and also recursively decode most of the standard parts.
Der encodes a pkix x509 certificate or part of such a certificate. This function must be used for encoding certificates or parts of certificates that are decoded/created on the otp format, whereas for the plain format this function will directly call der_encode/2.
Checks if
Checks if a Certificate is a fixed Diffie-Hellman Cert.
Checks if a Certificate is self signed.
Returns the issuer id.
Normalizes a issuer name so that it can be easily compared to another issuer name.
Signs a 'OTPTBSCertificate'. Returns the corresponding der encoded certificate.
Verify pkix x.509 certificate signature.
Creates a digital signature.
Decodes a ssh file-binary. In the case of know_hosts or auth_keys the binary may include one or more lines of the file. Returns a list of public keys and their attributes, possible attribute values depends on the file type represented by the binary.
Encodes a list of ssh file entries (public keys and attributes) to a binary. Possible
attributes depends on the file type, see
Verifies a digital signature