fix: Support for OpenSSL 3.0
This commit is contained in:
parent
50eea778fa
commit
c292a8602b
|
|
@ -18,15 +18,27 @@
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
final libcrypto = Platform.isIOS
|
final libcrypto = () {
|
||||||
? DynamicLibrary.process()
|
if (Platform.isIOS) {
|
||||||
: DynamicLibrary.open(Platform.isAndroid
|
return DynamicLibrary.process();
|
||||||
? 'libcrypto.so'
|
} else if (Platform.isAndroid) {
|
||||||
: Platform.isWindows
|
return DynamicLibrary.open('libcrypto.so');
|
||||||
? 'libcrypto.dll'
|
} else if (Platform.isWindows) {
|
||||||
: Platform.isMacOS
|
return DynamicLibrary.open('libcrypto.dll');
|
||||||
? 'libcrypto.1.1.dylib'
|
} else if (Platform.isMacOS) {
|
||||||
: 'libcrypto.so.1.1');
|
try {
|
||||||
|
return DynamicLibrary.open('libcrypto.3.dylib');
|
||||||
|
} catch (_) {
|
||||||
|
return DynamicLibrary.open('libcrypto.1.1.dylib');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return DynamicLibrary.open('libcrypto.so.3');
|
||||||
|
} catch (_) {
|
||||||
|
return DynamicLibrary.open('libcrypto.so.1.1');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
final PKCS5_PBKDF2_HMAC = libcrypto.lookupFunction<
|
final PKCS5_PBKDF2_HMAC = libcrypto.lookupFunction<
|
||||||
IntPtr Function(
|
IntPtr Function(
|
||||||
|
|
@ -118,6 +130,15 @@ final EVP_Digest = libcrypto.lookupFunction<
|
||||||
Pointer<NativeType> alg,
|
Pointer<NativeType> alg,
|
||||||
Pointer<NativeType> engine)>('EVP_Digest');
|
Pointer<NativeType> engine)>('EVP_Digest');
|
||||||
|
|
||||||
final EVP_MD_size = libcrypto.lookupFunction<
|
final EVP_MD_size = () {
|
||||||
IntPtr Function(Pointer<NativeType> ctx),
|
// EVP_MD_size was renamed to EVP_MD_get_size in Openssl3.0.
|
||||||
int Function(Pointer<NativeType> ctx)>('EVP_MD_size');
|
// There is an alias macro, but those don't exist in libraries.
|
||||||
|
// Try loading the new name first, then fall back to the old one if not found.
|
||||||
|
try {
|
||||||
|
return libcrypto.lookupFunction<IntPtr Function(Pointer<NativeType> ctx),
|
||||||
|
int Function(Pointer<NativeType> ctx)>('EVP_MD_get_size');
|
||||||
|
} catch (e) {
|
||||||
|
return libcrypto.lookupFunction<IntPtr Function(Pointer<NativeType> ctx),
|
||||||
|
int Function(Pointer<NativeType> ctx)>('EVP_MD_size');
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue