Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cd7dc07
Try loading OpenSSL using alternative names for 1.1 and 3.x.
JPeterMugaas Aug 5, 2024
c189c38
Remove redundant load attempt.
JPeterMugaas Aug 5, 2024
914c8e4
Fix warning about value not being used.
JPeterMugaas Aug 5, 2024
a03fa46
Found alt. to SSL_load_error_strings in OpenSSL 1.1.1 headers. Mark …
JPeterMugaas Aug 6, 2024
1ceaa39
Added OpenSSL 1.1 alternatives for OpenSSL_add_all_ciphers and OpenSS…
JPeterMugaas Aug 6, 2024
f3a2412
Commented out some code that just doesn't look right.
JPeterMugaas Aug 6, 2024
abb9b62
OpenSSL 1.1 alternative to SSLeay_add_ssl_algorithms.
JPeterMugaas Aug 6, 2024
05834dc
Forgot something. OOPS!!!
JPeterMugaas Aug 6, 2024
62f20bb
Alternatives to X509_NAME_hash and SSL_get_peer_certificate.
JPeterMugaas Aug 6, 2024
72a4842
CRYPTO_LOCK API is gone in this version.
JPeterMugaas Aug 6, 2024
c72ee44
Finally got OpenSSL 3.2 to load.
JPeterMugaas Aug 6, 2024
35e8e9a
The wrong .DLL was being for OpenSSL 1.1.1
JPeterMugaas Aug 6, 2024
a9f7435
Fix EVP_CIPHER_CTX_type.
JPeterMugaas Aug 6, 2024
9c5bc46
Add extra safety. Thanks to https://github.com/IndySockets/IndyTLS-O…
JPeterMugaas Aug 7, 2024
bb0f080
Start on TLS 1.3.
JPeterMugaas Aug 7, 2024
d464583
More work on trying to get TLS 1.3 in this.
JPeterMugaas Aug 7, 2024
3923a04
TLS 1.3 now works with "OpenSSL 1.1.1w 11 Sep 2023".
JPeterMugaas Aug 7, 2024
d71ed84
The if's were reversed to allow the user to specify a minimum.
JPeterMugaas Aug 7, 2024
74bb2d0
Fixed error in if reversal.
JPeterMugaas Aug 7, 2024
08ec18e
SSL_CTRL_SET_MIN_PROTO_VERSION and SSL_CTRL_SET_MAX_PROTO_VERSION are…
JPeterMugaas Aug 7, 2024
8db8dab
Fix more type breakage from Open SSL 1.1.0. Introduce some new funct…
JPeterMugaas Aug 8, 2024
6c2909c
SSL_CTX_set_info_callback now works with OpenSSL 1.0.2, 1.1.0, and th…
JPeterMugaas Aug 8, 2024
c11c3e2
SSL_CTX_set_info_callback now works with OpenSSL 1.0.2, 1.1.0, and th…
JPeterMugaas Aug 8, 2024
c838e2e
We can't assume TLS 1.3 is available since we support 1.0.2.
JPeterMugaas Aug 8, 2024
04527f6
Add {Do not localize} for quoted strings that aren't meant to be loca…
JPeterMugaas Aug 8, 2024
286cfa4
Enable @_threadid_func on Windows.
JPeterMugaas Aug 8, 2024
0d5662c
Fix put_error and try to match the locking API calls. This is from: …
JPeterMugaas Aug 8, 2024
c87ed17
SSL_CTX_get_cert_store and SSL_get_ex_data_X509_STORE_CTX_idx.
JPeterMugaas Aug 8, 2024
df4d349
X509_verify_cert_error_string
JPeterMugaas Aug 8, 2024
61f7798
Update function OpenSSLGetDigestCtx and OpenSSLFinalHashInst to match…
JPeterMugaas Aug 8, 2024
d4e973f
Update VerifyCallback( to use X509_STORE_CTX_get_ex_data if available.
JPeterMugaas Aug 8, 2024
b35775f
X509_STORE update.
JPeterMugaas Aug 8, 2024
f3ba6df
Changes suggested in review.
JPeterMugaas Aug 8, 2024
a5e7e9e
less_than not less_then.
JPeterMugaas Aug 8, 2024
a9e83de
Important change. You are NOT meant to access the fields in SSL_CTX.…
JPeterMugaas Aug 9, 2024
e44d6b1
Restore Password Callback and IndySSL_CTX_load_verify_locations.
JPeterMugaas Aug 9, 2024
06633ed
Add TLS_client_method and TLS_server_method.
JPeterMugaas Aug 9, 2024
50042ba
Use TLS_client_method and TLS_server_method. Verified that TLS_cclie…
JPeterMugaas Aug 9, 2024
56006f0
Fix access violation in IndySSL_CTX_use_certificate_file_PKCS1 and sk…
JPeterMugaas Aug 11, 2024
6be768e
OnStatusInfoEx now works in TIdServerIOHandlerSSLOpenSSL.
JPeterMugaas Aug 12, 2024
195b43b
Remove record structures for opaque types in OpenSSL 1.1.0 and use AP…
JPeterMugaas Aug 13, 2024
2df1f5a
Add SSL_set_min_proto_version and SSL_set_max_proto_version macros.
JPeterMugaas Aug 13, 2024
9b51aa8
Several things:
JPeterMugaas Aug 14, 2024
09e2ba0
Remove the usage of some depreciated functions. See: https://docs.op…
JPeterMugaas Aug 14, 2024
903a27b
Remove IsOpenSSL_1x since this only supports OpenSSL 1.1.0 and greate…
JPeterMugaas Aug 14, 2024
aa87484
Try to merge stuff from main branch.
JPeterMugaas Aug 15, 2024
227ae95
Fix some access violations.
JPeterMugaas Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
908 changes: 2 additions & 906 deletions IdCompilerDefines.inc

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions IdNTLMOpenSSL.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)

