@@ -331,76 +331,76 @@ class Dsa final {
331331};
332332
333333class BignumPointer final {
334- public:
335- BignumPointer () = default ;
336- explicit BignumPointer (BIGNUM* bignum);
337- explicit BignumPointer (const unsigned char * data, size_t len);
338- BignumPointer (BignumPointer&& other) noexcept ;
339- BignumPointer& operator =(BignumPointer&& other) noexcept ;
340- NCRYPTO_DISALLOW_COPY (BignumPointer)
341- ~BignumPointer ();
342-
343- int operator <=>(const BignumPointer& other) const noexcept ;
344- int operator <=>(const BIGNUM* other) const noexcept ;
345- inline operator bool () const { return bn_ != nullptr ; }
346- inline BIGNUM* get () const noexcept { return bn_.get (); }
347- void reset (BIGNUM* bn = nullptr );
348- void reset (const unsigned char * data, size_t len);
349- BIGNUM* release ();
350-
351- bool isZero () const ;
352- bool isOne () const ;
353-
354- bool setWord (unsigned long w); // NOLINT(runtime/int)
355- unsigned long getWord () const ; // NOLINT(runtime/int)
356-
357- size_t byteLength () const ;
358- size_t bitLength () const ;
359-
360- DataPointer toHex () const ;
361- DataPointer encode () const ;
362- DataPointer encodePadded (size_t size) const ;
363- size_t encodeInto (unsigned char * out) const ;
364- size_t encodePaddedInto (unsigned char * out, size_t size) const ;
365-
366- using PrimeCheckCallback = std::function<bool (int , int )>;
367- int isPrime (int checks,
368- PrimeCheckCallback cb = defaultPrimeCheckCallback) const ;
369- struct PrimeConfig {
370- int bits;
371- bool safe = false ;
372- const BignumPointer& add;
373- const BignumPointer& rem;
374- };
375-
376- static BignumPointer NewPrime (
377- const PrimeConfig& params,
378- PrimeCheckCallback cb = defaultPrimeCheckCallback);
379-
380- bool generate (const PrimeConfig& params,
381- PrimeCheckCallback cb = defaultPrimeCheckCallback) const ;
382-
383- static BignumPointer New ();
384- static BignumPointer NewSecure ();
385- static BignumPointer NewSub (const BignumPointer& a, const BignumPointer& b);
386- static BignumPointer NewLShift (size_t length);
387-
388- static DataPointer Encode (const BIGNUM* bn);
389- static DataPointer EncodePadded (const BIGNUM* bn, size_t size);
390- static size_t EncodePaddedInto (const BIGNUM* bn, unsigned char * out,
391- size_t size);
392- static int GetBitCount (const BIGNUM* bn);
393- static int GetByteCount (const BIGNUM* bn);
394- static unsigned long GetWord (const BIGNUM* bn); // NOLINT(runtime/int)
395- static const BIGNUM* One ();
396-
397- BignumPointer clone ();
398-
399- private:
400- DeleteFnPtr<BIGNUM, BN_clear_free> bn_;
401-
402- static bool defaultPrimeCheckCallback (int , int ) { return 1 ; }
403- };
334+ public:
335+ BignumPointer () = default ;
336+ explicit BignumPointer (BIGNUM* bignum);
337+ explicit BignumPointer (const unsigned char * data, size_t len);
338+ BignumPointer (BignumPointer&& other) noexcept ;
339+ BignumPointer& operator =(BignumPointer&& other) noexcept ;
340+ NCRYPTO_DISALLOW_COPY (BignumPointer)
341+ ~BignumPointer ();
342+
343+ int operator <=>(const BignumPointer& other) const noexcept ;
344+ int operator <=>(const BIGNUM* other) const noexcept ;
345+ inline operator bool () const { return bn_ != nullptr ; }
346+ inline BIGNUM* get () const noexcept { return bn_.get (); }
347+ void reset (BIGNUM* bn = nullptr );
348+ void reset (const unsigned char * data, size_t len);
349+ BIGNUM* release ();
350+
351+ bool isZero () const ;
352+ bool isOne () const ;
353+
354+ bool setWord (unsigned long w); // NOLINT(runtime/int)
355+ unsigned long getWord () const ; // NOLINT(runtime/int)
356+
357+ size_t byteLength () const ;
358+ size_t bitLength () const ;
359+
360+ DataPointer toHex () const ;
361+ DataPointer encode () const ;
362+ DataPointer encodePadded (size_t size) const ;
363+ size_t encodeInto (unsigned char * out) const ;
364+ size_t encodePaddedInto (unsigned char * out, size_t size) const ;
365+
366+ using PrimeCheckCallback = std::function<bool (int , int )>;
367+ int isPrime (int checks,
368+ PrimeCheckCallback cb = defaultPrimeCheckCallback) const ;
369+ struct PrimeConfig {
370+ int bits;
371+ bool safe = false ;
372+ const BignumPointer& add;
373+ const BignumPointer& rem;
374+ };
375+
376+ static BignumPointer NewPrime (
377+ const PrimeConfig& params,
378+ PrimeCheckCallback cb = defaultPrimeCheckCallback);
379+
380+ bool generate (const PrimeConfig& params,
381+ PrimeCheckCallback cb = defaultPrimeCheckCallback) const ;
382+
383+ static BignumPointer New ();
384+ static BignumPointer NewSecure ();
385+ static BignumPointer NewSub (const BignumPointer& a, const BignumPointer& b);
386+ static BignumPointer NewLShift (size_t length);
387+
388+ static DataPointer Encode (const BIGNUM* bn);
389+ static DataPointer EncodePadded (const BIGNUM* bn, size_t size);
390+ static size_t EncodePaddedInto (const BIGNUM* bn, unsigned char * out,
391+ size_t size);
392+ static int GetBitCount (const BIGNUM* bn);
393+ static int GetByteCount (const BIGNUM* bn);
394+ static unsigned long GetWord (const BIGNUM* bn); // NOLINT(runtime/int)
395+ static const BIGNUM* One ();
396+
397+ BignumPointer clone ();
398+
399+ private:
400+ DeleteFnPtr<BIGNUM, BN_clear_free> bn_;
401+
402+ static bool defaultPrimeCheckCallback (int , int ) { return 1 ; }
403+ };
404404
405405class Rsa final {
406406 public:
@@ -809,6 +809,8 @@ class EVPKeyPointer final {
809809 bool isSigVariant () const ;
810810 bool validateDsaParameters () const ;
811811
812+ EVPKeyPointer clone () const ;
813+
812814 private:
813815 DeleteFnPtr<EVP_PKEY, EVP_PKEY_free> pkey_;
814816};
0 commit comments