implement ecdsa

This commit is contained in:
2025-01-30 16:39:23 -08:00
parent 15c48ab1dc
commit eb01b304e3
7 changed files with 101 additions and 3 deletions

View File

@@ -41,8 +41,10 @@ struct Ref : std::unique_ptr<T, RefDeleter<T>>
explicit Ref(T *x) noexcept : base{x} {}
Ref(Ref &&ref) noexcept = default;
Ref(const Ref &ref) noexcept {
*this = ref;
Ref(const Ref &ref) noexcept : base{ref.get()} {
if (*this) {
RefTraits<T>::UpRef(this->get());
}
}
Ref &operator=(Ref&&) noexcept = default;

View File

@@ -1,5 +1,7 @@
#pragma once
#include "ref.hpp"
#include <boost/signals2.hpp>
#include <memory>
@@ -74,3 +76,35 @@ public:
return complete_;
}
};
class SaslEcdsa final : public SaslMechanism
{
std::string message1_;
Ref<EVP_PKEY> key_;
int stage_;
public:
SaslEcdsa(std::string authcid, std::string authzid, Ref<EVP_PKEY> key)
: message1_{std::move(authcid)}
, key_{std::move(key)}
, stage_{0}
{
if (not authzid.empty()) {
message1_.push_back(0);
message1_.append(authzid);
}
}
auto mechanism_name() const -> std::string override
{
return "ECDSA-NIST256P-CHALLENGE";
}
auto step(std::string_view msg) -> StepResult override;
auto is_complete() const -> bool override
{
return stage_ == 2;;
}
};