Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
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:

Go to the source code of this file.

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)
sha256_t crypto::hash (const std::string_view &plaintext)
 Hashes the given plaintext using SHA-256.
x509_t crypto::x509 (const std::string_view &x)
pkey_t crypto::pkey (const std::string_view &k)
std::string crypto::pem (x509_t &x509)
std::string crypto::pem (pkey_t &pkey)
std::string_view crypto::signature (const x509_t &x)
std::string crypto::rand (std::size_t bytes)
std::vector< uint8_t > crypto::sign (const pkey_t &pkey, const std::string_view &data, const EVP_MD *md)
creds_t crypto::gen_creds (const std::string_view &cn, std::uint32_t key_bits)
std::vector< uint8_t > crypto::sign256 (const pkey_t &pkey, const std::string_view &data)
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)
void crypto::md_ctx_destroy (EVP_MD_CTX *ctx)
std::string crypto::rand_alphabet (std::size_t bytes, const std::string_view &alphabet)

Detailed Description

Definitions for cryptography functions.

Definition in file crypto.cpp.

Typedef Documentation

◆ asn1_string_t

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

Definition at line 13 of file crypto.cpp.

Function Documentation

◆ gen_aes_key()

aes_t crypto::gen_aes_key ( const std::array< uint8_t, 16 > & salt,
const std::string_view & pin )

Definition at line 348 of file crypto.cpp.

◆ gen_creds()

creds_t crypto::gen_creds ( const std::string_view & cn,
std::uint32_t key_bits )

Definition at line 459 of file crypto.cpp.

◆ 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.

Definition at line 364 of file crypto.cpp.

◆ md_ctx_destroy()

void crypto::md_ctx_destroy ( EVP_MD_CTX * ctx)

Definition at line 533 of file crypto.cpp.

◆ pem() [1/2]

std::string crypto::pem ( pkey_t & pkey)

Definition at line 402 of file crypto.cpp.

◆ pem() [2/2]

std::string crypto::pem ( x509_t & x509)

Definition at line 392 of file crypto.cpp.

◆ pkey()

pkey_t crypto::pkey ( const std::string_view & k)

Definition at line 381 of file crypto.cpp.

◆ rand()

std::string crypto::rand ( std::size_t bytes)

Definition at line 426 of file crypto.cpp.

◆ rand_alphabet()

std::string crypto::rand_alphabet ( std::size_t bytes,
const std::string_view & alphabet )

Definition at line 537 of file crypto.cpp.

◆ sign()

std::vector< uint8_t > crypto::sign ( const pkey_t & pkey,
const std::string_view & data,
const EVP_MD * md )

Definition at line 435 of file crypto.cpp.

◆ sign256()

std::vector< uint8_t > crypto::sign256 ( const pkey_t & pkey,
const std::string_view & data )

Definition at line 505 of file crypto.cpp.

◆ signature()

std::string_view crypto::signature ( const x509_t & x)

Definition at line 412 of file crypto.cpp.

◆ verify()

bool crypto::verify ( const x509_t & x509,
const std::string_view & data,
const std::string_view & signature,
const EVP_MD * md )

Definition at line 509 of file crypto.cpp.

◆ verify256()

bool crypto::verify256 ( const x509_t & x509,
const std::string_view & data,
const std::string_view & signature )

Definition at line 529 of file crypto.cpp.

◆ x509()

x509_t crypto::x509 ( const std::string_view & x)

Definition at line 370 of file crypto.cpp.