src: update ECPointPointer in ncrypto · nodejs/node@c7b95fc · GitHub
Skip to content

Commit c7b95fc

Browse files
jasnelladuh95
authored andcommitted
src: update ECPointPointer in ncrypto
PR-URL: #56526 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent c008b15 commit c7b95fc

3 files changed

Lines changed: 97 additions & 41 deletions

File tree

deps/ncrypto/ncrypto.cc

Lines changed: 42 additions & 0 deletions

deps/ncrypto/ncrypto.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ using DeleteFnPtr = typename FunctionDeleter<T, function>::Pointer;
198198
using BignumCtxPointer = DeleteFnPtr<BN_CTX, BN_CTX_free>;
199199
using BignumGenCallbackPointer = DeleteFnPtr<BN_GENCB, BN_GENCB_free>;
200200
using ECKeyPointer = DeleteFnPtr<EC_KEY, EC_KEY_free>;
201-
using ECPointPointer = DeleteFnPtr<EC_POINT, EC_POINT_free>;
202201
using EVPKeyCtxPointer = DeleteFnPtr<EVP_PKEY_CTX, EVP_PKEY_CTX_free>;
203202
using EVPMDCtxPointer = DeleteFnPtr<EVP_MD_CTX, EVP_MD_CTX_free>;
204203
using HMACCtxPointer = DeleteFnPtr<HMAC_CTX, HMAC_CTX_free>;
@@ -873,6 +872,32 @@ class ECGroupPointer final {
873872
DeleteFnPtr<EC_GROUP, EC_GROUP_free> group_;
874873
};
875874

875+
class ECPointPointer final {
876+
public:
877+
ECPointPointer();
878+
explicit ECPointPointer(EC_POINT* point);
879+
ECPointPointer(ECPointPointer&& other) noexcept;
880+
ECPointPointer& operator=(ECPointPointer&& other) noexcept;
881+
NCRYPTO_DISALLOW_COPY(ECPointPointer)
882+
~ECPointPointer();
883+
884+
inline bool operator==(std::nullptr_t) noexcept { return point_ == nullptr; }
885+
inline operator bool() const { return point_ != nullptr; }
886+
inline EC_POINT* get() const { return point_.get(); }
887+
inline operator EC_POINT*() const { return point_.get(); }
888+
void reset(EC_POINT* point = nullptr);
889+
EC_POINT* release();
890+
891+
bool setFromBuffer(const Buffer<const unsigned char>& buffer,
892+
const EC_GROUP* group);
893+
bool mul(const EC_GROUP* group, const BIGNUM* priv_key);
894+
895+
static ECPointPointer New(const EC_GROUP* group);
896+
897+
private:
898+
DeleteFnPtr<EC_POINT, EC_POINT_free> point_;
899+
};
900+
876901
#ifndef OPENSSL_NO_ENGINE
877902
class EnginePointer final {
878903
public:

src/crypto/crypto_ec.cc

Lines changed: 29 additions & 40 deletions

0 commit comments

Comments
 (0)