@@ -61,14 +61,14 @@ namespace ncrypto {
6161
6262#if NCRYPTO_DEVELOPMENT_CHECKS
6363#define NCRYPTO_STR (x ) #x
64- #define NCRYPTO_REQUIRE (EXPR ) \
65- { \
64+ #define NCRYPTO_REQUIRE (EXPR ) \
65+ { \
6666 if (!(EXPR) { abort (); }) }
6767
68- #define NCRYPTO_FAIL (MESSAGE ) \
69- do { \
70- std::cerr << " FAIL: " << (MESSAGE) << std::endl; \
71- abort (); \
68+ #define NCRYPTO_FAIL (MESSAGE ) \
69+ do { \
70+ std::cerr << " FAIL: " << (MESSAGE) << std::endl; \
71+ abort (); \
7272 } while (0 );
7373#define NCRYPTO_ASSERT_EQUAL (LHS, RHS, MESSAGE ) \
7474 do { \
@@ -77,31 +77,31 @@ namespace ncrypto {
7777 NCRYPTO_FAIL (MESSAGE); \
7878 } \
7979 } while (0 );
80- #define NCRYPTO_ASSERT_TRUE (COND ) \
81- do { \
82- if (!(COND)) { \
83- std::cerr << " Assert at line " << __LINE__ << " of file " << __FILE__ \
84- << std::endl; \
85- NCRYPTO_FAIL (NCRYPTO_STR (COND)); \
86- } \
80+ #define NCRYPTO_ASSERT_TRUE (COND ) \
81+ do { \
82+ if (!(COND)) { \
83+ std::cerr << " Assert at line " << __LINE__ << " of file " << __FILE__ \
84+ << std::endl; \
85+ NCRYPTO_FAIL (NCRYPTO_STR (COND)); \
86+ } \
8787 } while (0 );
8888#else
8989#define NCRYPTO_FAIL (MESSAGE )
9090#define NCRYPTO_ASSERT_EQUAL (LHS, RHS, MESSAGE )
9191#define NCRYPTO_ASSERT_TRUE (COND )
9292#endif
9393
94- #define NCRYPTO_DISALLOW_COPY (Name ) \
95- Name (const Name&) = delete ; \
94+ #define NCRYPTO_DISALLOW_COPY (Name ) \
95+ Name (const Name&) = delete ; \
9696 Name& operator =(const Name&) = delete ;
97- #define NCRYPTO_DISALLOW_MOVE (Name ) \
98- Name (Name&&) = delete ; \
97+ #define NCRYPTO_DISALLOW_MOVE (Name ) \
98+ Name (Name&&) = delete ; \
9999 Name& operator =(Name&&) = delete ;
100- #define NCRYPTO_DISALLOW_COPY_AND_MOVE (Name ) \
101- NCRYPTO_DISALLOW_COPY (Name) \
100+ #define NCRYPTO_DISALLOW_COPY_AND_MOVE (Name ) \
101+ NCRYPTO_DISALLOW_COPY (Name) \
102102 NCRYPTO_DISALLOW_MOVE (Name)
103- #define NCRYPTO_DISALLOW_NEW_DELETE () \
104- void * operator new (size_t ) = delete ; \
103+ #define NCRYPTO_DISALLOW_NEW_DELETE () \
104+ void * operator new (size_t ) = delete ; \
105105 void operator delete (void *) = delete ;
106106
107107[[noreturn]] inline void unreachable () {
@@ -299,7 +299,8 @@ class Cipher final {
299299 const CipherParams& params,
300300 const Buffer<const void > in);
301301
302- static DataPointer sign (const EVPKeyPointer& key, const CipherParams& params,
302+ static DataPointer sign (const EVPKeyPointer& key,
303+ const CipherParams& params,
303304 const Buffer<const void > in);
304305
305306 static DataPointer recover (const EVPKeyPointer& key,
@@ -392,7 +393,8 @@ class BignumPointer final {
392393
393394 static DataPointer Encode (const BIGNUM* bn);
394395 static DataPointer EncodePadded (const BIGNUM* bn, size_t size);
395- static size_t EncodePaddedInto (const BIGNUM* bn, unsigned char * out,
396+ static size_t EncodePaddedInto (const BIGNUM* bn,
397+ unsigned char * out,
396398 size_t size);
397399 static int GetBitCount (const BIGNUM* bn);
398400 static int GetByteCount (const BIGNUM* bn);
@@ -439,8 +441,11 @@ class Rsa final {
439441 const std::optional<PssParams> getPssParams () const ;
440442
441443 bool setPublicKey (BignumPointer&& n, BignumPointer&& e);
442- bool setPrivateKey (BignumPointer&& d, BignumPointer&& q, BignumPointer&& p,
443- BignumPointer&& dp, BignumPointer&& dq,
444+ bool setPrivateKey (BignumPointer&& d,
445+ BignumPointer&& q,
446+ BignumPointer&& p,
447+ BignumPointer&& dp,
448+ BignumPointer&& dq,
444449 BignumPointer&& qi);
445450
446451 using CipherParams = Cipher::CipherParams;
@@ -613,16 +618,19 @@ class CipherCtxPointer final {
613618 bool setAeadTag (const Buffer<const char >& tag);
614619 bool setAeadTagLength (size_t length);
615620 bool setPadding (bool padding);
616- bool init (const Cipher& cipher, bool encrypt,
621+ bool init (const Cipher& cipher,
622+ bool encrypt,
617623 const unsigned char * key = nullptr ,
618624 const unsigned char * iv = nullptr );
619625
620626 int getBlockSize () const ;
621627 int getMode () const ;
622628 int getNid () const ;
623629
624- bool update (const Buffer<const unsigned char >& in, unsigned char * out,
625- int * out_len, bool finalize = false );
630+ bool update (const Buffer<const unsigned char >& in,
631+ unsigned char * out,
632+ int * out_len,
633+ bool finalize = false );
626634 bool getAeadTag (size_t len, unsigned char * out);
627635
628636 private:
@@ -678,7 +686,8 @@ class EVPKeyCtxPointer final {
678686
679687 static constexpr int kDefaultRsaExponent = 0x10001 ;
680688
681- static bool setRsaPadding (EVP_PKEY_CTX* ctx, int padding,
689+ static bool setRsaPadding (EVP_PKEY_CTX* ctx,
690+ int padding,
682691 std::optional<int > salt_len = std::nullopt );
683692
684693 EVPKeyPointer paramgen () const ;
@@ -731,7 +740,8 @@ class EVPKeyPointer final {
731740 PKFormatType format = PKFormatType::DER;
732741 PKEncodingType type = PKEncodingType::PKCS8;
733742 AsymmetricKeyEncodingConfig () = default ;
734- AsymmetricKeyEncodingConfig (bool output_key_object, PKFormatType format,
743+ AsymmetricKeyEncodingConfig (bool output_key_object,
744+ PKFormatType format,
735745 PKEncodingType type);
736746 AsymmetricKeyEncodingConfig (const AsymmetricKeyEncodingConfig&) = default ;
737747 AsymmetricKeyEncodingConfig& operator =(const AsymmetricKeyEncodingConfig&) =
@@ -743,7 +753,8 @@ class EVPKeyPointer final {
743753 const EVP_CIPHER* cipher = nullptr ;
744754 std::optional<DataPointer> passphrase = std::nullopt ;
745755 PrivateKeyEncodingConfig () = default ;
746- PrivateKeyEncodingConfig (bool output_key_object, PKFormatType format,
756+ PrivateKeyEncodingConfig (bool output_key_object,
757+ PKFormatType format,
747758 PKEncodingType type)
748759 : AsymmetricKeyEncodingConfig(output_key_object, format, type) {}
749760 PrivateKeyEncodingConfig (const PrivateKeyEncodingConfig&);
@@ -1072,7 +1083,8 @@ class X509View final {
10721083 INVALID_NAME,
10731084 OPERATION_FAILED,
10741085 };
1075- CheckMatch checkHost (const std::string_view host, int flags,
1086+ CheckMatch checkHost (const std::string_view host,
1087+ int flags,
10761088 DataPointer* peerName = nullptr ) const ;
10771089 CheckMatch checkEmail (const std::string_view email, int flags) const ;
10781090 CheckMatch checkIp (const std::string_view ip, int flags) const ;
@@ -1404,35 +1416,53 @@ const EVP_CIPHER* getCipherByName(const std::string_view name);
14041416// hash size for the given digest algorithm.
14051417bool checkHkdfLength (const EVP_MD* md, size_t length);
14061418
1407- bool extractP1363 (const Buffer<const unsigned char >& buf, unsigned char * dest,
1419+ bool extractP1363 (const Buffer<const unsigned char >& buf,
1420+ unsigned char * dest,
14081421 size_t n);
14091422
1410- bool hkdfInfo (const EVP_MD* md, const Buffer<const unsigned char >& key,
1423+ bool hkdfInfo (const EVP_MD* md,
1424+ const Buffer<const unsigned char >& key,
14111425 const Buffer<const unsigned char >& info,
1412- const Buffer<const unsigned char >& salt, size_t length,
1426+ const Buffer<const unsigned char >& salt,
1427+ size_t length,
14131428 Buffer<unsigned char >* out);
14141429
1415- DataPointer hkdf (const EVP_MD* md, const Buffer<const unsigned char >& key,
1430+ DataPointer hkdf (const EVP_MD* md,
1431+ const Buffer<const unsigned char >& key,
14161432 const Buffer<const unsigned char >& info,
1417- const Buffer<const unsigned char >& salt, size_t length);
1433+ const Buffer<const unsigned char >& salt,
1434+ size_t length);
14181435
14191436bool checkScryptParams (uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem);
14201437
14211438bool scryptInto (const Buffer<const char >& pass,
1422- const Buffer<const unsigned char >& salt, uint64_t N, uint64_t r,
1423- uint64_t p, uint64_t maxmem, size_t length,
1439+ const Buffer<const unsigned char >& salt,
1440+ uint64_t N,
1441+ uint64_t r,
1442+ uint64_t p,
1443+ uint64_t maxmem,
1444+ size_t length,
14241445 Buffer<unsigned char >* out);
14251446
14261447DataPointer scrypt (const Buffer<const char >& pass,
1427- const Buffer<const unsigned char >& salt, uint64_t N,
1428- uint64_t r, uint64_t p, uint64_t maxmem, size_t length);
1448+ const Buffer<const unsigned char >& salt,
1449+ uint64_t N,
1450+ uint64_t r,
1451+ uint64_t p,
1452+ uint64_t maxmem,
1453+ size_t length);
14291454
1430- bool pbkdf2Into (const EVP_MD* md, const Buffer<const char >& pass,
1431- const Buffer<const unsigned char >& salt, uint32_t iterations,
1432- size_t length, Buffer<unsigned char >* out);
1455+ bool pbkdf2Into (const EVP_MD* md,
1456+ const Buffer<const char >& pass,
1457+ const Buffer<const unsigned char >& salt,
1458+ uint32_t iterations,
1459+ size_t length,
1460+ Buffer<unsigned char >* out);
14331461
1434- DataPointer pbkdf2 (const EVP_MD* md, const Buffer<const char >& pass,
1435- const Buffer<const unsigned char >& salt, uint32_t iterations,
1462+ DataPointer pbkdf2 (const EVP_MD* md,
1463+ const Buffer<const char >& pass,
1464+ const Buffer<const unsigned char >& salt,
1465+ uint32_t iterations,
14361466 size_t length);
14371467
14381468// ============================================================================
0 commit comments