My Project: dht::crypto::PrivateKey Struct Reference

My Project 3.7.7 C++ Distributed Hash Table

Loading...
Searching...
No Matches
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
PrivateKey & | operator= (PrivateKey &&o) noexcept
| PrivateKey (const uint8_t *src, size_t src_size, const char *password=nullptr)
| PrivateKey (const Blob &src, const std::string &password={})
| PrivateKey (std::string_view src, const std::string &password={})
| operator bool () const
const PublicKey & | getPublicKey () const
const std::shared_ptr< PublicKey > & | getSharedPublicKey () const
int | serialize (uint8_t *out, size_t *out_len, const std::string &password={}) const
Blob | serialize (const std::string &password={}) const
Blob | sign (const uint8_t *data, size_t data_len) const
Blob | sign (std::string_view dat) const
Blob | sign (const Blob &dat) const
Blob | decrypt (const uint8_t *cypher, size_t cypher_len) const
Blob | decrypt (const Blob &cypher) const

## Static Public Member Functions
static PrivateKey | generate (unsigned key_length=4096, gnutls_pk_algorithm_t algo=GNUTLS_PK_RSA)
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 153 of file crypto.h.

## Constructor & Destructor Documentation

## ◆ PrivateKey() [1/3]

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

Takes ownership of an existing gnutls_x509_privkey.

## ◆ PrivateKey() [2/3]

dht::crypto::PrivateKey::PrivateKey | ( | const Blob & | src,
|  | const std::string & | password = {} )
| inline

Definition at line 167 of file crypto.h.

## ◆ PrivateKey() [3/3]

dht::crypto::PrivateKey::PrivateKey | ( | std::string_view | src,
|  | const std::string & | password = {} )
| inline

Definition at line 170 of file crypto.h.

## Member Function Documentation

## ◆ decrypt() [1/2]

Blob dht::crypto::PrivateKey::decrypt | ( | const Blob & | cypher | ) | const
| inline

Definition at line 197 of file crypto.h.

## ◆ decrypt() [2/2]

Blob dht::crypto::PrivateKey::decrypt | ( | const uint8_t * | cypher,
|  | size_t | cypher_len ) const

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

Returns
  the decrypted data.

## ◆ generate()

PrivateKey dht::crypto::PrivateKey::generate | ( | unsigned | key_length = 4096,
|  | gnutls_pk_algorithm_t | algo = GNUTLS_PK_RSA )
| static

Generate a new RSA key pair

Parameters

  key_length | : size of the modulus in bits Minimim value: 2048 Recommended values: 4096, 8192
  algo | : the public key algorithm to use, GNUTLS_PK_RSA or GNUTLS_PK_RSA_OAEP

## ◆ operator bool()

dht::crypto::PrivateKey::operator bool | ( |  | ) | const
| inlineexplicit

Definition at line 175 of file crypto.h.

## ◆ sign() [1/3]

Blob dht::crypto::PrivateKey::sign | ( | const Blob & | dat | ) | const
| inline

Definition at line 189 of file crypto.h.

## ◆ sign() [2/3]

Blob dht::crypto::PrivateKey::sign | ( | const uint8_t * | data,
|  | size_t | data_len ) const

Sign the provided binary object.

Returns
  the signature data.

## ◆ sign() [3/3]

Blob dht::crypto::PrivateKey::sign | ( | std::string_view | dat | ) | const
| inline

Definition at line 188 of file crypto.h.

## Member Data Documentation

## ◆ key

gnutls_privkey_t dht::crypto::PrivateKey::key {}

Definition at line 209 of file crypto.h.

## ◆ x509_key

gnutls_x509_privkey_t dht::crypto::PrivateKey::x509_key {}

Definition at line 210 of file crypto.h.

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

- /home/noptrix/ba/blackarch/packages/opendht-c/src/opendht/include/opendht/crypto.h