RADLib
RADical C++ application framework
RADSecurity::Crypto Class Reference

Digest and signing primitives backed by OpenSSL. More...

#include <RADSecurity.h>

Static Public Member Functions

static std::vector< uint8_t > sha256 (const std::vector< uint8_t > &bytes)
 Computes SHA-256 over bytes. More...
 
static std::vector< uint8_t > sha256 (const std::string &text)
 Computes SHA-256 over text bytes. More...
 
static RADCore::RADResult< std::vector< uint8_t > > sha256File (const std::string &path)
 Computes SHA-256 over file contents. More...
 
static std::string toHex (const std::vector< uint8_t > &bytes)
 Returns lowercase hexadecimal text for bytes. More...
 
static RADCore::RADResult< std::vector< uint8_t > > fromHex (const std::string &hex)
 Parses lowercase or uppercase hexadecimal text. More...
 
static RADCore::RADResult< std::vector< uint8_t > > randomBytes (size_t count)
 Generates cryptographically secure random bytes. More...
 
static RADCore::RADResult< std::string > generateRsaPrivateKeyPem (int bits=2048)
 Generates an RSA private key in PEM format. More...
 
static RADCore::RADResult< std::string > publicKeyFromPrivateKeyPem (const std::string &privateKeyPem)
 Extracts the public key PEM from a private key PEM. More...
 
static RADCore::RADResult< std::vector< uint8_t > > signSha256 (const std::vector< uint8_t > &bytes, const std::string &privateKeyPem)
 Signs bytes using RSA-SHA256 and a private key PEM. More...
 
static bool verifySha256 (const std::vector< uint8_t > &bytes, const std::vector< uint8_t > &signature, const std::string &publicKeyPem)
 Verifies an RSA-SHA256 signature over bytes. More...
 
static RADCore::RADResult< void > signFileSha256 (const std::string &filePath, const std::string &signaturePath, const std::string &privateKeyPem)
 Signs a file using RSA-SHA256 and writes the signature bytes. More...
 
static bool verifyFileSha256 (const std::string &filePath, const std::string &signaturePath, const std::string &publicKeyPem)
 Verifies a file signature generated by signFileSha256(). More...
 
static RADCore::RADResult< std::string > fileFingerprintSha256 (const std::string &path)
 Returns a SHA-256 fingerprint for a certificate/key file. More...
 

Detailed Description

Digest and signing primitives backed by OpenSSL.

Member Function Documentation

◆ fileFingerprintSha256()

static RADCore::RADResult<std::string> RADSecurity::Crypto::fileFingerprintSha256 ( const std::string &  path)
static

Returns a SHA-256 fingerprint for a certificate/key file.

◆ fromHex()

static RADCore::RADResult<std::vector<uint8_t> > RADSecurity::Crypto::fromHex ( const std::string &  hex)
static

Parses lowercase or uppercase hexadecimal text.

◆ generateRsaPrivateKeyPem()

static RADCore::RADResult<std::string> RADSecurity::Crypto::generateRsaPrivateKeyPem ( int  bits = 2048)
static

Generates an RSA private key in PEM format.

◆ publicKeyFromPrivateKeyPem()

static RADCore::RADResult<std::string> RADSecurity::Crypto::publicKeyFromPrivateKeyPem ( const std::string &  privateKeyPem)
static

Extracts the public key PEM from a private key PEM.

◆ randomBytes()

static RADCore::RADResult<std::vector<uint8_t> > RADSecurity::Crypto::randomBytes ( size_t  count)
static

Generates cryptographically secure random bytes.

◆ sha256() [1/2]

static std::vector<uint8_t> RADSecurity::Crypto::sha256 ( const std::string &  text)
static

Computes SHA-256 over text bytes.

◆ sha256() [2/2]

static std::vector<uint8_t> RADSecurity::Crypto::sha256 ( const std::vector< uint8_t > &  bytes)
static

Computes SHA-256 over bytes.

◆ sha256File()

static RADCore::RADResult<std::vector<uint8_t> > RADSecurity::Crypto::sha256File ( const std::string &  path)
static

Computes SHA-256 over file contents.

◆ signFileSha256()

static RADCore::RADResult<void> RADSecurity::Crypto::signFileSha256 ( const std::string &  filePath,
const std::string &  signaturePath,
const std::string &  privateKeyPem 
)
static

Signs a file using RSA-SHA256 and writes the signature bytes.

◆ signSha256()

static RADCore::RADResult<std::vector<uint8_t> > RADSecurity::Crypto::signSha256 ( const std::vector< uint8_t > &  bytes,
const std::string &  privateKeyPem 
)
static

Signs bytes using RSA-SHA256 and a private key PEM.

◆ toHex()

static std::string RADSecurity::Crypto::toHex ( const std::vector< uint8_t > &  bytes)
static

Returns lowercase hexadecimal text for bytes.

◆ verifyFileSha256()

static bool RADSecurity::Crypto::verifyFileSha256 ( const std::string &  filePath,
const std::string &  signaturePath,
const std::string &  publicKeyPem 
)
static

Verifies a file signature generated by signFileSha256().

◆ verifySha256()

static bool RADSecurity::Crypto::verifySha256 ( const std::vector< uint8_t > &  bytes,
const std::vector< uint8_t > &  signature,
const std::string &  publicKeyPem 
)
static

Verifies an RSA-SHA256 signature over bytes.


The documentation for this class was generated from the following file: