View Source ecies_pem (ecies v1.1.0)

This module contains functions for encoding and decoding public and private keys, as well as pair of these keys, in PEM format.

Summary

Functions

Decodes the given Pem binary representation a PEM formatted "EC PRIVATE KEY" into a PrivateKey.
Decodes the given Pem binary representation a PEM formatted "PUBLIC KEY" or "EC PRIVATE KEY" into a PublicKey.
Encodes the given KeyPair into PEM "EC PRIVATE KEY" format (public key included).
Encodes the given PrivateKey into PEM "EC PRIVATE KEY" format.
Encodes the given PublicKey into PEM "PUBLIC KEY" format.
Returns a list of named curves that are supported by the ecies_pem module.

See also: pubkey_cert_records:namedCurves/1.

Checks if the given NamedCurve is supported by the ecies_pem module.

Functions

-spec decode_keypair(Pem :: binary()) -> ecies:keypair() | error.

Equivalent to decode_keypair(Pem, ecies:default_params()).

Decodes the given Pem binary representation a PEM formatted "EC PRIVATE KEY" into a key pair {PublicKey, PrivateKey}. If the public key is not included in the given Pem`, it recovers the public key from the private one using `ecies_pubkey:from_private/2. This is only possible for curves returned by ecies_pubkey:supports_from_private/0.
Link to this function

decode_keypair(Pem, Params)

View Source
-spec decode_keypair(Pem :: binary(), #{return_curve := true, verify_curve => boolean(), _ => _}) ->
                  {ecies:named_curve(), ecies:keypair()} | error;
              (Pem :: binary(), #{verify_curve => boolean(), _ => _}) -> ecies:keypair() | error.

Equivalent to decode_keypair(Pem, ecies:default_params()).

Decodes the given Pem binary representation a PEM formatted "EC PRIVATE KEY" into a key pair {PublicKey, PrivateKey}. If the public key is not included in the given Pem`, it recovers the public key from the private one using `ecies_pubkey:from_private/2. This is only possible for curves returned by ecies_pubkey:supports_from_private/0.
-spec decode_private(Pem :: binary()) -> ecies:private_key() | error.

Equivalent to decode_private(Pem, ecies:default_params()).

Decodes the given Pem binary representation a PEM formatted "EC PRIVATE KEY" into a PrivateKey.
Link to this function

decode_private(Pem, Params)

View Source
-spec decode_private(Pem :: binary(), #{return_curve := true, verify_curve => boolean(), _ => _}) ->
                  {ecies:named_curve(), ecies:private_key()} | error;
              (Pem :: binary(), #{verify_curve => boolean(), _ => _}) ->
                  ecies:private_key() | error.
Decodes the given Pem binary representation a PEM formatted "EC PRIVATE KEY" into a PrivateKey.
-spec decode_public(Pem :: binary()) -> ecies:public_key().

Equivalent to decode_public(PemEncodedPublicKey, ecies:default_params()).

Decodes the given Pem binary representation a PEM formatted "PUBLIC KEY" or "EC PRIVATE KEY" into a PublicKey.
Link to this function

decode_public(Pem, Params)

View Source
-spec decode_public(binary(), ecies:ecies_params()) -> ecies:public_key().
Decodes the given Pem binary representation a PEM formatted "PUBLIC KEY" or "EC PRIVATE KEY" into a PublicKey.
-spec encode_keypair(KeyPair :: ecies:keypair()) -> binary().

Equivalent to encode_keypair(KeyPair, ecies:default_params()).

Encodes the given KeyPair into PEM "EC PRIVATE KEY" format (public key included).
-spec encode_keypair(ecies:keypair(), #{curve := ecies:named_curve(), _ => _}) -> binary().
Encodes the given KeyPair into PEM "EC PRIVATE KEY" format (public key included).
Link to this function

encode_private(PrivateKey)

View Source
-spec encode_private(PrivateKey :: ecies:private_key()) -> binary().

Equivalent to encode_private(PrivateKey, ecies:default_params()).

Encodes the given PrivateKey into PEM "EC PRIVATE KEY" format.
Link to this function

encode_private(PrivateKey, _)

View Source
-spec encode_private(PrivateKey :: ecies:private_key(), #{curve := ecies:named_curve(), _ => _}) ->
                  binary().
Encodes the given PrivateKey into PEM "EC PRIVATE KEY" format.
Link to this function

encode_public(PublicKey)

View Source
-spec encode_public(PublicKey :: ecies:public_key()) -> binary().

Equivalent to encode_public(PublicKey, ecies:default_params()).

Encodes the given PublicKey into PEM "PUBLIC KEY" format.
Link to this function

encode_public(PublicKey, _)

View Source
-spec encode_public(ecies:public_key(), ecies:ecies_params()) -> binary().
Encodes the given PublicKey into PEM "PUBLIC KEY" format.
-spec supports() -> [ecies:named_curve()].
Returns a list of named curves that are supported by the ecies_pem module.

See also: pubkey_cert_records:namedCurves/1.

-spec supports(NamedCurve :: ecies:named_curve()) -> boolean().
Checks if the given NamedCurve is supported by the ecies_pem module.