Recent

Author Topic: Quiche (and BoringSSL) bindings  (Read 3338 times)

TRon

  • Hero Member
  • *****
  • Posts: 3643
Re: Quiche (and BoringSSL) bindings
« Reply #30 on: October 07, 2024, 02:48:55 am »
I'm just trying to help, from the most logical translation from C to Pascal.
I did not state anywhere that you weren't trying to help.

I chipped in because I did see a potential disaster coming up. Still is because there are too many unanswered and unseen variables in play.

Quote
It doesn't work so I suggested other ways
And there is nothing wrong with that. I applaud you for it but guessing things without any further knowledge on what TS is working with is imho not the way to go.

Quote
but of course your path is better and I'll let you find the solution that you will surely find easily.
I did not say my path is better, it is imho more logical e.g. literally translating c to its pascal counterpart. Pascalifying you can do when things are known to work so that you have a (working) reference.

Have you ever tried filing a bug-report using a fancy pascalified function declaration ? I for one am only able to do that with a literal translation which means the same bug appears when using c itself.

Quote
Good night TRon and sorry for the shadow.
A very good night to you as well (although I presume you meant it in a sarcastic way, sbi), and imho you are by any means not a shadow. all I did see is you trying to help TS but not knowing all the facts (we still don't know them).

Translating headers is a precise and tiresome work and I have seen many things go wrong in so many ways that it isn't fun anymore. In this day and age I still regularly stumble upon translated headers that are 32-bit hard-coded and of course preferably windows only. I do not even use them as a starting point but start from scratch instead. And I did not even mention the lack of using proper pascal prefixes.

But never mind all that. I was explicitly providing TS with a choice so that I am able to step back from this topic depending on what route TS wishes to take. I do not want to confuse him/her any further with my postings.

Sorry to have upset you Fred. That was most certainly not my intention.
« Last Edit: October 07, 2024, 02:55:06 am by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #31 on: October 07, 2024, 03:11:54 am »
Quote
It doesn't work so I suggested other ways
And there is nothing wrong with that. I applaud you for it but guessing things without any further knowledge on what TS is working with is imho not the way to go.
:)

I like to guess things I already have a lot of trouble with like translating many C headers that work with buffers and internet connections and do not work out-of-the-box.
Peace and have fun.
Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

r.lukasiak

  • Full Member
  • ***
  • Posts: 167
Re: Quiche (and BoringSSL) bindings
« Reply #32 on: October 08, 2024, 11:27:43 am »
I see you had some disagreement... I hope it won't discourage you from further helping me  :-\

