crypto#

Include dependency graph for crypto.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "4" [label="openssl/rand.h" tooltip="openssl/rand.h"]
    "16" [label="variant" tooltip="variant"]
    "6" [label="openssl/x509.h" tooltip="openssl/x509.h"]
    "5" [label="openssl/sha.h" tooltip="openssl/sha.h"]
    "13" [label="string" tooltip="string"]
    "7" [label="utility.h" tooltip="utility.h"]
    "14" [label="string_view" tooltip="string_view"]
    "9" [label="condition_variable" tooltip="condition_variable"]
    "12" [label="optional" tooltip="optional"]
    "17" [label="vector" tooltip="vector"]
    "2" [label="array" tooltip="array"]
    "3" [label="openssl/evp.h" tooltip="openssl/evp.h"]
    "11" [label="mutex" tooltip="mutex"]
    "1" [label="src/crypto.h" tooltip="src/crypto.h" fillcolor="#BFBFBF"]
    "15" [label="type_traits" tooltip="type_traits"]
    "8" [label="algorithm" tooltip="algorithm"]
    "10" [label="memory" tooltip="memory"]
    "7" -> "8" [dir=forward tooltip="include"]
    "7" -> "9" [dir=forward tooltip="include"]
    "7" -> "10" [dir=forward tooltip="include"]
    "7" -> "11" [dir=forward tooltip="include"]
    "7" -> "12" [dir=forward tooltip="include"]
    "7" -> "13" [dir=forward tooltip="include"]
    "7" -> "14" [dir=forward tooltip="include"]
    "7" -> "15" [dir=forward tooltip="include"]
    "7" -> "16" [dir=forward tooltip="include"]
    "7" -> "17" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "4" [dir=forward tooltip="include"]
    "1" -> "5" [dir=forward tooltip="include"]
    "1" -> "6" [dir=forward tooltip="include"]
    "1" -> "7" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include crypto.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "10" [label="src/stream.cpp" tooltip="src/stream.cpp"]
    "3" [label="src/crypto.cpp" tooltip="src/crypto.cpp"]
    "6" [label="src/rtsp.h" tooltip="src/rtsp.h"]
    "11" [label="src/upnp.cpp" tooltip="src/upnp.cpp"]
    "7" [label="src/config.cpp" tooltip="src/config.cpp"]
    "8" [label="src/process.h" tooltip="src/process.h"]
    "5" [label="src/process.cpp" tooltip="src/process.cpp"]
    "9" [label="src/main.cpp" tooltip="src/main.cpp"]
    "12" [label="src/stream.h" tooltip="src/stream.h"]
    "2" [label="src/confighttp.cpp" tooltip="src/confighttp.cpp"]
    "1" [label="src/crypto.h" tooltip="src/crypto.h" fillcolor="#BFBFBF"]
    "4" [label="src/httpcommon.cpp" tooltip="src/httpcommon.cpp"]
    "6" -> "7" [dir=back tooltip="include"]
    "6" -> "2" [dir=back tooltip="include"]
    "6" -> "4" [dir=back tooltip="include"]
    "6" -> "8" [dir=back tooltip="include"]
    "6" -> "11" [dir=back tooltip="include"]
    "8" -> "2" [dir=back tooltip="include"]
    "8" -> "4" [dir=back tooltip="include"]
    "8" -> "9" [dir=back tooltip="include"]
    "8" -> "5" [dir=back tooltip="include"]
    "8" -> "10" [dir=back tooltip="include"]
    "12" -> "10" [dir=back tooltip="include"]
    "12" -> "11" [dir=back tooltip="include"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "3" [dir=back tooltip="include"]
    "1" -> "4" [dir=back tooltip="include"]
    "1" -> "5" [dir=back tooltip="include"]
    "1" -> "6" [dir=back tooltip="include"]
    "1" -> "12" [dir=back tooltip="include"]
}

todo

namespace crypto#

Typedefs

using aes_t = std::vector<std::uint8_t>#
using bignum_t = util::safe_ptr<BIGNUM, BN_free>#
using bio_t = util::safe_ptr<BIO, BIO_free_all>#
using cipher_ctx_t = util::safe_ptr<EVP_CIPHER_CTX, EVP_CIPHER_CTX_free>#
using md_ctx_t = util::safe_ptr<EVP_MD_CTX, md_ctx_destroy>#
using pkey_ctx_t = util::safe_ptr<EVP_PKEY_CTX, EVP_PKEY_CTX_free>#
using pkey_t = util::safe_ptr<EVP_PKEY, EVP_PKEY_free>#
using sha256_t = std::array<std::uint8_t, SHA256_DIGEST_LENGTH>#
using x509_store_ctx_t = util::safe_ptr<X509_STORE_CTX, X509_STORE_CTX_free>#
using x509_store_t = util::safe_ptr<X509_STORE, X509_STORE_free>#
using x509_t = util::safe_ptr<X509, X509_free>#
class cert_chain_t#

