Skip to content

Commit 93c756b

Browse files
committed
OpenSSLAPI fixes for Delphi on Linux
1 parent 5378dde commit 93c756b

File tree

80 files changed

+41918
-29748
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+41918
-29748
lines changed

src/opensslHdrs/IdOpenSSLHeaders_aes.pas

Lines changed: 173 additions & 124 deletions
Large diffs are not rendered by default.

src/opensslHdrs/IdOpenSSLHeaders_asn1.pas

Lines changed: 1988 additions & 1444 deletions
Large diffs are not rendered by default.

src/opensslHdrs/IdOpenSSLHeaders_asn1_mac.pas

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ interface
4444
{$IFDEF OPENSSL_STATIC_LINK_MODEL}
4545

4646
{$ELSE}
47-
4847
{$ENDIF}
4948

5049
implementation

src/opensslHdrs/IdOpenSSLHeaders_asn1err.pas

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,8 @@ interface
277277
function ERR_load_ASN1_strings: TOpenSSL_C_INT; cdecl; external CLibCrypto;
278278

279279
{$ELSE}
280-
281-
{Declare external function initialisers - should not be called directly}
282-
283-
function Load_ERR_load_ASN1_strings: TOpenSSL_C_INT; cdecl;
284-
285280
var
286-
ERR_load_ASN1_strings: function : TOpenSSL_C_INT; cdecl = Load_ERR_load_ASN1_strings;
281+
ERR_load_ASN1_strings: function : TOpenSSL_C_INT; cdecl = nil;
287282
{$ENDIF}
288283

289284
implementation
@@ -301,24 +296,36 @@ implementation
301296
{$IFNDEF OPENSSL_STATIC_LINK_MODEL}
302297
{$IFNDEF OPENSSL_NO_LEGACY_SUPPORT}
303298
{$ENDIF} { End of OPENSSL_NO_LEGACY_SUPPORT}
304-
function Load_ERR_load_ASN1_strings: TOpenSSL_C_INT; cdecl;
299+
300+
{$WARN NO_RETVAL OFF}
301+
function ERROR_ERR_load_ASN1_strings: TOpenSSL_C_INT; cdecl;
305302
begin
306-
ERR_load_ASN1_strings := LoadLibCryptoFunction('ERR_load_ASN1_strings');
307-
if not assigned(ERR_load_ASN1_strings) then
308-
EOpenSSLAPIFunctionNotPresent.RaiseException('ERR_load_ASN1_strings');
309-
Result := ERR_load_ASN1_strings();
303+
EOpenSSLAPIFunctionNotPresent.RaiseException('ERR_load_ASN1_strings');
310304
end;
311305

306+
{$WARN NO_RETVAL ON}
307+
procedure Load(LibVersion: TOpenSSL_C_UINT; const AFailed: TStringList);
308+
var FuncLoadError: boolean;
309+
begin
310+
ERR_load_ASN1_strings := LoadLibCryptoFunction('ERR_load_ASN1_strings');
311+
FuncLoadError := not assigned(ERR_load_ASN1_strings);
312+
if FuncLoadError then
313+
begin
314+
ERR_load_ASN1_strings := @ERROR_ERR_load_ASN1_strings;
315+
end;
316+
317+
end;
312318

313319
procedure UnLoad;
314320
begin
315-
ERR_load_ASN1_strings := Load_ERR_load_ASN1_strings;
321+
ERR_load_ASN1_strings := nil;
316322
end;
317323
{$ENDIF}
318324

319325
initialization
320326

321327
{$IFNDEF OPENSSL_STATIC_LINK_MODEL}
328+
Register_SSLLoader(@Load);
322329
Register_SSLUnloader(@Unload);
323330
{$ENDIF}
324331
finalization