Copyright:
(c) 1993-2024, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}

unit IdNTLMOpenSSL;

interface

implementation

uses
IdGlobal, IdFIPS, IdSSLOpenSSLHeaders, IdHashMessageDigest,
SysUtils;

{$I IdCompilerDefines.inc}

function LoadOpenSSL: Boolean;
begin
Result := IdSSLOpenSSLHeaders.Load;
end;

function IsNTLMFuncsAvail: Boolean;
begin
Result := Assigned(DES_set_odd_parity) and
Assigned(DES_set_key) and
Assigned(DES_ecb_encrypt);
end;

type
Pdes_key_schedule = ^des_key_schedule;

{/*
* turns a 56 bit key into the 64 bit, odd parity key and sets the key.
* The key schedule ks is also set.
*/}
procedure setup_des_key(key_56: des_cblock; Var ks: des_key_schedule);
Var
key: des_cblock;
begin
key[0] := key_56[0];

key[1] := ((key_56[0] SHL 7) and $FF) or (key_56[1] SHR 1);
key[2] := ((key_56[1] SHL 6) and $FF) or (key_56[2] SHR 2);
key[3] := ((key_56[2] SHL 5) and $FF) or (key_56[3] SHR 3);
key[4] := ((key_56[3] SHL 4) and $FF) or (key_56[4] SHR 4);
key[5] := ((key_56[4] SHL 3) and $FF) or (key_56[5] SHR 5);
key[6] := ((key_56[5] SHL 2) and $FF) or (key_56[6] SHR 6);
key[7] := (key_56[6] SHL 1) and $FF;

DES_set_odd_parity(@key);
DES_set_key(@key, ks);
end;

{/*
* takes a 21 byte array and treats it as 3 56-bit DES keys. The
* 8 byte plaintext is encrypted with each key and the resulting 24
* bytes are stored in the results array.
*/}
procedure calc_resp(keys: PDES_cblock; const ANonce: TIdBytes; results: Pdes_key_schedule);
Var
ks: des_key_schedule;
nonce: des_cblock;
begin
setup_des_key(keys^, ks);
Move(ANonce[0], nonce, 8);
des_ecb_encrypt(@nonce, Pconst_DES_cblock(results), ks, DES_ENCRYPT);

setup_des_key(PDES_cblock(PtrUInt(keys) + 7)^, ks);
des_ecb_encrypt(@nonce, Pconst_DES_cblock(PtrUInt(results) + 8), ks, DES_ENCRYPT);

setup_des_key(PDES_cblock(PtrUInt(keys) + 14)^, ks);
des_ecb_encrypt(@nonce, Pconst_DES_cblock(PtrUInt(results) + 16), ks, DES_ENCRYPT);
end;

Const
Magic: des_cblock = ($4B, $47, $53, $21, $40, $23, $24, $25 );

