5252#ifdef OPENSSL_IS_BORINGSSL
5353#define NCRYPTO_USE_BORINGSSL 1
5454#define NCRYPTO_USE_OPENSSL_PROVIDER 0
55- #else
55+ #elif OPENSSL_VERSION_PREREQ(3, 0)
5656#define NCRYPTO_USE_BORINGSSL 0
5757#define NCRYPTO_USE_OPENSSL_PROVIDER 1
58+ #else
59+ #error "Unsupported crypto backend"
5860#endif
5961
6062#define NCRYPTO_USE_LEGACY_KEY_TYPES NCRYPTO_USE_BORINGSSL
@@ -404,6 +406,8 @@ class DigestCache final {
404406 static_cast <void >(id);
405407 static_cast <void >(generation);
406408 return {};
409+ #else
410+ #error "Unsupported crypto backend"
407411#endif
408412 }
409413 Result insert (const char * name, const EVP_MD * digest, uint64_t generation);
@@ -591,6 +595,8 @@ class Dsa final {
591595 explicit Dsa (const EVP_PKEY * pkey);
592596#elif NCRYPTO_USE_BORINGSSL
593597 Dsa (OSSL3_CONST DSA * dsa);
598+ #else
599+ #error "Unsupported crypto backend"
594600#endif
595601 NCRYPTO_DISALLOW_COPY_AND_MOVE (Dsa)
596602
@@ -600,6 +606,8 @@ class Dsa final {
600606 }
601607#elif NCRYPTO_USE_BORINGSSL
602608 inline operator bool () const { return dsa_ != nullptr ; }
609+ #else
610+ #error "Unsupported crypto backend"
603611#endif
604612#if NCRYPTO_USE_LEGACY_KEY_TYPES
605613 inline operator OSSL3_CONST DSA *() const { return dsa_; }
@@ -617,6 +625,8 @@ class Dsa final {
617625 DeleteFnPtr<BIGNUM , BN_free> q_;
618626#elif NCRYPTO_USE_BORINGSSL
619627 OSSL3_CONST DSA * dsa_;
628+ #else
629+ #error "Unsupported crypto backend"
620630#endif
621631};
622632
@@ -632,6 +642,8 @@ class Rsa final {
632642 explicit Rsa (const EVP_PKEY * pkey, Selection selection = Selection::Private);
633643#elif NCRYPTO_USE_BORINGSSL
634644 Rsa (OSSL3_CONST RSA * rsa);
645+ #else
646+ #error "Unsupported crypto backend"
635647#endif
636648 NCRYPTO_DISALLOW_COPY_AND_MOVE (Rsa)
637649
@@ -641,6 +653,8 @@ class Rsa final {
641653 }
642654#elif NCRYPTO_USE_BORINGSSL
643655 inline operator bool () const { return rsa_ != nullptr ; }
656+ #else
657+ #error "Unsupported crypto backend"
644658#endif
645659#if NCRYPTO_USE_LEGACY_KEY_TYPES
646660 inline operator OSSL3_CONST RSA *() const { return rsa_; }
@@ -724,6 +738,8 @@ class Rsa final {
724738 std::optional<PssParams> pss_params_;
725739#elif NCRYPTO_USE_BORINGSSL
726740 OSSL3_CONST RSA * rsa_;
741+ #else
742+ #error "Unsupported crypto backend"
727743#endif
728744};
729745
@@ -734,6 +750,8 @@ class Ec final {
734750 explicit Ec (const EVP_PKEY * pkey);
735751#elif NCRYPTO_USE_BORINGSSL
736752 Ec (OSSL3_CONST EC_KEY * key);
753+ #else
754+ #error "Unsupported crypto backend"
737755#endif
738756 NCRYPTO_DISALLOW_COPY_AND_MOVE (Ec)
739757
@@ -772,6 +790,8 @@ class Ec final {
772790 point_conversion_form_t form_ = POINT_CONVERSION_UNCOMPRESSED ;
773791#elif NCRYPTO_USE_BORINGSSL
774792 OSSL3_CONST EC_KEY * ec_ = nullptr ;
793+ #else
794+ #error "Unsupported crypto backend"
775795#endif
776796};
777797
@@ -1216,6 +1236,8 @@ class EVPKeyPointer final {
12161236 static EVPKeyPointer NewRSA (const Rsa& rsa);
12171237#elif NCRYPTO_USE_BORINGSSL
12181238 static EVPKeyPointer NewRSA (RSAPointer&& rsa);
1239+ #else
1240+ #error "Unsupported crypto backend"
12191241#endif
12201242
12211243 enum class PKEncodingType {
@@ -1404,6 +1426,8 @@ class DHPointer final {
14041426 DHPointer (BignumPointer&& p, BignumPointer&& g, const char * group_name);
14051427#elif NCRYPTO_USE_BORINGSSL
14061428 explicit DHPointer (DH * dh);
1429+ #else
1430+ #error "Unsupported crypto backend"
14071431#endif
14081432 DHPointer (DHPointer&& other) noexcept ;
14091433 DHPointer& operator =(DHPointer&& other) noexcept ;
@@ -1420,17 +1444,21 @@ class DHPointer final {
14201444#elif NCRYPTO_USE_BORINGSSL
14211445 inline bool operator ==(std::nullptr_t ) noexcept { return dh_ == nullptr ; }
14221446 inline operator bool () const { return dh_ != nullptr ; }
1447+ #else
1448+ #error "Unsupported crypto backend"
14231449#endif
1424- #if NCRYPTO_USE_LEGACY_KEY_TYPES
1450+ #if NCRYPTO_USE_BORINGSSL
14251451 inline DH * get () const { return dh_.get (); }
14261452 void reset (DH * dh = nullptr );
14271453 DH * release ();
1428- #else
1454+ #elif NCRYPTO_USE_OPENSSL_PROVIDER
14291455 inline EVP_PKEY * get () const {
14301456 return dh_.get ();
14311457 }
14321458 void reset (EVP_PKEY * dh = nullptr );
14331459 EVP_PKEY * release ();
1460+ #else
1461+ #error "Unsupported crypto backend"
14341462#endif
14351463
14361464 enum class CheckResult {
@@ -1488,6 +1516,8 @@ class DHPointer final {
14881516 const char * group_name_ = nullptr ;
14891517#elif NCRYPTO_USE_BORINGSSL
14901518 DeleteFnPtr<DH , DH_free> dh_;
1519+ #else
1520+ #error "Unsupported crypto backend"
14911521#endif
14921522};
14931523
@@ -1824,14 +1854,18 @@ class ECKeyPointer final {
18241854#elif NCRYPTO_USE_BORINGSSL
18251855 inline bool operator ==(std::nullptr_t ) noexcept { return key_ == nullptr ; }
18261856 inline operator bool () const { return key_ != nullptr ; }
1857+ #else
1858+ #error "Unsupported crypto backend"
18271859#endif
1828- #if NCRYPTO_USE_LEGACY_KEY_TYPES
1860+ #if NCRYPTO_USE_BORINGSSL
18291861 inline EC_KEY * get () const { return key_.get (); }
18301862 inline operator EC_KEY *() const { return key_.get (); }
18311863 void reset (EC_KEY * key = nullptr );
18321864 EC_KEY * release ();
1833- #else
1865+ #elif NCRYPTO_USE_OPENSSL_PROVIDER
18341866 void reset ();
1867+ #else
1868+ #error "Unsupported crypto backend"
18351869#endif
18361870
18371871 ECKeyPointer clone () const ;
@@ -1865,6 +1899,8 @@ class ECKeyPointer final {
18651899 DeleteFnPtr<BIGNUM , BN_clear_free> priv_;
18661900#elif NCRYPTO_USE_BORINGSSL
18671901 DeleteFnPtr<EC_KEY , EC_KEY_free> key_;
1902+ #else
1903+ #error "Unsupported crypto backend"
18681904#endif
18691905};
18701906
0 commit comments