mirror of
https://github.com/openssl/openssl.git
synced 2024-11-23 10:03:32 +08:00
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)
This commit is contained in:
parent
56aa3e8d1a
commit
86db958835
@ -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 \
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
TESTS = tls-client-block \
|
||||
quic-client-block \
|
||||
quic-multi-stream \
|
||||
tls-client-non-block \
|
||||
quic-client-non-block
|
||||
|
||||
CFLAGS = -I../../include -g -Wall
|
||||
LDFLAGS = -L../..
|
||||
LDLIBS = -lcrypto -lssl
|
||||
LDLIBS = -lcrypto -lssl
|
||||
|
||||
all: tls-client-block quic-client-block quic-multi-stream tls-client-non-block \
|
||||
quic-client-non-block
|
||||
all: $(TESTS)
|
||||
|
||||
tls-client-block: tls-client-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-block: quic-client-block.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
||||
|
||||
quic-multi-stream: quic-multi-stream.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
||||
|
||||
tls-client-non-block: tls-client-non-block.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
|
||||
|
||||
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"
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
||||
|
@ -145,6 +145,8 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("Success\n");
|
||||
|
||||
rv = EXIT_SUCCESS;
|
||||
end:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
|
@ -95,6 +95,8 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("Success\n");
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
end:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
|
@ -108,6 +108,8 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("Success\n");
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
end:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
|
@ -111,6 +111,8 @@ int main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
printf("Success\n");
|
||||
|
||||
ret = EXIT_SUCCESS;
|
||||
end:
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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");
|
||||
|
@ -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
|
||||
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
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
|
@ -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
|
||||
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
|
||||
|
||||
TESTS=EVP_EC_Signature_demo EVP_DSA_Signature_demo EVP_ED_Signature_demo rsa_pss_direct rsa_pss_hash
|
||||
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)
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
37
demos/smime/Makefile
Normal file
37
demos/smime/Makefile
Normal file
@ -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
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
25
demos/sslecho/Makefile
Normal file
25
demos/sslecho/Makefile
Normal file
@ -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"
|
@ -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 */
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user