//* setup LanManager password */
function SetupLanManagerPassword(const APassword: String; const ANonce: TIdBytes): TIdBytes;
var
lm_hpw: array[0..20] of Byte;
lm_pw: array[0..13] of Byte;
idx, len: Integer;
ks: des_key_schedule;
lm_resp: array [0..23] of Byte;
lPassword: {$IFDEF STRING_IS_UNICODE}TIdBytes{$ELSE}AnsiString{$ENDIF};
begin
{$IFDEF STRING_IS_UNICODE}
lPassword := IndyTextEncoding_OSDefault.GetBytes(UpperCase(APassword));
{$ELSE}
lPassword := UpperCase(APassword);
{$ENDIF}

len := IndyMin(Length(lPassword), 14);
if len > 0 then begin
Move(lPassword[{$IFDEF STRING_IS_UNICODE}0{$ELSE}1{$ENDIF}], lm_pw[0], len);
end;
if len < 14 then begin
for idx := len to 13 do begin
lm_pw[idx] := $0;
end;
end;

//* create LanManager hashed password */

setup_des_key(pdes_cblock(@lm_pw[0])^, ks);
des_ecb_encrypt(@magic, Pconst_DES_cblock(@lm_hpw[0]), ks, DES_ENCRYPT);

setup_des_key(pdes_cblock(PtrUInt(@lm_pw[0]) + 7)^, ks);
des_ecb_encrypt(@magic, Pconst_DES_cblock(PtrUInt(@lm_hpw[0]) + 8), ks, DES_ENCRYPT);

FillChar(lm_hpw[16], 5, 0);

calc_resp(PDes_cblock(@lm_hpw[0]), ANonce, Pdes_key_schedule(@lm_resp[0]));

SetLength(Result, SizeOf(lm_resp));
Move(lm_resp[0], Result[0], SizeOf(lm_resp));
end;

//* create NT hashed password */
function CreateNTPassword(const APassword: String; const ANonce: TIdBytes): TIdBytes;
var
nt_hpw: array [1..21] of Byte;
nt_hpw128: TIdBytes;
nt_resp: array [1..24] of Byte;
LMD4: TIdHashMessageDigest4;
begin
CheckMD4Permitted;
LMD4 := TIdHashMessageDigest4.Create;
try
{$IFDEF STRING_IS_UNICODE}
nt_hpw128 := LMD4.HashString(APassword, IndyTextEncoding_UTF16LE);
{$ELSE}
nt_hpw128 := LMD4.HashBytes(BuildUnicode(APassword));
{$ENDIF}
finally
LMD4.Free;
end;

Move(nt_hpw128[0], nt_hpw[1], 16);
FillChar(nt_hpw[17], 5, 0);

calc_resp(pdes_cblock(@nt_hpw[1]), ANonce, Pdes_key_schedule(@nt_resp[1]));

SetLength(Result, SizeOf(nt_resp));
Move(nt_resp[1], Result[0], SizeOf(nt_resp));
end;

initialization
IdFIPS.LoadNTLMLibrary := LoadOpenSSL;
IdFIPS.IsNTLMFuncsAvail := IsNTLMFuncsAvail;
IdFIPS.NTLMGetLmChallengeResponse := SetupLanManagerPassword;
IdFIPS.NTLMGetNtChallengeResponse := CreateNTPassword;