I was cleaning the code and I merged all into 1 file to make it easier to paste here.
I stripped it down to bare minimum and for now I have:
Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4. {$PACKRECORDS C}
  5.  
  6. {$L ./libs/libssl.so}
  7. {$L ./libs/libcrypto.so}
  8. //{$L ./libs/libquiche_dbg.so}
  9.  
  10. uses
  11.   {$IFDEF UNIX}
  12.   cthreads,
  13.   {$ENDIF}
  14.   Classes,
  15.   Crt, SysUtils, CTypes, BaseUnix, Sockets;
  16.  
  17. type
  18.   CSsize_t = NativeInt;
  19.  
  20.   PQuiche_config = ^TQuiche_config;
  21.   TQuiche_config = record
  22.   end;
  23.  
  24.   PQuiche_conn = ^TQuiche_conn;
  25.   TQuiche_conn = record
  26.   end;
  27.  
  28.   PSSL_METHOD = ^TSSL_METHOD;
  29.   TSSL_METHOD = record
  30.   end;
  31.  
  32.   PSSL_CTX = ^TSSL_CTX;
  33.   TSSL_CTX = record
  34.   end;
  35.  
  36.   PSSL = ^TSSL;
  37.   TSSL = record
  38.   end;
  39.  
  40.   PQuiche_Recv_Info = ^TQuiche_Recv_Info;
  41.   TQuiche_Recv_Info = record
  42.       from : Psockaddr;
  43.       from_len : socklen_t;
  44.       &to : Psockaddr;
  45.       to_len : socklen_t;
  46.   end;
  47.  
  48.   PQuiche_stats = ^TQuiche_stats;
  49.   Tquiche_stats = record
  50.     recv : size_t;
  51.     sent : size_t;
  52.     lost : size_t;
  53.     retrans : size_t;
  54.     sent_bytes : uint64;
  55.     recv_bytes : uint64;
  56.     acked_bytes : uint64;
  57.     lost_bytes : uint64;
  58.     stream_retrans_bytes : uint64;
  59.     paths_count : size_t;
  60.     reset_stream_count_local : uint64;
  61.     stopped_stream_count_local : uint64;
  62.     reset_stream_count_remote : uint64;
  63.     stopped_stream_count_remote : uint64;
  64.   end;
  65.  
  66. var
  67.   i: integer;
  68.   ch: Char;
  69.   PConfig: Pquiche_config;
  70.   Pctx: PSSL_CTX;
  71.   SSL: PSSL;
  72.   method: PSSL_METHOD;
  73.   isServer: boolean = true;
  74.   scid, odcid: array[0..15] of Byte;
  75.   Pconn: PQuiche_conn;
  76.   Stats: TQuiche_stats;
  77.   PStats: PQuiche_stats;
  78.   localAddr, peerAddr: TSockAddr;
  79.   trace_id: PByte;
  80.   trace_id_len: Csize_t;
  81.   buf: PByte;
  82.   BUF_SIZE: size_t = 8192 * 4;
  83.   recv_info: TQuiche_recv_info;
  84.   Precv_info: PQuiche_recv_info;
  85.   bytes_received: CSsize_t;
  86.  
  87. const
  88.   QUICHE_LIB = 'libquiche.so';
  89.   BORINGSSL_LIB = 'libssl.so';
  90.   CRYPTO_LIB = 'libcrypto.so';
  91.   QUICHE_PROTOCOL_VERSION = 1;
  92.   TLS1_3_VERSION = $0304; //0x0304
  93.   SSL_FILETYPE_PEM = 1;
  94.   SSL_OP_NO_RENEGOTIATION = 0;
  95.  
  96. {---------- BORINGSSL ----------}
  97. function OpenSSL_version_num: cint; cdecl; external CRYPTO_LIB;
  98. function TLS_method: PSSL_METHOD; cdecl; external BORINGSSL_LIB;
  99. function SSL_CTX_new(const method: PSSL_METHOD): PSSL_CTX; cdecl; external BORINGSSL_LIB;
  100. procedure SSL_CTX_set_min_proto_version(ctx: PSSL_CTX; version: cint); cdecl; external BORINGSSL_LIB;
  101. procedure SSL_CTX_set_max_proto_version(ctx: PSSL_CTX; version: cint); cdecl; external BORINGSSL_LIB;
  102. function SSL_CTX_use_certificate_file(ctx: PSSL_CTX; const filename: PChar; type_: cint): cint; cdecl; external BORINGSSL_LIB;
  103. function SSL_CTX_use_PrivateKey_file(ctx: PSSL_CTX; const filename: PChar; type_: cint): cint; cdecl; external BORINGSSL_LIB;
  104. function SSL_CTX_check_private_key(ctx: PSSL_CTX): cint; cdecl; external BORINGSSL_LIB;
  105. function SSL_CTX_set_options(ctx: PSSL_CTX; options: UInt32 ): UInt32; cdecl; external BORINGSSL_LIB;
  106. function SSL_new(ctx: PSSL_CTX): PSSL; cdecl; external BORINGSSL_LIB;
  107.  
  108. {---------- QUICHE ----------}
  109. function quiche_version: PChar; cdecl; external QUICHE_LIB;
  110. function quiche_config_new(version: UInt32): PQuiche_config; cdecl; external QUICHE_LIB;
  111. function quiche_config_load_cert_chain_from_pem_file(var config: TQuiche_config; path: Pansichar) : longint; cdecl; external QUICHE_LIB;
  112. function quiche_config_load_priv_key_from_pem_file(var config: TQuiche_config; path: Pansichar): longint;cdecl;external QUICHE_LIB;
  113. function quiche_conn_new_with_tls(const scid: PByte; scid_len: csize_t;
  114.                                   const odcid: PByte; odcid_len: csize_t;
  115.                                   const local: PSockAddr; local_len: csize_t;
  116.                                   const peer: PSockAddr; peer_len: csize_t;
  117.                                   const config: PQuiche_config; ssl: PSSL;
  118.                                   is_server: Boolean): PQuiche_conn;
  119.                                   cdecl; external QUICHE_LIB;
  120. function quiche_conn_is_established(var conn: PQuiche_conn): Boolean; cdecl; external QUICHE_LIB;
  121. function quiche_conn_is_closed(var conn:PQuiche_conn):Boolean; cdecl; external QUICHE_LIB;
  122. procedure quiche_conn_trace_id(const conn: PQuiche_Conn; var out: PByte; var out_len: Csize_t); cdecl; external QUICHE_LIB;
  123. procedure quiche_conn_source_id(const conn: PQuiche_Conn; var out: PByte; var out_len: Csize_t); cdecl; external QUICHE_LIB;
  124. procedure quiche_conn_stats(var conn:PQuiche_conn; var &out:PQuiche_stats); cdecl; external QUICHE_LIB;
  125.  
  126. //function quiche_conn_recv(var conn:PQuiche_conn; buf:PByte; buf_len:csize_t; info:PQuiche_recv_info):cssize_t; cdecl; external QUICHE_LIB;
  127. {H2Pas}//function quiche_conn_recv(var conn:quiche_conn; var buf:Cuint8; buf_len:Csize_t; var info:quiche_recv_info):Cssize_t;cdecl;external QUICHE_LIB name 'quiche_conn_recv';
  128. //function quiche_conn_recv(var conn: PQuiche_Conn; buf: PByte; buf_len: CSize_t;
  129.   //                        var info: PQuiche_Recv_Info): CSsize_t; cdecl; external QUICHE_LIB;
  130. {TRon}  //function quiche_conn_recv(conn: pquiche_conn; buf: pcuint8; buf_len: size_t; const info: pquiche_recv_info): ssize_t; cdecl; external QUICHE_LIB;
  131. {Fred}// function quiche_conn_recv(conn: PQuiche_Conn; buf: PByte; buf_len: CSize_t;
  132.         //           var info: TQuiche_Recv_Info): CSsize_t; cdecl; external QUICHE_LIB;
  133. {Fred2} function quiche_conn_recv(var conn: PQuiche_Conn; var buf: PByte; var buf_len: CSize_t;
  134.                   var info: PQuiche_Recv_Info): CSsize_t; cdecl; external QUICHE_LIB;
  135.  
  136. begin
  137.   writeln('Quiche version: ', quiche_version); //returns: 0.22.0
  138.   writeln('BoringSSL version: ', Format('%d.%d.%d.%d',
  139.                  [(OpenSSL_version_num shr 28) and $F,
  140.                   (OpenSSL_version_num shr 20) and $F,
  141.                   (OpenSSL_version_num shr 12) and $F,
  142.                   (OpenSSL_version_num shr 4) and $F]));  //
  143.  
  144.   Pconfig := quiche_config_new(QUICHE_PROTOCOL_VERSION);
  145.   if Pconfig = nil then writeln('Failed to create QUIC configuration')
  146.                    else writeln('QUIC configuration CREATED');
  147.  
  148.   if quiche_config_load_cert_chain_from_pem_file(PConfig^, './keys/server.cert') = 0
  149.      then writeln('Cert OK') else writeln('Cert ERROR');
  150.   if quiche_config_load_priv_key_from_pem_file(PConfig^, './keys/server.key') = 0
  151.      then writeln('Priv_key OK') else writeln('Priv_key ERROR');
  152.  
  153.   method := TLS_method;
  154.   Pctx := SSL_CTX_new(method);
  155.   if Pctx = nil then Writeln('Failed to create SSL_CTX') else Writeln('SSL_CTX CREATED!');
  156.   SSL_CTX_set_min_proto_version(Pctx, TLS1_3_VERSION);
  157.   SSL_CTX_set_max_proto_version(Pctx, TLS1_3_VERSION);
  158.   if SSL_CTX_use_certificate_file(Pctx, './keys/server.cert', SSL_FILETYPE_PEM) <= 0
  159.      then Writeln('SSL_CTX_use_certificate_file ERROR!')
  160.      else writeln('SSL_CTX_use_certificate_file OK!');
  161.   if SSL_CTX_use_PrivateKey_file(Pctx, './keys/server.key', SSL_FILETYPE_PEM) <= 0
  162.      then Writeln('SSL_CTX_use_PrivateKey_file ERROR!')
  163.      else Writeln('SSL_CTX_use_PrivateKey_file OK!');
  164.   if SSL_CTX_check_private_key(Pctx) <= 0 then Writeln('Private key DOES NOT match certificate')
  165.                                           else Writeln('Private key MATCHES certificate');
  166.   SSL_CTX_set_options(Pctx, SSL_OP_NO_RENEGOTIATION);
  167.   SSL := SSL_new(Pctx);
  168.   if SSL = nil then writeln('SSL_new ERROR')
  169.                  else writeln('SSL_new OK ');
  170.  
  171.  
  172.   Randomize;
  173.   for i := 0 to High(scid) do scid[i] := Random(256);
  174.   for i := 0 to High(odcid) do odcid[i] := Random(256);
  175.   FillChar(localAddr, SizeOf(localAddr), 0);
  176.   localAddr.sin_family := AF_INET;
  177.   localAddr.sin_port := htons(12345);
  178.   localAddr.sin_addr := StrToNetAddr('192.168.1.4');
  179.   FillChar(peerAddr, SizeOf(peerAddr), 0);
  180.   peerAddr.sin_family := AF_INET;
  181.   peerAddr.sin_port := htons(0);
  182.   peerAddr.sin_addr.s_addr := INADDR_ANY;
  183.  
  184.   Pconn := quiche_conn_new_with_tls(@scid[0], Length(scid),
  185.                                     @odcid[0], Length(odcid),
  186.                                     @localAddr, SizeOf(localAddr),
  187.                                     @peerAddr, SizeOf(peerAddr),
  188.                                     Pconfig, SSL, isServer);
  189.   Writeln('--------------------------------------------------');
  190.   if Pconn = nil then WriteLn('Failed to create QUIC connection')
  191.                  else WriteLn('QUIC connection created successfully!');
  192.   if quiche_conn_is_established(Pconn)
  193.      then WriteLn('QUIC connection IS established')
  194.      else WriteLn('QUIC connection ISN''T established');
  195.   if quiche_conn_is_closed(Pconn)
  196.        then Writeln('Conn CLOSED')
  197.        else Writeln('Conn NOT CLOSED');
  198.  
  199.   quiche_conn_source_id(PConn, trace_id, trace_id_len);
  200.   if (trace_id <> nil) and (trace_id_len > 0) then
  201.     begin
  202.       Writeln('Trace ID Length: ', trace_id_len);
  203.       Write('Trace ID: ');
  204.       for i := 0 to trace_id_len - 1 do Write(trace_id[i], ' ');
  205.       Writeln;
  206.     end else writeln('  trace_id = nil');
  207.  
  208.   writeln('SizeOf(recv_info)=',SizeOf(recv_info));
  209.   quiche_conn_stats(Pconn, PStats);
  210.  
  211.   GetMem(buf, BUF_SIZE);
  212.  
  213.   Writeln;
  214.   repeat
  215.     Writeln('bytes_received...');
  216.     {TRon} //bytes_received := quiche_conn_recv(PConn, buf, BUF_SIZE, Precv_info);
  217.     {Fred} //bytes_received := quiche_conn_recv(PConn, buf, BUF_SIZE, recv_info);
  218.     {Fred2}bytes_received := quiche_conn_recv(PConn, buf, BUF_SIZE, Precv_info);
  219.     Sleep(10);
  220.     if KeyPressed then ch := ReadKey;
  221.   until Ch = #13;
  222.  
  223.   //TODO: cleaning
  224.  
  225. end.
  226.  

