@@ -616,13 +616,51 @@ class CipherPushContext {
616
616
Environment* env_;
617
617
};
618
618
619
+ #if OPENSSL_VERSION_MAJOR >= 3
620
+ template <class TypeName ,
621
+ TypeName* fetch_type (OSSL_LIB_CTX*, const char *, const char *),
622
+ void free_type(TypeName*),
623
+ const TypeName* getbyname(const char *),
624
+ const char* getname(const TypeName*)>
625
+ void array_push_back(const TypeName* evp_ref,
626
+ const char * from,
627
+ const char * to,
628
+ void * arg) {
629
+ if (!from)
630
+ return ;
631
+
632
+ const TypeName* real_instance = getbyname (from);
633
+ if (!real_instance)
634
+ return ;
635
+
636
+ const char * real_name = getname (real_instance);
637
+ if (!real_name)
638
+ return ;
639
+
640
+ // EVP_*_fetch() does not support alias names, so we need to pass it the
641
+ // real/original algorithm name
642
+ // We use EVP_*_fetch() as a filter here because it will only return an
643
+ // instance if the algorithm is supported by the public OpenSSL APIs (some
644
+ // algorithms are used internally by OpenSSL and are also passed to this
645
+ // callback)
646
+ TypeName* fetched = fetch_type (nullptr , real_name, nullptr );
647
+ if (!fetched)
648
+ return ;
649
+
650
+ free_type (fetched);
651
+ static_cast <CipherPushContext*>(arg)->push_back (from);
652
+ }
653
+ #else
619
654
template <class TypeName >
620
- void array_push_back (const TypeName* md ,
655
+ void array_push_back (const TypeName* evp_ref ,
621
656
const char * from,
622
657
const char * to,
623
658
void * arg) {
659
+ if (!from)
660
+ return ;
624
661
static_cast <CipherPushContext*>(arg)->push_back (from);
625
662
}
663
+ #endif
626
664
627
665
inline bool IsAnyByteSource (v8::Local<v8::Value> arg) {
628
666
return arg->IsArrayBufferView () ||
0 commit comments