end.
Binary file added IdRegisterOpenSSL.dcr
Binary file not shown.
54 changes: 54 additions & 0 deletions IdRegisterOpenSSL.lrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
LazarusResources.Add('TIdServerIOHandlerSSLOpenSSL','XPM',[
'/* XPM */'#13#10'static char *Pixmap[] = {'#13#10'"24 24 16 2",'#13#10'"00 c'
+' black",'#13#10'"01 c #800000",'#13#10'"02 c #008000",'#13#10'"03 c #808000'
+'",'#13#10'"04 c #000080",'#13#10'"05 c none",'#13#10'"06 c #008080",'#13#10
+'"07 c #808080",'#13#10'"08 c #C0C0C0",'#13#10'"09 c red",'#13#10'"10 c gree'
+'n",'#13#10'"11 c yellow",'#13#10'"12 c blue",'#13#10'"13 c magenta",'#13#10
+'"14 c cyan",'#13#10'"15 c Gray100",'#13#10'"0505000000000000000505050505050'
+'50505050505050505",'#13#10'"05050015151515150004040404040404040404040404040'
+'5",'#13#10'"050400151414141500151515151515151515151515150404",'#13#10'"0504'
+'00151414141500151515151515151515151515150404",'#13#10'"05040015070707070015'
+'1515151515151515151515150404",'#13#10'"050400000000000000151500000000151515'
+'151515150404",'#13#10'"000000151508080800000008080808001515151515150404",'
+#13#10'"001515080808080808070000000008070715151515150404",'#13#10'"001507070'
+'707070707070015151500080015151515150404",'#13#10'"0000000000000000000000151'
+'51500080015151515150404",'#13#10'"05041515151515150008001515150008001515151'
+'5150404",'#13#10'"050415151515150000000000000000000000151515150404",'#13#10
+'"050415151515000808080808080808080808001515150404",'#13#10'"050415151515000'
+'707070700000007070707001515150404",'#13#10'"0504151515150008080808000000080'
+'80808001515150404",'#13#10'"05041515151500070707080800080807070700151515040'
+'4",'#13#10'"050415151515000808080807000708080808001515150404",'#13#10'"0504'
+'15151515150007070807000708070700151515150404",'#13#10'"05041515151515150000'
+'0808080808000015151515150404",'#13#10'"050415151515151515150000000000151515'
+'151515150404",'#13#10'"050415151515151515151515151515151515151515150404",'
+#13#10'"050415151515151515151515151515151515151515150404",'#13#10'"050404040'
+'404040404040404040404040404040404040404",'#13#10'"0505040404040404040404040'
+'40404040404040404040405"'#13#10'};'#13#10
]);
LazarusResources.Add('TIdSSLIOHandlerSocketOpenSSL','XPM',[
'/* XPM */'#13#10'static char *Pixmap[] = {'#13#10'"24 24 16 2",'#13#10'"00 c'
+' black",'#13#10'"01 c #800000",'#13#10'"02 c #008000",'#13#10'"03 c #808000'
+'",'#13#10'"04 c #000080",'#13#10'"05 c none",'#13#10'"06 c #008080",'#13#10
+'"07 c #C0C0C0",'#13#10'"08 c #808080",'#13#10'"09 c red",'#13#10'"10 c gree'
+'n",'#13#10'"11 c yellow",'#13#10'"12 c blue",'#13#10'"13 c magenta",'#13#10
+'"14 c cyan",'#13#10'"15 c Gray100",'#13#10'"0505050505050505050505050505050'
+'50505050505050505",'#13#10'"05050404040404040404040404040404040404040404040'
+'5",'#13#10'"050415151515151515151515151515151515151515150404",'#13#10'"0504'
+'15151515151515151515151515151515151515150404",'#13#10'"05041515151515151515'
+'1515151515151515151515150404",'#13#10'"050415151515151515150000000000151515'
+'151515150404",'#13#10'"050415151515151515000707070707001515151515150404",'
+#13#10'"050415151515151508080700000007080815151515150404",'#13#10'"050415151'
+'515151500070015151500070015151515150404",'#13#10'"0504151515151515000700151'
+'51500070015151515150404",'#13#10'"05041515151515150007001515150007001515151'
+'5150404",'#13#10'"050415151515150000000000000000000000151515150404",'#13#10
+'"050415151515000707070707070707070707001515150404",'#13#10'"050415151515000'
+'808080800000008080808001515150404",'#13#10'"0504151515150007070707000000070'
+'70707001515150404",'#13#10'"05041515151500080808070700070708080800151515040'
+'4",'#13#10'"050415151515000707070708000807070707001515150404",'#13#10'"0504'
+'15151515150008080708000807080800151515150404",'#13#10'"05041515151515150000'
+'0707070707000015151515150404",'#13#10'"050415151515151515150000000000151515'
+'151515150404",'#13#10'"050415151515151515151515151515151515151515150404",'
+#13#10'"050415151515151515151515151515151515151515150404",'#13#10'"050404040'
+'404040404040404040404040404040404040404",'#13#10'"0505040404040404040404040'
+'40404040404040404040405"'#13#10'};'#13#10
]);
2 changes: 2 additions & 0 deletions IdResourceStringsOpenSSL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface
RSOSSLConnectionDropped = 'SSL connection has dropped.';
RSOSSLCertificateLookup = 'SSL certificate request error.';
RSOSSLInternal = 'SSL library internal error.';
RSOSSLCouldNotSetMinProtocolVersion = 'Could not set min protocol version';
RSOSSLCouldNotSetMaxProtocolVersion = 'Could not set max protocol version';
//callback where strings
RSOSSLAlert = '%s Alert';
RSOSSLReadAlert = '%s Read Alert';
Expand Down
Loading