Sunshine latest
Self-hosted game stream host for Moonlight.
crypto.cpp File Reference

Definitions for cryptography functions. More...

#include <openssl/pem.h>
#include <openssl/rsa.h>
#include "crypto.h"
Include dependency graph for crypto.cpp:

Typedefs

using crypto::asn1_string_t = util::safe_ptr<ASN1_STRING, ASN1_STRING_free>
 

Functions

aes_t crypto::gen_aes_key (const std::array< uint8_t, 16 > &salt, const std::string_view &pin)
 
creds_t crypto::gen_creds (const std::string_view &cn, std::uint32_t key_bits)
 
sha256_t crypto::hash (const std::string_view &plaintext)
 Hashes the given plaintext using SHA-256.
 
void crypto::md_ctx_destroy (EVP_MD_CTX *ctx)
 
std::string crypto::pem (pkey_t &pkey)
 
std::string crypto::pem (x509_t &x509)
 
pkey_t crypto::pkey (const std::string_view &k)
 
std::string crypto::rand (std::size_t bytes)
 
std::string crypto::rand_alphabet (std::size_t bytes, const std::string_view &alphabet)
 
std::vector< uint8_t > crypto::sign (const pkey_t &pkey, const std::string_view &data, const EVP_MD *md)
 
std::vector< uint8_t > crypto::sign256 (const pkey_t &pkey, const std::string_view &data)
 
std::string_view crypto::signature (const x509_t &x)
 
bool crypto::verify (const x509_t &x509, const std::string_view &data, const std::string_view &signature, const EVP_MD *md)
 
bool crypto::verify256 (const x509_t &x509, const std::string_view &data, const std::string_view &signature)
 
x509_t crypto::x509 (const std::string_view &x)
 

Detailed Description

Definitions for cryptography functions.

Function Documentation

◆ hash()

sha256_t crypto::hash ( const std::string_view & plaintext)

Hashes the given plaintext using SHA-256.

Parameters
plaintext
Returns
The SHA-256 hash of the plaintext.