Public Functions

void add(x509_t &&cert)#
cert_chain_t()#
cert_chain_t(cert_chain_t&&) noexcept = default#
void clear()#
cert_chain_t &operator=(cert_chain_t&&) noexcept = default#
const char *verify(x509_t::element_type *cert)#

When certificates from two or more instances of Moonlight have been added to x509_store_t, only one of them will be verified by X509_verify_cert, resulting in only a single instance of Moonlight to be able to use Sunshine

To circumvent this, x509_store_t instance will be created for each instance of the certificates.

Private Members

x509_store_ctx_t _cert_ctx#
std::vector<std::pair<x509_t, x509_store_t>> _certs#
struct creds_t#

Public Members

std::string pkey#
std::string x509#
namespace cipher#

Functions

constexpr std::size_t round_to_pkcs7_padded(std::size_t size)#

Variables

constexpr std::size_t tag_size = 16#
class cbc_t : public crypto::cipher::cipher_t#

Inheritence diagram for crypto::cipher::cbc_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="crypto::cipher::cbc_t" tooltip="crypto::cipher::cbc_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for crypto::cipher::cbc_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >" tooltip="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >"]
    "1" [label="crypto::cipher::cbc_t" tooltip="crypto::cipher::cbc_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "2" -> "3" [dir=forward tooltip="usage"]
}

Public Functions

cbc_t() = default#
cbc_t(cbc_t&&) noexcept = default#
cbc_t(const crypto::aes_t &key, bool padding = true)#
int encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv)#

length of cipher must be at least: round_to_pkcs7_padded(plaintext.size())

return -1 on error return bytes written on success

cbc_t &operator=(cbc_t&&) noexcept = default#
class cipher_t#

Inheritence diagram for crypto::cipher::cipher_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="crypto::cipher::ecb_t" tooltip="crypto::cipher::ecb_t"]
    "4" [label="crypto::cipher::gcm_t" tooltip="crypto::cipher::gcm_t"]
    "2" [label="crypto::cipher::cbc_t" tooltip="crypto::cipher::cbc_t"]
    "1" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t" fillcolor="#BFBFBF"]
    "3" -> "1" [dir=forward tooltip="public-inheritance"]
    "4" -> "1" [dir=forward tooltip="public-inheritance"]
    "2" -> "1" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for crypto::cipher::cipher_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >" tooltip="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >"]
    "1" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="usage"]
}

Subclassed by crypto::cipher::cbc_t, crypto::cipher::ecb_t, crypto::cipher::gcm_t

Public Members

cipher_ctx_t decrypt_ctx#
cipher_ctx_t encrypt_ctx#
aes_t key#
bool padding#
class ecb_t : public crypto::cipher::cipher_t#

Inheritence diagram for crypto::cipher::ecb_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="crypto::cipher::ecb_t" tooltip="crypto::cipher::ecb_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for crypto::cipher::ecb_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >" tooltip="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >"]
    "1" [label="crypto::cipher::ecb_t" tooltip="crypto::cipher::ecb_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "2" -> "3" [dir=forward tooltip="usage"]
}

Public Functions

int decrypt(const std::string_view &cipher, std::vector<std::uint8_t> &plaintext)#
ecb_t() = default#
ecb_t(const aes_t &key, bool padding = true)#
ecb_t(ecb_t&&) noexcept = default#
int encrypt(const std::string_view &plaintext, std::vector<std::uint8_t> &cipher)#
ecb_t &operator=(ecb_t&&) noexcept = default#
class gcm_t : public crypto::cipher::cipher_t#

Inheritence diagram for crypto::cipher::gcm_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="crypto::cipher::gcm_t" tooltip="crypto::cipher::gcm_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for crypto::cipher::gcm_t:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "3" [label="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >" tooltip="util::uniq_ptr< EVP_CIPHER_CTX, EVP_CIPHER_CTX_free >"]
    "1" [label="crypto::cipher::gcm_t" tooltip="crypto::cipher::gcm_t" fillcolor="#BFBFBF"]
    "2" [label="crypto::cipher::cipher_t" tooltip="crypto::cipher::cipher_t"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "2" -> "3" [dir=forward tooltip="usage"]
}

Public Functions

int decrypt(const std::string_view &cipher, std::vector<std::uint8_t> &plaintext, aes_t *iv)#
int encrypt(const std::string_view &plaintext, std::uint8_t *tagged_cipher, aes_t *iv)#

length of cipher must be at least: round_to_pkcs7_padded(plaintext.size()) + crypto::cipher::tag_size

return -1 on error return bytes written on success

gcm_t() = default#
gcm_t(const crypto::aes_t &key, bool padding = true)#
gcm_t(gcm_t&&) noexcept = default#
gcm_t &operator=(gcm_t&&) noexcept = default#