and it results in:
Quote
Quiche version: 0.22.0
BoringSSL version: 1.1.1.7
QUIC configuration CREATED
Cert OK
Priv_key OK
SSL_CTX CREATED!
SSL_CTX_use_certificate_file OK!
SSL_CTX_use_PrivateKey_file OK!
Private key MATCHES certificate
SSL_new OK
--------------------------------------------------
QUIC connection created successfully!
QUIC connection ISN'T established
Conn NOT CLOSED
Trace ID Length: 16
Trace ID: 0 100 246 204 225 122 243 132 116 231 62 43 237 252 250 196
SizeOf(recv_info)=32

bytes_received...
An unhandled exception occurred at $00007F178AFE392A:
                                                     EAccessViolation: Access violation
                                                                                         $00007F178AFE392A

          --------------------------------------------------
Press enter

What I noticed is that in the original version, there is some difference in the output:
Quote
..
QUIC connection IS established already.
Conn CLOSED
..
[/quote
both are exactly the opposite, even though I just copy-pasted this part of the code.
Anyway, the quiche_conn_recv error persists.

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #33 on: October 08, 2024, 01:05:23 pm »
May be I don't understand something, but from https://github.com/cloudflare/quiche/tree/master/quiche#calling-quiche-from-cc:
Quote
Calling quiche from C/C++

quiche exposes a thin C API on top of the Rust API that can be used to more easily integrate quiche into C/C++ applications (as well as in other languages that allow calling C APIs via some form of FFI). The C API follows the same design of the Rust one, modulo the constraints imposed by the C language itself.

When running cargo build, a static library called libquiche.a will be built automatically alongside the Rust one. This is fully stand-alone and can be linked directly into C/C++ applications.

Note that in order to enable the FFI API, the ffi feature must be enabled (it is disabled by default), by passing --features ffi to cargo.

and in Makefile from examples I see that C examples are linked with this libquiche.a.
But you link with dynamic libquiche.so. I suppose that it is generated by rust. Why do you think that it's functions are C declared?

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #34 on: October 08, 2024, 01:53:51 pm »
You have to read about variable parameters in Pascal (https://www.freepascal.org/docs-html/current/ref/refsu65.html#x181-20500014.4.2).
For example, this
Code: Pascal  [Select][+][-]
  1. function quiche_conn_recv(var conn: PQuiche_Conn; var buf: PByte; var buf_len: CSize_t;
  2.                   var info: PQuiche_Recv_Info): CSsize_t; cdecl; external QUICHE_LIB;
does not correspond to
Code: C  [Select][+][-]
  1. ssize_t quiche_conn_recv(quiche_conn *conn, uint8_t *buf, size_t buf_len,
  2.                          const quiche_recv_info *info);
  3.  

silvercoder70

  • Jr. Member
  • **
  • Posts: 96
    • Tim Coates
Re: Quiche (and BoringSSL) bindings
« Reply #35 on: October 08, 2024, 01:55:48 pm »
I was looking at the code from r.lukasiak and ... compared with code here

https://android.googlesource.com/platform/external/rust/crates/quiche/+/HEAD/examples/server.c

and noticed the last parameter is filled out ...

Code: C  [Select][+][-]
  1.  quiche_recv_info recv_info = {
  2.             (struct sockaddr *)&peer_addr,
  3.             peer_addr_len,
  4.             conns->local_addr,
  5.             conns->local_addr_len,
  6.         };
  7.         ssize_t done = quiche_conn_recv(conn_io->conn, buf, read, &recv_info);

whereas in the Pascal code, this parameter (Precv_info) is passed in is not allocated any memory OR assigned Nil?

Hope this helps?
Explore the beauty of modern Pascal programming with Delphi & Free Pascal - https://www.youtube.com/@silvercoder70

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #36 on: October 08, 2024, 02:29:40 pm »
You have to read about variable parameters in Pascal (https://www.freepascal.org/docs-html/current/ref/refsu65.html#x181-20500014.4.2).
For example, this
Code: Pascal  [Select][+][-]
  1. function quiche_conn_recv(var conn: PQuiche_Conn; var buf: PByte; var buf_len: CSize_t;
  2.                   var info: PQuiche_Recv_Info): CSsize_t; cdecl; external QUICHE_LIB;
does not correspond to
Code: C  [Select][+][-]
  1. ssize_t quiche_conn_recv(quiche_conn *conn, uint8_t *buf, size_t buf_len,
  2.                          const quiche_recv_info *info);
  3.  

Yes, this code is not correct, we know it, it was for testing and of course did not help.
It is a variation of code give by h2pas (see first post of OP).
« Last Edit: October 08, 2024, 02:34:05 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #37 on: October 08, 2024, 02:50:16 pm »
Yes, I understand.
But reading this
Code: Pascal  [Select][+][-]
  1. function quiche_conn_recv(var conn:quiche_conn; var buf:uint8_t; buf_len:size_t;
  2.                           var info:quiche_recv_info):ssize_t;cdecl;external External_library name 'quiche_conn_recv';
  3.  
here, var conn:quiche_conn and var info:quiche_recv_info are not pointers.
I still think OP has to read about variable parameters in Pascal.  ;)

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #38 on: October 08, 2024, 02:57:16 pm »
whereas in the Pascal code, this parameter (Precv_info) is passed in is not allocated any memory OR assigned Nil?

Hope this helps?

Yes, I think. You are the most attentive!

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #39 on: October 08, 2024, 03:21:53 pm »
whereas in the Pascal code, this parameter (Precv_info) is passed in is not allocated any memory OR assigned Nil?

Hope this helps?

Yes, I think. You are the most attentive!

Yep, well seen, but in a previous post, OP did it, maybe do it again with his last code?:

Code: Pascal  [Select][+][-]
  1. FillChar(recv_info, SizeOf(recv_info), 0);
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #40 on: October 08, 2024, 04:38:10 pm »
Yep, well seen, but in a previous post, OP did it, maybe do it again with his last code?:

Code: Pascal  [Select][+][-]
  1. FillChar(recv_info, SizeOf(recv_info), 0);

Well, I think it must be initialized not with zeros, but with some actual values, like in C code.

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #41 on: October 08, 2024, 05:37:02 pm »
Here binary of libquiche.so for Linux 64 bit:
https://github.com/user-attachments/files/17295533/libquiche.so.zip
Maybe the binary could help for exploration...

Code: Pascal  [Select][+][-]
  1. > file libquiche.so
  2.   libquiche.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked,
  3.   BuildID[sha1]=ffc99bd0987e104ba3b7144a6862cae3be7ad5e9, stripped
  4.  

quiche_conn_recv is indeed there.
Code: Pascal  [Select][+][-]
  1. > nm -D libquiche.so
  2.   ...
  3.   00000000000a7870 T quiche_conn_recv
  4.   ...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #42 on: October 08, 2024, 07:24:26 pm »
Hello r.lukasiak

I did try your demo program using libquiche.so from my previous post.
But at linking, there is that error:
Quote
undefined reference to `SSL_CTX_set_min_proto_version'
undefined reference to `SSL_CTX_set_max_proto_version'

So I commented their declaration + use because there are not defined in my libssl.so:
Code: Pascal  [Select][+][-]
  1. //SSL_CTX_set_min_proto_version(Pctx, TLS1_3_VERSION);
  2. //SSL_CTX_set_max_proto_version(Pctx, TLS1_3_VERSION);

Also I dont have a SSL certificate file to test, so error while initialize it.

So I get a crash far before your result, when trying quiche_conn_new_with_tls().

But, strangely, when using your declaration:

Code: Pascal  [Select][+][-]
  1. function quiche_conn_new_with_tls(const scid: PByte; scid_len: csize_t;
  2.                                   const odcid: PByte; odcid_len: csize_t;
  3.                                   const local: PSockAddr; local_len: csize_t;
  4.                                   const peer: PSockAddr; peer_len: csize_t;
  5.                                   const config: PQuiche_config; ssl: PSSL;
  6.                                   is_server: Boolean): PQuiche_conn;
  7.                                   cdecl; external QUICHE_LIB;

I get that error:

Code: Pascal  [Select][+][-]
  1. Quiche version: 0.22.0
  2. BoringSSL version: 3.0.0.2
  3. QUIC configuration CREATED
  4. Cert ERROR
  5. Priv_key ERROR
  6. SSL_CTX CREATED!
  7. SSL_CTX_use_certificate_file ERROR!
  8. SSL_CTX_use_PrivateKey_file ERROR!
  9. Private key DOES NOT match certificate
  10. SSL_new OK
  11. An unhandled exception occurred at $0000720615ABA658:
  12. EAccessViolation: Access violation
  13.   $0000720615ABA658
  14.   $0000720615A8E7AA

But using this declaration:

Code: Pascal  [Select][+][-]
  1. function quiche_conn_new_with_tls( scid: PByte; scid_len: csize_t;
  2.                                        odcid: PByte; odcid_len: csize_t;
  3.                                        local: PSockAddr; local_len: csize_t;
  4.                                        peer: PSockAddr; peer_len: csize_t;
  5.                                        var config: PQuiche_config; ssl: PSSL;
  6.                                       is_server: Boolean): PQuiche_conn;
  7.                                       cdecl; external QUICHE_LIB;

There is still error but more detailed.

Code: Pascal  [Select][+][-]
  1. Quiche version: 0.22.0
  2. BoringSSL version: 3.0.0.2
  3. QUIC configuration CREATED
  4. Cert ERROR
  5. Priv_key ERROR
  6. SSL_CTX CREATED!
  7. SSL_CTX_use_certificate_file ERROR!
  8. SSL_CTX_use_PrivateKey_file ERROR!
  9. Private key DOES NOT match certificate
  10. SSL_new OK
  11. thread '<unnamed>' panicked at quiche/src/recovery/congestion/pacer.rs:83:24:
  12. attempt to divide by zero
  13. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  14. fatal runtime error: failed to initiate panic, error 5
  15. Aborted (core dumped)
  16.  

 :-\
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

tetrastes

  • Hero Member
  • *****
  • Posts: 595
Re: Quiche (and BoringSSL) bindings
« Reply #43 on: October 08, 2024, 07:41:20 pm »
Code: Pascal  [Select][+][-]
  1. function quiche_conn_new_with_tls( scid: PByte; scid_len: csize_t;
  2.                                        odcid: PByte; odcid_len: csize_t;
  3.                                        local: PSockAddr; local_len: csize_t;
  4.                                        peer: PSockAddr; peer_len: csize_t;
  5.                            { ! var ! } config: PQuiche_config; ssl: PSSL;
  6.                                        is_server: Boolean): PQuiche_conn;
  7.                                        cdecl; external QUICHE_LIB;

Fred vS

  • Hero Member
  • *****
  • Posts: 3413
    • StrumPract is the musicians best friend
Re: Quiche (and BoringSSL) bindings
« Reply #44 on: October 08, 2024, 07:52:01 pm »
Code: Pascal  [Select][+][-]
  1. function quiche_conn_new_with_tls( scid: PByte; scid_len: csize_t;
  2.                                        odcid: PByte; odcid_len: csize_t;
  3.                                        local: PSockAddr; local_len: csize_t;
  4.                                        peer: PSockAddr; peer_len: csize_t;
  5.                            { ! var ! } config: PQuiche_config; ssl: PSSL;
  6.                                        is_server: Boolean): PQuiche_conn;
  7.                                        cdecl; external QUICHE_LIB;

Without var or with const:

Code: Pascal  [Select][+][-]
  1. Quiche version: 0.22.0
  2. BoringSSL version: 3.0.0.2
  3. QUIC configuration CREATED
  4. Cert ERROR
  5. Priv_key ERROR
  6. SSL_CTX CREATED!
  7. SSL_CTX_use_certificate_file ERROR!
  8. SSL_CTX_use_PrivateKey_file ERROR!
  9. Private key DOES NOT match certificate
  10. SSL_new OK
  11. An unhandled exception occurred at $00007CBEE42BA658:
  12. EAccessViolation: Access violation
  13.   $00007CBEE42BA658
  14.   $00007CBEE428E7AA

Note that a error is normal, the SSL key file is missing, but strange to have different error message.
« Last Edit: October 08, 2024, 07:55:01 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018