src/opensslHdrs/IdOpenSSLHeaders_asn1t.pas

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -993,19 +993,11 @@ function ASN1_item_ex_d2i(pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C
993993
function ASN1_item_ex_i2d(pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl; external CLibCrypto;
994994

995995
{$ELSE}
996-
997-
{Declare external function initialisers - should not be called directly}
998-
999-
function Load_ASN1_item_ex_new(pval: PPASN1_VALUE; const it: PASN1_ITEM): TOpenSSL_C_INT; cdecl;
1000-
procedure Load_ASN1_item_ex_free(pval: PPASN1_VALUE; const it: PASN1_ITEM); cdecl;
1001-
function Load_ASN1_item_ex_d2i(pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C_LONG; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT; opt: AnsiChar; ctx: PASN1_TLC): TOpenSSL_C_INT; cdecl;
1002-
function Load_ASN1_item_ex_i2d(pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl;
1003-
1004996
var
1005-
ASN1_item_ex_new: function (pval: PPASN1_VALUE; const it: PASN1_ITEM): TOpenSSL_C_INT; cdecl = Load_ASN1_item_ex_new;
1006-
ASN1_item_ex_free: procedure (pval: PPASN1_VALUE; const it: PASN1_ITEM); cdecl = Load_ASN1_item_ex_free;
1007-
ASN1_item_ex_d2i: function (pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C_LONG; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT; opt: AnsiChar; ctx: PASN1_TLC): TOpenSSL_C_INT; cdecl = Load_ASN1_item_ex_d2i;
1008-
ASN1_item_ex_i2d: function (pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl = Load_ASN1_item_ex_i2d;
997+
ASN1_item_ex_new: function (pval: PPASN1_VALUE; const it: PASN1_ITEM): TOpenSSL_C_INT; cdecl = nil;
998+
ASN1_item_ex_free: procedure (pval: PPASN1_VALUE; const it: PASN1_ITEM); cdecl = nil;
999+
ASN1_item_ex_d2i: function (pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C_LONG; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT; opt: AnsiChar; ctx: PASN1_TLC): TOpenSSL_C_INT; cdecl = nil;
1000+
ASN1_item_ex_i2d: function (pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl = nil;
10091001
{$ENDIF}
10101002

10111003
implementation
@@ -1023,51 +1015,75 @@ implementation
10231015
{$IFNDEF OPENSSL_STATIC_LINK_MODEL}
10241016
{$IFNDEF OPENSSL_NO_LEGACY_SUPPORT}
10251017
{$ENDIF} { End of OPENSSL_NO_LEGACY_SUPPORT}
1026-
function Load_ASN1_item_ex_new(pval: PPASN1_VALUE; const it: PASN1_ITEM): TOpenSSL_C_INT; cdecl;
1018+
1019+
{$WARN NO_RETVAL OFF}
1020+
function ERROR_ASN1_item_ex_new(pval: PPASN1_VALUE; const it: PASN1_ITEM): TOpenSSL_C_INT; cdecl;
10271021
begin
1028-
ASN1_item_ex_new := LoadLibCryptoFunction('ASN1_item_ex_new');
1029-
if not assigned(ASN1_item_ex_new) then
1030-
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_new');
1031-
Result := ASN1_item_ex_new(pval,it);
1022+
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_new');
10321023
end;
10331024

1034-
procedure Load_ASN1_item_ex_free(pval: PPASN1_VALUE; const it: PASN1_ITEM); cdecl;
1025+
procedure ERROR_ASN1_item_ex_free(pval: PPASN1_VALUE; const it: PASN1_ITEM); cdecl;
10351026
begin
1036-
ASN1_item_ex_free := LoadLibCryptoFunction('ASN1_item_ex_free');
1037-
if not assigned(ASN1_item_ex_free) then
1038-
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_free');
1039-
ASN1_item_ex_free(pval,it);
1027+
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_free');
10401028
end;
10411029

1042-
function Load_ASN1_item_ex_d2i(pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C_LONG; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT; opt: AnsiChar; ctx: PASN1_TLC): TOpenSSL_C_INT; cdecl;
1030+
function ERROR_ASN1_item_ex_d2i(pval: PPASN1_VALUE; const AIn: PPByte; len: TOpenSSL_C_LONG; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT; opt: AnsiChar; ctx: PASN1_TLC): TOpenSSL_C_INT; cdecl;
10431031
begin
1044-
ASN1_item_ex_d2i := LoadLibCryptoFunction('ASN1_item_ex_d2i');
1045-
if not assigned(ASN1_item_ex_d2i) then
1046-
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_d2i');
1047-
Result := ASN1_item_ex_d2i(pval,AIn,len,it,tag,aclass,opt,ctx);
1032+
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_d2i');
10481033
end;
10491034

1050-
function Load_ASN1_item_ex_i2d(pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl;
1035+
function ERROR_ASN1_item_ex_i2d(pval: PPASN1_VALUE; AOut: PPByte; const it: PASN1_ITEM; tag: TOpenSSL_C_INT; aclass: TOpenSSL_C_INT): TOpenSSL_C_INT; cdecl;
10511036
begin
1052-
ASN1_item_ex_i2d := LoadLibCryptoFunction('ASN1_item_ex_i2d');
1053-
if not assigned(ASN1_item_ex_i2d) then
1054-
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_i2d');
1055-
Result := ASN1_item_ex_i2d(pval,AOut,it,tag,aclass);
1037+
EOpenSSLAPIFunctionNotPresent.RaiseException('ASN1_item_ex_i2d');
10561038
end;
10571039

1040+
{$WARN NO_RETVAL ON}
1041+
procedure Load(LibVersion: TOpenSSL_C_UINT; const AFailed: TStringList);
1042+
var FuncLoadError: boolean;
1043+
begin
1044+
ASN1_item_ex_new := LoadLibCryptoFunction('ASN1_item_ex_new');
1045+
FuncLoadError := not assigned(ASN1_item_ex_new);
1046+
if FuncLoadError then
1047+
begin
1048+
ASN1_item_ex_new := @ERROR_ASN1_item_ex_new;
1049+
end;
1050+
1051+
ASN1_item_ex_free := LoadLibCryptoFunction('ASN1_item_ex_free');
1052+
FuncLoadError := not assigned(ASN1_item_ex_free);
1053+
if FuncLoadError then
1054+
begin
1055+
ASN1_item_ex_free := @ERROR_ASN1_item_ex_free;
1056+
end;
1057+
1058+
ASN1_item_ex_d2i := LoadLibCryptoFunction('ASN1_item_ex_d2i');
1059+
FuncLoadError := not assigned(ASN1_item_ex_d2i);
1060+
if FuncLoadError then
1061+
begin
1062+
ASN1_item_ex_d2i := @ERROR_ASN1_item_ex_d2i;
1063+
end;
1064+
1065+
ASN1_item_ex_i2d := LoadLibCryptoFunction('ASN1_item_ex_i2d');
1066+
FuncLoadError := not assigned(ASN1_item_ex_i2d);
1067+
if FuncLoadError then
1068+
begin
1069+
ASN1_item_ex_i2d := @ERROR_ASN1_item_ex_i2d;
1070+
end;
1071+
1072+
end;
10581073

10591074
procedure UnLoad;
10601075
begin
1061-
ASN1_item_ex_new := Load_ASN1_item_ex_new;
1062-
ASN1_item_ex_free := Load_ASN1_item_ex_free;
1063-
ASN1_item_ex_d2i := Load_ASN1_item_ex_d2i;
1064-
ASN1_item_ex_i2d := Load_ASN1_item_ex_i2d;
1076+
ASN1_item_ex_new := nil;
1077+
ASN1_item_ex_free := nil;
1078+
ASN1_item_ex_d2i := nil;
1079+
ASN1_item_ex_i2d := nil;
10651080
end;
10661081
{$ENDIF}
10671082

10681083
initialization
10691084

10701085
{$IFNDEF OPENSSL_STATIC_LINK_MODEL}
1086+
Register_SSLLoader(@Load);
10711087
Register_SSLUnloader(@Unload);
10721088
{$ENDIF}
10731089
finalization

0 commit comments

Comments
 (0)