Skip to content

Commit 1952bcd

Browse files
committed
Revert "deps: delete OpenSSL demos, doc and test folders"
This reverts commit dfaded8.
1 parent fc054bb commit 1952bcd

File tree

2,521 files changed

+529845
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,521 files changed

+529845
-3
lines changed

deps/openssl/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
openssl/demos
2-
openssl/doc
31
openssl/fuzz/corpora
42
openssl/makefile.in
53
openssl/Makefile.in
6-
openssl/test
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
OpenSSL Demonstration Applications
2+
3+
This folder contains source code that demonstrates the proper use of the OpenSSL
4+
library API.
5+
6+
bio: Demonstration of a simple TLS client and server
7+
8+
certs: Demonstration of creating certs, using OCSP
9+
10+
cipher:
11+
aesgcm.c Demonstration of symmetric cipher GCM mode encrypt/decrypt
12+
aesccm.c Demonstration of symmetric cipher CCM mode encrypt/decrypt
13+
ariacbc.c Demonstration of symmetric cipher CBC mode encrypt/decrypt
14+
15+
cms:
16+
17+
digest:
18+
EVP_MD_demo.c Compute a digest from multiple buffers
19+
EVP_MD_stdin.c Compute a digest with data read from stdin
20+
EVP_MD_xof.c Compute a digest using the SHAKE256 XOF
21+
EVP_f_md.c Compute a digest using BIO and EVP_f_md
22+
23+
kdf:
24+
hkdf.c Demonstration of HMAC based key derivation
25+
pbkdf2.c Demonstration of PBKDF2 password based key derivation
26+
scrypt.c Demonstration of SCRYPT password based key derivation
27+
28+
mac:
29+
gmac.c Demonstration of GMAC message authentication
30+
poly1305.c Demonstration of Poly1305-AES message authentication
31+
siphash.c Demonstration of SIPHASH message authentication
32+
33+
pkey:
34+
EVP_PKEY_EC_keygen.c Generate an EC key.
35+
EVP_PKEY_RSA_keygen.c Generate an RSA key.
36+
EVP_PKEY_DSA_keygen.c Generate a DSA key.
37+
EVP_PKEY_DSA_paramgen.c Generate a DSA param key.
38+
EVP_PKEY_DSA_paramvalidate.c Validate a DSA param key.
39+
EVP_PKEY_DSA_paramfromdata.c Load a DSA param key using raw data.
40+
41+
smime:
42+
43+
pkcs12:
44+
pkread.c Print out a description of a PKCS12 file.
45+
pkwrite.c Add a password to an existing PKCS12 file.
46+
47+
signature:
48+
EVP_Signature_demo.c Compute and verify a signature from multiple buffers
49+
rsa_pss_direct.c Compute and verify an RSA-PSS signature from a hash
50+
rsa_pss_hash.c Compute and verify an RSA-PSS signature over a buffer
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Quick instruction:
2+
# To build against an OpenSSL built in the source tree, do this:
3+
#
4+
# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../..
5+
#
6+
# To run the demos when linked with a shared library (default):
7+
#
8+
# LD_LIBRARY_PATH=../.. ./server-arg
9+
# LD_LIBRARY_PATH=../.. ./server-cmod
10+
# LD_LIBRARY_PATH=../.. ./server-conf
11+
# LD_LIBRARY_PATH=../.. ./client-arg
12+
# LD_LIBRARY_PATH=../.. ./client-conf
13+
# LD_LIBRARY_PATH=../.. ./saccept
14+
# LD_LIBRARY_PATH=../.. ./sconnect
15+
16+
CFLAGS = $(OPENSSL_INCS_LOCATION)
17+
LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto $(EX_LIBS)
18+
19+
all: client-arg client-conf saccept sconnect server-arg server-cmod server-conf
20+
21+
client-arg: client-arg.o
22+
client-conf: client-conf.o
23+
saccept: saccept.o
24+
sconnect: sconnect.o
25+
server-arg: server-arg.o
26+
server-cmod: server-cmod.o
27+
server-conf: server-conf.o
28+
29+
client-arg client-conf saccept sconnect server-arg server-cmod server-conf:
30+
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
31+
32+
clean:
33+
$(RM) *.o client-arg client-conf saccept sconnect server-arg server-cmod server-conf
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This directory contains some simple examples of the use of BIO's
2+
to simplify socket programming.
3+
4+
The client-conf, server-conf, client-arg and client-conf include examples
5+
of how to use the SSL_CONF API for configuration file or command line
6+
processing.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Example configuration file
2+
3+
# Comment out the next line to ignore configuration errors
4+
config_diagnostics = 1
5+
6+
# Port to listen on
7+
Port = 4433
8+
9+
# Disable TLS v1.2 for test.
10+
# Protocol = ALL, -TLSv1.2
11+
# Only support 3 curves
12+
Curves = P-521:P-384:P-256
13+
14+
# Restricted signature algorithms
15+
SignatureAlgorithms = RSA+SHA512:ECDSA+SHA512
16+
Certificate=server.pem
17+
PrivateKey=server.pem
18+
ChainCAFile=root.pem
19+
VerifyCAFile=root.pem
20+
21+
# Request certificate
22+
VerifyMode=Request
23+
ClientCAFile=root.pem
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. You can obtain a copy
6+
* in the file LICENSE in the source distribution or at
7+
* https://www.openssl.org/source/license.html
8+
*/
9+
10+
#include <string.h>
11+
#include <openssl/err.h>
12+
#include <openssl/ssl.h>
13+
14+
int main(int argc, char **argv)
15+
{
16+
BIO *sbio = NULL, *out = NULL;
17+
int len;
18+
char tmpbuf[1024];
19+
SSL_CTX *ctx;
20+
SSL_CONF_CTX *cctx;
21+
SSL *ssl;
22+
char **args = argv + 1;
23+
const char *connect_str = "localhost:4433";
24+
int nargs = argc - 1;
25+
26+
ctx = SSL_CTX_new(TLS_client_method());
27+
cctx = SSL_CONF_CTX_new();
28+
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CLIENT);
29+
SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
30+
while (*args && **args == '-') {
31+
int rv;
32+
/* Parse standard arguments */
33+
rv = SSL_CONF_cmd_argv(cctx, &nargs, &args);
34+
if (rv == -3) {
35+
fprintf(stderr, "Missing argument for %s\n", *args);
36+
goto end;
37+
}
38+
if (rv < 0) {
39+
fprintf(stderr, "Error in command %s\n", *args);
40+
ERR_print_errors_fp(stderr);
41+
goto end;
42+
}
43+
/* If rv > 0 we processed something so proceed to next arg */
44+
if (rv > 0)
45+
continue;
46+
/* Otherwise application specific argument processing */
47+
if (strcmp(*args, "-connect") == 0) {
48+
connect_str = args[1];
49+
if (connect_str == NULL) {
50+
fprintf(stderr, "Missing -connect argument\n");
51+
goto end;
52+
}
53+
args += 2;
54+
nargs -= 2;
55+
continue;
56+
} else {
57+
fprintf(stderr, "Unknown argument %s\n", *args);
58+
goto end;
59+
}
60+
}
61+
62+
if (!SSL_CONF_CTX_finish(cctx)) {
63+
fprintf(stderr, "Finish error\n");
64+
ERR_print_errors_fp(stderr);
65+
goto end;
66+
}
67+
68+
/*
69+
* We'd normally set some stuff like the verify paths and * mode here
70+
* because as things stand this will connect to * any server whose
71+
* certificate is signed by any CA.
72+
*/
73+
74+
sbio = BIO_new_ssl_connect(ctx);
75+
76+
BIO_get_ssl(sbio, &ssl);
77+
78+
if (!ssl) {
79+
fprintf(stderr, "Can't locate SSL pointer\n");
80+
goto end;
81+
}
82+
83+
/* We might want to do other things with ssl here */
84+
85+
BIO_set_conn_hostname(sbio, connect_str);
86+
87+
out = BIO_new_fp(stdout, BIO_NOCLOSE);
88+
if (BIO_do_connect(sbio) <= 0) {
89+
fprintf(stderr, "Error connecting to server\n");
90+
ERR_print_errors_fp(stderr);
91+
goto end;
92+
}
93+
94+
/* Could examine ssl here to get connection info */
95+
96+
BIO_puts(sbio, "GET / HTTP/1.0\n\n");
97+
for (;;) {
98+
len = BIO_read(sbio, tmpbuf, 1024);
99+
if (len <= 0)
100+
break;
101+
BIO_write(out, tmpbuf, len);
102+
}
103+
end:
104+
SSL_CONF_CTX_free(cctx);
105+
BIO_free_all(sbio);
106+
BIO_free(out);
107+
return 0;
108+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. You can obtain a copy
6+
* in the file LICENSE in the source distribution or at
7+
* https://www.openssl.org/source/license.html
8+
*/
9+
10+
#include <string.h>
11+
#include <openssl/err.h>
12+
#include <openssl/ssl.h>
13+
#include <openssl/conf.h>
14+
15+
int main(int argc, char **argv)
16+
{
17+
BIO *sbio = NULL, *out = NULL;
18+
int i, len, rv;
19+
char tmpbuf[1024];
20+
SSL_CTX *ctx = NULL;
21+
SSL_CONF_CTX *cctx = NULL;
22+
SSL *ssl = NULL;
23+
CONF *conf = NULL;
24+
STACK_OF(CONF_VALUE) *sect = NULL;
25+
CONF_VALUE *cnf;
26+
const char *connect_str = "localhost:4433";
27+
long errline = -1;
28+
29+
conf = NCONF_new(NULL);
30+
31+
if (NCONF_load(conf, "connect.cnf", &errline) <= 0) {
32+
if (errline <= 0)
33+
fprintf(stderr, "Error processing config file\n");
34+
else
35+
fprintf(stderr, "Error on line %ld\n", errline);
36+
goto end;
37+
}
38+
39+
sect = NCONF_get_section(conf, "default");
40+
41+
if (sect == NULL) {
42+
fprintf(stderr, "Error retrieving default section\n");
43+
goto end;
44+
}
45+
46+
ctx = SSL_CTX_new(TLS_client_method());
47+
cctx = SSL_CONF_CTX_new();
48+
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_CLIENT);
49+
SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_FILE);
50+
SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
51+
for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
52+
cnf = sk_CONF_VALUE_value(sect, i);
53+
rv = SSL_CONF_cmd(cctx, cnf->name, cnf->value);
54+
if (rv > 0)
55+
continue;
56+
if (rv != -2) {
57+
fprintf(stderr, "Error processing %s = %s\n",
58+
cnf->name, cnf->value);
59+
ERR_print_errors_fp(stderr);
60+
goto end;
61+
}
62+
if (strcmp(cnf->name, "Connect") == 0) {
63+
connect_str = cnf->value;
64+
} else {
65+
fprintf(stderr, "Unknown configuration option %s\n", cnf->name);
66+
goto end;
67+
}
68+
}
69+
70+
if (!SSL_CONF_CTX_finish(cctx)) {
71+
fprintf(stderr, "Finish error\n");
72+
ERR_print_errors_fp(stderr);
73+
goto end;
74+
}
75+
76+
/*
77+
* We'd normally set some stuff like the verify paths and * mode here
78+
* because as things stand this will connect to * any server whose
79+
* certificate is signed by any CA.
80+
*/
81+
82+
sbio = BIO_new_ssl_connect(ctx);
83+
84+
BIO_get_ssl(sbio, &ssl);
85+
86+
if (!ssl) {
87+
fprintf(stderr, "Can't locate SSL pointer\n");
88+
goto end;
89+
}
90+
91+
/* We might want to do other things with ssl here */
92+
93+
BIO_set_conn_hostname(sbio, connect_str);
94+
95+
out = BIO_new_fp(stdout, BIO_NOCLOSE);
96+
if (BIO_do_connect(sbio) <= 0) {
97+
fprintf(stderr, "Error connecting to server\n");
98+
ERR_print_errors_fp(stderr);
99+
goto end;
100+
}
101+
102+
/* Could examine ssl here to get connection info */
103+
104+
BIO_puts(sbio, "GET / HTTP/1.0\n\n");
105+
for (;;) {
106+
len = BIO_read(sbio, tmpbuf, 1024);
107+
if (len <= 0)
108+
break;
109+
BIO_write(out, tmpbuf, len);
110+
}
111+
end:
112+
SSL_CONF_CTX_free(cctx);
113+
BIO_free_all(sbio);
114+
BIO_free(out);
115+
NCONF_free(conf);
116+
return 0;
117+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Example config module configuration
2+
3+
# Name supplied by application to CONF_modules_load_file
4+
# and section containing configuration
5+
testapp = test_sect
6+
7+
# Comment out the next line to ignore configuration errors
8+
config_diagnostics = 1
9+
10+
[test_sect]
11+
# list of configuration modules
12+
13+
# SSL configuration module
14+
ssl_conf = ssl_sect
15+
16+
[ssl_sect]
17+
# list of SSL configurations
18+
server = server_sect
19+
20+
[server_sect]
21+
# Only support 3 curves
22+
Curves = P-521:P-384:P-256
23+
# Restricted signature algorithms
24+
SignatureAlgorithms = RSA+SHA512:ECDSA+SHA512
25+
# Certificates and keys
26+
RSA.Certificate=server.pem
27+
ECDSA.Certificate=server-ec.pem
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Example configuration file
2+
3+
# Comment out the next line to ignore configuration errors
4+
config_diagnostics = 1
5+
6+
# Connects to the default port of s_server
7+
Connect = localhost:4433
8+
9+
# Disable TLS v1.2 for test.
10+
# Protocol = ALL, -TLSv1.2
11+
# Only support 3 curves
12+
Curves = P-521:P-384:P-256
13+
14+
# Restricted signature algorithms
15+
SignatureAlgorithms = RSA+SHA512:ECDSA+SHA512

0 commit comments

Comments
 (0)