Commit Graph

351 Commits

Author SHA1 Message Date
Neil Horman d4188f2486 Augment README.md in top level to indicate Makefile presence
Note that they are available but only meant as a guide to self building,
and are not used expressly to build as part of the overall openssl build

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 693071c088 disable http3 demo on windows
The external nghttp3 library seems to have a linking issue on windows
(several missing symbols).  Disable that build in windows for now until
its fixed

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 6195c08d10 make addr_len the right sign in sslecho
cygwin caught a signedness difference in this pointer.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 793a4056ad Replace getline with fgets in sslecho demo
Windows doesn't support getline, so we need to use fgets here

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 4ad6e549fa dont include unistd.h on windows for sslecho
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 3b56cd4f04 Don't include unistd.h in sconnect for windows
The platform doesn't support it

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:20 -04:00
Neil Horman 7acdd776e3 Fix signal handling in saccept for windows
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:19 -04:00
Neil Horman f2f13cff21 Fix warnings found by clang in CI
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:19 -04:00
Neil Horman 7a7fbeb924 fix all the warnings in our demos and make them enableable
Fix up the warnings in the demos and make them configurable with
enable-demos

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:19 -04:00
Neil Horman 2000281dad Convert demos to primary build system
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24047)
2024-04-12 08:02:19 -04:00
slontis 56e4d112ae Add demo for ECDH key exchange
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22916)
2024-04-09 20:15:31 +02:00
Matt Caswell 496bc128fd Copyright year updates
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes
(cherry picked from commit 3764f200f9)

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24034)
2024-04-09 13:43:27 +02:00
Richard Levitte b646179229 Copyright year updates
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes
(cherry picked from commit 0ce7d1f355)

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24034)
2024-04-09 13:43:26 +02:00
Jiasheng Jiang 87e747000f Replace size_t with int and add the check for the EVP_MD_get_size()
Replace the type of "digest_size" with int to avoid implicit conversion when it is assigned by EVP_MD_get_size().
Moreover, add the check for the "digest_size".

Fixes: 29ce1066bc ("Update the demos/README file because it is really old. New demos should provide best practice for API use. Add demonstration for computing a SHA3-512 digest - digest/EVP_MD_demo")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23924)
2024-03-25 17:49:03 +01:00
Jiasheng Jiang f13ddaab69 Replace unsigned with int
Replace the type of "digest_length" with int to avoid implicit conversion when it is assigned by EVP_MD_get_size().
Otherwise, it may pass the following check and cause the integer overflow error when EVP_MD_get_size() returns negative numbers.
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23922)
2024-03-25 17:45:33 +01:00
sashan 01eaf20385 fix demos/sslecho/main.c so it builds on OpenBSD too
trying to build `demos/sslecho/main.c` shipped by current openssl
fails with error as follows:
```
cc -I../../include -g -Wall   -c -o main.o main.c
main.c:35:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in addr;
                       ^
main.c:35:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in addr;
           ^
main.c:46:32: error: use of undeclared identifier 'INADDR_ANY'
        addr.sin_addr.s_addr = INADDR_ANY;
                               ^
main.c:152:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in addr;
                       ^
main.c:152:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in addr;
           ^
3 errors generated.
gmake: *** [<builtin>: main.o] Error 1
```

including `netinet/in.h` fixes the build

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23936)
2024-03-25 13:49:47 +01:00
Alexandr Nedvedicky c18c301deb demos/http3: Use `SSL_write_ex2()` together with `SSL_WRITE_FLAG_CONCLUDE`
These calls were introduced by PR #23343.

Change also does a minor tweak to Makefile so CFLAGS and LDFLAGS variables
from the environment are respected.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23602)
2024-03-01 10:56:16 +01:00
James Muir bcd92754d5 demos: fix cert scripts
set LD_LIBRARY_PATH so the correct libs can be found.

Testing:

  cd demos/certs && sh mkcerts.sh
  cd demos/certs/apps && sh -x mkacerts.sh

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23142)
2023-12-29 10:22:05 +01:00
Neil Horman 5091aadc22 augment quic demos to support ipv4/6 connections
Because the quicserver utility supports expressly listening in ipv4/6
mode, its possible/likely that the server will listen on an ipv4
address, while the clients will connect via ipv6, leading to connection
failures.

Augment quic demo clients to afford them the same -6 option that the
server has so that connection family can be co-ordinated

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22577)
2023-11-21 13:01:54 +01:00
James Muir 86db958835 demos: tidy up makefiles, fix warnings
Update makefiles so that consistent patterns are used.  Object files
are compiled from source using an implicit rule (but using our
CFLAGS); for linking, we give an explicit rule.  Ensure that "make
test" works in each subdirectory (even if it does not actually run any
applications).  The top-level demo makefile now works.

The makefiles are not make-agnostic.  e.g. they use the variable $(RM)
in "clean" recipes, which is defined in gnu-make but may not be
defined in others.

Part of #17806

