C++ Distributed Hash Table
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
dht::crypto::PrivateKey Struct Reference

#include <crypto.h>

Public Member Functions

 PrivateKey (gnutls_x509_privkey_t k)
 
 PrivateKey (PrivateKey &&o) noexcept
 
PrivateKeyoperator= (PrivateKey &&o) noexcept
 
 PrivateKey (const Blob &import, const std::string &password={})
 
 operator bool () const
 
PublicKey getPublicKey () const
 
Blob serialize (const std::string &password={}) const
 
Blob sign (const Blob &) const
 
Blob decrypt (const Blob &cypher) const
 

Static Public Member Functions

static PrivateKey generate (unsigned key_length=4096)
 
static PrivateKey generateEC ()
 

Public Attributes

gnutls_privkey_t key {}
 
gnutls_x509_privkey_t x509_key {}
 

Detailed Description

A private key, including the corresponding public key.

Definition at line 128 of file crypto.h.

Constructor & Destructor Documentation

◆ PrivateKey()

dht::crypto::PrivateKey::PrivateKey ( gnutls_x509_privkey_t  k)

Takes ownership of an existing gnutls_x509_privkey.

Member Function Documentation

◆ decrypt()

Blob dht::crypto::PrivateKey::decrypt ( const Blob cypher) const

Try to decrypt the provided cypher text. In case of failure a CryptoException is thrown.

Returns
the decrypted data.

◆ generate()

static PrivateKey dht::crypto::PrivateKey::generate ( unsigned  key_length = 4096)
static

Generate a new RSA key pair

Parameters
key_length: size of the modulus in bits Minimim value: 2048 Recommended values: 4096, 8192

◆ sign()

Blob dht::crypto::PrivateKey::sign ( const Blob ) const

Sign the provided binary object.

Returns
the signature data.

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