Kryptonite v0.1.9 Kryptonite.RSA.PublicKey View Source

This module provides abstraction functions based around the manipulation of public keys.

Link to this section Summary

Functions

Decrypts a cypher that was generated using the matching private key. Note that this is not a common way of doing things and you will not be likelly to use this function. Instead, see PrivateKey.decrypt/2 function

Encrypts a given message using the provided public key. The resulting cypher can later be decrypted using the Kryptonite.RSA.PrivateKey.decrypt/2 function using the matching private key

Performs the conversion of an underlying Erlang’s public key into the library’s easy to use struct

Because this module uses Erlang lower level functions, it has to also use the native public key format that those functions expect - this helper method is therefore provided

Verifies that a given signature matches a provided messages and ensures that it was issued using the private key that matches the given public key

Link to this section Types

Link to this type t() View Source
t() :: %Kryptonite.RSA.PublicKey{
  public_exponent: pos_integer(),
  public_modulus: pos_integer()
}

Link to this section Functions

Link to this function decrypt(key, cypher_bytes) View Source
decrypt(t(), Kryptonite.RSA.cypher()) ::
  {:ok, Kryptonite.RSA.message()} | {:error, any()}

Decrypts a cypher that was generated using the matching private key. Note that this is not a common way of doing things and you will not be likelly to use this function. Instead, see PrivateKey.decrypt/2 function.

Link to this function encrypt(key, msg) View Source
encrypt(t(), Kryptonite.RSA.message()) ::
  {:ok, Kryptonite.RSA.cypher()} | {:error, any()}

Encrypts a given message using the provided public key. The resulting cypher can later be decrypted using the Kryptonite.RSA.PrivateKey.decrypt/2 function using the matching private key.

Link to this function from_native(arg1) View Source
from_native(any()) :: {:ok, t()} | {:error, any()}

Performs the conversion of an underlying Erlang’s public key into the library’s easy to use struct.

Link to this function to_native(t) View Source
to_native(any()) :: {:ok, native()} | {:error, any()}

Because this module uses Erlang lower level functions, it has to also use the native public key format that those functions expect - this helper method is therefore provided.

Link to this function verify(key, msg, sig) View Source
verify(t(), Kryptonite.RSA.message(), Kryptonite.RSA.signature()) ::
  boolean() | {:error, :verification_error}

Verifies that a given signature matches a provided messages and ensures that it was issued using the private key that matches the given public key.