Kryptonite v0.1.11 Kryptonite.RSA.PrivateKey View Source
This module provides abstraction around Erlang’s :public_key
functions that
aim to manipulate private keys.
Most if not all of the functions in this module are meant to be easily compatible
with elixir’s with
construct, and therefore returns something that can always
be pattern-matched for success (Typically a {:ok, value}
tuple).
Link to this section Summary
Functions
Performs the decryption of a given message
using the provided private key
.
The message has to be encrypted using the matching public key, or an error will
be returned
Performs the encryption of a given message
using the provided private key
.
Note that this function will rarelly be used, as the only way to decrypt the
generated cypher would be using the public key, which isn’t usually the intended
way of exchanging secure messages
Can be used when an Erlang native private key has to be converted in a format that this library will understand
This function is used to generate a new private key given a size_in_bits
and
a public_exponent
, both of which have sane default values
Allows to extract the public components from a private key and return a
Kryptonite.RSA.PublicKey.t()
construct, which later can be used to perform
various cryptographic operations such as decrypting cypher messages
Signs a given message
using the provided private key
Most of this module’s function internally use Erlang’s native format when performing cryptographic operations; therefore this function is provided as a helper
Link to this section Types
t() :: %Kryptonite.RSA.PrivateKey{ ctr_coefficient: pos_integer(), exponent_one: pos_integer(), exponent_two: pos_integer(), other_prime_infos: atom(), prime_one: pos_integer(), prime_two: pos_integer(), private_exponent: pos_integer(), public_exponent: pos_integer(), public_modulus: pos_integer(), version: :"two-prime" }
Link to this section Functions
decrypt(t(), Kryptonite.RSA.cypher()) :: {:ok, Kryptonite.RSA.message()} | {:error, any()}
Performs the decryption of a given message
using the provided private key
.
The message has to be encrypted using the matching public key, or an error will
be returned.
encrypt(t(), Kryptonite.RSA.message()) :: {:ok, Kryptonite.RSA.cypher()} | {:error, any()}
Performs the encryption of a given message
using the provided private key
.
Note that this function will rarelly be used, as the only way to decrypt the
generated cypher would be using the public key, which isn’t usually the intended
way of exchanging secure messages.
Can be used when an Erlang native private key has to be converted in a format that this library will understand.
new(pos_integer(), pos_integer()) :: {:ok, t()} | {:error, any()}
This function is used to generate a new private key given a size_in_bits
and
a public_exponent
, both of which have sane default values.
public_key(t()) :: {:ok, Kryptonite.RSA.PublicKey.t()} | {:error, any()}
Allows to extract the public components from a private key and return a
Kryptonite.RSA.PublicKey.t()
construct, which later can be used to perform
various cryptographic operations such as decrypting cypher messages.
sign(t(), Kryptonite.RSA.message()) :: {:ok, Kryptonite.RSA.signature()} | {:error, any()}
Signs a given message
using the provided private key
.
Most of this module’s function internally use Erlang’s native format when performing cryptographic operations; therefore this function is provided as a helper.