Testing:

  $ cd demo
  $ make test

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22698)
2023-11-15 08:43:23 +01:00
James Muir 9257a89b6f cms demos: print signingTime attributes
Add a makefile for the cms demos, and add a routine to cms_ver.c to
print any signingTime attributes from the CMS_ContentInfo object.
This provides an example that could be extended if an application
wants to examine the purported signing times.

Part of #8026

Testing:

  $ cd demos/cms
  $ make test

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22618)
2023-11-10 13:06:46 +01:00
James Muir 22fa1602da quic http3 demo: minor updates
-update run command to include LD_LIBRARY_PATH
-suggest installing libnghttp3-dev on Ubuntu
-drop "-f" from clean recipe (it is already included in $(RM))

Part of https://github.com/openssl/project/issues/253

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22623)
2023-11-08 11:12:55 +11:00
Matt Caswell cb8107b632 Update the README with information about how to run the QUIC demos
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22552)
2023-11-02 08:14:46 +00:00
Matt Caswell 420037c82c Update the QUIC demos to accept hostname/port on the command line
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22552)
2023-11-02 08:14:46 +00:00
Matt Caswell a2b824730e Extend the README to describe how to run the TLS demos
We also supply some test certificates for use with the demos.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22552)
2023-11-02 08:14:46 +00:00
Matt Caswell 2ec4e73c01 Amend the TLS demos to accept hostname/port as an argument
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22552)
2023-11-02 08:14:38 +00:00
Matt Caswell ada33e98f5 Add a separate README for the guide demos
Point users at the actual guide, and also explain about LD_LIBRARY_PATH

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22505)
2023-10-30 07:54:00 +00:00
Matt Caswell aefb529422 Update to the demos README file
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22505)
2023-10-30 07:53:40 +00:00
James Muir 59d8a338ed quic: documentation and demo nits
The code for the quic demos (from the openssl guide) is presented as
modifications of tls-client-block.c.  Make it so that the quic code
better matches the tls code (drop unneeded assignments to "ret", use
the same comment on SSL_connect(), add the same printf() statement).

Also fix some minor typos.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22483)
2023-10-25 09:44:32 +01:00
slontis 66f4782f14 Create hierarchical demo Makefile.
Adds a Makefile with all, clean, and test targets.
This has only been added for demos that already contain Makefiles.
For problematic tests that require inputs, the test target does nothing.

(Note: Demos should be self contained and not require unknown external
inputs. This PR does not attempt to fix this.)

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20546)
2023-10-25 09:21:07 +01:00
Hugo Landau 9f54da4136 Fix markdown
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau f92d4a07cc Add SNI
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau 17b8f405a2 Rename
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau 10c04246be Add link to nghttp3
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau 444d18fc7a Add copyright headers
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau 47f8cfead0 QUIC: Add comments to HTTP/3 demo
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Hugo Landau e33af8000f QUIC: Add HTTP/3 demo using nghttp3
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22369)
2023-10-19 08:28:59 +01:00
Dimitri Papadopoulos e22ebb893e Bad function definition
void f() should probably be void f(void)

Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21468)
2023-09-11 10:15:30 +02:00
Dimitri Papadopoulos bbaeadb068 "foo * bar" should be "foo *bar"
Found by running the checkpatch.pl Linux script to enforce coding style.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21468)
2023-09-11 10:15:30 +02:00
Matt Caswell 11b7d46fa7 Return NULL if we fail to create a BIO in the demos/quicserver
Strictly speaking the previous code was still correct since BIO_set_fd
is tolerant of a NULL BIO. But this way is more clear.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell cdedecd503 Add a missing call to BIO_closesocket()
A couple of the demos missed a call to this function in an error case.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell 38c3c1dbef Expand the explanation of how to go and do useful work in non-blocking
Add additional commentary to the non-blocking examples explaining where to
add code to go and do other useful work.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell e8a5b06bdc Add a new guide page on writing a non-blocking QUIC client
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell b71784f741 Add a QUIC non-blocking demo
Show how to write a QUIC client using a non-blocking socket

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell 0295364548 Add a TLS non-blocking demo
Show how to write a TLS client using a non-blocking socket

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21950)
2023-09-08 15:44:37 +01:00
Matt Caswell da1c088f59 Copyright year updates
Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes
2023-09-07 09:59:15 +01:00
slontis b544c72f37 Add ED25519 Signature demo.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21883)
2023-09-01 10:09:56 +01:00
Matt Caswell dac42bdce1 Fix a bad merge in quic-multi-stream.c demo
The function SSL_set_initial_peer_addr() got renamed to
SSL_set1_initial_peer_addr(). The demo missed out on the rename when it
got rebased on top of it.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21842)
2023-08-28 09:58:20 +02:00
Matt Caswell 02e36ed352 Update demos/tutorial to distinguish between stream and connection errors
We can use SSL_get_stream_read_state() to distinguish these cases.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21765)
2023-08-25 11:42:51 +01:00
Matt Caswell 8d74a13160 Add some additional comments to the demos
Add some additional explanation for some code lines in the demos that did
not have a comment.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21765)
2023-08-25 11:42:51 +01:00