Kryptonite v0.1.11 Kryptonite.RSA View Source

This module provides high-level functions abstracting asymetric RSA-based cryptographic operations, such as:

  • Generating RSA key pairs.
  • Performing authenticated encryption.
  • Performing authenticated decryption.

It uses its own types internally. For more informations, please see Kryptonite.RSA.PublicKey and Kryptonite.RSA.PrivateKey.

Link to this section Summary

Functions

This function offers a quick and easy way to verify that a serializer cypher is signed. If the signature was issued by an expected party (Identified by ver_pub_key), this function proceeds to decrypting it. Otherwise, it just aborts and returns an error. When all the checks pass, this function directly returns the decrypted message

This function provides a quick and easy way to encrypt a message using a public key, sign the cypher using a separate private key and serialize the result to binary. This is the prefered way of exchanging secure messages, as the recipient party will be able to verify the authenticity (and origin) of the message

Generates a new RSA keypair given a provided size_in_bits and public_exponent parameters, both of which could be omited

Link to this section Types

Link to this section Functions

Link to this function authenticated_decrypt(dec_priv_key, ver_pub_key, serialized) View Source
authenticated_decrypt(priv(), pub(), signed_cypher()) ::
  {:ok, message()} | {:error, any()}

This function offers a quick and easy way to verify that a serializer cypher is signed. If the signature was issued by an expected party (Identified by ver_pub_key), this function proceeds to decrypting it. Otherwise, it just aborts and returns an error. When all the checks pass, this function directly returns the decrypted message.

Link to this function authenticated_encrypt(enc_pub_key, sig_priv_key, msg) View Source
authenticated_encrypt(pub(), priv(), message()) ::
  {:ok, signed_cypher()} | {:error, any()}

This function provides a quick and easy way to encrypt a message using a public key, sign the cypher using a separate private key and serialize the result to binary. This is the prefered way of exchanging secure messages, as the recipient party will be able to verify the authenticity (and origin) of the message.

Link to this function new_keypair(size_in_bits \\ 2048, public_exponent \\ 65537) View Source
new_keypair(pos_integer(), pos_integer()) ::
  {:ok, priv(), pub()} | {:error, any()}

Generates a new RSA keypair given a provided size_in_bits and public_exponent parameters, both of which could be omited.