aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Muir <james@openssl.org>2023-11-10 14:02:00 -0500
committerTomas Mraz <tomas@openssl.org>2023-11-15 08:43:23 +0100
commit86db958835d1f8ba9ce49a9f93b5309c3d13b91c (patch)
tree39e47920c615243afc3dd7df206a54ec05fa1045
parent56aa3e8d1a286e11e56d9a9f6373c33a87a69ff4 (diff)
downloadopenssl-86db958835d1f8ba9ce49a9f93b5309c3d13b91c.tar.gz
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)
-rw-r--r--demos/Makefile16
-rw-r--r--demos/bio/Makefile38
-rw-r--r--demos/bio/sconnect.c1
-rw-r--r--demos/cipher/Makefile26
-rw-r--r--demos/cipher/ariacbc.c5
-rw-r--r--demos/cms/Makefile18
-rw-r--r--demos/cms/cms_ddec.c3
-rw-r--r--demos/cms/cms_dec.c3
-rw-r--r--demos/cms/cms_sign.c9
-rw-r--r--demos/cms/cms_sign2.c6
-rw-r--r--demos/digest/Makefile29
-rw-r--r--demos/encode/Makefile26
-rw-r--r--demos/encrypt/Makefile17
-rw-r--r--demos/encrypt/rsa_encrypt.c2
-rw-r--r--demos/guide/Makefile44
-rw-r--r--demos/http3/Makefile12
-rw-r--r--demos/kdf/Makefile20
-rw-r--r--demos/kdf/argon2.c2
-rw-r--r--demos/kdf/hkdf.c2
-rw-r--r--demos/kdf/pbkdf2.c2
-rw-r--r--demos/kdf/scrypt.c2
-rw-r--r--demos/keyexch/Makefile21
-rw-r--r--demos/mac/Makefile22
-rw-r--r--demos/pkey/EVP_PKEY_RSA_keygen.c6
-rw-r--r--demos/pkey/Makefile36
-rw-r--r--demos/signature/Makefile25
-rw-r--r--demos/signature/rsa_pss_direct.c2
-rw-r--r--demos/signature/rsa_pss_hash.c2
-rw-r--r--demos/smime/Makefile37
-rw-r--r--demos/smime/smdec.c7
-rw-r--r--demos/smime/smenc.c5
-rw-r--r--demos/smime/smsign.c15
-rw-r--r--demos/smime/smsign2.c11
-rw-r--r--demos/smime/smver.c3
-rw-r--r--demos/sslecho/Makefile25
-rw-r--r--demos/sslecho/main.c2
-rw-r--r--demos/sslecho/makefile14
37 files changed, 314 insertions, 202 deletions
diff --git a/demos/Makefile b/demos/Makefile
index 4c807a0561..208249e0fd 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -1,4 +1,18 @@
-MODULES=bio digest encode encrypt kdf keyexch mac pkey signature sslecho
+MODULES = bio \
+ cipher \
+ cms \
+ digest \
+ encode \
+ encrypt \
+ guide \
+ http3 \
+ kdf \
+ keyexch \
+ mac \
+ pkey \
+ signature \
+ smime \
+ sslecho
all:
@set -e; for i in $(MODULES); do \
diff --git a/demos/bio/Makefile b/demos/bio/Makefile
index ca4dee851f..5171e75e59 100644
--- a/demos/bio/Makefile
+++ b/demos/bio/Makefile
@@ -1,24 +1,22 @@
-# Quick instruction:
-# To build against an OpenSSL built in the source tree, do this:
#
-# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
-#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto and libssl are on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./server-arg
-# LD_LIBRARY_PATH=../.. ./server-cmod
-# LD_LIBRARY_PATH=../.. ./server-conf
-# LD_LIBRARY_PATH=../.. ./client-arg
-# LD_LIBRARY_PATH=../.. ./client-conf
-# LD_LIBRARY_PATH=../.. ./saccept
-# LD_LIBRARY_PATH=../.. ./sconnect
-CFLAGS = $(OPENSSL_INCS_LOCATION)
-LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto $(EX_LIBS)
+TESTS = client-arg \
+ client-conf \
+ saccept \
+ sconnect \
+ server-arg \
+ server-cmod \
+ server-conf
-all: client-arg client-conf saccept sconnect server-arg server-cmod server-conf
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lssl -lcrypto
-test:
+all: $(TESTS)
client-arg: client-arg.o
client-conf: client-conf.o
@@ -28,8 +26,12 @@ server-arg: server-arg.o
server-cmod: server-cmod.o
server-conf: server-conf.o
-client-arg client-conf saccept sconnect server-arg server-cmod server-conf:
- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
- $(RM) *.o client-arg client-conf saccept sconnect server-arg server-cmod server-conf
+ $(RM) $(TESTS) *.o
+
+test: all
+ @echo "\nBIO tests:"
+ @echo "skipped"
diff --git a/demos/bio/sconnect.c b/demos/bio/sconnect.c
index 18f7007ce7..ef0787c30e 100644
--- a/demos/bio/sconnect.c
+++ b/demos/bio/sconnect.c
@@ -30,7 +30,6 @@ int main(int argc, char *argv[])
const char *hostport = HOSTPORT;
const char *CAfile = CAFILE;
const char *hostname;
- char *cp;
BIO *out = NULL;
char buf[1024 * 10], *p;
SSL_CTX *ssl_ctx = NULL;
diff --git a/demos/cipher/Makefile b/demos/cipher/Makefile
index df6ebeb3b6..cdd7736758 100644
--- a/demos/cipher/Makefile
+++ b/demos/cipher/Makefile
@@ -1,19 +1,17 @@
-# Quick instruction:
-# To build against an OpenSSL built in the source tree, do this:
#
-# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
-#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./aesccm
-# LD_LIBRARY_PATH=../.. ./aesgcm
-# LD_LIBRARY_PATH=../.. ./aeskeywrap
-# LD_LIBRARY_PATH=../.. ./ariacbc
-CFLAGS = $(OPENSSL_INCS_LOCATION)
-LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
+TESTS = aesccm \
+ aesgcm \
+ aeskeywrap \
+ ariacbc
-TESTS=aesccm aesgcm aeskeywrap ariacbc
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
@@ -22,11 +20,11 @@ aesgcm: aesgcm.o
aeskeywrap: aeskeywrap.o
ariacbc: ariacbc.o
-aesccm aesgcm aeskeywrap ariacbc:
- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
- $(RM) aesccm aesgcm aeskeywrap ariacbc *.o
+ $(RM) $(TESTS) *.o
.PHONY: test
test: all
diff --git a/demos/cipher/ariacbc.c b/demos/cipher/ariacbc.c
index f9898e12c7..de84d995ec 100644
--- a/demos/cipher/ariacbc.c
+++ b/demos/cipher/ariacbc.c
@@ -58,9 +58,7 @@ int aria_cbc_encrypt(void)
EVP_CIPHER_CTX *ctx;
EVP_CIPHER *cipher = NULL;
int outlen, tmplen;
- size_t cbc_ivlen = sizeof(cbc_iv);
unsigned char outbuf[1024];
- unsigned char outtag[16];
printf("ARIA CBC Encrypt:\n");
printf("Plaintext:\n");
@@ -115,8 +113,7 @@ int aria_cbc_decrypt(void)
int ret = 0;
EVP_CIPHER_CTX *ctx;
EVP_CIPHER *cipher = NULL;
- int outlen, tmplen, rv;
- size_t cbc_ivlen = sizeof(cbc_iv);
+ int outlen, tmplen;
unsigned char outbuf[1024];
printf("ARIA CBC Decrypt:\n");
diff --git a/demos/cms/Makefile b/demos/cms/Makefile
index 7c8f30d632..3d4cb90750 100644
--- a/demos/cms/Makefile
+++ b/demos/cms/Makefile
@@ -15,18 +15,28 @@ TESTS = cms_comp \
cms_uncomp \
cms_ver
-CFLAGS = -I../../include -g
+CFLAGS = -I../../include -g -Wall
LDFLAGS = -L../..
LDLIBS = -lcrypto
all: $(TESTS)
+cms_comp: cms_comp.o
+cms_ddec: cms_ddec.o
+cms_dec: cms_dec.o
+cms_denc: cms_denc.o
+cms_enc: cms_enc.o
+cms_sign: cms_sign.o
+cms_sign2: cms_sign2.o
+cms_uncomp: cms_uncomp.o
+cms_ver: cms_ver.o
+
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
clean:
$(RM) $(TESTS) *.o
-cms_%: cms_%.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o "$@" "$<" $(LDLIBS)
-
test: all
@echo "\nCMS tests:"
LD_LIBRARY_PATH=../.. ./cms_enc
diff --git a/demos/cms/cms_ddec.c b/demos/cms/cms_ddec.c
index f65a77e129..d119e97222 100644
--- a/demos/cms/cms_ddec.c
+++ b/demos/cms/cms_ddec.c
@@ -34,7 +34,8 @@ int main(int argc, char **argv)
rcert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
rkey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
diff --git a/demos/cms/cms_dec.c b/demos/cms/cms_dec.c
index f64a68ab42..b15885eb18 100644
--- a/demos/cms/cms_dec.c
+++ b/demos/cms/cms_dec.c
@@ -31,7 +31,8 @@ int main(int argc, char **argv)
rcert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
rkey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
diff --git a/demos/cms/cms_sign.c b/demos/cms/cms_sign.c
index 35fc889f80..31e71e8b63 100644
--- a/demos/cms/cms_sign.c
+++ b/demos/cms/cms_sign.c
@@ -38,7 +38,8 @@ int main(int argc, char **argv)
scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -62,8 +63,10 @@ int main(int argc, char **argv)
if (!out)
goto err;
- if (!(flags & CMS_STREAM))
- BIO_reset(in);
+ if (!(flags & CMS_STREAM)) {
+ if (BIO_reset(in) < 0)
+ goto err;
+ }
/* Write out S/MIME message */
if (!SMIME_write_CMS(out, cms, in, flags))
diff --git a/demos/cms/cms_sign2.c b/demos/cms/cms_sign2.c
index 61d9f8bbe8..af3386eb76 100644
--- a/demos/cms/cms_sign2.c
+++ b/demos/cms/cms_sign2.c
@@ -30,7 +30,8 @@ int main(int argc, char **argv)
scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -43,7 +44,8 @@ int main(int argc, char **argv)
scert2 = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey2 = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
diff --git a/demos/digest/Makefile b/demos/digest/Makefile
index d72a9d095b..05fb299cc3 100644
--- a/demos/digest/Makefile
+++ b/demos/digest/Makefile
@@ -1,32 +1,37 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./EVP_MD_demo
-CFLAGS = -I../../include -g -Wall
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = EVP_MD_demo \
+ EVP_MD_stdin \
+ EVP_MD_xof \
+ BIO_f_md
-TESTS=EVP_MD_demo EVP_MD_stdin EVP_MD_xof BIO_f_md
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
-
EVP_MD_demo: EVP_MD_demo.o
EVP_MD_stdin: EVP_MD_stdin.o
EVP_MD_xof: EVP_MD_xof.o
BIO_f_md: BIO_f_md.o
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+clean:
+ $(RM) *.o $(TESTS)
+
.PHONY: test
-# Since some of these tests use stdin we use the source file as stdin when running the exes
+# Since some of these tests use stdin, we use the source file as stdin
+# when running the tests
test: all
@echo "\nDigest tests:"
@set -e; for tst in $(TESTS); do \
echo "\n"$$tst; \
cat $$tst.c | ./$$tst; \
done
-
-clean:
- $(RM) *.o $(TESTS)
diff --git a/demos/encode/Makefile b/demos/encode/Makefile
index 9be11794b0..dc556a524a 100644
--- a/demos/encode/Makefile
+++ b/demos/encode/Makefile
@@ -1,22 +1,28 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./rsa_encode
-CFLAGS = -I../../include -g -Wall
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = ec_encode \
+ rsa_encode
-TESTS=ec_encode rsa_encode
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
+ec_encode: ec_encode.o
+rsa_encode: rsa_encode.o
-%_encode: %_encode.o
-
-test:
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
$(RM) *.o $(TESTS)
+
+.PHONY: test
+test: all
+ @echo "\nencode tests:"
+ @echo "skipped"
diff --git a/demos/encrypt/Makefile b/demos/encrypt/Makefile
index 6d4e060668..378d277d21 100644
--- a/demos/encrypt/Makefile
+++ b/demos/encrypt/Makefile
@@ -1,21 +1,22 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./rsa_encrypt
-CFLAGS = -I../../include -g
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = rsa_encrypt
-TESTS=rsa_encrypt
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
-
rsa_encrypt: rsa_encrypt.o
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
clean:
$(RM) *.o $(TESTS)
diff --git a/demos/encrypt/rsa_encrypt.c b/demos/encrypt/rsa_encrypt.c
index e3d8981e41..d95b985511 100644
--- a/demos/encrypt/rsa_encrypt.c
+++ b/demos/encrypt/rsa_encrypt.c
@@ -151,7 +151,7 @@ cleanup:
return ret;
}
-static int do_decrypt(OSSL_LIB_CTX *libctx, const char *in, size_t in_len,
+static int do_decrypt(OSSL_LIB_CTX *libctx, const unsigned char *in, size_t in_len,
unsigned char **out, size_t *out_len)
{
int ret = 0, public = 0;
diff --git a/demos/guide/Makefile b/demos/guide/Makefile
index d12d6c0cad..29a0fd56e4 100644
--- a/demos/guide/Makefile
+++ b/demos/guide/Makefile
@@ -1,32 +1,34 @@
#
# To run the demos when linked with a shared library (default) ensure that
-# libcrypto and libssl are on the library path. For example to run the
-# tls-client-block demo:
+# libcrypto and libssl are on the library path. For example:
#
-# LD_LIBRARY_PATH=../.. ./tls-client-block
+# LD_LIBRARY_PATH=../.. ./tls-client-block www.example.com 443
-CFLAGS = -I../../include -g
-LDFLAGS = -L../..
-LDLIBS = -lcrypto -lssl
-
-all: tls-client-block quic-client-block quic-multi-stream tls-client-non-block \
- quic-client-non-block
+TESTS = tls-client-block \
+ quic-client-block \
+ quic-multi-stream \
+ tls-client-non-block \
+ quic-client-non-block
-tls-client-block: tls-client-block.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
-
-quic-client-block: quic-client-block.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto -lssl
-quic-multi-stream: quic-multi-stream.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+all: $(TESTS)
-tls-client-non-block: tls-client-non-block.c
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+tls-client-block: tls-client-block.o
+quic-client-block: quic-client-block.o
+quic-multi-stream: quic-multi-stream.o
+tls-client-non-block: tls-client-non-block.o
+quic-client-non-block: quic-client-non-block.o
-quic-client-non-block: quic-client-non-block.c
+$(TESTS):
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
- $(RM) *.o tls-client-block quic-client-block quic-multi-stream \
- tls-client-non-block quic-client-non-block
+ $(RM) $(TESTS) *.o
+
+.PHONY: test
+test: all
+ @echo "\nTLS and QUIC tests:"
+ @echo "skipped"
diff --git a/demos/http3/Makefile b/demos/http3/Makefile
index 9d8212ff0a..aeff1e9e4f 100644
--- a/demos/http3/Makefile
+++ b/demos/http3/Makefile
@@ -10,11 +10,13 @@ LDLIBS = -lcrypto -lssl -lnghttp3
all: ossl-nghttp3-demo
+ossl-nghttp3-demo: ossl-nghttp3-demo.o ossl-nghttp3.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
clean:
$(RM) ossl-nghttp3-demo *.o
-ossl-nghttp3-demo: ossl-nghttp3-demo.o ossl-nghttp3.o
- $(CC) $(CFLAGS) -o "$@" $^ $(LDFLAGS) $(LDLIBS)
-
-%.o: %.c
- $(CC) $(CFLAGS) -c -o "$@" "$<"
+.PHONY: test
+test: all
+ @echo "\nHTTP/3 tests:"
+ @echo "skipped"
diff --git a/demos/kdf/Makefile b/demos/kdf/Makefile
index 28ad7209b1..81efbeeff7 100644
--- a/demos/kdf/Makefile
+++ b/demos/kdf/Makefile
@@ -1,24 +1,28 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./hkdf
-CFLAGS = -I../../include -g
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = hkdf \
+ pbkdf2 \
+ scrypt \
+ argon2
-TESTS=hkdf pbkdf2 scrypt argon2
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
-
hkdf: hkdf.o
pbkdf2: pbkdf2.o
scrypt: scrypt.o
argon2: argon2.o
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
clean:
$(RM) *.o $(TESTS)
diff --git a/demos/kdf/argon2.c b/demos/kdf/argon2.c
index b6a1590328..6c542d54ed 100644
--- a/demos/kdf/argon2.c
+++ b/demos/kdf/argon2.c
@@ -145,6 +145,8 @@ int main(int argc, char **argv)
goto end;
}
+ printf("Success\n");
+
rv = EXIT_SUCCESS;
end:
EVP_KDF_CTX_free(kctx);
diff --git a/demos/kdf/hkdf.c b/demos/kdf/hkdf.c
index 8d7c436575..9818d61afe 100644
--- a/demos/kdf/hkdf.c
+++ b/demos/kdf/hkdf.c
@@ -95,6 +95,8 @@ int main(int argc, char **argv)
goto end;
}
+ printf("Success\n");
+
ret = EXIT_SUCCESS;
end:
EVP_KDF_CTX_free(kctx);
diff --git a/demos/kdf/pbkdf2.c b/demos/kdf/pbkdf2.c
index ae9a9d726c..28a075513c 100644
--- a/demos/kdf/pbkdf2.c
+++ b/demos/kdf/pbkdf2.c
@@ -108,6 +108,8 @@ int main(int argc, char **argv)
goto end;
}
+ printf("Success\n");
+
ret = EXIT_SUCCESS;
end:
EVP_KDF_CTX_free(kctx);
diff --git a/demos/kdf/scrypt.c b/demos/kdf/scrypt.c
index 5c07ebffbd..a1c33f5963 100644
--- a/demos/kdf/scrypt.c
+++ b/demos/kdf/scrypt.c
@@ -111,6 +111,8 @@ int main(int argc, char **argv)
goto end;
}
+ printf("Success\n");
+
ret = EXIT_SUCCESS;
end:
EVP_KDF_CTX_free(kctx);
diff --git a/demos/keyexch/Makefile b/demos/keyexch/Makefile
index 24243e13a4..f8018a13df 100644
--- a/demos/keyexch/Makefile
+++ b/demos/keyexch/Makefile
@@ -1,20 +1,22 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./x25519
-CFLAGS = -I../../include -g -Wall
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = x25519
-TESTS=x25519
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
+x25519: x25519.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-%x25519: %x25519.o
+clean:
+ $(RM) *.o $(TESTS)
.PHONY: test
test: all
@@ -23,6 +25,3 @@ test: all
echo "\n"$$tst; \
LD_LIBRARY_PATH=../.. ./$$tst; \
done
-
-clean:
- $(RM) *.o $(TESTS)
diff --git a/demos/mac/Makefile b/demos/mac/Makefile
index 629e77dfc2..6c870a3d45 100644
--- a/demos/mac/Makefile
+++ b/demos/mac/Makefile
@@ -1,17 +1,17 @@
-# Quick instruction:
-# To build against an OpenSSL built in the source tree, do this:
#
-# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
-#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./gmac
-# LD_LIBRARY_PATH=../.. ./poly1305
-CFLAGS = $(OPENSSL_INCS_LOCATION) -Wall
-LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto
+TESTS = gmac \
+ hmac-sha512 \
+ cmac-aes256 \
+ poly1305
-TESTS=gmac hmac-sha512 cmac-aes256 poly1305
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
@@ -20,8 +20,8 @@ hmac-sha512: hmac-sha512.o
cmac-aes256: cmac-aes256.o
poly1305: poly1305.o
-gmac hmac-sha512 cmac-aes256 poly1305:
- $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
$(RM) *.o $(TESTS)
diff --git a/demos/pkey/EVP_PKEY_RSA_keygen.c b/demos/pkey/EVP_PKEY_RSA_keygen.c
index 353c08152c..62dd8405e7 100644
--- a/demos/pkey/EVP_PKEY_RSA_keygen.c
+++ b/demos/pkey/EVP_PKEY_RSA_keygen.c
@@ -83,7 +83,7 @@ static EVP_PKEY *generate_rsa_key_long(OSSL_LIB_CTX *libctx, unsigned int bits)
* you can set a progress callback using EVP_PKEY_set_cb; see the example in
* EVP_PKEY_generate(3).
*/
- fprintf(stderr, "Generating RSA key, this may take some time...\n");
+ fprintf(stdout, "Generating RSA key, this may take some time...\n");
if (EVP_PKEY_generate(genctx, &pkey) <= 0) {
fprintf(stderr, "EVP_PKEY_generate() failed\n");
goto cleanup;
@@ -109,7 +109,7 @@ static EVP_PKEY *generate_rsa_key_short(OSSL_LIB_CTX *libctx, unsigned int bits)
{
EVP_PKEY *pkey = NULL;
- fprintf(stderr, "Generating RSA key, this may take some time...\n");
+ fprintf(stdout, "Generating RSA key, this may take some time...\n");
pkey = EVP_PKEY_Q_keygen(libctx, propq, "RSA", (size_t)bits);
if (pkey == NULL)
@@ -189,7 +189,7 @@ static int dump_key(const EVP_PKEY *pkey)
/* Output hexadecimal representations of the BIGNUM objects. */
fprintf(stdout, "\nNumber of bits: %d\n\n", bits);
- fprintf(stderr, "Public values:\n");
+ fprintf(stdout, "Public values:\n");
fprintf(stdout, " n = 0x");
BN_print_fp(stdout, n);
fprintf(stdout, "\n");
diff --git a/demos/pkey/Makefile b/demos/pkey/Makefile
index d84fcd634f..e785964187 100644
--- a/demos/pkey/Makefile
+++ b/demos/pkey/Makefile
@@ -1,37 +1,37 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./EVP_PKEY_EC_keygen
-# LD_LIBRARY_PATH=../.. ./EVP_PKEY_RSA_keygen
-# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_keygen
-# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramgen
-# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramvalidate
-# LD_LIBRARY_PATH=../.. ./EVP_PKEY_DSA_paramfromdata
-CFLAGS = -I../../include -g -Wall
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = EVP_PKEY_EC_keygen \
+ EVP_PKEY_RSA_keygen \
+ EVP_PKEY_DSA_keygen \
+ EVP_PKEY_DSA_paramgen \
+ EVP_PKEY_DSA_paramvalidate \
+ EVP_PKEY_DSA_paramfromdata
-TESTS=EVP_PKEY_EC_keygen EVP_PKEY_RSA_keygen EVP_PKEY_DSA_keygen \
-EVP_PKEY_DSA_paramgen EVP_PKEY_DSA_paramvalidate EVP_PKEY_DSA_paramfromdata
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c dsa.inc
- $(CC) $(CFLAGS) -c $<
+EVP_PKEY_DSA_keygen.o: EVP_PKEY_DSA_keygen.c dsa.inc
+EVP_PKEY_DSA_paramgen.o: EVP_PKEY_DSA_paramgen.c dsa.inc
+EVP_PKEY_DSA_paramvalidate.o: EVP_PKEY_DSA_paramvalidate.c dsa.inc
+EVP_PKEY_DSA_paramfromdata.o: EVP_PKEY_DSA_paramfromdata.c dsa.inc
EVP_PKEY_EC_keygen: EVP_PKEY_EC_keygen.o
-
EVP_PKEY_RSA_keygen: EVP_PKEY_RSA_keygen.o
-
EVP_PKEY_DSA_keygen: EVP_PKEY_DSA_keygen.o
-
EVP_PKEY_DSA_paramgen: EVP_PKEY_DSA_paramgen.o
-
EVP_PKEY_DSA_paramvalidate: EVP_PKEY_DSA_paramvalidate.o
-
EVP_PKEY_DSA_paramfromdata: EVP_PKEY_DSA_paramfromdata.o
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
clean:
$(RM) *.o $(TESTS)
diff --git a/demos/signature/Makefile b/demos/signature/Makefile
index 50f1c3452d..4f02b07d73 100644
--- a/demos/signature/Makefile
+++ b/demos/signature/Makefile
@@ -1,29 +1,30 @@
#
-# To run the demos when linked with a shared library (default):
+# To run the demos when linked with a shared library (default) ensure
+# that libcrypto is on the library path. For example:
#
# LD_LIBRARY_PATH=../.. ./EVP_EC_Signature_demo
-# LD_LIBRARY_PATH=../.. ./EVP_DSA_Signature_demo
-# LD_LIBRARY_PATH=../.. ./EVP_ED_Signature_demo
-# LD_LIBRARY_PATH=../.. ./rsa_pss_direct
-# LD_LIBRARY_PATH=../.. ./rsa_pss_hash
-CFLAGS = -I../../include -g -Wall
-LDFLAGS = -L../..
-LDLIBS = -lcrypto
+TESTS = EVP_EC_Signature_demo \
+ EVP_DSA_Signature_demo \
+ EVP_ED_Signature_demo \
+ rsa_pss_direct \
+ rsa_pss_hash
-TESTS=EVP_EC_Signature_demo EVP_DSA_Signature_demo EVP_ED_Signature_demo rsa_pss_direct rsa_pss_hash
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
all: $(TESTS)
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
-
EVP_EC_Signature_demo: EVP_EC_Signature_demo.o
EVP_DSA_Signature_demo: EVP_DSA_Signature_demo.o
EVP_ED_Signature_demo: EVP_ED_Signature_demo.o
rsa_pss_direct: rsa_pss_direct.o
rsa_pss_hash: rsa_pss_hash.o
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
clean:
$(RM) *.o $(TESTS)
diff --git a/demos/signature/rsa_pss_direct.c b/demos/signature/rsa_pss_direct.c
index 41d8c2211d..097ad69f24 100644
--- a/demos/signature/rsa_pss_direct.c
+++ b/demos/signature/rsa_pss_direct.c
@@ -196,6 +196,8 @@ int main(int argc, char **argv)
if (verify(libctx, sig, sig_len) == 0)
goto end;
+ printf("Success\n");
+
ret = EXIT_SUCCESS;
end:
OPENSSL_free(sig);
diff --git a/demos/signature/rsa_pss_hash.c b/demos/signature/rsa_pss_hash.c
index a84df8ab62..57d5c5ae19 100644
--- a/demos/signature/rsa_pss_hash.c
+++ b/demos/signature/rsa_pss_hash.c
@@ -181,6 +181,8 @@ int main(int argc, char **argv)
if (verify(libctx, sig, sig_len) == 0)
goto end;
+ printf("Success\n");
+
ret = EXIT_SUCCESS;
end:
OPENSSL_free(sig);
diff --git a/demos/smime/Makefile b/demos/smime/Makefile
new file mode 100644
index 0000000000..449efd627b
--- /dev/null
+++ b/demos/smime/Makefile
@@ -0,0 +1,37 @@
+#
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto is on the library path. For example, to run the
+# sm_enc demo:
+#
+# LD_LIBRARY_PATH=../.. ./sms_enc
+
+TESTS = smenc \
+ smdec \
+ smsign \
+ smsign2 \
+ smver
+
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lcrypto
+
+all: $(TESTS)
+
+smenc: smenc.o
+smdec: smdec.o
+smsign: smsign.o
+smsign2: smsign2.o
+smver: smver.o
+
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+clean:
+ $(RM) $(TESTS) *.o
+
+test: all
+ @echo "\nS/MIME tests:"
+ LD_LIBRARY_PATH=../.. ./smenc
+ LD_LIBRARY_PATH=../.. ./smdec
+ LD_LIBRARY_PATH=../.. ./smsign2
+ LD_LIBRARY_PATH=../.. ./smver
diff --git a/demos/smime/smdec.c b/demos/smime/smdec.c
index 7cf66f1dcd..f27c353f40 100644
--- a/demos/smime/smdec.c
+++ b/demos/smime/smdec.c
@@ -31,7 +31,8 @@ int main(int argc, char **argv)
rcert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
rkey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -59,8 +60,9 @@ int main(int argc, char **argv)
if (!PKCS7_decrypt(p7, rkey, rcert, out, 0))
goto err;
- ret = EXIT_SUCCESS;
+ printf("Success\n");
+ ret = EXIT_SUCCESS;
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Signing Data\n");
@@ -74,5 +76,4 @@ int main(int argc, char **argv)
BIO_free(tbio);
return ret;
-
}
diff --git a/demos/smime/smenc.c b/demos/smime/smenc.c
index 3e3f34d1cf..2113e12d1c 100644
--- a/demos/smime/smenc.c
+++ b/demos/smime/smenc.c
@@ -21,7 +21,6 @@ int main(int argc, char **argv)
int ret = EXIT_FAILURE;
/*
- * On OpenSSL 0.9.9 only:
* for streaming set PKCS7_STREAM
*/
int flags = PKCS7_STREAM;
@@ -73,8 +72,9 @@ int main(int argc, char **argv)
if (!SMIME_write_PKCS7(out, p7, in, flags))
goto err;
- ret = EXIT_SUCCESS;
+ printf("Success\n");
+ ret = EXIT_SUCCESS;
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Encrypting Data\n");
@@ -87,5 +87,4 @@ int main(int argc, char **argv)
BIO_free(out);
BIO_free(tbio);
return ret;
-
}
diff --git a/demos/smime/smsign.c b/demos/smime/smsign.c
index 4ce671d05c..3e27c931f6 100644
--- a/demos/smime/smsign.c
+++ b/demos/smime/smsign.c
@@ -21,7 +21,7 @@ int main(int argc, char **argv)
int ret = EXIT_FAILURE;
/*
- * For simple S/MIME signing use PKCS7_DETACHED. On OpenSSL 0.9.9 only:
+ * For simple S/MIME signing use PKCS7_DETACHED.
* for streaming detached set PKCS7_DETACHED|PKCS7_STREAM for streaming
* non-detached set PKCS7_STREAM
*/
@@ -38,7 +38,8 @@ int main(int argc, char **argv)
scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -62,15 +63,18 @@ int main(int argc, char **argv)
if (!out)
goto err;
- if (!(flags & PKCS7_STREAM))
- BIO_reset(in);
+ if (!(flags & PKCS7_STREAM)) {
+ if (BIO_reset(in) < 0)
+ goto err;
+ }
/* Write out S/MIME message */
if (!SMIME_write_PKCS7(out, p7, in, flags))
goto err;
- ret = EXIT_SUCCESS;
+ printf("Success\n");
+ ret = EXIT_SUCCESS;
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Signing Data\n");
@@ -84,5 +88,4 @@ int main(int argc, char **argv)
BIO_free(tbio);
return ret;
-
}
diff --git a/demos/smime/smsign2.c b/demos/smime/smsign2.c
index 4e62c6b82c..5ad86f15f8 100644
--- a/demos/smime/smsign2.c
+++ b/demos/smime/smsign2.c
@@ -7,7 +7,7 @@
* https://www.openssl.org/source/license.html
*/
-/* S/MIME signing example: 2 signers. OpenSSL 0.9.9 only */
+/* S/MIME signing example: 2 signers */
#include <openssl/pem.h>
#include <openssl/pkcs7.h>
#include <openssl/err.h>
@@ -30,7 +30,8 @@ int main(int argc, char **argv)
scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -43,7 +44,8 @@ int main(int argc, char **argv)
scert2 = PEM_read_bio_X509(tbio, NULL, 0, NULL);
- BIO_reset(tbio);
+ if (BIO_reset(tbio) < 0)
+ goto err;
skey2 = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);
@@ -77,8 +79,9 @@ int main(int argc, char **argv)
if (!SMIME_write_PKCS7(out, p7, in, PKCS7_STREAM))
goto err;
- ret = EXIT_SUCCESS;
+ printf("Success\n");
+ ret = EXIT_SUCCESS;
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Signing Data\n");
diff --git a/demos/smime/smver.c b/demos/smime/smver.c
index 2e55c72584..caa9ed304f 100644
--- a/demos/smime/smver.c
+++ b/demos/smime/smver.c
@@ -66,10 +66,9 @@ int main(int argc, char **argv)
goto err;
}
- fprintf(stderr, "Verification Successful\n");
+ printf("Verification Successful\n");
ret = EXIT_SUCCESS;
-
err:
if (ret != EXIT_SUCCESS) {
fprintf(stderr, "Error Verifying Data\n");
diff --git a/demos/sslecho/Makefile b/demos/sslecho/Makefile
new file mode 100644
index 0000000000..defb1597e1
--- /dev/null
+++ b/demos/sslecho/Makefile
@@ -0,0 +1,25 @@
+#
+# To run the demos when linked with a shared library (default) ensure that
+# libcrypto and libssl are on the library path. For example:
+#
+# LD_LIBRARY_PATH=../.. ./sslecho
+
+TESTS = sslecho
+
+CFLAGS = -I../../include -g -Wall
+LDFLAGS = -L../..
+LDLIBS = -lssl -lcrypto
+
+all: $(TESTS)
+
+sslecho: main.o
+
+$(TESTS):
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+clean:
+ $(RM) $(TESTS) *.o
+
+test: all
+ @echo "\nSSL Echo tests:"
+ @echo "skipped"
diff --git a/demos/sslecho/main.c b/demos/sslecho/main.c
index 8cf7744501..20b018c7a1 100644
--- a/demos/sslecho/main.c
+++ b/demos/sslecho/main.c
@@ -156,7 +156,7 @@ int main(int argc, char **argv)
signal(SIGPIPE, SIG_IGN);
/* Splash */
- printf("\nsslecho : Simple Echo Client/Server (OpenSSL 3.0.1-dev) : %s : %s\n\n", __DATE__,
+ printf("\nsslecho : Simple Echo Client/Server : %s : %s\n\n", __DATE__,
__TIME__);
/* Need to know if client or server */
diff --git a/demos/sslecho/makefile b/demos/sslecho/makefile
deleted file mode 100644
index 1e91567277..0000000000
--- a/demos/sslecho/makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-PROG ?= sslecho
-
-all: $(PROG)
-
-# Debug version.
-#
-$(PROG): main.c
-
- $(CC) -O0 -g3 -W -Wall -I../../include -L../../ -o $(PROG) main.c -lssl -lcrypto
-
-test:
-
-clean:
- rm -rf $(PROG) *.o *.obj