Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-chrismc committed Dec 7, 2023
1 parent 52a8637 commit c347270
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/jwt-cpp/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,24 @@ namespace jwt {
*/
class evp_pkey_handle {
public:
/// @brief Creates a null key pointer
constexpr evp_pkey_handle() noexcept = default;
/// @brief Creates a owning handle wrapper around an existing raw key
/// @param key Existing key to reference count
/// This does not increment the reference count
explicit evp_pkey_handle(EVP_PKEY* key) noexcept {
#ifdef JWT_OPENSSL_1_0_0
m_key = std::shared_ptr<EVP_PKEY>(key, EVP_PKEY_free);
#else
m_key = key;
#endif
}
evp_pkey_handle(const evp_pkey_handle& other) = default;
/// @brief Create a new handle incrementing the reference count
/// @param other key pointer to copy and increase
/// @throws std::runtime_error
evp_pkey_handle(const evp_pkey_handle& other) : m_key{other.m_key} { increment_ref_count(m_key); }
evp_pkey_handle(evp_pkey_handle&& other) noexcept : m_key{other.m_key} { other.m_key = nullptr; }
~evp_pkey_handle() noexcept { decrement_ref_count(m_key); }

EVP_PKEY* get() const noexcept {
#ifdef JWT_OPENSSL_1_0_0
Expand Down Expand Up @@ -103,7 +112,6 @@ namespace jwt {
increment_ref_count(m_key);
return *this;
}
~evp_pkey_handle() noexcept { decrement_ref_count(m_key); }

private:
#ifdef JWT_OPENSSL_1_0_0
Expand Down

0 comments on commit c347270

Please sign in to comment.