OpenSSL ECC Engine  1.0
OpenSSL Engine implementation using ATECC508 for ECC key storage and ECDSA, ECDH, and RNG.
tlsutil.h
Go to the documentation of this file.
1 
44 #ifndef SSLUTIL_H_
45 #define SSLUTIL_H_
46 
47 #include <stdio.h>
48 #include <memory.h>
49 #include <unistd.h>
50 #include <errno.h>
51 #include <assert.h>
52 #include <sys/types.h>
53 #include <sys/socket.h>
54 #include <netinet/in.h>
55 #include <arpa/inet.h>
56 #include <netdb.h>
57 
58 #include <openssl/crypto.h>
59 #include <openssl/x509.h>
60 #include <openssl/pem.h>
61 #include <openssl/ssl.h>
62 #include <openssl/err.h>
63 #include <openssl/engine.h>
64 
65 #include <engine_meth/ecc_meth.h>
66 
67 #define EXCHANGE_VERSION "1.1.0"
68 #define PORT_NUMBER_DEFAULT (49917)
69 
70 #define CHK_NULL(x) if ((x)==NULL) { sleep(1); exit (1); }
71 #define CHK_ERR(err,s) if ((err)==-1) { perror(s); sleep(1); exit(1); }
72 #define CHK_SSL(err) if ((err)==-1) { ERR_print_errors_fp(stderr); sleep(2); exit(2); }
73 
74 int setup_engine(const char *engine_id);
75 void init_openssl(void);
76 SSL_CTX* create_context(uint32_t is_server);
77 int config_args_ssl_call(SSL_CTX *ctx, SSL_CONF_CTX *cctx);
78 int configure_context(SSL_CTX *ctx, const char *ca_path, const char *chain_file,
79  const char *cert_file);
80 int verify_callback(int ok, X509_STORE_CTX *ctx);
81 int load_private_key(const char *engine_id, SSL_CTX *ctx, const char *key_file);
82 void cleanup_openssl(void);
83 
84 int connect_client(const char *engine_id, const char *ca_path, const char *chain_file,
85  const char *cert_file, const char *key_file, const char *cipher_list,
86  const char *ip_address, uint16_t port_number);
87 int connect_server(const char *engine_id, const char *ca_path, const char *chain_file,
88  const char *cert_file, const char *key_file,
89  const char *ip_address, uint16_t port_number);
90 
91 int save_private_key(EVP_PKEY *pkey, const char *privkey_fname);
92 int save_x509_certificate(X509 *x509, const char *cert_fname);
93 int run_engine_cmds(const char *engine_id, int cmd, char *buffer, int len);
94 
95 
96 #endif /* SSLUTIL_H_ */
int setup_engine(const char *engine_id)
setup OpenSSL engine by engine ID
Definition: tlsutil.c:58
int configure_context(SSL_CTX *ctx, const char *ca_path, const char *chain_file, const char *cert_file)
Configures the SSL context for server or client using provided certificates, chain files...
Definition: tlsutil.c:136
int connect_server(const char *engine_id, const char *ca_path, const char *chain_file, const char *cert_file, const char *key_file, const char *ip_address, uint16_t port_number)
A complete procedure of connecting server using TLS-1.2 protocol over TCP/IP.
Definition: server-tls2.c:58
int run_engine_cmds(const char *engine_id, int cmd, char *buffer, int len)
Definition: tlsutil.c:403
int config_args_ssl_call(SSL_CTX *ctx, SSL_CONF_CTX *cctx)
A modification of the args_ssl_call() function from the openssl aps/s_cb.c file.
Definition: tlsutil.c:236
void cleanup_openssl(void)
Call OpenSSL standard cleanup methods.
Definition: tlsutil.c:329
SSL_CTX * create_context(uint32_t is_server)
Creates the SSL context for server or client.
Definition: tlsutil.c:100
int save_x509_certificate(X509 *x509, const char *cert_fname)
Definition: tlsutil.c:373
int verify_callback(int ok, X509_STORE_CTX *ctx)
A modification of the verify_callback() function from the openssl aps/s_cb.c file.
Definition: tlsutil.c:265
void init_openssl(void)
Calls OpenSSL standard initialize methods.
Definition: tlsutil.c:86
int save_private_key(EVP_PKEY *pkey, const char *privkey_fname)
Definition: tlsutil.c:347
Function definitions used in OpenSSL ENGINE.
int load_private_key(const char *engine_id, SSL_CTX *ctx, const char *key_file)
setup OpenSSL engine by engine ID
Definition: tlsutil.c:187
int connect_client(const char *engine_id, const char *ca_path, const char *chain_file, const char *cert_file, const char *key_file, const char *cipher_list, const char *ip_address, uint16_t port_number)
A complete procedure of connecting client using TLS-1.2 protocol over TCP/IP.
Definition: client-tls2.c:62