Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fboulnois/ring-pkae-example

An example of public key authenticated encryption in Rust
https://github.com/fboulnois/ring-pkae-example

aead crypto cryptography ecdh elliptic-curve-cryptography public-key-cryptography public-key-encryption rust

Last synced: 4 days ago
JSON representation

An example of public key authenticated encryption in Rust

Awesome Lists containing this project

README

        

# Public key authenticated encryption in Rust

This is an example implementation of public key authenticated encryption (PKAE)
in Rust using only the high performance [Ring](https://github.com/briansmith/ring)
cryptography library.

PKAE enables a person or service X to send confidential data to another person
or service Y such that only Y can read the data. Y can also verify that the data
originated from X and not an impostor.

## Motivation

Both the [libsodium](https://doc.libsodium.org/public-key_cryptography/authenticated_encryption)
and [openssl](https://www.openssl.org/docs/manmaster/man7/evp.html) libraries
can perform PKAE using specific primitives, however these are easy to misuse and
call a lot of potentially unsafe C code. No such similar examples to perform
PKAE exist for `ring`. Also, the Rust interfaces to libsodium and openssl
require the full libraries which substantially increase code size. Finally, many
Rust crates already depend on `ring` directly or transitively, including
`rustls` and by extension `actix-net`, `actix-web`, `tokio-rustls`, `h2`, and
`reqwest`. Writing PKAE functionality using `ring` avoids having to bring in a
separate dependency.

## Documentation

The implementation is short and each function is documented, so the best
documentation is the [code itself](src/main.rs). A browsable `rustdoc` version
can also be created using `cargo rustdoc -- --document-private-items`.

## Building and running the code

Type `cargo run`. If the code encrypts and decrypts the message successfully, it
should print `Ok`.