Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1756857446, "reponame":"openssl", "desc":"OpenSSL", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/openssl", "f":3, "items": [ {"schema":"libjg2-1", "cid":"6b3f4f5ad772e61b84365f53490033cb", "commit": {"type":"commit", "time": 1457380572, "time_ofs": 18446744073709551316, "oid_tree": { "oid": "ba30c078a473f92b8c08e5901c6a65ad00de6a4e", "alias": []}, "oid":{ "oid": "ec59112a822e16a539bc5dd1b8bed12afbcb82b8", "alias": []}, "msg": "Remove really old demo's", "sig_commit": { "git_time": { "time": 1457380572, "offset": -300 }, "name": "Rich Salz", "email": "rsalz@openssl.org", "md5": "3ed6b9cf7bbe83902a044f6590346d26" }, "sig_author": { "git_time": { "time": 1457380544, "offset": -300 }, "name": "Rich Salz", "email": "rsalz@akamai.com", "md5": "825a7f3ef767f852ea1717d3b4a10cd3" }}, "body": "Remove really old demo's\n\nReviewed-by: Richard Levitte \u003clevitte@openssl.org\u003e\n" , "diff": "diff --git a/demos/easy_tls/Makefile.in b/demos/easy_tls/Makefile.in\ndeleted file mode 100644\nindex 087caa8..0000000\n--- a/demos/easy_tls/Makefile.in\n+++ /dev/null\n@@ -1,124 +0,0 @@\n-# Makefile for easy-tls example application (rudimentary client and server)\n-# $Id: Makefile,v 1.2 2001/09/18 09:15:40 bodo Exp $\n-\n-SOLARIS_CFLAGS\u003d-Wall -pedantic -g -O2\n-SOLARIS_LIBS\u003d-lxnet\n-\n-LINUX_CFLAGS\u003d-Wall -pedantic -g -O2\n-LINUX_LIBS\u003d\n-\n-\n-auto-all:\n-\tcase `uname -s` in \u005c\n-\tSunOS) echo Using SunOS configuration; \u005c\n-\t make SYSCFLAGS\u003d\u0022$(SOLARIS_CFLAGS)\u0022 SYSLIBS\u003d\u0022$(SOLARIS_LIBS)\u0022 all;; \u005c\n-\tLinux) echo Using Linux configuration; \u005c\n-\t make SYSCFLAGS\u003d\u0022$(LINUX_CFLAGS)\u0022 SYSLIBS\u003d\u0022$(LINUX_LIBS)\u0022 all;; \u005c\n-\t*) echo \u0022unknown system\u0022; exit 1;; \u005c\n-\tesac\n-\n-all: test TAGS\n-\n-# For adapting this Makefile to a different system, only the following\n-# definitions should need customizing:\n-\n-OPENSSLDIR\u003d../..\n-CC\u003dgcc\n-\n-SYSCFLAGS\u003dwhatever\n-SYSLIBS\u003dwhatever\n-\n-\n-#############################################################################\n-#\n-# SSLeay/OpenSSL imports\n-#\n-# OPENSSLDIR (set above) can be either the directory where OpenSSL is\n-# installed or the directory where it was compiled.\n-\n-# We rely on having a new OpenSSL release where include files\n-# have names like \u003copenssl/ssl.h\u003e (not just \u003cssl.h\u003e).\n-OPENSSLINCLUDES\u003d-I$(OPENSSLDIR)/include\n-\n-# libcrypto.a and libssl.a are directly in $(OPENSSLDIR) if this is\n-# the compile directory, or in $(OPENSSLDIR)/lib if we use an installed\n-# library. With the following definition, we can handle either case.\n-OPENSSLLIBS\u003d-L$(OPENSSLDIR) -L$(OPENSSLDIR)/lib -lssl -lcrypto\n-\n-\n-#############################################################################\n-#\n-# Stuff for handling the source files\n-#\n-\n-SOURCES\u003deasy-tls.c test.c\n-HEADERS\u003deasy-tls.h test.h\n-DOCSandEXAMPLESetc\u003dMakefile cert.pem cacerts.pem\n-EVERYTHING\u003d$(SOURCES) $(HEADERS) $(DOCSandEXAMPLESetc)\n-\n-ls: ls-l\n-ls-l:\n-\tls -l $(EVERYTHING)\n-# For RCS:\n-tag:\n-\t-rcs -n_`date +%y%m%d`: $(EVERYTHING)\n-\trcs -nMYTAG $(EVERYTHING)\n-\trcs -nMYTAG: $(EVERYTHING)\n-diff:\n-\t-rcsdiff -rMYTAG -u $(EVERYTHING)\n-today:\n-\t-rcsdiff -r_`date +%y%m%d` -u $(EVERYTHING)\n-ident:\n-\tfor a in $(EVERYTHING); do ident $$a; done\n-\n-# Distribution .tar:\n-easy-tls.tar.gz: $(EVERYTHING)\n-\ttar cvf - $(EVERYTHING) | \u005c\n-\tgzip -9 \u003e easy-tls.tar.gz\n-\n-# Working .tar:\n-tls.tgz: $(EVERYTHING)\n-\ttar cfv - `find . -type f -a ! -name '*.tgz' -a ! -name '*.tar.gz'` | \u005c\n-\tgzip -9 \u003e tls.tgz\n-\n-# For emacs:\n-etags: TAGS\n-TAGS: $(SOURCES) $(HEADERS)\n-\t-etags $(SOURCES) $(HEADERS)\n-\n-\n-#############################################################################\n-#\n-# Compilation\n-#\n-# The following definitions are system dependent (and hence defined\n-# at the beginning of this Makefile, where they are more easily found):\n-\n-### CC\u003dgcc\n-### SYSCFLAGS\u003d-Wall -pedantic -g -O2\n-### SYSLIBS\u003d-lxnet\n-\n-EXTRACFLAGS\u003d-DTLS_APP\u003d\u005c\u0022test.h\u005c\u0022\n-# EXTRACFLAGS\u003d-DTLS_APP\u003d\u005c\u0022test.h\u005c\u0022 -DDEBUG_TLS\n-\n-#\n-# The rest shouldn't need to be touched.\n-#\n-LDFLAGS\u003d$(SYSLIBS) $(OPENSSLLIBS)\n-INCLUDES\u003d$(OPENSSLINCLUDES)\n-CFLAGS\u003d$(SYSCFLAGS) $(EXTRACFLAGS) $(INCLUDES)\n-\n-OBJS\u003deasy-tls.o test.o\n-\n-clean:\n-\t@rm -f test\n-\t@rm -f TAGS\n-\t@rm -f *.o\n-\t@rm -f core\n-\n-test: $(OBJS)\n-\t$(CC) $(OBJS) $(LDFLAGS) -o test\n-\n-test.o: $(HEADERS)\n-easy-tls.o: $(HEADERS)\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/easy_tls/README b/demos/easy_tls/README\ndeleted file mode 100644\nindex ee89dfb..0000000\n--- a/demos/easy_tls/README\n+++ /dev/null\n@@ -1,65 +0,0 @@\n-easy_tls - generic SSL/TLS proxy\n-\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-\n-(... and example for non-blocking SSL/TLS I/O multiplexing.)\n-\n-\n- easy_tls.c, easy_tls.h:\n-\n- Small generic SSL/TLS proxy library: With a few function calls,\n- an application socket will be replaced by a pipe handled by a\n- separate SSL/TLS proxy process. This allows easily adding\n- SSL/TLS support to many programs not originally designed for it.\n-\n- [Actually easy_tls.c is not a proper library: Customization\n- requires defining preprocessor macros while compiling it.\n- This is quite confusing, so I'll probably change it.]\n-\n- These files may be used under the OpenSSL license.\n-\n-\n-\n- test.c, test.h, Makefile, cert.pem, cacerts.pem:\n-\n- Rudimentary example program using the easy_tls library, and\n- example key and certificates for it. Usage examples:\n-\n- $ ./test 8443 # create server listening at port 8443\n- $ ./test 127.0.0.1 8443 # create client, connect to port 8443\n- # at IP address 127.0.0.1\n-\n- 'test' will not automatically do SSL/TLS, or even read or write\n- data -- it must be told to do so on input lines starting\n- with a command letter. 'W' means write a line, 'R' means\n- read a line, 'C' means close the connection, 'T' means\n- start an SSL/TLS proxy. E.g. (user input tagged with '*'):\n-\n- * R\n- \u003c\u003c\u003c 220 mail.example.net\n- * WSTARTTLS\n- \u003e\u003e\u003e STARTTLS\n- * R\n- \u003c\u003c\u003c 220 Ready to start TLS\n- * T\n- test_process_init(fd \u003d 3, client_p \u003d 1, apparg \u003d (nil))\n- +++ `E:self signed certificate in certificate chain'\n- +++ `\u003c... certificate info ...\u003e'\n- * WHELO localhost\n- \u003e\u003e\u003e HELO localhost\n- R\n- \u003c\u003c\u003c 250 mail.example.net\n-\n- You can even do SSL/TLS over SSL/TLS over SSL/TLS ... by using\n- 'T' multiple times. I have no idea why you would want to though.\n-\n-\n-This code is rather old. When I find time I will update anything that\n-should be changed, and improve code comments. To compile the sample\n-program 'test' on platforms other then Linux or Solaris, you will have\n-to edit the Makefile.\n-\n-As noted above, easy_tls.c will be changed to become a library one\n-day, which means that future revisions will not be fully compatible to\n-the current version.\n-\n-Bodo Möller \u003cbodo@openssl.org\u003e\ndiff --git a/demos/easy_tls/cacerts.pem b/demos/easy_tls/cacerts.pem\ndeleted file mode 100644\nindex acc70ba..0000000\n--- a/demos/easy_tls/cacerts.pem\n+++ /dev/null\n@@ -1,18 +0,0 @@\n-$Id: cacerts.pem,v 1.1 2001/09/17 19:06:57 bodo Exp $\n-\n-issuer\u003d /C\u003dAU/ST\u003dQueensland/O\u003dCryptSoft Pty Ltd/CN\u003dTest PCA (1024 bit)\n-subject\u003d/C\u003dAU/ST\u003dQueensland/O\u003dCryptSoft Pty Ltd/CN\u003dTest CA (1024 bit)\n------BEGIN CERTIFICATE-----\n-MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV\n-BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD\n-VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw\n-OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY\n-BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0\n-IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ\n-DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv\n-1F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2\n-mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v\n-hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4\n-YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA\n-q30KIqGM/uoM60INq97qjDmCJapagcNBGQs\u003d\n------END CERTIFICATE-----\ndiff --git a/demos/easy_tls/cert.pem b/demos/easy_tls/cert.pem\ndeleted file mode 100644\nindex 364fe10..0000000\n--- a/demos/easy_tls/cert.pem\n+++ /dev/null\n@@ -1,31 +0,0 @@\n-$Id: cert.pem,v 1.1 2001/09/17 19:06:57 bodo Exp $\n-\n-Example certificate and key.\n-\n------BEGIN CERTIFICATE-----\n-MIIB1jCCAT8CAQEwDQYJKoZIhvcNAQEEBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV\n-BAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0\n-ZDAeFw05OTA1MDEwMTI2MzVaFw05OTA1MzEwMTI2MzVaMCIxCzAJBgNVBAYTAkRF\n-MRMwEQYDVQQDEwpUZXN0c2VydmVyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n-gQD6I3oDKiexwwlkzjar69AIFnVUaG85LtCege2R+CtIDlkQYw68/8MbT3ou0pdF\n-AcL9IGiYY3Y0SHM9PqF00RO1MCtNpqTnF3ScLpbmggGjKilmWYn2ai7emdjMjXVL\n-tzWW2xGgIGATWQN32KgfJng4jXi1UjEiyLhkw0Zf1I/ggwIDAQABMA0GCSqGSIb3\n-DQEBBAUAA4GBAMgM+sbAk8DfjSfa+Rf2gcGXmbrvZAzKzC+5RU3kaq/NyxIXAGco\n-9dZjozzWfN/xuGup5boFk+KrP+xdgsaqGHsyzlgEoqz4ekqLjQeVbnoj339hVFU9\n-MhPi6JULPxjXKumjfX2LLNkikW5puz8Df3UiX0EiaJvd7EwP8J75tiUT\n------END CERTIFICATE-----\n------BEGIN RSA PRIVATE KEY-----\n-MIICXQIBAAKBgQD6I3oDKiexwwlkzjar69AIFnVUaG85LtCege2R+CtIDlkQYw68\n-/8MbT3ou0pdFAcL9IGiYY3Y0SHM9PqF00RO1MCtNpqTnF3ScLpbmggGjKilmWYn2\n-ai7emdjMjXVLtzWW2xGgIGATWQN32KgfJng4jXi1UjEiyLhkw0Zf1I/ggwIDAQAB\n-AoGANST8c1etf1MU19oIO5aqaE19OCXIG7oakNLCCtVTPMfvnE+vffBJH7BPIUuU\n-4BBzwRv1nQrkvk72TPjVjOAu81B1SStKQueun2flVuYxp9NyupNWCBley4QdohlP\n-I92ml2tzTSPmNIoA6jdGyNzFcGchapRRmejsC39F1RUbHQECQQD9KX81Wt8ZOrri\n-dWiEXja1L3X8Bkb9vvUjVMQDTJJPxBJjehC6eurgE6PP6SJD5p/f3RHPCcLr8tSM\n-D4P/OpKhAkEA/PFNlhIZUDKK6aTvG2mn7qQ5phbadOoyN1Js3ttWG5OMOZ6b/QlC\n-Wvp84h44506BIlv+Tg2YAI0AdBUrf7oEowJAM4joAVd/ROaEtqbJ4PBA2L9RmD06\n-5FqkEk4mHLnQqvYx/BgUIbH18ClvVlqSBBqFfw/EmU3WZSuogt6Bs0ocIQJBAOxB\n-AoPiYcxbeQ5kZIVJOXaX49SzUdaUDNVJYrEBUzsspHQJJo/Avz606kJVkjbSR6Ft\n-JWmIHuqcyMikIV4KxFsCQQCU2evoVjVsqkkbHi7W28f73PGBsyu0KIwlK7nu4h08\n-Daf7TAI+A6jW/WRUsJ6dFhUYi7/Jvkcdrlnbgm2fxziX\n------END RSA PRIVATE KEY-----\ndiff --git a/demos/easy_tls/easy-tls.c b/demos/easy_tls/easy-tls.c\ndeleted file mode 100644\nindex deef1fd..0000000\n--- a/demos/easy_tls/easy-tls.c\n+++ /dev/null\n@@ -1,1293 +0,0 @@\n-/* */\n-/*-\n- * easy-tls.c -- generic TLS proxy.\n- * $Id: easy-tls.c,v 1.4 2002/03/05 09:07:16 bodo Exp $\n- */\n-/*-\n- (c) Copyright 1999 Bodo Moeller. All rights reserved.\n-\n- This is free software; you can redistributed and/or modify it\n- unter the terms of either\n- - the GNU General Public License as published by the\n- Free Software Foundation, version 1, or (at your option)\n- any later version,\n- or\n- - the following license:\n-*/\n-/*-\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that each of the following\n- * conditions is met:\n- *\n- * 1. Redistributions qualify as \u0022freeware\u0022 or \u0022Open Source Software\u0022 under\n- * one of the following terms:\n- *\n- * (a) Redistributions are made at no charge beyond the reasonable cost of\n- * materials and delivery.\n- *\n- * (b) Redistributions are accompanied by a copy of the Source Code\n- * or by an irrevocable offer to provide a copy of the Source Code\n- * for up to three years at the cost of materials and delivery.\n- * Such redistributions must allow further use, modification, and\n- * redistribution of the Source Code under substantially the same\n- * terms as this license.\n- *\n- * 2. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 3. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 4. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by Bodo Moeller.\u0022\n- * (If available, substitute umlauted o for oe.)\n- *\n- * 5. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by Bodo Moeller.\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY BODO MOELLER ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BODO MOELLER OR\n- * HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- */\n-/*-\n- * Attribution for OpenSSL library:\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- * This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\n- */\n-\n-static char const rcsid[] \u003d\n- \u0022$Id: easy-tls.c,v 1.4 2002/03/05 09:07:16 bodo Exp $\u0022;\n-\n-#include \u003cassert.h\u003e\n-#include \u003cerrno.h\u003e\n-#include \u003cfcntl.h\u003e\n-#include \u003climits.h\u003e\n-#include \u003cstdarg.h\u003e\n-#include \u003cstdio.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u003csys/select.h\u003e\n-#include \u003csys/socket.h\u003e\n-#include \u003csys/stat.h\u003e\n-#include \u003csys/time.h\u003e\n-#include \u003csys/types.h\u003e\n-#include \u003csys/utsname.h\u003e\n-#include \u003cunistd.h\u003e\n-\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/dh.h\u003e\n-#include \u003copenssl/dsa.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u003copenssl/evp.h\u003e\n-#include \u003copenssl/opensslv.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/rand.h\u003e\n-#ifndef NO_RSA\n-# include \u003copenssl/rsa.h\u003e\n-#endif\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/x509_vfy.h\u003e\n-\n-#if OPENSSL_VERSION_NUMBER \u003c 0x00904000L /* 0.9.4-dev */\n-# error \u0022This program needs OpenSSL 0.9.4 or later.\u0022\n-#endif\n-\n-#include \u0022easy-tls.h\u0022 /* include after \u003copenssl/ssl.h\u003e if both are\n- * needed */\n-\n-#if TLS_INFO_SIZE \u003e PIPE_BUF\n-# if PIPE_BUF \u003c 512\n-# error \u0022PIPE_BUF \u003c 512\u0022 /* non-POSIX */\n-# endif\n-# error \u0022TLS_INFO_SIZE \u003e PIPE_BUF\u0022\n-#endif\n-\n-/*****************************************************************************/\n-\n-#ifdef TLS_APP\n-# include TLS_APP\n-#endif\n-\n-/*-\n- * Applications can define:\n- * TLS_APP_PROCESS_INIT -- void ...(int fd, int client_p, void *apparg)\n- * TLS_CUMULATE_ERRORS\n- * TLS_ERROR_BUFSIZ\n- * TLS_APP_ERRFLUSH -- void ...(int child_p, char *, size_t, void *apparg)\n- */\n-\n-#ifndef TLS_APP_PROCESS_INIT\n-# define TLS_APP_PROCESS_INIT(fd, client_p, apparg) ((void) 0)\n-#endif\n-\n-#ifndef TLS_ERROR_BUFSIZ\n-# define TLS_ERROR_BUFSIZ (10*160)\n-#endif\n-#if TLS_ERROR_BUFSIZ \u003c 2 /* {'\u005cn',0} */\n-# error \u0022TLS_ERROR_BUFSIZE is too small.\u0022\n-#endif\n-\n-#ifndef TLS_APP_ERRFLUSH\n-# define TLS_APP_ERRFLUSH tls_app_errflush\n-static void\n-tls_app_errflush(int child_p, char *errbuf, size_t num, void *apparg)\n-{\n- fputs(errbuf, stderr);\n-}\n-#endif\n-\n-/*****************************************************************************/\n-\n-#ifdef DEBUG_TLS\n-# define DEBUG_MSG(x) fprintf(stderr,\u0022 %s\u005cn\u0022,x)\n-# define DEBUG_MSG2(x,y) fprintf(stderr, \u0022 %s: %d\u005cn\u0022,x,y)\n-static int tls_loop_count \u003d 0;\n-static int tls_select_count \u003d 0;\n-#else\n-# define DEBUG_MSG(x) (void)0\n-# define DEBUG_MSG2(x,y) (void)0\n-#endif\n-\n-static void tls_rand_seed_uniquely(void);\n-static void tls_proxy(int clear_fd, int tls_fd, int info_fd, SSL_CTX *ctx,\n- int client_p);\n-static int tls_socket_nonblocking(int fd);\n-\n-static int tls_child_p \u003d 0;\n-static void *tls_child_apparg;\n-\n-struct tls_start_proxy_args tls_start_proxy_defaultargs(void)\n-{\n- struct tls_start_proxy_args ret;\n-\n- ret.fd \u003d -1;\n- ret.client_p \u003d -1;\n- ret.ctx \u003d NULL;\n- ret.pid \u003d NULL;\n- ret.infofd \u003d NULL;\n-\n- return ret;\n-}\n-\n-/*-\n- * Slice in TLS proxy process at fd.\n- * Return value:\n- * 0 ok (*pid is set to child's PID if pid !\u003d NULL),\n- * \u003c 0 look at errno\n- * \u003e 0 other error\n- * (return value encodes place of error)\n- *\n- */\n-int tls_start_proxy(struct tls_start_proxy_args a, void *apparg)\n-{\n- int fds[2] \u003d { -1, -1 };\n- int infofds[2] \u003d { -1, -1 };\n- int r, getfd, getfl;\n- int ret;\n-\n- DEBUG_MSG2(\u0022tls_start_proxy fd\u0022, a.fd);\n- DEBUG_MSG2(\u0022tls_start_proxy client_p\u0022, a.client_p);\n-\n- if (a.fd \u003d\u003d -1 || a.client_p \u003d\u003d -1 || a.ctx \u003d\u003d NULL)\n- return 1;\n-\n- if (a.pid !\u003d NULL) {\n- *a.pid \u003d 0;\n- }\n- if (a.infofd !\u003d NULL) {\n- *a.infofd \u003d -1;\n- }\n-\n- r \u003d socketpair(AF_UNIX, SOCK_STREAM, 0, fds);\n- if (r \u003d\u003d -1)\n- return -1;\n- if (a.fd \u003e\u003d FD_SETSIZE || fds[0] \u003e\u003d FD_SETSIZE) {\n- ret \u003d 2;\n- goto err;\n- }\n- if (a.infofd !\u003d NULL) {\n- r \u003d pipe(infofds);\n- if (r \u003d\u003d -1) {\n- ret \u003d -3;\n- goto err;\n- }\n- }\n-\n- r \u003d fork();\n- if (r \u003d\u003d -1) {\n- ret \u003d -4;\n- goto err;\n- }\n- if (r \u003d\u003d 0) {\n- DEBUG_MSG(\u0022fork\u0022);\n- tls_child_p \u003d 1;\n- tls_child_apparg \u003d apparg;\n- close(fds[1]);\n- if (infofds[0] !\u003d -1)\n- close(infofds[0]);\n- TLS_APP_PROCESS_INIT(a.fd, a.client_p, apparg);\n- DEBUG_MSG(\u0022TLS_APP_PROCESS_INIT\u0022);\n- tls_proxy(fds[0], a.fd, infofds[1], a.ctx, a.client_p);\n- exit(0);\n- }\n- if (a.pid !\u003d NULL)\n- *a.pid \u003d r;\n- if (infofds[1] !\u003d -1) {\n- close(infofds[1]);\n- infofds[1] \u003d -1;\n- }\n- /* install fds[1] in place of fd: */\n- close(fds[0]);\n- fds[0] \u003d -1;\n- getfd \u003d fcntl(a.fd, F_GETFD);\n- getfl \u003d fcntl(a.fd, F_GETFL);\n- r \u003d dup2(fds[1], a.fd);\n- close(fds[1]);\n- fds[1] \u003d -1;\n- if (r \u003d\u003d -1) {\n- ret \u003d -5;\n- goto err;\n- }\n- if (getfd !\u003d 1)\n- fcntl(a.fd, F_SETFD, getfd);\n- if (getfl \u0026 O_NONBLOCK)\n- (void)tls_socket_nonblocking(a.fd);\n- if (a.infofd !\u003d NULL)\n- *a.infofd \u003d infofds[0];\n- return 0;\n-\n- err:\n- if (fds[0] !\u003d -1)\n- close(fds[0]);\n- if (fds[1] !\u003d -1)\n- close(fds[1]);\n- if (infofds[0] !\u003d -1)\n- close(infofds[0]);\n- if (infofds[1] !\u003d -1)\n- close(infofds[1]);\n- return ret;\n-}\n-\n-/*****************************************************************************/\n-\n-static char errbuf[TLS_ERROR_BUFSIZ];\n-static size_t errbuf_i \u003d 0;\n-\n-static void tls_errflush(void *apparg)\n-{\n- if (errbuf_i \u003d\u003d 0)\n- return;\n-\n- assert(errbuf_i \u003c sizeof errbuf);\n- assert(errbuf[errbuf_i] \u003d\u003d 0);\n- if (errbuf_i \u003d\u003d sizeof errbuf - 1) {\n- /* make sure we have a newline, even if string has been truncated */\n- errbuf[errbuf_i - 1] \u003d '\u005cn';\n- }\n-\n- /*\n- * TLS_APP_ERRFLUSH may modify the string as needed, e.g. substitute\n- * other characters for \u005cn for convenience\n- */\n- TLS_APP_ERRFLUSH(tls_child_p, errbuf, errbuf_i, apparg);\n-\n- errbuf_i \u003d 0;\n-}\n-\n-static void tls_errprintf(int flush, void *apparg, const char *fmt, ...)\n-{\n- va_list args;\n- int r;\n-\n- if (errbuf_i \u003c sizeof errbuf - 1) {\n- size_t n;\n-\n- va_start(args, fmt);\n- n \u003d (sizeof errbuf) - errbuf_i;\n- r \u003d vsnprintf(errbuf + errbuf_i, n, fmt, args);\n- if (r \u003e\u003d n)\n- r \u003d n - 1;\n- if (r \u003e\u003d 0) {\n- errbuf_i +\u003d r;\n- } else {\n- errbuf_i \u003d sizeof errbuf - 1;\n- errbuf[errbuf_i] \u003d '\u005c0';\n- }\n- assert(errbuf_i \u003c sizeof errbuf);\n- assert(errbuf[errbuf_i] \u003d\u003d 0);\n- }\n-#ifndef TLS_CUMULATE_ERRORS\n- tls_errflush(apparg);\n-#else\n- if (flush)\n- tls_errflush(apparg);\n-#endif\n-}\n-\n-/*\n- * app_prefix.. are for additional information provided by caller. If OpenSSL\n- * error queue is empty, print default_text (\u0022???\u0022 if NULL).\n- */\n-static char *tls_openssl_errors(const char *app_prefix_1,\n- const char *app_prefix_2,\n- const char *default_text, void *apparg)\n-{\n- static char reasons[255];\n- size_t reasons_i;\n- unsigned long err;\n- const char *file;\n- int line;\n- const char *data;\n- int flags;\n- char *errstring;\n- int printed_something \u003d 0;\n-\n- reasons_i \u003d 0;\n-\n- assert(app_prefix_1 !\u003d NULL);\n- assert(app_prefix_2 !\u003d NULL);\n-\n- if (default_text \u003d\u003d NULL)\n- default_text \u003d \u0022?\u0022 \u0022?\u0022 \u0022?\u0022;\n-\n- while ((err \u003d ERR_get_error_line_data(\u0026file, \u0026line, \u0026data, \u0026flags)) !\u003d 0) {\n- if (reasons_i \u003c sizeof reasons) {\n- size_t n;\n- int r;\n-\n- n \u003d (sizeof reasons) - reasons_i;\n- r \u003d snprintf(reasons + reasons_i, n, \u0022%s%s\u0022,\n- (reasons_i \u003e 0 ? \u0022, \u0022 : \u0022\u0022),\n- ERR_reason_error_string(err));\n- if (r \u003e\u003d n)\n- r \u003d n - 1;\n- if (r \u003e\u003d 0) {\n- reasons_i +\u003d r;\n- } else {\n- reasons_i \u003d sizeof reasons;\n- }\n- assert(reasons_i \u003c\u003d sizeof reasons);\n- }\n-\n- errstring \u003d ERR_error_string(err, NULL);\n- assert(errstring !\u003d NULL);\n- tls_errprintf(0, apparg, \u0022OpenSSL error%s%s: %s:%s:%d:%s\u005cn\u0022,\n- app_prefix_1, app_prefix_2, errstring, file, line,\n- (flags \u0026 ERR_TXT_STRING) ? data : \u0022\u0022);\n- printed_something \u003d 1;\n- }\n-\n- if (!printed_something) {\n- assert(reasons_i \u003d\u003d 0);\n- snprintf(reasons, sizeof reasons, \u0022%s\u0022, default_text);\n- tls_errprintf(0, apparg, \u0022OpenSSL error%s%s: %s\u005cn\u0022, app_prefix_1,\n- app_prefix_2, default_text);\n- }\n-#ifdef TLS_CUMULATE_ERRORS\n- tls_errflush(apparg);\n-#endif\n- assert(errbuf_i \u003d\u003d 0);\n-\n- return reasons;\n-}\n-\n-/*****************************************************************************/\n-\n-static int tls_init_done \u003d 0;\n-\n-static int tls_init(void *apparg)\n-{\n- if (tls_init_done)\n- return 0;\n-\n- SSL_load_error_strings();\n- if (!SSL_library_init()) {\n- tls_errprintf(1, apparg, \u0022SSL_library_init failed.\u005cn\u0022);\n- return -1;\n- }\n- tls_init_done \u003d 1;\n- tls_rand_seed();\n- return 0;\n-}\n-\n-/*****************************************************************************/\n-\n-static void tls_rand_seed_uniquely(void)\n-{\n- struct {\n- pid_t pid;\n- time_t time;\n- void *stack;\n- } data;\n-\n- data.pid \u003d getpid();\n- data.time \u003d time(NULL);\n- data.stack \u003d (void *)\u0026data;\n-\n- RAND_seed((const void *)\u0026data, sizeof data);\n-}\n-\n-void tls_rand_seed(void)\n-{\n- struct {\n- struct utsname uname;\n- int uname_1;\n- int uname_2;\n- uid_t uid;\n- uid_t euid;\n- gid_t gid;\n- gid_t egid;\n- } data;\n-\n- data.uname_1 \u003d uname(\u0026data.uname);\n- data.uname_2 \u003d errno; /* Let's hope that uname fails randomly :-) */\n-\n- data.uid \u003d getuid();\n- data.euid \u003d geteuid();\n- data.gid \u003d getgid();\n- data.egid \u003d getegid();\n-\n- RAND_seed((const void *)\u0026data, sizeof data);\n- tls_rand_seed_uniquely();\n-}\n-\n-static int tls_rand_seeded_p \u003d 0;\n-\n-#define my_MIN_SEED_BYTES 256 /* struct stat can be larger than 128 */\n-int tls_rand_seed_from_file(const char *filename, size_t n, void *apparg)\n-{\n- /*\n- * Seed OpenSSL's random number generator from file. Try to read n bytes\n- * if n \u003e 0, whole file if n \u003d\u003d 0.\n- */\n-\n- int r;\n-\n- if (tls_init(apparg) \u003d\u003d -1)\n- return -1;\n- tls_rand_seed();\n-\n- r \u003d RAND_load_file(filename,\n- (n \u003e 0 \u0026\u0026 n \u003c LONG_MAX) ? (long)n : LONG_MAX);\n- /*\n- * r is the number of bytes filled into the random number generator,\n- * which are taken from \u0022stat(filename, ...)\u0022 in addition to the file\n- * contents.\n- */\n- assert(1 \u003c my_MIN_SEED_BYTES);\n- /*\n- * We need to detect at least those cases when the file does not exist at\n- * all. With current versions of OpenSSL, this should do it:\n- */\n- if (n \u003d\u003d 0)\n- n \u003d my_MIN_SEED_BYTES;\n- if (r \u003c n) {\n- tls_errprintf(1, apparg,\n- \u0022rand_seed_from_file: could not read %d bytes from %s.\u005cn\u0022,\n- n, filename);\n- return -1;\n- } else {\n- tls_rand_seeded_p \u003d 1;\n- return 0;\n- }\n-}\n-\n-void tls_rand_seed_from_memory(const void *buf, size_t n)\n-{\n- size_t i \u003d 0;\n-\n- while (i \u003c n) {\n- size_t rest \u003d n - i;\n- int chunk \u003d rest \u003c INT_MAX ? (int)rest : INT_MAX;\n- RAND_seed((const char *)buf + i, chunk);\n- i +\u003d chunk;\n- }\n- tls_rand_seeded_p \u003d 1;\n-}\n-\n-/*****************************************************************************/\n-\n-struct tls_x509_name_string {\n- char str[100];\n-};\n-\n-static void\n-tls_get_x509_subject_name_oneline(X509 *cert,\n- struct tls_x509_name_string *namestring)\n-{\n- X509_NAME *name;\n-\n- if (cert \u003d\u003d NULL) {\n- namestring-\u003estr[0] \u003d '\u005c0';\n- return;\n- }\n-\n- name \u003d X509_get_subject_name(cert); /* does not increment any reference\n- * counter */\n-\n- assert(sizeof namestring-\u003estr \u003e\u003d 4); /* \u0022?\u0022 or \u0022...\u0022, plus 0 */\n-\n- if (name \u003d\u003d NULL) {\n- namestring-\u003estr[0] \u003d '?';\n- namestring-\u003estr[1] \u003d 0;\n- } else {\n- size_t len;\n-\n- X509_NAME_oneline(name, namestring-\u003estr, sizeof namestring-\u003estr);\n- len \u003d strlen(namestring-\u003estr);\n- assert(namestring-\u003estr[len] \u003d\u003d 0);\n- assert(len \u003c sizeof namestring-\u003estr);\n-\n- if (len + 1 \u003d\u003d sizeof namestring-\u003estr) {\n- /*\n- * (Probably something was cut off.) Does not really work --\n- * X509_NAME_oneline truncates after name components, we cannot\n- * tell from the result whether anything is missing.\n- */\n-\n- assert(namestring-\u003estr[len] \u003d\u003d 0);\n- namestring-\u003estr[--len] \u003d '.';\n- namestring-\u003estr[--len] \u003d '.';\n- namestring-\u003estr[--len] \u003d '.';\n- }\n- }\n-}\n-\n-/*****************************************************************************/\n-\n-/* to hinder OpenSSL from asking for passphrases */\n-static int no_passphrase_callback(char *buf, int num, int w, void *arg)\n-{\n- return -1;\n-}\n-\n-#if OPENSSL_VERSION_NUMBER \u003e\u003d 0x00907000L\n-static int verify_dont_fail_cb(X509_STORE_CTX *c, void *unused_arg)\n-#else\n-static int verify_dont_fail_cb(X509_STORE_CTX *c)\n-#endif\n-{\n- int i;\n-\n- i \u003d X509_verify_cert(c); /* sets c-\u003eerror */\n-#if OPENSSL_VERSION_NUMBER \u003e\u003d 0x00905000L /* don't allow unverified\n- * certificates -- they could\n- * survive session reuse, but\n- * OpenSSL \u003c 0.9.5-dev does not\n- * preserve their verify_result */\n- if (i \u003d\u003d 0)\n- return 1;\n- else\n-#endif\n- return i;\n-}\n-\n-static DH *tls_dhe1024 \u003d NULL; /* generating these takes a while, so do it\n- * just once */\n-\n-void tls_set_dhe1024(int i, void *apparg)\n-{\n- DSA *dsaparams;\n- DH *dhparams;\n- const char *seed[] \u003d { \u0022;-) :-( :-) :-( \u0022,\n- \u0022;-) :-( :-) :-( \u0022,\n- \u0022Random String no. 12\u0022,\n- \u0022;-) :-( :-) :-( \u0022,\n- \u0022hackers have even mo\u0022, /* from jargon file */\n- };\n- unsigned char seedbuf[20];\n-\n- tls_init(apparg);\n- if (i \u003e\u003d 0) {\n- i %\u003d sizeof seed / sizeof seed[0];\n- assert(strlen(seed[i]) \u003d\u003d 20);\n- memcpy(seedbuf, seed[i], 20);\n- dsaparams \u003d\n- DSA_generate_parameters(1024, seedbuf, 20, NULL, NULL, 0, NULL);\n- } else {\n- /* random parameters (may take a while) */\n- dsaparams \u003d\n- DSA_generate_parameters(1024, NULL, 0, NULL, NULL, 0, NULL);\n- }\n-\n- if (dsaparams \u003d\u003d NULL) {\n- tls_openssl_errors(\u0022\u0022, \u0022\u0022, NULL, apparg);\n- return;\n- }\n- dhparams \u003d DSA_dup_DH(dsaparams);\n- DSA_free(dsaparams);\n- if (dhparams \u003d\u003d NULL) {\n- tls_openssl_errors(\u0022\u0022, \u0022\u0022, NULL, apparg);\n- return;\n- }\n- DH_free(tls_dhe1024);\n- tls_dhe1024 \u003d dhparams;\n-}\n-\n-struct tls_create_ctx_args tls_create_ctx_defaultargs(void)\n-{\n- struct tls_create_ctx_args ret;\n-\n- ret.client_p \u003d 0;\n- ret.certificate_file \u003d NULL;\n- ret.key_file \u003d NULL;\n- ret.ca_file \u003d NULL;\n- ret.verify_depth \u003d -1;\n- ret.fail_unless_verified \u003d 0;\n-\n- return ret;\n-}\n-\n-SSL_CTX *tls_create_ctx(struct tls_create_ctx_args a, void *apparg)\n-{\n- int r;\n- static long context_num \u003d 0;\n- SSL_CTX *ret;\n- const char *err_pref_1 \u003d \u0022\u0022, *err_pref_2 \u003d \u0022\u0022;\n-\n- if (tls_init(apparg) \u003d\u003d -1)\n- return NULL;\n-\n- ret \u003d\n- SSL_CTX_new((a.client_p ? TLS_client_method :\n- TLS_server_method) ());\n-\n- if (ret \u003d\u003d NULL)\n- goto err;\n-\n- SSL_CTX_set_default_passwd_cb(ret, no_passphrase_callback);\n- SSL_CTX_set_mode(ret, SSL_MODE_ENABLE_PARTIAL_WRITE);\n-\n- if ((a.certificate_file !\u003d NULL) || (a.key_file !\u003d NULL)) {\n- if (a.key_file \u003d\u003d NULL) {\n- tls_errprintf(1, apparg, \u0022Need a key file.\u005cn\u0022);\n- goto err_return;\n- }\n- if (a.certificate_file \u003d\u003d NULL) {\n- tls_errprintf(1, apparg, \u0022Need a certificate chain file.\u005cn\u0022);\n- goto err_return;\n- }\n-\n- if (!SSL_CTX_use_PrivateKey_file(ret, a.key_file, SSL_FILETYPE_PEM))\n- goto err;\n- if (!tls_rand_seeded_p) {\n- /*\n- * particularly paranoid people may not like this -- so provide\n- * your own random seeding before calling this\n- */\n- if (tls_rand_seed_from_file(a.key_file, 0, apparg) \u003d\u003d -1)\n- goto err_return;\n- }\n- if (!SSL_CTX_use_certificate_chain_file(ret, a.certificate_file))\n- goto err;\n- if (!SSL_CTX_check_private_key(ret)) {\n- tls_errprintf(1, apparg,\n- \u0022Private key \u005c\u0022%s\u005c\u0022 does not match certificate \u005c\u0022%s\u005c\u0022.\u005cn\u0022,\n- a.key_file, a.certificate_file);\n- goto err_peek;\n- }\n- }\n-\n- if ((a.ca_file !\u003d NULL) || (a.verify_depth \u003e 0)) {\n- context_num++;\n- r \u003d SSL_CTX_set_session_id_context(ret, (const void *)\u0026context_num,\n- (unsigned int)sizeof context_num);\n- if (!r)\n- goto err;\n-\n- SSL_CTX_set_verify(ret,\n- SSL_VERIFY_PEER | (a.fail_unless_verified ?\n- SSL_VERIFY_FAIL_IF_NO_PEER_CERT\n- : 0), 0);\n- if (!a.fail_unless_verified)\n- SSL_CTX_set_cert_verify_callback(ret, verify_dont_fail_cb, NULL);\n-\n- if (a.verify_depth \u003e 0)\n- SSL_CTX_set_verify_depth(ret, a.verify_depth);\n-\n- if (a.ca_file !\u003d NULL) {\n- /* does not report failure if file does not exist ... */\n- /* NULL argument means no CA-directory */\n- r \u003d SSL_CTX_load_verify_locations(ret, a.ca_file, NULL);\n- if (!r) {\n- err_pref_1 \u003d \u0022 while processing certificate file \u0022;\n- err_pref_2 \u003d a.ca_file;\n- goto err;\n- }\n-\n- if (!a.client_p) {\n- /*\n- * SSL_load_client_CA_file is a misnomer, it just creates a\n- * list of CNs.\n- */\n- SSL_CTX_set_client_CA_list(ret,\n- SSL_load_client_CA_file\n- (a.ca_file));\n- /*\n- * SSL_CTX_set_client_CA_list does not have a return value;\n- * it does not really need one, but make sure (we really test\n- * if SSL_load_client_CA_file worked)\n- */\n- if (SSL_CTX_get_client_CA_list(ret) \u003d\u003d NULL) {\n- tls_errprintf(1, apparg,\n- \u0022Could not set client CA list from \u005c\u0022%s\u005c\u0022.\u005cn\u0022,\n- a.ca_file);\n- goto err_peek;\n- }\n- }\n- }\n- }\n-\n- if (!a.client_p) {\n- if (tls_dhe1024 \u003d\u003d NULL) {\n- int i;\n-\n- if (RAND_bytes((unsigned char *)\u0026i, sizeof i) \u003c\u003d 0)\n- goto err_return;\n- /*\n- * make sure that i is non-negative -- pick one of the provided\n- * seeds\n- */\n- if (i \u003c 0)\n- i \u003d -i;\n- if (i \u003c 0)\n- i \u003d 0;\n- tls_set_dhe1024(i, apparg);\n- if (tls_dhe1024 \u003d\u003d NULL)\n- goto err_return;\n- }\n-\n- if (!SSL_CTX_set_tmp_dh(ret, tls_dhe1024))\n- goto err;\n-\n- /* avoid small subgroup attacks: */\n- SSL_CTX_set_options(ret, SSL_OP_SINGLE_DH_USE);\n- }\n-\n- return ret;\n-\n- err_peek:\n- if (!ERR_peek_error())\n- goto err_return;\n- err:\n- tls_openssl_errors(err_pref_1, err_pref_2, NULL, apparg);\n- err_return:\n- SSL_CTX_free(ret);\n- return NULL;\n-}\n-\n-/*****************************************************************************/\n-\n-static int tls_socket_nonblocking(int fd)\n-{\n- int v, r;\n-\n- v \u003d fcntl(fd, F_GETFL, 0);\n- if (v \u003d\u003d -1) {\n- if (errno \u003d\u003d EINVAL)\n- return 0; /* already shut down -- ignore */\n- return -1;\n- }\n- r \u003d fcntl(fd, F_SETFL, v | O_NONBLOCK);\n- if (r \u003d\u003d -1) {\n- if (errno \u003d\u003d EINVAL)\n- return 0; /* already shut down -- ignore */\n- return -1;\n- }\n- return 0;\n-}\n-\n-static int max(int a, int b)\n-{\n- return a \u003e b ? a : b;\n-}\n-\n-/* timeout, -1 means no timeout */\n-static void\n-tls_sockets_select(int read_select_1, int read_select_2, int write_select_1,\n- int write_select_2, int seconds)\n-{\n- int maxfd, n;\n- fd_set reads, writes;\n- struct timeval timeout;\n- struct timeval *timeout_p;\n-\n- assert(read_select_1 \u003e\u003d -1 \u0026\u0026 read_select_2 \u003e\u003d -1 \u0026\u0026 write_select_1 \u003e\u003d -1\n- \u0026\u0026 write_select_2 \u003e\u003d -1);\n- assert(read_select_1 \u003c FD_SETSIZE \u0026\u0026 read_select_2 \u003c FD_SETSIZE - 1\n- \u0026\u0026 write_select_1 \u003c FD_SETSIZE - 1\n- \u0026\u0026 write_select_2 \u003c FD_SETSIZE - 1);\n-\n- maxfd \u003d\n- max(max(read_select_1, read_select_2),\n- max(write_select_1, write_select_2));\n- assert(maxfd \u003e\u003d 0);\n-\n- FD_ZERO(\u0026reads);\n- FD_ZERO(\u0026writes);\n-\n- for (n \u003d 0; n \u003c 4; ++n) {\n- int i \u003d n % 2;\n- int w \u003d n \u003e\u003d 2;\n- /* loop over all (i, w) in {0,1}x{0,1} */\n- int fd;\n-\n- if (i \u003d\u003d 0 \u0026\u0026 w \u003d\u003d 0)\n- fd \u003d read_select_1;\n- else if (i \u003d\u003d 1 \u0026\u0026 w \u003d\u003d 0)\n- fd \u003d read_select_2;\n- else if (i \u003d\u003d 0 \u0026\u0026 w \u003d\u003d 1)\n- fd \u003d write_select_1;\n- else {\n- assert(i \u003d\u003d 1 \u0026\u0026 w \u003d\u003d 1);\n- fd \u003d write_select_2;\n- }\n-\n- if (fd \u003e\u003d 0) {\n- if (w \u003d\u003d 0)\n- FD_SET(fd, \u0026reads);\n- else /* w \u003d\u003d 1 */\n- FD_SET(fd, \u0026writes);\n- }\n- }\n-\n- if (seconds \u003e\u003d 0) {\n- timeout.tv_sec \u003d seconds;\n- timeout.tv_usec \u003d 0;\n- timeout_p \u003d \u0026timeout;\n- } else\n- timeout_p \u003d NULL;\n-\n- DEBUG_MSG2(\u0022select no.\u0022, ++tls_select_count);\n- select(maxfd + 1, \u0026reads, \u0026writes, (fd_set *) NULL, timeout_p);\n- DEBUG_MSG(\u0022cont.\u0022);\n-}\n-\n-/*****************************************************************************/\n-\n-#define TUNNELBUFSIZE (16*1024)\n-struct tunnelbuf {\n- char buf[TUNNELBUFSIZE];\n- size_t len;\n- size_t offset;\n-};\n-\n-static int tls_connect_attempt(SSL *, int *write_select, int *read_select,\n- int *closed, int *progress,\n- const char **err_pref);\n-\n-static int tls_accept_attempt(SSL *, int *write_select, int *read_select,\n- int *closed, int *progress,\n- const char **err_pref);\n-\n-static int tls_write_attempt(SSL *, struct tunnelbuf *, int *write_select,\n- int *read_select, int *closed, int *progress,\n- const char **err_pref);\n-\n-static int tls_read_attempt(SSL *, struct tunnelbuf *, int *write_select,\n- int *read_select, int *closed, int *progress,\n- const char **err_pref);\n-\n-static int write_attempt(int fd, struct tunnelbuf *, int *select, int *closed,\n- int *progress);\n-\n-static int read_attempt(int fd, struct tunnelbuf *, int *select, int *closed,\n- int *progress);\n-\n-static void write_info(SSL *ssl, int *info_fd)\n-{\n- if (*info_fd !\u003d -1) {\n- long v;\n- int v_ok;\n- struct tls_x509_name_string peer;\n- char infobuf[TLS_INFO_SIZE];\n- int r;\n-\n- DEBUG_MSG(\u0022write_info\u0022);\n- v \u003d SSL_get_verify_result(ssl);\n- v_ok \u003d (v \u003d\u003d X509_V_OK) ? 'A' : 'E'; /* Auth./Error */\n- {\n- X509 *peercert;\n-\n- peercert \u003d SSL_get_peer_certificate(ssl);\n- tls_get_x509_subject_name_oneline(peercert, \u0026peer);\n- X509_free(peercert);\n- }\n- if (peer.str[0] \u003d\u003d '\u005c0')\n- v_ok \u003d '0'; /* no cert at all */\n- else if (strchr(peer.str, '\u005cn')) {\n- /* should not happen, but make sure */\n- *strchr(peer.str, '\u005cn') \u003d '\u005c0';\n- }\n- r \u003d snprintf(infobuf, sizeof infobuf, \u0022%c:%s\u005cn%s\u005cn\u0022, v_ok,\n- X509_verify_cert_error_string(v), peer.str);\n- DEBUG_MSG2(\u0022snprintf\u0022, r);\n- if (r \u003d\u003d -1 || r \u003e\u003d sizeof infobuf)\n- r \u003d sizeof infobuf - 1;\n- write(*info_fd, infobuf, r);\n- close(*info_fd);\n- *info_fd \u003d -1;\n- }\n-}\n-\n-/* tls_proxy expects that all fds are closed after return */\n-static void\n-tls_proxy(int clear_fd, int tls_fd, int info_fd, SSL_CTX *ctx, int client_p)\n-{\n- struct tunnelbuf clear_to_tls, tls_to_clear;\n- SSL *ssl;\n- BIO *rbio, *wbio;\n- int closed, in_handshake;\n- const char *err_pref_1 \u003d \u0022\u0022, *err_pref_2 \u003d \u0022\u0022;\n- const char *err_def \u003d NULL;\n-\n- assert(clear_fd !\u003d -1);\n- assert(tls_fd !\u003d -1);\n- assert(clear_fd \u003c FD_SETSIZE);\n- assert(tls_fd \u003c FD_SETSIZE);\n- /* info_fd may be -1 */\n- assert(ctx !\u003d NULL);\n-\n- tls_rand_seed_uniquely();\n-\n- tls_socket_nonblocking(clear_fd);\n- DEBUG_MSG2(\u0022clear_fd\u0022, clear_fd);\n- tls_socket_nonblocking(tls_fd);\n- DEBUG_MSG2(\u0022tls_fd\u0022, tls_fd);\n-\n- ssl \u003d SSL_new(ctx);\n- if (ssl \u003d\u003d NULL)\n- goto err;\n- DEBUG_MSG(\u0022SSL_new\u0022);\n- if (!SSL_set_fd(ssl, tls_fd))\n- goto err;\n- rbio \u003d SSL_get_rbio(ssl);\n- wbio \u003d SSL_get_wbio(ssl); /* should be the same, but who cares */\n- assert(rbio !\u003d NULL);\n- assert(wbio !\u003d NULL);\n- if (client_p)\n- SSL_set_connect_state(ssl);\n- else\n- SSL_set_accept_state(ssl);\n-\n- closed \u003d 0;\n- in_handshake \u003d 1;\n- tls_to_clear.len \u003d 0;\n- tls_to_clear.offset \u003d 0;\n- clear_to_tls.len \u003d 0;\n- clear_to_tls.offset \u003d 0;\n-\n- err_def \u003d \u0022I/O error\u0022;\n-\n- /*\n- * loop finishes as soon as we detect that one side closed; when all\n- * (program and OS) buffers have enough space, the data from the last\n- * successful read in each direction is transferred before close\n- */\n- do {\n- int clear_read_select \u003d 0, clear_write_select \u003d 0,\n- tls_read_select \u003d 0, tls_write_select \u003d 0, progress \u003d 0;\n- int r;\n- uint64_t num_read \u003d BIO_number_read(rbio),\n- num_written \u003d BIO_number_written(wbio);\n-\n- DEBUG_MSG2(\u0022loop iteration\u0022, ++tls_loop_count);\n-\n- if (in_handshake) {\n- DEBUG_MSG(\u0022in_handshake\u0022);\n- if (client_p)\n- r \u003d tls_connect_attempt(ssl, \u0026tls_write_select,\n- \u0026tls_read_select, \u0026closed, \u0026progress,\n- \u0026err_pref_1);\n- else\n- r \u003d tls_accept_attempt(ssl, \u0026tls_write_select,\n- \u0026tls_read_select, \u0026closed, \u0026progress,\n- \u0026err_pref_1);\n- if (r !\u003d 0) {\n- write_info(ssl, \u0026info_fd);\n- goto err;\n- }\n- if (closed)\n- goto err_return;\n- if (!SSL_in_init(ssl)) {\n- in_handshake \u003d 0;\n- write_info(ssl, \u0026info_fd);\n- }\n- }\n-\n- if (clear_to_tls.len !\u003d 0 \u0026\u0026 !in_handshake) {\n- assert(!closed);\n-\n- r \u003d tls_write_attempt(ssl, \u0026clear_to_tls, \u0026tls_write_select,\n- \u0026tls_read_select, \u0026closed, \u0026progress,\n- \u0026err_pref_1);\n- if (r !\u003d 0)\n- goto err;\n- if (closed) {\n- assert(progress);\n- tls_to_clear.offset \u003d 0;\n- tls_to_clear.len \u003d 0;\n- }\n- }\n-\n- if (tls_to_clear.len !\u003d 0) {\n- assert(!closed);\n-\n- r \u003d write_attempt(clear_fd, \u0026tls_to_clear, \u0026clear_write_select,\n- \u0026closed, \u0026progress);\n- if (r !\u003d 0)\n- goto err_return;\n- if (closed) {\n- assert(progress);\n- clear_to_tls.offset \u003d 0;\n- clear_to_tls.len \u003d 0;\n- }\n- }\n-\n- if (!closed) {\n- if (clear_to_tls.offset + clear_to_tls.len \u003c\n- sizeof clear_to_tls.buf) {\n- r \u003d read_attempt(clear_fd, \u0026clear_to_tls, \u0026clear_read_select,\n- \u0026closed, \u0026progress);\n- if (r !\u003d 0)\n- goto err_return;\n- if (closed) {\n- r \u003d SSL_shutdown(ssl);\n- DEBUG_MSG2(\u0022SSL_shutdown\u0022, r);\n- }\n- }\n- }\n-\n- if (!closed \u0026\u0026 !in_handshake) {\n- if (tls_to_clear.offset + tls_to_clear.len \u003c\n- sizeof tls_to_clear.buf) {\n- r \u003d tls_read_attempt(ssl, \u0026tls_to_clear, \u0026tls_write_select,\n- \u0026tls_read_select, \u0026closed, \u0026progress,\n- \u0026err_pref_1);\n- if (r !\u003d 0)\n- goto err;\n- if (closed) {\n- r \u003d SSL_shutdown(ssl);\n- DEBUG_MSG2(\u0022SSL_shutdown\u0022, r);\n- }\n- }\n- }\n-\n- if (!progress) {\n- DEBUG_MSG(\u0022!progress?\u0022);\n- if (num_read !\u003d BIO_number_read(rbio)\n- || num_written !\u003d BIO_number_written(wbio))\n- progress \u003d 1;\n-\n- if (!progress) {\n- DEBUG_MSG(\u0022!progress\u0022);\n- assert(clear_read_select || tls_read_select\n- || clear_write_select || tls_write_select);\n- tls_sockets_select(clear_read_select ? clear_fd : -1,\n- tls_read_select ? tls_fd : -1,\n- clear_write_select ? clear_fd : -1,\n- tls_write_select ? tls_fd : -1, -1);\n- }\n- }\n- } while (!closed);\n- return;\n-\n- err:\n- tls_openssl_errors(err_pref_1, err_pref_2, err_def, tls_child_apparg);\n- err_return:\n- return;\n-}\n-\n-static int\n-tls_get_error(SSL *ssl, int r, int *write_select, int *read_select,\n- int *closed, int *progress)\n-{\n- int err \u003d SSL_get_error(ssl, r);\n-\n- if (err \u003d\u003d SSL_ERROR_NONE) {\n- assert(r \u003e 0);\n- *progress \u003d 1;\n- return 0;\n- }\n-\n- assert(r \u003c\u003d 0);\n-\n- switch (err) {\n- case SSL_ERROR_ZERO_RETURN:\n- assert(r \u003d\u003d 0);\n- *closed \u003d 1;\n- *progress \u003d 1;\n- return 0;\n-\n- case SSL_ERROR_WANT_WRITE:\n- *write_select \u003d 1;\n- return 0;\n-\n- case SSL_ERROR_WANT_READ:\n- *read_select \u003d 1;\n- return 0;\n- }\n-\n- return -1;\n-}\n-\n-static int\n-tls_connect_attempt(SSL *ssl, int *write_select, int *read_select,\n- int *closed, int *progress, const char **err_pref)\n-{\n- int n, r;\n-\n- DEBUG_MSG(\u0022tls_connect_attempt\u0022);\n- n \u003d SSL_connect(ssl);\n- DEBUG_MSG2(\u0022SSL_connect\u0022, n);\n- r \u003d tls_get_error(ssl, n, write_select, read_select, closed, progress);\n- if (r \u003d\u003d -1)\n- *err_pref \u003d \u0022 during SSL_connect\u0022;\n- return r;\n-}\n-\n-static int\n-tls_accept_attempt(SSL *ssl, int *write_select, int *read_select, int *closed,\n- int *progress, const char **err_pref)\n-{\n- int n, r;\n-\n- DEBUG_MSG(\u0022tls_accept_attempt\u0022);\n- n \u003d SSL_accept(ssl);\n- DEBUG_MSG2(\u0022SSL_accept\u0022, n);\n- r \u003d tls_get_error(ssl, n, write_select, read_select, closed, progress);\n- if (r \u003d\u003d -1)\n- *err_pref \u003d \u0022 during SSL_accept\u0022;\n- return r;\n-}\n-\n-static int\n-tls_write_attempt(SSL *ssl, struct tunnelbuf *buf, int *write_select,\n- int *read_select, int *closed, int *progress,\n- const char **err_pref)\n-{\n- int n, r;\n-\n- DEBUG_MSG(\u0022tls_write_attempt\u0022);\n- n \u003d SSL_write(ssl, buf-\u003ebuf + buf-\u003eoffset, buf-\u003elen);\n- DEBUG_MSG2(\u0022SSL_write\u0022, n);\n- r \u003d tls_get_error(ssl, n, write_select, read_select, closed, progress);\n- if (n \u003e 0) {\n- buf-\u003elen -\u003d n;\n- assert(buf-\u003elen \u003e\u003d 0);\n- if (buf-\u003elen \u003d\u003d 0)\n- buf-\u003eoffset \u003d 0;\n- else\n- buf-\u003eoffset +\u003d n;\n- }\n- if (r \u003d\u003d -1)\n- *err_pref \u003d \u0022 during SSL_write\u0022;\n- return r;\n-}\n-\n-static int\n-tls_read_attempt(SSL *ssl, struct tunnelbuf *buf, int *write_select,\n- int *read_select, int *closed, int *progress,\n- const char **err_pref)\n-{\n- int n, r;\n- size_t total;\n-\n- DEBUG_MSG(\u0022tls_read_attempt\u0022);\n- total \u003d buf-\u003eoffset + buf-\u003elen;\n- assert(total \u003c sizeof buf-\u003ebuf);\n- n \u003d SSL_read(ssl, buf-\u003ebuf + total, (sizeof buf-\u003ebuf) - total);\n- DEBUG_MSG2(\u0022SSL_read\u0022, n);\n- r \u003d tls_get_error(ssl, n, write_select, read_select, closed, progress);\n- if (n \u003e 0) {\n- buf-\u003elen +\u003d n;\n- assert(buf-\u003eoffset + buf-\u003elen \u003c\u003d sizeof buf-\u003ebuf);\n- }\n- if (r \u003d\u003d -1)\n- *err_pref \u003d \u0022 during SSL_read\u0022;\n- return r;\n-}\n-\n-static int get_error(int r, int *select, int *closed, int *progress)\n-{\n- if (r \u003e\u003d 0) {\n- *progress \u003d 1;\n- if (r \u003d\u003d 0)\n- *closed \u003d 1;\n- return 0;\n- } else {\n- assert(r \u003d\u003d -1);\n- if (errno \u003d\u003d EAGAIN || errno \u003d\u003d EWOULDBLOCK) {\n- *select \u003d 1;\n- return 0;\n- } else if (errno \u003d\u003d EPIPE) {\n- *progress \u003d 1;\n- *closed \u003d 1;\n- return 0;\n- } else\n- return -1;\n- }\n-}\n-\n-static int write_attempt(int fd, struct tunnelbuf *buf, int *select,\n- int *closed, int *progress)\n-{\n- int n, r;\n-\n- DEBUG_MSG(\u0022write_attempt\u0022);\n- n \u003d write(fd, buf-\u003ebuf + buf-\u003eoffset, buf-\u003elen);\n- DEBUG_MSG2(\u0022write\u0022, n);\n- r \u003d get_error(n, select, closed, progress);\n- if (n \u003e 0) {\n- buf-\u003elen -\u003d n;\n- assert(buf-\u003elen \u003e\u003d 0);\n- if (buf-\u003elen \u003d\u003d 0)\n- buf-\u003eoffset \u003d 0;\n- else\n- buf-\u003eoffset +\u003d n;\n- }\n- if (r \u003d\u003d -1)\n- tls_errprintf(1, tls_child_apparg, \u0022write error: %s\u005cn\u0022,\n- strerror(errno));\n- return r;\n-}\n-\n-static int\n-read_attempt(int fd, struct tunnelbuf *buf, int *select, int *closed,\n- int *progress)\n-{\n- int n, r;\n- size_t total;\n-\n- DEBUG_MSG(\u0022read_attempt\u0022);\n- total \u003d buf-\u003eoffset + buf-\u003elen;\n- assert(total \u003c sizeof buf-\u003ebuf);\n- n \u003d read(fd, buf-\u003ebuf + total, (sizeof buf-\u003ebuf) - total);\n- DEBUG_MSG2(\u0022read\u0022, n);\n- r \u003d get_error(n, select, closed, progress);\n- if (n \u003e 0) {\n- buf-\u003elen +\u003d n;\n- assert(buf-\u003eoffset + buf-\u003elen \u003c\u003d sizeof buf-\u003ebuf);\n- }\n- if (r \u003d\u003d -1)\n- tls_errprintf(1, tls_child_apparg, \u0022read error: %s\u005cn\u0022,\n- strerror(errno));\n- return r;\n-}\ndiff --git a/demos/easy_tls/easy-tls.h b/demos/easy_tls/easy-tls.h\ndeleted file mode 100644\nindex 3ec8d63..0000000\n--- a/demos/easy_tls/easy-tls.h\n+++ /dev/null\n@@ -1,59 +0,0 @@\n-/* */\n-/*-\n- * easy-tls.h -- generic TLS proxy.\n- * $Id: easy-tls.h,v 1.1 2001/09/17 19:06:59 bodo Exp $\n- */\n-/*\n- * (c) Copyright 1999 Bodo Moeller. All rights reserved.\n- */\n-\n-#ifndef HEADER_TLS_H\n-# define HEADER_TLS_H\n-\n-# ifndef HEADER_SSL_H\n-typedef struct ssl_ctx_st SSL_CTX;\n-# endif\n-\n-# define TLS_INFO_SIZE 512 /* max. # of bytes written to infofd */\n-\n-void tls_set_dhe1024(int i, void *apparg);\n-/*\n- * Generate DHE parameters: i \u003e\u003d 0 deterministic (i selects seed), i \u003c 0\n- * random (may take a while). tls_create_ctx calls this with random\n- * non-negative i if the application has never called it.\n- */\n-\n-void tls_rand_seed(void);\n-int tls_rand_seed_from_file(const char *filename, size_t n, void *apparg);\n-void tls_rand_seed_from_memory(const void *buf, size_t n);\n-\n-struct tls_create_ctx_args {\n- int client_p;\n- const char *certificate_file;\n- const char *key_file;\n- const char *ca_file;\n- int verify_depth;\n- int fail_unless_verified;\n-};\n-struct tls_create_ctx_args tls_create_ctx_defaultargs(void);\n-/*\n- * struct tls_create_ctx_args is similar to a conventional argument list, but\n- * it can provide default values and allows for future extension.\n- */\n-SSL_CTX *tls_create_ctx(struct tls_create_ctx_args, void *apparg);\n-\n-struct tls_start_proxy_args {\n- int fd;\n- int client_p;\n- SSL_CTX *ctx;\n- pid_t *pid;\n- int *infofd;\n-};\n-struct tls_start_proxy_args tls_start_proxy_defaultargs(void);\n-/*\n- * tls_start_proxy return value *MUST* be checked! 0 means ok, otherwise\n- * we've probably run out of some resources.\n- */\n-int tls_start_proxy(struct tls_start_proxy_args, void *apparg);\n-\n-#endif\ndiff --git a/demos/easy_tls/test.c b/demos/easy_tls/test.c\ndeleted file mode 100644\nindex 713da09..0000000\n--- a/demos/easy_tls/test.c\n+++ /dev/null\n@@ -1,247 +0,0 @@\n-/* $Id: test.c,v 1.1 2001/09/17 19:06:59 bodo Exp $ */\n-\n-#define L_PORT 9999\n-#define C_PORT 443\n-\n-#include \u003carpa/inet.h\u003e\n-#include \u003cassert.h\u003e\n-#include \u003cerrno.h\u003e\n-#include \u003cfcntl.h\u003e\n-#include \u003cnetinet/in.h\u003e\n-#include \u003cnetinet/tcp.h\u003e\n-#include \u003cstdlib.h\u003e\n-#include \u003cstdio.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u003csys/select.h\u003e\n-#include \u003csys/socket.h\u003e\n-#include \u003cunistd.h\u003e\n-\n-#include \u0022test.h\u0022\n-#include \u0022easy-tls.h\u0022\n-\n-void test_process_init(int fd, int client_p, void *apparg)\n-{\n- fprintf(stderr,\n- \u0022test_process_init(fd \u003d %d, client_p \u003d %d, apparg \u003d %p)\u005cn\u0022, fd,\n- client_p, apparg);\n-}\n-\n-void test_errflush(int child_p, char *errbuf, size_t num, void *apparg)\n-{\n- fputs(errbuf, stderr);\n-}\n-\n-int main(int argc, char *argv[])\n-{\n- int s, fd, r;\n- FILE *conn_in;\n- FILE *conn_out;\n- char buf[256];\n- SSL_CTX *ctx;\n- int client_p \u003d 0;\n- int port;\n- int tls \u003d 0;\n- char infobuf[TLS_INFO_SIZE + 1];\n-\n- if (argc \u003e 1 \u0026\u0026 argv[1][0] \u003d\u003d '-') {\n- fputs(\u0022Usage: test [port] -- server\u005cn\u0022\n- \u0022 test num.num.num.num [port] -- client\u005cn\u0022, stderr);\n- exit(1);\n- }\n-\n- if (argc \u003e 1) {\n- if (strchr(argv[1], '.')) {\n- client_p \u003d 1;\n- }\n- }\n-\n- fputs(client_p ? \u0022Client\u005cn\u0022 : \u0022Server\u005cn\u0022, stderr);\n-\n- {\n- struct tls_create_ctx_args a \u003d tls_create_ctx_defaultargs();\n- a.client_p \u003d client_p;\n- a.certificate_file \u003d \u0022cert.pem\u0022;\n- a.key_file \u003d \u0022cert.pem\u0022;\n- a.ca_file \u003d \u0022cacerts.pem\u0022;\n-\n- ctx \u003d tls_create_ctx(a, NULL);\n- if (ctx \u003d\u003d NULL)\n- exit(1);\n- }\n-\n- s \u003d socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\n- if (s \u003d\u003d -1) {\n- perror(\u0022socket\u0022);\n- exit(1);\n- }\n-\n- if (client_p) {\n- struct sockaddr_in addr;\n- size_t addr_len \u003d sizeof addr;\n-\n- addr.sin_family \u003d AF_INET;\n- assert(argc \u003e 1);\n- if (argc \u003e 2)\n- sscanf(argv[2], \u0022%d\u0022, \u0026port);\n- else\n- port \u003d C_PORT;\n- addr.sin_port \u003d htons(port);\n- addr.sin_addr.s_addr \u003d inet_addr(argv[1]);\n-\n- r \u003d connect(s, \u0026addr, addr_len);\n- if (r !\u003d 0) {\n- perror(\u0022connect\u0022);\n- exit(1);\n- }\n- fd \u003d s;\n- fprintf(stderr, \u0022Connect (fd \u003d %d).\u005cn\u0022, fd);\n- } else {\n- /* server */\n- {\n- int i \u003d 1;\n-\n- r \u003d setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *)\u0026i, sizeof i);\n- if (r \u003d\u003d -1) {\n- perror(\u0022setsockopt\u0022);\n- exit(1);\n- }\n- }\n-\n- {\n- struct sockaddr_in addr;\n- size_t addr_len \u003d sizeof addr;\n-\n- if (argc \u003e 1)\n- sscanf(argv[1], \u0022%d\u0022, \u0026port);\n- else\n- port \u003d L_PORT;\n- addr.sin_family \u003d AF_INET;\n- addr.sin_port \u003d htons(port);\n- addr.sin_addr.s_addr \u003d INADDR_ANY;\n-\n- r \u003d bind(s, \u0026addr, addr_len);\n- if (r !\u003d 0) {\n- perror(\u0022bind\u0022);\n- exit(1);\n- }\n- }\n-\n- r \u003d listen(s, 1);\n- if (r \u003d\u003d -1) {\n- perror(\u0022listen\u0022);\n- exit(1);\n- }\n-\n- fprintf(stderr, \u0022Listening at port %i.\u005cn\u0022, port);\n-\n- fd \u003d accept(s, NULL, 0);\n- if (fd \u003d\u003d -1) {\n- perror(\u0022accept\u0022);\n- exit(1);\n- }\n-\n- fprintf(stderr, \u0022Accept (fd \u003d %d).\u005cn\u0022, fd);\n- }\n-\n- conn_in \u003d fdopen(fd, \u0022r\u0022);\n- if (conn_in \u003d\u003d NULL) {\n- perror(\u0022fdopen\u0022);\n- exit(1);\n- }\n- conn_out \u003d fdopen(fd, \u0022w\u0022);\n- if (conn_out \u003d\u003d NULL) {\n- perror(\u0022fdopen\u0022);\n- exit(1);\n- }\n-\n- setvbuf(conn_in, NULL, _IOLBF, 256);\n- setvbuf(conn_out, NULL, _IOLBF, 256);\n-\n- while (fgets(buf, sizeof buf, stdin) !\u003d NULL) {\n- if (buf[0] \u003d\u003d 'W') {\n- fprintf(conn_out, \u0022%.*s\u005cr\u005cn\u0022, (int)(strlen(buf + 1) - 1),\n- buf + 1);\n- fprintf(stderr, \u0022\u003e\u003e\u003e %.*s\u005cn\u0022, (int)(strlen(buf + 1) - 1),\n- buf + 1);\n- } else if (buf[0] \u003d\u003d 'C') {\n- fprintf(stderr, \u0022Closing.\u005cn\u0022);\n- fclose(conn_in);\n- fclose(conn_out);\n- exit(0);\n- } else if (buf[0] \u003d\u003d 'R') {\n- int lines \u003d 0;\n-\n- sscanf(buf + 1, \u0022%d\u0022, \u0026lines);\n- do {\n- if (fgets(buf, sizeof buf, conn_in) \u003d\u003d NULL) {\n- if (ferror(conn_in)) {\n- fprintf(stderr, \u0022ERROR\u005cn\u0022);\n- exit(1);\n- }\n- fprintf(stderr, \u0022CLOSED\u005cn\u0022);\n- return 0;\n- }\n- fprintf(stderr, \u0022\u003c\u003c\u003c %s\u0022, buf);\n- } while (--lines \u003e 0);\n- } else if (buf[0] \u003d\u003d 'T') {\n- int infofd;\n-\n- tls++;\n- {\n- struct tls_start_proxy_args a \u003d tls_start_proxy_defaultargs();\n- a.fd \u003d fd;\n- a.client_p \u003d client_p;\n- a.ctx \u003d ctx;\n- a.infofd \u003d \u0026infofd;\n- r \u003d tls_start_proxy(a, NULL);\n- }\n- assert(r !\u003d 1);\n- if (r !\u003d 0) {\n- fprintf(stderr, \u0022tls_start_proxy failed: %d\u005cn\u0022, r);\n- switch (r) {\n- case -1:\n- fputs(\u0022socketpair\u0022, stderr);\n- break;\n- case 2:\n- fputs(\u0022FD_SETSIZE exceeded\u0022, stderr);\n- break;\n- case -3:\n- fputs(\u0022pipe\u0022, stderr);\n- break;\n- case -4:\n- fputs(\u0022fork\u0022, stderr);\n- break;\n- case -5:\n- fputs(\u0022dup2\u0022, stderr);\n- break;\n- default:\n- fputs(\u0022?\u0022, stderr);\n- }\n- if (r \u003c 0)\n- perror(\u0022\u0022);\n- else\n- fputc('\u005cn', stderr);\n- exit(1);\n- }\n-\n- r \u003d read(infofd, infobuf, sizeof infobuf - 1);\n- if (r \u003e 0) {\n- const char *info \u003d infobuf;\n- const char *eol;\n-\n- infobuf[r] \u003d '\u005c0';\n- while ((eol \u003d strchr(info, '\u005cn')) !\u003d NULL) {\n- fprintf(stderr, \u0022+++ `%.*s'\u005cn\u0022, eol - info, info);\n- info \u003d eol + 1;\n- }\n- close(infofd);\n- }\n- } else {\n- fprintf(stderr, \u0022W... write line to network\u005cn\u0022\n- \u0022R[n] read line (n lines) from network\u005cn\u0022\n- \u0022C close\u005cn\u0022\n- \u0022T start %sTLS proxy\u005cn\u0022, tls ? \u0022another \u0022 : \u0022\u0022);\n- }\n- }\n- return 0;\n-}\ndiff --git a/demos/easy_tls/test.h b/demos/easy_tls/test.h\ndeleted file mode 100644\nindex b30a605..0000000\n--- a/demos/easy_tls/test.h\n+++ /dev/null\n@@ -1,9 +0,0 @@\n-/* $Id: test.h,v 1.1 2001/09/17 19:07:00 bodo Exp $ */\n-\n-void test_process_init(int fd, int client_p, void *apparg);\n-#define TLS_APP_PROCESS_INIT test_process_init\n-\n-#undef TLS_CUMULATE_ERRORS\n-\n-void test_errflush(int child_p, char *errbuf, size_t num, void *apparg);\n-#define TLS_APP_ERRFLUSH test_errflush\ndiff --git a/demos/engines/cluster_labs/Makefile.in b/demos/engines/cluster_labs/Makefile.in\ndeleted file mode 100644\nindex af84275..0000000\n--- a/demos/engines/cluster_labs/Makefile.in\n+++ /dev/null\n@@ -1,93 +0,0 @@\n-LIBNAME\u003d\tlibclabs\n-SRC\u003d\t\thw_cluster_labs.c\n-OBJ\u003d\t\thw_cluster_labs.o\n-HEADER\u003d\t\thw_cluster_labs.h\n-\n-CC\u003d\t\tgcc\n-PIC\u003d\t\t-fPIC\n-CFLAGS\u003d\t\t-g -I../../../include $(PIC) -DENGINE_DYNAMIC_SUPPORT -DFLAT_INC\n-AR\u003d\t\tar r\n-RANLIB\u003d\t\tranlib\n-\n-LIB\u003d\t\t$(LIBNAME).a\n-SHLIB\u003d\t\t$(LIBNAME).so\n-\n-all:\n-\t\t@echo 'Please choose a system to build on:'\n-\t\t@echo ''\n-\t\t@echo 'tru64: Tru64 Unix, Digital Unix, Digital OSF/1'\n-\t\t@echo 'solaris: Solaris'\n-\t\t@echo 'irix: IRIX'\n-\t\t@echo 'hpux32: 32-bit HP/UX'\n-\t\t@echo 'hpux64: 64-bit HP/UX'\n-\t\t@echo 'aix: AIX'\n-\t\t@echo 'gnu: Generic GNU-based system (gcc and GNU ld)'\n-\t\t@echo ''\n-\n-generate:\n-\t\tperl ../../../util/mkerr.pl -conf hw_cluster_labs.ec \u005c\n-\t\t\t-nostatic -staticloader -write hw_cluster_labs.c\n-\n-gnu:\t\t$(SHLIB).gnu\n-tru64:\t\t$(SHLIB).tru64\n-solaris:\t$(SHLIB).solaris\n-irix:\t\t$(SHLIB).irix\n-hpux32:\t\t$(SHLIB).hpux32\n-hpux64:\t\t$(SHLIB).hpux64\n-aix:\t\t$(SHLIB).aix\n-\n-$(LIB):\t\t$(OBJ)\n-\t\t$(AR) $(LIB) $(OBJ)\n-\t\t- $(RANLIB) $(LIB)\n-\n-LINK_SO\u003d\t\u005c\n- ld -r -o $(LIBNAME).o $$ALLSYMSFLAGS $(LIB) \u0026\u0026 \u005c\n- (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' \u003e $(LIBNAME).exp; \u005c\n- $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc)\n-\n-$(SHLIB).gnu:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'--whole-archive' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname\u003d$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).gnu\n-$(SHLIB).tru64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).tru64\n-$(SHLIB).solaris:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-z allextract' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).solaris\n-$(SHLIB).irix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname,$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).irix\n-$(SHLIB).hpux32:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-Fl' \u005c\n-\t\tSHAREDFLAGS\u003d'+vnocompatwarnings -b -z +s +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux32\n-$(SHLIB).hpux64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'+forceload' \u005c\n-\t\tSHAREDFLAGS\u003d'-b -z +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux64\n-$(SHLIB).aix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-bnogc' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -bE:$(LIBNAME).exp -bM:SRE' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).aix\n-\n-depend:\n-\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/engines/cluster_labs/cluster_labs.h b/demos/engines/cluster_labs/cluster_labs.h\ndeleted file mode 100644\nindex d024d91..0000000\n--- a/demos/engines/cluster_labs/cluster_labs.h\n+++ /dev/null\n@@ -1,33 +0,0 @@\n-typedef int cl_engine_init(void);\n-typedef int cl_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *cgx);\n-typedef int cl_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *q, const BIGNUM *dmp1,\n- const BIGNUM *dmq1, const BIGNUM *iqmp,\n- BN_CTX *ctx);\n-typedef int cl_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);\n-typedef int cl_rsa_pub_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-typedef int cl_rsa_pub_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-typedef int cl_rsa_priv_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-typedef int cl_rsa_priv_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-typedef int cl_rand_bytes(unsigned char *buf, int num);\n-typedef DSA_SIG *cl_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);\n-typedef int cl_dsa_verify(const unsigned char *dgst, int dgst_len,\n- DSA_SIG *sig, DSA *dsa);\n-\n-static const char *CLUSTER_LABS_LIB_NAME \u003d \u0022cluster_labs\u0022;\n-static const char *CLUSTER_LABS_F1 \u003d \u0022hw_engine_init\u0022;\n-static const char *CLUSTER_LABS_F2 \u003d \u0022hw_mod_exp\u0022;\n-static const char *CLUSTER_LABS_F3 \u003d \u0022hw_mod_exp_crt\u0022;\n-static const char *CLUSTER_LABS_F4 \u003d \u0022hw_rsa_mod_exp\u0022;\n-static const char *CLUSTER_LABS_F5 \u003d \u0022hw_rsa_priv_enc\u0022;\n-static const char *CLUSTER_LABS_F6 \u003d \u0022hw_rsa_priv_dec\u0022;\n-static const char *CLUSTER_LABS_F7 \u003d \u0022hw_rsa_pub_enc\u0022;\n-static const char *CLUSTER_LABS_F8 \u003d \u0022hw_rsa_pub_dec\u0022;\n-static const char *CLUSTER_LABS_F20 \u003d \u0022hw_rand_bytes\u0022;\n-static const char *CLUSTER_LABS_F30 \u003d \u0022hw_dsa_sign\u0022;\n-static const char *CLUSTER_LABS_F31 \u003d \u0022hw_dsa_verify\u0022;\ndiff --git a/demos/engines/cluster_labs/hw_cluster_labs.c b/demos/engines/cluster_labs/hw_cluster_labs.c\ndeleted file mode 100644\nindex 8353dd9..0000000\n--- a/demos/engines/cluster_labs/hw_cluster_labs.c\n+++ /dev/null\n@@ -1,684 +0,0 @@\n-/*\n- * Written by Jan Tschirschwitz (jan.tschirschwitz@cluster-labs.com for the\n- * OpenSSL project 2000.\n- */\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * licensing@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-#define MSC_VER /* only used cryptic.h */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/dso.h\u003e\n-#include \u003copenssl/des.h\u003e\n-#include \u003copenssl/engine.h\u003e\n-\n-#ifndef NO_HW\n-# ifndef NO_HW_CLUSTER_LABS\n-\n-# ifdef FLAT_INC\n-# include \u0022cluster_labs.h\u0022\n-# else\n-# include \u0022vendor_defns/cluster_labs.h\u0022\n-# endif\n-\n-# define CL_LIB_NAME \u0022cluster_labs engine\u0022\n-# include \u0022hw_cluster_labs_err.c\u0022\n-\n-static int cluster_labs_destroy(ENGINE *e);\n-static int cluster_labs_init(ENGINE *e);\n-static int cluster_labs_finish(ENGINE *e);\n-static int cluster_labs_ctrl(ENGINE *e, int cmd, long i, void *p,\n- void (*f) ());\n-\n-/* BIGNUM stuff */\n-/* This function is aliased to mod_exp (with the mont stuff dropped). */\n-static int cluster_labs_mod_exp_mont(BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-\n-/* RSA stuff */\n-# ifndef OPENSSL_NO_RSA\n-static int cluster_labs_rsa_pub_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int cluster_labs_rsa_pub_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int cluster_labs_rsa_priv_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa,\n- int padding);\n-static int cluster_labs_rsa_priv_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa,\n- int padding);\n-static int cluster_labs_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);\n-# endif\n-\n-/* DSA stuff */\n-# ifndef OPENSSL_NO_DSA\n-static DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen,\n- DSA *dsa);\n-static int cluster_labs_dsa_verify(const unsigned char *dgst, int dgst_len,\n- DSA_SIG *sig, DSA *dsa);\n-static int cluster_labs_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,\n- BIGNUM *p1, BIGNUM *a2, BIGNUM *p2,\n- BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *in_mont);\n-static int cluster_labs_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-# endif\n-\n-/* DH stuff */\n-# ifndef OPENSSL_NO_DH\n-/* This function is alised to mod_exp (with the DH and mont dropped). */\n-static int cluster_labs_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-# endif\n-\n-/* RANDOM stuff */\n-static int cluster_labs_rand_bytes(unsigned char *buf, int num);\n-\n-/* The definitions for control commands specific to this engine */\n-# define CLUSTER_LABS_CMD_SO_PATH ENGINE_CMD_BASE\n-static const ENGINE_CMD_DEFN cluster_labs_cmd_defns[] \u003d {\n- {CLUSTER_LABS_CMD_SO_PATH,\n- \u0022SO_PATH\u0022,\n- \u0022Specifies the path to the 'cluster labs' shared library\u0022,\n- ENGINE_CMD_FLAG_STRING},\n- {0, NULL, NULL, 0}\n-};\n-\n-/* Our internal RSA_METHOD that we provide pointers to */\n-# ifndef OPENSSL_NO_RSA\n-static RSA_METHOD cluster_labs_rsa \u003d {\n- \u0022Cluster Labs RSA method\u0022,\n- cluster_labs_rsa_pub_enc, /* rsa_pub_enc */\n- cluster_labs_rsa_pub_dec, /* rsa_pub_dec */\n- cluster_labs_rsa_priv_enc, /* rsa_priv_enc */\n- cluster_labs_rsa_priv_dec, /* rsa_priv_dec */\n- cluster_labs_rsa_mod_exp, /* rsa_mod_exp */\n- cluster_labs_mod_exp_mont, /* bn_mod_exp */\n- NULL, /* init */\n- NULL, /* finish */\n- 0, /* flags */\n- NULL, /* apps_data */\n- NULL, /* rsa_sign */\n- NULL /* rsa_verify */\n-};\n-# endif\n-\n-/* Our internal DSA_METHOD that we provide pointers to */\n-# ifndef OPENSSL_NO_DSA\n-static DSA_METHOD cluster_labs_dsa \u003d {\n- \u0022Cluster Labs DSA method\u0022,\n- cluster_labs_dsa_sign, /* dsa_do_sign */\n- NULL, /* dsa_sign_setup */\n- cluster_labs_dsa_verify, /* dsa_do_verify */\n- cluster_labs_dsa_mod_exp, /* dsa_mod_exp */\n- cluster_labs_mod_exp_dsa, /* bn_mod_exp */\n- NULL, /* init */\n- NULL, /* finish */\n- 0, /* flags */\n- NULL /* app_data */\n-};\n-# endif\n-\n-/* Our internal DH_METHOD that we provide pointers to */\n-# ifndef OPENSSL_NO_DH\n-static DH_METHOD cluster_labs_dh \u003d {\n- \u0022Cluster Labs DH method\u0022,\n- NULL, /* generate key */\n- NULL, /* compute key */\n- cluster_labs_mod_exp_dh, /* bn_mod_exp */\n- NULL, /* init */\n- NULL, /* finish */\n- 0, /* flags */\n- NULL /* app_data */\n-};\n-# endif\n-\n-static RAND_METHOD cluster_labs_rand \u003d {\n- /* \u0022Cluster Labs RAND method\u0022, */\n- NULL, /* seed */\n- cluster_labs_rand_bytes, /* bytes */\n- NULL, /* cleanup */\n- NULL, /* add */\n- cluster_labs_rand_bytes, /* pseudorand */\n- NULL, /* status */\n-};\n-\n-static const char *engine_cluster_labs_id \u003d \u0022cluster_labs\u0022;\n-static const char *engine_cluster_labs_name \u003d\n- \u0022Cluster Labs hardware engine support\u0022;\n-\n-/* engine implementation */\n-/* ---------------------*/\n-static int bind_helper(ENGINE *e)\n-{\n-\n- if (!ENGINE_set_id(e, engine_cluster_labs_id) ||\n- !ENGINE_set_name(e, engine_cluster_labs_name) ||\n-# ifndef OPENSSL_NO_RSA\n- !ENGINE_set_RSA(e, \u0026cluster_labs_rsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DSA\n- !ENGINE_set_DSA(e, \u0026cluster_labs_dsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DH\n- !ENGINE_set_DH(e, \u0026cluster_labs_dh) ||\n-# endif\n- !ENGINE_set_RAND(e, \u0026cluster_labs_rand) ||\n- !ENGINE_set_destroy_function(e, cluster_labs_destroy) ||\n- !ENGINE_set_init_function(e, cluster_labs_init) ||\n- !ENGINE_set_finish_function(e, cluster_labs_finish) ||\n- !ENGINE_set_ctrl_function(e, cluster_labs_ctrl) ||\n- !ENGINE_set_cmd_defns(e, cluster_labs_cmd_defns))\n- return 0;\n- /* Ensure the error handling is set up */\n- ERR_load_CL_strings();\n- return 1;\n-}\n-\n-# ifndef ENGINE_DYNAMIC_SUPPORT\n-static ENGINE *engine_cluster_labs(void)\n-{\n- ENGINE *ret \u003d ENGINE_new();\n-\n- if (!ret)\n- return NULL;\n- if (!bind_helper(ret)) {\n- ENGINE_free(ret);\n- return NULL;\n- }\n- return ret;\n-}\n-\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static\n-# endif\n-void ENGINE_load_cluster_labs(void)\n-{\n-\n- ENGINE *cluster_labs \u003d engine_cluster_labs();\n-\n- if (!cluster_labs)\n- return;\n- ENGINE_add(cluster_labs);\n- ENGINE_free(cluster_labs);\n- ERR_clear_error();\n-}\n-# endif /* !ENGINE_DYNAMIC_SUPPORT */\n-\n-static int cluster_labs_destroy(ENGINE *e)\n-{\n-\n- ERR_unload_CL_strings();\n- return 1;\n-}\n-\n-/*\n- * This is a process-global DSO handle used for loading and unloading the\n- * Cluster Labs library. NB: This is only set (or unset) during an init() or\n- * finish() call (reference counts permitting) and they're operating with\n- * global locks, so this should be thread-safe implicitly.\n- */\n-static DSO *cluster_labs_dso \u003d NULL;\n-\n-/*\n- * These are the function pointers that are (un)set when the library has\n- * successfully (un)loaded.\n- */\n-static cl_engine_init *p_cl_engine_init \u003d NULL;\n-static cl_mod_exp *p_cl_mod_exp \u003d NULL;\n-static cl_mod_exp_crt *p_cl_mod_exp_crt \u003d NULL;\n-static cl_rsa_mod_exp *p_cl_rsa_mod_exp \u003d NULL;\n-static cl_rsa_priv_enc *p_cl_rsa_priv_enc \u003d NULL;\n-static cl_rsa_priv_dec *p_cl_rsa_priv_dec \u003d NULL;\n-static cl_rsa_pub_enc *p_cl_rsa_pub_enc \u003d NULL;\n-static cl_rsa_pub_dec *p_cl_rsa_pub_dec \u003d NULL;\n-static cl_rand_bytes *p_cl_rand_bytes \u003d NULL;\n-static cl_dsa_sign *p_cl_dsa_sign \u003d NULL;\n-static cl_dsa_verify *p_cl_dsa_verify \u003d NULL;\n-\n-int cluster_labs_init(ENGINE *e)\n-{\n-\n- cl_engine_init *p1;\n- cl_mod_exp *p2;\n- cl_mod_exp_crt *p3;\n- cl_rsa_mod_exp *p4;\n- cl_rsa_priv_enc *p5;\n- cl_rsa_priv_dec *p6;\n- cl_rsa_pub_enc *p7;\n- cl_rsa_pub_dec *p8;\n- cl_rand_bytes *p20;\n- cl_dsa_sign *p30;\n- cl_dsa_verify *p31;\n-\n- /* engine already loaded */\n- if (cluster_labs_dso !\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_ALREADY_LOADED);\n- goto err;\n- }\n- /* try to load engine */\n- cluster_labs_dso \u003d DSO_load(NULL, CLUSTER_LABS_LIB_NAME, NULL, 0);\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);\n- goto err;\n- }\n- /* bind functions */\n-#define BINDIT(t, name) (t *)DSO_bind_func(cluster_labs_dso, name)\n- if ((p1 \u003d (cl_engine_init, CLUSTER_LABS_F1)) \u003d\u003d NULL\n- || (p2 \u003d BINDIT(cl_mod_exp, CLUSTER_LABS_F2)) \u003d\u003d NULL\n- || (p3 \u003d BINDIT(cl_mod_exp_crt, CLUSTER_LABS_F3)) \u003d\u003d NULL\n- || (p4 \u003d BINDIT(cl_rsa_mod_exp, CLUSTER_LABS_F4)) \u003d\u003d NULL\n- || (p5 \u003d BINDIT(cl_rsa_priv_enc, CLUSTER_LABS_F5)) \u003d\u003d NULL\n- || (p6 \u003d BINDIT(cl_rsa_priv_dec, CLUSTER_LABS_F6)) \u003d\u003d NULL\n- || (p7 \u003d BINDIT(cl_rsa_pub_enc, CLUSTER_LABS_F7)) \u003d\u003d NULL\n- || (p8 \u003d BINDIT(cl_rsa_pub_dec, CLUSTER_LABS_F8)) \u003d\u003d NULL\n- || (p20 \u003d BINDIT(cl_rand_bytes, CLUSTER_LABS_F20)) \u003d\u003d NULL\n- || (p30 \u003d BINDIT(cl_dsa_sign, CLUSTER_LABS_F30)) \u003d\u003d NULL\n- || (p31 \u003d BINDIT(cl_dsa_verify, CLUSTER_LABS_F31)) \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);\n- goto err;\n- }\n-\n- /* copy function pointers */\n- p_cl_engine_init \u003d p1;\n- p_cl_mod_exp \u003d p2;\n- p_cl_mod_exp_crt \u003d p3;\n- p_cl_rsa_mod_exp \u003d p4;\n- p_cl_rsa_priv_enc \u003d p5;\n- p_cl_rsa_priv_dec \u003d p6;\n- p_cl_rsa_pub_enc \u003d p7;\n- p_cl_rsa_pub_dec \u003d p8;\n- p_cl_rand_bytes \u003d p20;\n- p_cl_dsa_sign \u003d p30;\n- p_cl_dsa_verify \u003d p31;\n-\n- /* cluster labs engine init */\n- if (p_cl_engine_init() \u003d\u003d 0) {\n- CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_INIT_FAILED);\n- goto err;\n- }\n-\n- return (1);\n-\n- err:\n- /* reset all pointers */\n- DSO_free(cluster_labs_dso);\n- cluster_labs_dso \u003d NULL;\n- p_cl_engine_init \u003d NULL;\n- p_cl_mod_exp \u003d NULL;\n- p_cl_mod_exp_crt \u003d NULL;\n- p_cl_rsa_mod_exp \u003d NULL;\n- p_cl_rsa_priv_enc \u003d NULL;\n- p_cl_rsa_priv_dec \u003d NULL;\n- p_cl_rsa_pub_enc \u003d NULL;\n- p_cl_rsa_pub_dec \u003d NULL;\n- p_cl_rand_bytes \u003d NULL;\n- p_cl_dsa_sign \u003d NULL;\n- p_cl_dsa_verify \u003d NULL;\n-\n- return (0);\n-}\n-\n-static int cluster_labs_finish(ENGINE *e)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_FINISH, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (!DSO_free(cluster_labs_dso)) {\n- CLerr(CL_F_CLUSTER_LABS_FINISH, CL_R_DSO_FAILURE);\n- return 0;\n- }\n-\n- cluster_labs_dso \u003d NULL;\n- p_cl_engine_init \u003d NULL;\n- p_cl_mod_exp \u003d NULL;\n- p_cl_rsa_mod_exp \u003d NULL;\n- p_cl_mod_exp_crt \u003d NULL;\n- p_cl_rsa_priv_enc \u003d NULL;\n- p_cl_rsa_priv_dec \u003d NULL;\n- p_cl_rsa_pub_enc \u003d NULL;\n- p_cl_rsa_pub_dec \u003d NULL;\n- p_cl_rand_bytes \u003d NULL;\n- p_cl_dsa_sign \u003d NULL;\n- p_cl_dsa_verify \u003d NULL;\n-\n- return (1);\n-\n-}\n-\n-static int cluster_labs_ctrl(ENGINE *e, int cmd, long i, void *p,\n- void (*f) ())\n-{\n- int initialised \u003d ((cluster_labs_dso \u003d\u003d NULL) ? 0 : 1);\n-\n- switch (cmd) {\n- case CLUSTER_LABS_CMD_SO_PATH:\n- if (p \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_CTRL, ERR_R_PASSED_NULL_PARAMETER);\n- return 0;\n- }\n- if (initialised) {\n- CLerr(CL_F_CLUSTER_LABS_CTRL, CL_R_ALREADY_LOADED);\n- return 0;\n- }\n- CLUSTER_LABS_LIB_NAME \u003d (const char *)p;\n- return 1;\n- default:\n- break;\n- }\n- CLerr(CL_F_CLUSTER_LABS_CTRL, CL_R_COMMAND_NOT_IMPLEMENTED);\n- return 0;\n-}\n-\n-static int cluster_labs_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_MOD_EXP, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_mod_exp \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_MOD_EXP, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_mod_exp(r, a, p, m, ctx);\n-\n-}\n-\n-static int cluster_labs_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *q, const BIGNUM *dmp1,\n- const BIGNUM *dmq1, const BIGNUM *iqmp,\n- BN_CTX *ctx)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_MOD_EXP_CRT, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_mod_exp_crt \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_MOD_EXP_CRT, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_mod_exp_crt(r, a, p, q, dmp1, dmq1, iqmp, ctx);\n-\n-}\n-\n-static int cluster_labs_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_MOD_EXP, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_rsa_mod_exp \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_MOD_EXP, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rsa_mod_exp(r0, I, rsa);\n-\n-}\n-\n-static DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen,\n- DSA *dsa)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_DSA_SIGN, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_dsa_sign \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_DSA_SIGN, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_dsa_sign(dgst, dlen, dsa);\n-\n-}\n-\n-static int cluster_labs_dsa_verify(const unsigned char *dgst, int dgst_len,\n- DSA_SIG *sig, DSA *dsa)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_DSA_VERIFY, CL_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (p_cl_dsa_verify \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_DSA_VERIFY, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_dsa_verify(dgst, dgst_len, sig, dsa);\n-\n-}\n-\n-static int cluster_labs_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,\n- BIGNUM *p1, BIGNUM *a2, BIGNUM *p2,\n- BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *in_mont)\n-{\n- BIGNUM t;\n- int status \u003d 0;\n-\n- BN_init(\u0026t);\n- /* let rr \u003d a1 ^ p1 mod m */\n- if (!cluster_labs_mod_exp(rr, a1, p1, m, ctx))\n- goto end;\n- /* let t \u003d a2 ^ p2 mod m */\n- if (!cluster_labs_mod_exp(\u0026t, a2, p2, m, ctx))\n- goto end;\n- /* let rr \u003d rr * t mod m */\n- if (!BN_mod_mul(rr, rr, \u0026t, m, ctx))\n- goto end;\n- status \u003d 1;\n- end:\n- BN_free(\u0026t);\n-\n- return (1);\n-\n-}\n-\n-static int cluster_labs_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- return cluster_labs_mod_exp(r, a, p, m, ctx);\n-}\n-\n-/* This function is aliased to mod_exp (with the mont stuff dropped). */\n-static int cluster_labs_mod_exp_mont(BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- return cluster_labs_mod_exp(r, a, p, m, ctx);\n-}\n-\n-/* This function is aliased to mod_exp (with the dh and mont dropped). */\n-static int cluster_labs_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- return cluster_labs_mod_exp(r, a, p, m, ctx);\n-}\n-\n-static int cluster_labs_rsa_pub_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PUB_ENC, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_rsa_priv_enc \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PUB_ENC, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rsa_pub_enc(flen, from, to, rsa, padding);\n-\n-}\n-\n-static int cluster_labs_rsa_pub_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PUB_DEC, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_rsa_priv_enc \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PUB_DEC, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rsa_pub_dec(flen, from, to, rsa, padding);\n-\n-}\n-\n-static int cluster_labs_rsa_priv_enc(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_ENC, CL_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (p_cl_rsa_priv_enc \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_ENC, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rsa_priv_enc(flen, from, to, rsa, padding);\n-\n-}\n-\n-static int cluster_labs_rsa_priv_dec(int flen, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_DEC, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_rsa_priv_dec \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_DEC, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rsa_priv_dec(flen, from, to, rsa, padding);\n-\n-}\n-\n-/************************************************************************************\n-* Symmetric algorithms\n-************************************************************************************/\n-/* this will be come soon! */\n-\n-/************************************************************************************\n-* Random generator\n-************************************************************************************/\n-\n-static int cluster_labs_rand_bytes(unsigned char *buf, int num)\n-{\n-\n- if (cluster_labs_dso \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RAND_BYTES, CL_R_NOT_LOADED);\n- return 0;\n- }\n- if (p_cl_mod_exp_crt \u003d\u003d NULL) {\n- CLerr(CL_F_CLUSTER_LABS_RAND_BYTES, CL_R_FUNCTION_NOT_BINDED);\n- return 0;\n- }\n-\n- return p_cl_rand_bytes(buf, num);\n-\n-}\n-\n-/*\n- * This stuff is needed if this ENGINE is being compiled into a\n- * self-contained shared-library.\n- */\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static int bind_fn(ENGINE *e, const char *id)\n-{\n- fprintf(stderr, \u0022bind_fn CLUSTER_LABS\u005cn\u0022);\n- if (id \u0026\u0026 (strcmp(id, engine_cluster_labs_id) !\u003d 0)) {\n- fprintf(stderr, \u0022bind_fn return(0) first\u005cn\u0022);\n- return 0;\n- }\n- if (!bind_helper(e)) {\n- fprintf(stderr, \u0022bind_fn return(1) first\u005cn\u0022);\n- return 0;\n- }\n- fprintf(stderr, \u0022bind_fn return(1)\u005cn\u0022);\n- return 1;\n-}\n-\n-IMPLEMENT_DYNAMIC_CHECK_FN()\n- IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)\n-# endif /* ENGINE_DYNAMIC_SUPPORT */\n-# endif /* !NO_HW_CLUSTER_LABS */\n-#endif /* !NO_HW */\ndiff --git a/demos/engines/cluster_labs/hw_cluster_labs.ec b/demos/engines/cluster_labs/hw_cluster_labs.ec\ndeleted file mode 100644\nindex 1f64786..0000000\n--- a/demos/engines/cluster_labs/hw_cluster_labs.ec\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-# configuration file for util/mkerr.pl\n-#\n-# use like this:\n-#\n-#\tperl ../../../util/mkerr.pl -conf hw_cluster_labs.ec \u005c\n-#\t\t-nostatic -staticloader -write *.c\n-\n-L CL\t\thw_cluster_labs_err.h\t\thw_cluster_labs_err.c\ndiff --git a/demos/engines/cluster_labs/hw_cluster_labs_err.c b/demos/engines/cluster_labs/hw_cluster_labs_err.c\ndeleted file mode 100644\nindex b2cfdd3..0000000\n--- a/demos/engines/cluster_labs/hw_cluster_labs_err.c\n+++ /dev/null\n@@ -1,151 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/*\n- * NOTE: this file was auto generated by the mkerr.pl script: any changes\n- * made to it will be overwritten when the script next updates this file,\n- * only reason strings will be preserved.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u0022hw_cluster_labs_err.h\u0022\n-\n-/* BEGIN ERROR CODES */\n-#ifndef OPENSSL_NO_ERR\n-static ERR_STRING_DATA CL_str_functs[] \u003d {\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_CTRL, 0), \u0022CLUSTER_LABS_CTRL\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_DSA_SIGN, 0), \u0022CLUSTER_LABS_DSA_SIGN\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_DSA_VERIFY, 0), \u0022CLUSTER_LABS_DSA_VERIFY\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_FINISH, 0), \u0022CLUSTER_LABS_FINISH\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_INIT, 0), \u0022CLUSTER_LABS_INIT\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_MOD_EXP, 0), \u0022CLUSTER_LABS_MOD_EXP\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_MOD_EXP_CRT, 0),\n- \u0022CLUSTER_LABS_MOD_EXP_CRT\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RAND_BYTES, 0), \u0022CLUSTER_LABS_RAND_BYTES\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RSA_MOD_EXP, 0),\n- \u0022CLUSTER_LABS_RSA_MOD_EXP\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RSA_PRIV_DEC, 0),\n- \u0022CLUSTER_LABS_RSA_PRIV_DEC\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RSA_PRIV_ENC, 0),\n- \u0022CLUSTER_LABS_RSA_PRIV_ENC\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RSA_PUB_DEC, 0),\n- \u0022CLUSTER_LABS_RSA_PUB_DEC\u0022},\n- {ERR_PACK(0, CL_F_CLUSTER_LABS_RSA_PUB_ENC, 0),\n- \u0022CLUSTER_LABS_RSA_PUB_ENC\u0022},\n- {0, NULL}\n-};\n-\n-static ERR_STRING_DATA CL_str_reasons[] \u003d {\n- {CL_R_ALREADY_LOADED, \u0022already loaded\u0022},\n- {CL_R_COMMAND_NOT_IMPLEMENTED, \u0022command not implemented\u0022},\n- {CL_R_DSO_FAILURE, \u0022dso failure\u0022},\n- {CL_R_FUNCTION_NOT_BINDED, \u0022function not binded\u0022},\n- {CL_R_INIT_FAILED, \u0022init failed\u0022},\n- {CL_R_NOT_LOADED, \u0022not loaded\u0022},\n- {0, NULL}\n-};\n-\n-#endif\n-\n-#ifdef CL_LIB_NAME\n-static ERR_STRING_DATA CL_lib_name[] \u003d {\n- {0, CL_LIB_NAME},\n- {0, NULL}\n-};\n-#endif\n-\n-static int CL_lib_error_code \u003d 0;\n-static int CL_error_init \u003d 1;\n-\n-static void ERR_load_CL_strings(void)\n-{\n- if (CL_lib_error_code \u003d\u003d 0)\n- CL_lib_error_code \u003d ERR_get_next_error_library();\n-\n- if (CL_error_init) {\n- CL_error_init \u003d 0;\n-#ifndef OPENSSL_NO_ERR\n- ERR_load_strings(CL_lib_error_code, CL_str_functs);\n- ERR_load_strings(CL_lib_error_code, CL_str_reasons);\n-#endif\n-\n-#ifdef CL_LIB_NAME\n- CL_lib_name-\u003eerror \u003d ERR_PACK(CL_lib_error_code, 0, 0);\n- ERR_load_strings(0, CL_lib_name);\n-#endif\n- }\n-}\n-\n-static void ERR_unload_CL_strings(void)\n-{\n- if (CL_error_init \u003d\u003d 0) {\n-#ifndef OPENSSL_NO_ERR\n- ERR_unload_strings(CL_lib_error_code, CL_str_functs);\n- ERR_unload_strings(CL_lib_error_code, CL_str_reasons);\n-#endif\n-\n-#ifdef CL_LIB_NAME\n- ERR_unload_strings(0, CL_lib_name);\n-#endif\n- CL_error_init \u003d 1;\n- }\n-}\n-\n-static void ERR_CL_error(int function, int reason, char *file, int line)\n-{\n- if (CL_lib_error_code \u003d\u003d 0)\n- CL_lib_error_code \u003d ERR_get_next_error_library();\n- ERR_PUT_error(CL_lib_error_code, function, reason, file, line);\n-}\ndiff --git a/demos/engines/cluster_labs/hw_cluster_labs_err.h b/demos/engines/cluster_labs/hw_cluster_labs_err.h\ndeleted file mode 100644\nindex e9e58d5..0000000\n--- a/demos/engines/cluster_labs/hw_cluster_labs_err.h\n+++ /dev/null\n@@ -1,100 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@openssl.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.openssl.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-#ifndef HEADER_CL_ERR_H\n-# define HEADER_CL_ERR_H\n-\n-#ifdef __cplusplus\n-extern \u0022C\u0022 {\n-#endif\n-\n-/* BEGIN ERROR CODES */\n-/*\n- * The following lines are auto generated by the script mkerr.pl. Any changes\n- * made after this point may be overwritten when the script is next run.\n- */\n-static void ERR_load_CL_strings(void);\n-static void ERR_unload_CL_strings(void);\n-static void ERR_CL_error(int function, int reason, char *file, int line);\n-# define CLerr(f,r) ERR_CL_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)\n-\n-/* Error codes for the CL functions. */\n-\n-/* Function codes. */\n-# define CL_F_CLUSTER_LABS_CTRL 100\n-# define CL_F_CLUSTER_LABS_DSA_SIGN 101\n-# define CL_F_CLUSTER_LABS_DSA_VERIFY 102\n-# define CL_F_CLUSTER_LABS_FINISH 103\n-# define CL_F_CLUSTER_LABS_INIT 104\n-# define CL_F_CLUSTER_LABS_MOD_EXP 105\n-# define CL_F_CLUSTER_LABS_MOD_EXP_CRT 106\n-# define CL_F_CLUSTER_LABS_RAND_BYTES 107\n-# define CL_F_CLUSTER_LABS_RSA_MOD_EXP 108\n-# define CL_F_CLUSTER_LABS_RSA_PRIV_DEC 109\n-# define CL_F_CLUSTER_LABS_RSA_PRIV_ENC 110\n-# define CL_F_CLUSTER_LABS_RSA_PUB_DEC 111\n-# define CL_F_CLUSTER_LABS_RSA_PUB_ENC 112\n-\n-/* Reason codes. */\n-# define CL_R_ALREADY_LOADED 100\n-# define CL_R_COMMAND_NOT_IMPLEMENTED 101\n-# define CL_R_DSO_FAILURE 102\n-# define CL_R_FUNCTION_NOT_BINDED 103\n-# define CL_R_INIT_FAILED 104\n-# define CL_R_NOT_LOADED 105\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-#endif\ndiff --git a/demos/engines/ibmca/Makefile.in b/demos/engines/ibmca/Makefile.in\ndeleted file mode 100644\nindex 3f3d327..0000000\n--- a/demos/engines/ibmca/Makefile.in\n+++ /dev/null\n@@ -1,93 +0,0 @@\n-LIBNAME\u003d\tlibibmca\n-SRC\u003d\t\thw_ibmca.c\n-OBJ\u003d\t\thw_ibmca.o\n-HEADER\u003d\t\thw_ibmca.h\n-\n-CC\u003d\t\tgcc\n-PIC\u003d\t\t-fPIC\n-CFLAGS\u003d\t\t-g -I../../../include $(PIC) -DENGINE_DYNAMIC_SUPPORT -DFLAT_INC\n-AR\u003d\t\tar r\n-RANLIB\u003d\t\tranlib\n-\n-LIB\u003d\t\t$(LIBNAME).a\n-SHLIB\u003d\t\t$(LIBNAME).so\n-\n-all:\n-\t\t@echo 'Please choose a system to build on:'\n-\t\t@echo ''\n-\t\t@echo 'tru64: Tru64 Unix, Digital Unix, Digital OSF/1'\n-\t\t@echo 'solaris: Solaris'\n-\t\t@echo 'irix: IRIX'\n-\t\t@echo 'hpux32: 32-bit HP/UX'\n-\t\t@echo 'hpux64: 64-bit HP/UX'\n-\t\t@echo 'aix: AIX'\n-\t\t@echo 'gnu: Generic GNU-based system (gcc and GNU ld)'\n-\t\t@echo ''\n-\n-generate:\n-\t\tperl ../../../util/mkerr.pl -conf hw_ibmca.ec \u005c\n-\t\t\t-nostatic -staticloader -write hw_ibmca.c\n-\n-gnu:\t\t$(SHLIB).gnu\n-tru64:\t\t$(SHLIB).tru64\n-solaris:\t$(SHLIB).solaris\n-irix:\t\t$(SHLIB).irix\n-hpux32:\t\t$(SHLIB).hpux32\n-hpux64:\t\t$(SHLIB).hpux64\n-aix:\t\t$(SHLIB).aix\n-\n-$(LIB):\t\t$(OBJ)\n-\t\t$(AR) $(LIB) $(OBJ)\n-\t\t- $(RANLIB) $(LIB)\n-\n-LINK_SO\u003d\t\u005c\n- ld -r -o $(LIBNAME).o $$ALLSYMSFLAGS $(LIB) \u0026\u0026 \u005c\n- (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' \u003e $(LIBNAME).exp; \u005c\n- $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc)\n-\n-$(SHLIB).gnu:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'--whole-archive' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname\u003d$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).gnu\n-$(SHLIB).tru64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).tru64\n-$(SHLIB).solaris:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-z allextract' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).solaris\n-$(SHLIB).irix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname,$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).irix\n-$(SHLIB).hpux32:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-Fl' \u005c\n-\t\tSHAREDFLAGS\u003d'+vnocompatwarnings -b -z +s +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux32\n-$(SHLIB).hpux64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'+forceload' \u005c\n-\t\tSHAREDFLAGS\u003d'-b -z +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux64\n-$(SHLIB).aix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-bnogc' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -bE:$(LIBNAME).exp -bM:SRE' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).aix\n-\n-depend:\n-\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/engines/ibmca/hw_ibmca.c b/demos/engines/ibmca/hw_ibmca.c\ndeleted file mode 100644\nindex 0f065b2..0000000\n--- a/demos/engines/ibmca/hw_ibmca.c\n+++ /dev/null\n@@ -1,896 +0,0 @@\n-/*\n- * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project\n- * 2000.\n- */\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * licensing@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/* (C) COPYRIGHT International Business Machines Corp. 2001 */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/dso.h\u003e\n-#include \u003copenssl/engine.h\u003e\n-\n-#ifndef OPENSSL_NO_HW\n-# ifndef OPENSSL_NO_HW_IBMCA\n-\n-# ifdef FLAT_INC\n-# include \u0022ica_openssl_api.h\u0022\n-# else\n-# include \u0022vendor_defns/ica_openssl_api.h\u0022\n-# endif\n-\n-# define IBMCA_LIB_NAME \u0022ibmca engine\u0022\n-# include \u0022hw_ibmca_err.c\u0022\n-\n-static int ibmca_destroy(ENGINE *e);\n-static int ibmca_init(ENGINE *e);\n-static int ibmca_finish(ENGINE *e);\n-static int ibmca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) ());\n-\n-static const char *IBMCA_F1 \u003d \u0022icaOpenAdapter\u0022;\n-static const char *IBMCA_F2 \u003d \u0022icaCloseAdapter\u0022;\n-static const char *IBMCA_F3 \u003d \u0022icaRsaModExpo\u0022;\n-static const char *IBMCA_F4 \u003d \u0022icaRandomNumberGenerate\u0022;\n-static const char *IBMCA_F5 \u003d \u0022icaRsaCrt\u0022;\n-\n-ICA_ADAPTER_HANDLE handle \u003d 0;\n-\n-/* BIGNUM stuff */\n-static int ibmca_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx);\n-\n-static int ibmca_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *q, const BIGNUM *dmp1,\n- const BIGNUM *dmq1, const BIGNUM *iqmp,\n- BN_CTX *ctx);\n-\n-# ifndef OPENSSL_NO_RSA\n-/* RSA stuff */\n-static int ibmca_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);\n-# endif\n-\n-/* This function is aliased to mod_exp (with the mont stuff dropped). */\n-static int ibmca_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx);\n-\n-# ifndef OPENSSL_NO_DSA\n-/* DSA stuff */\n-static int ibmca_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,\n- BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *in_mont);\n-static int ibmca_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx);\n-# endif\n-\n-# ifndef OPENSSL_NO_DH\n-/* DH stuff */\n-/* This function is alised to mod_exp (with the DH and mont dropped). */\n-static int ibmca_mod_exp_dh(const DH *dh, BIGNUM *r,\n- const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-# endif\n-\n-/* RAND stuff */\n-static int ibmca_rand_bytes(unsigned char *buf, int num);\n-static int ibmca_rand_status(void);\n-\n-/* WJH - check for more commands, like in nuron */\n-\n-/* The definitions for control commands specific to this engine */\n-# define IBMCA_CMD_SO_PATH ENGINE_CMD_BASE\n-static const ENGINE_CMD_DEFN ibmca_cmd_defns[] \u003d {\n- {IBMCA_CMD_SO_PATH,\n- \u0022SO_PATH\u0022,\n- \u0022Specifies the path to the 'atasi' shared library\u0022,\n- ENGINE_CMD_FLAG_STRING},\n- {0, NULL, NULL, 0}\n-};\n-\n-# ifndef OPENSSL_NO_RSA\n-/* Our internal RSA_METHOD that we provide pointers to */\n-static RSA_METHOD ibmca_rsa \u003d {\n- \u0022Ibmca RSA method\u0022,\n- NULL,\n- NULL,\n- NULL,\n- NULL,\n- ibmca_rsa_mod_exp,\n- ibmca_mod_exp_mont,\n- NULL,\n- NULL,\n- 0,\n- NULL,\n- NULL,\n- NULL\n-};\n-# endif\n-\n-# ifndef OPENSSL_NO_DSA\n-/* Our internal DSA_METHOD that we provide pointers to */\n-static DSA_METHOD ibmca_dsa \u003d {\n- \u0022Ibmca DSA method\u0022,\n- NULL, /* dsa_do_sign */\n- NULL, /* dsa_sign_setup */\n- NULL, /* dsa_do_verify */\n- ibmca_dsa_mod_exp, /* dsa_mod_exp */\n- ibmca_mod_exp_dsa, /* bn_mod_exp */\n- NULL, /* init */\n- NULL, /* finish */\n- 0, /* flags */\n- NULL /* app_data */\n-};\n-# endif\n-\n-# ifndef OPENSSL_NO_DH\n-/* Our internal DH_METHOD that we provide pointers to */\n-static DH_METHOD ibmca_dh \u003d {\n- \u0022Ibmca DH method\u0022,\n- NULL,\n- NULL,\n- ibmca_mod_exp_dh,\n- NULL,\n- NULL,\n- 0,\n- NULL\n-};\n-# endif\n-\n-static RAND_METHOD ibmca_rand \u003d {\n- /* \u0022IBMCA RAND method\u0022, */\n- NULL,\n- ibmca_rand_bytes,\n- NULL,\n- NULL,\n- ibmca_rand_bytes,\n- ibmca_rand_status,\n-};\n-\n-/* Constants used when creating the ENGINE */\n-static const char *engine_ibmca_id \u003d \u0022ibmca\u0022;\n-static const char *engine_ibmca_name \u003d \u0022Ibmca hardware engine support\u0022;\n-\n-/*\n- * This internal function is used by ENGINE_ibmca() and possibly by the\n- * \u0022dynamic\u0022 ENGINE support too\n- */\n-static int bind_helper(ENGINE *e)\n-{\n-# ifndef OPENSSL_NO_RSA\n- const RSA_METHOD *meth1;\n-# endif\n-# ifndef OPENSSL_NO_DSA\n- const DSA_METHOD *meth2;\n-# endif\n-# ifndef OPENSSL_NO_DH\n- const DH_METHOD *meth3;\n-# endif\n- if (!ENGINE_set_id(e, engine_ibmca_id) ||\n- !ENGINE_set_name(e, engine_ibmca_name) ||\n-# ifndef OPENSSL_NO_RSA\n- !ENGINE_set_RSA(e, \u0026ibmca_rsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DSA\n- !ENGINE_set_DSA(e, \u0026ibmca_dsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DH\n- !ENGINE_set_DH(e, \u0026ibmca_dh) ||\n-# endif\n- !ENGINE_set_RAND(e, \u0026ibmca_rand) ||\n- !ENGINE_set_destroy_function(e, ibmca_destroy) ||\n- !ENGINE_set_init_function(e, ibmca_init) ||\n- !ENGINE_set_finish_function(e, ibmca_finish) ||\n- !ENGINE_set_ctrl_function(e, ibmca_ctrl) ||\n- !ENGINE_set_cmd_defns(e, ibmca_cmd_defns))\n- return 0;\n-\n-# ifndef OPENSSL_NO_RSA\n- /*\n- * We know that the \u0022PKCS1_OpenSSL()\u0022 functions hook properly to the\n- * ibmca-specific mod_exp and mod_exp_crt so we use those functions. NB:\n- * We don't use ENGINE_openssl() or anything \u0022more generic\u0022 because\n- * something like the RSAref code may not hook properly, and if you own\n- * one of these cards then you have the right to do RSA operations on it\n- * anyway!\n- */\n- meth1 \u003d RSA_PKCS1_OpenSSL();\n- ibmca_rsa.rsa_pub_enc \u003d meth1-\u003ersa_pub_enc;\n- ibmca_rsa.rsa_pub_dec \u003d meth1-\u003ersa_pub_dec;\n- ibmca_rsa.rsa_priv_enc \u003d meth1-\u003ersa_priv_enc;\n- ibmca_rsa.rsa_priv_dec \u003d meth1-\u003ersa_priv_dec;\n-# endif\n-\n-# ifndef OPENSSL_NO_DSA\n- /*\n- * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits.\n- */\n- meth2 \u003d DSA_OpenSSL();\n- ibmca_dsa.dsa_do_sign \u003d meth2-\u003edsa_do_sign;\n- ibmca_dsa.dsa_sign_setup \u003d meth2-\u003edsa_sign_setup;\n- ibmca_dsa.dsa_do_verify \u003d meth2-\u003edsa_do_verify;\n-# endif\n-\n-# ifndef OPENSSL_NO_DH\n- /* Much the same for Diffie-Hellman */\n- meth3 \u003d DH_OpenSSL();\n- ibmca_dh.generate_key \u003d meth3-\u003egenerate_key;\n- ibmca_dh.compute_key \u003d meth3-\u003ecompute_key;\n-# endif\n-\n- /* Ensure the ibmca error handling is set up */\n- ERR_load_IBMCA_strings();\n- return 1;\n-}\n-\n-static ENGINE *engine_ibmca(void)\n-{\n- ENGINE *ret \u003d ENGINE_new();\n- if (!ret)\n- return NULL;\n- if (!bind_helper(ret)) {\n- ENGINE_free(ret);\n- return NULL;\n- }\n- return ret;\n-}\n-\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static\n-# endif\n-void ENGINE_load_ibmca(void)\n-{\n- /* Copied from eng_[openssl|dyn].c */\n- ENGINE *toadd \u003d engine_ibmca();\n- if (!toadd)\n- return;\n- ENGINE_add(toadd);\n- ENGINE_free(toadd);\n- ERR_clear_error();\n-}\n-\n-/* Destructor (complements the \u0022ENGINE_ibmca()\u0022 constructor) */\n-static int ibmca_destroy(ENGINE *e)\n-{\n- /*\n- * Unload the ibmca error strings so any error state including our functs\n- * or reasons won't lead to a segfault (they simply get displayed without\n- * corresponding string data because none will be found).\n- */\n- ERR_unload_IBMCA_strings();\n- return 1;\n-}\n-\n-/*\n- * This is a process-global DSO handle used for loading and unloading the\n- * Ibmca library. NB: This is only set (or unset) during an init() or\n- * finish() call (reference counts permitting) and they're operating with\n- * global locks, so this should be thread-safe implicitly.\n- */\n-\n-static DSO *ibmca_dso \u003d NULL;\n-\n-/*\n- * These are the function pointers that are (un)set when the library has\n- * successfully (un)loaded.\n- */\n-\n-static unsigned int (ICA_CALL * p_icaOpenAdapter) ();\n-static unsigned int (ICA_CALL * p_icaCloseAdapter) ();\n-static unsigned int (ICA_CALL * p_icaRsaModExpo) ();\n-static unsigned int (ICA_CALL * p_icaRandomNumberGenerate) ();\n-static unsigned int (ICA_CALL * p_icaRsaCrt) ();\n-\n-/* utility function to obtain a context */\n-static int get_context(ICA_ADAPTER_HANDLE * p_handle)\n-{\n- unsigned int status \u003d 0;\n-\n- status \u003d p_icaOpenAdapter(0, p_handle);\n- if (status !\u003d 0)\n- return 0;\n- return 1;\n-}\n-\n-/* similarly to release one. */\n-static void release_context(ICA_ADAPTER_HANDLE handle)\n-{\n- p_icaCloseAdapter(handle);\n-}\n-\n-/* (de)initialisation functions. */\n-static int ibmca_init(ENGINE *e)\n-{\n-\n- void (*p1) ();\n- void (*p2) ();\n- void (*p3) ();\n- void (*p4) ();\n- void (*p5) ();\n-\n- if (ibmca_dso !\u003d NULL) {\n- IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_ALREADY_LOADED);\n- goto err;\n- }\n- /*\n- * Attempt to load libatasi.so/atasi.dll/whatever. Needs to be changed\n- * unfortunately because the Ibmca drivers don't have standard library\n- * names that can be platform-translated well.\n- */\n- /*\n- * TODO: Work out how to actually map to the names the Ibmca drivers\n- * really use - for now a symbollic link needs to be created on the host\n- * system from libatasi.so to atasi.so on unix variants.\n- */\n-\n- /* WJH XXX check name translation */\n-\n- ibmca_dso \u003d DSO_load(NULL, IBMCA_LIBNAME, NULL,\n- /*\n- * DSO_FLAG_NAME_TRANSLATION\n- */ 0);\n- if (ibmca_dso \u003d\u003d NULL) {\n- IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_DSO_FAILURE);\n- goto err;\n- }\n-\n- if ((p1 \u003d DSO_bind_func(ibmca_dso, IBMCA_F1)) \u003d\u003d NULL\n- || (p2 \u003d DSO_bind_func(ibmca_dso, IBMCA_F2)) \u003d\u003d NULL\n- || (p3 \u003d DSO_bind_func(ibmca_dso, IBMCA_F3)) \u003d\u003d NULL\n- || (p4 \u003d DSO_bind_func(ibmca_dso, IBMCA_F4)) \u003d\u003d NULL\n- || (p5 \u003d DSO_bind_func(ibmca_dso, IBMCA_F5)) \u003d\u003d NULL) {\n- IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_DSO_FAILURE);\n- goto err;\n- }\n-\n- /* Copy the pointers */\n-\n- p_icaOpenAdapter \u003d (unsigned int (ICA_CALL *) ())p1;\n- p_icaCloseAdapter \u003d (unsigned int (ICA_CALL *) ())p2;\n- p_icaRsaModExpo \u003d (unsigned int (ICA_CALL *) ())p3;\n- p_icaRandomNumberGenerate \u003d (unsigned int (ICA_CALL *) ())p4;\n- p_icaRsaCrt \u003d (unsigned int (ICA_CALL *) ())p5;\n-\n- if (!get_context(\u0026handle)) {\n- IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_UNIT_FAILURE);\n- goto err;\n- }\n-\n- return 1;\n- err:\n- DSO_free(ibmca_dso);\n- p_icaOpenAdapter \u003d NULL;\n- p_icaCloseAdapter \u003d NULL;\n- p_icaRsaModExpo \u003d NULL;\n- p_icaRandomNumberGenerate \u003d NULL;\n-\n- return 0;\n-}\n-\n-static int ibmca_finish(ENGINE *e)\n-{\n- if (ibmca_dso \u003d\u003d NULL) {\n- IBMCAerr(IBMCA_F_IBMCA_FINISH, IBMCA_R_NOT_LOADED);\n- return 0;\n- }\n- release_context(handle);\n- if (!DSO_free(ibmca_dso)) {\n- IBMCAerr(IBMCA_F_IBMCA_FINISH, IBMCA_R_DSO_FAILURE);\n- return 0;\n- }\n- ibmca_dso \u003d NULL;\n-\n- return 1;\n-}\n-\n-static int ibmca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) ())\n-{\n- int initialised \u003d ((ibmca_dso \u003d\u003d NULL) ? 0 : 1);\n- switch (cmd) {\n- case IBMCA_CMD_SO_PATH:\n- if (p \u003d\u003d NULL) {\n- IBMCAerr(IBMCA_F_IBMCA_CTRL, ERR_R_PASSED_NULL_PARAMETER);\n- return 0;\n- }\n- if (initialised) {\n- IBMCAerr(IBMCA_F_IBMCA_CTRL, IBMCA_R_ALREADY_LOADED);\n- return 0;\n- }\n- IBMCA_LIBNAME \u003d (const char *)p;\n- return 1;\n- default:\n- break;\n- }\n- IBMCAerr(IBMCA_F_IBMCA_CTRL, IBMCA_R_CTRL_COMMAND_NOT_IMPLEMENTED);\n- return 0;\n-}\n-\n-static int ibmca_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx)\n-{\n- /*\n- * I need somewhere to store temporary serialised values for use with the\n- * Ibmca API calls. A neat cheat - I'll use BIGNUMs from the BN_CTX but\n- * access their arrays directly as byte arrays \u003cgrin\u003e. This way I don't\n- * have to clean anything up.\n- */\n-\n- BIGNUM *argument \u003d NULL;\n- BIGNUM *result \u003d NULL;\n- BIGNUM *key \u003d NULL;\n- int to_return;\n- int inLen, outLen, tmpLen;\n-\n- ICA_KEY_RSA_MODEXPO *publKey \u003d NULL;\n- unsigned int rc;\n-\n- to_return \u003d 0; /* expect failure */\n-\n- if (!ibmca_dso) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_NOT_LOADED);\n- goto err;\n- }\n- /* Prepare the params */\n- BN_CTX_start(ctx);\n- argument \u003d BN_CTX_get(ctx);\n- result \u003d BN_CTX_get(ctx);\n- key \u003d BN_CTX_get(ctx);\n-\n- if (!argument || !result || !key) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_BN_CTX_FULL);\n- goto err;\n- }\n-\n- if (!bn_wexpand(argument, m-\u003etop) || !bn_wexpand(result, m-\u003etop) ||\n- !bn_wexpand(key, sizeof(*publKey) / BN_BYTES)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_BN_EXPAND_FAIL);\n- goto err;\n- }\n-\n- publKey \u003d (ICA_KEY_RSA_MODEXPO *)key-\u003ed;\n-\n- if (publKey \u003d\u003d NULL) {\n- goto err;\n- }\n- memset(publKey, 0, sizeof(*publKey));\n-\n- publKey-\u003ekeyType \u003d CORRECT_ENDIANNESS(ME_KEY_TYPE);\n- publKey-\u003ekeyLength \u003d CORRECT_ENDIANNESS(sizeof(ICA_KEY_RSA_MODEXPO));\n- publKey-\u003eexpOffset \u003d (char *)publKey-\u003ekeyRecord - (char *)publKey;\n-\n- /*\n- * A quirk of the card: the exponent length has to be the same as the\n- * modulus (key) length\n- */\n-\n- outLen \u003d BN_num_bytes(m);\n-\n-/* check for modulus length SAB*/\n- if (outLen \u003e 256) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_MEXP_LENGTH_TO_LARGE);\n- goto err;\n- }\n-/* check for modulus length SAB*/\n-\n- publKey-\u003eexpLength \u003d publKey-\u003enLength \u003d outLen;\n- /*\n- * SAB Check for underflow condition the size of the exponent is less\n- * than the size of the parameter then we have a big problem and will\n- * underflow the keyRecord buffer. Bad stuff could happen then\n- */\n- if (outLen \u003c BN_num_bytes(p)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_UNDERFLOW_KEYRECORD);\n- goto err;\n- }\n-/* SAB End check for underflow */\n-\n- BN_bn2bin(p, \u0026publKey-\u003ekeyRecord[publKey-\u003eexpLength - BN_num_bytes(p)]);\n- BN_bn2bin(m, \u0026publKey-\u003ekeyRecord[publKey-\u003eexpLength]);\n-\n- publKey-\u003emodulusBitLength \u003d CORRECT_ENDIANNESS(publKey-\u003enLength * 8);\n- publKey-\u003enOffset \u003d CORRECT_ENDIANNESS(publKey-\u003eexpOffset +\n- publKey-\u003eexpLength);\n-\n- publKey-\u003eexpOffset \u003d CORRECT_ENDIANNESS((char *)publKey-\u003ekeyRecord -\n- (char *)publKey);\n-\n- tmpLen \u003d outLen;\n- publKey-\u003eexpLength \u003d publKey-\u003enLength \u003d CORRECT_ENDIANNESS(tmpLen);\n-\n- /* Prepare the argument */\n-\n- memset(argument-\u003ed, 0, outLen);\n- BN_bn2bin(a, (unsigned char *)argument-\u003ed + outLen - BN_num_bytes(a));\n-\n- inLen \u003d outLen;\n-\n- /* Perform the operation */\n-\n- if ((rc \u003d p_icaRsaModExpo(handle, inLen, (unsigned char *)argument-\u003ed,\n- publKey, \u0026outLen, (unsigned char *)result-\u003ed))\n- !\u003d 0) {\n- printf(\u0022rc \u003d %d\u005cn\u0022, rc);\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP, IBMCA_R_REQUEST_FAILED);\n- goto err;\n- }\n-\n- /* Convert the response */\n- BN_bin2bn((unsigned char *)result-\u003ed, outLen, r);\n- to_return \u003d 1;\n- err:\n- BN_CTX_end(ctx);\n- return to_return;\n-}\n-\n-# ifndef OPENSSL_NO_RSA\n-static int ibmca_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)\n-{\n- BN_CTX *ctx;\n- int to_return \u003d 0;\n-\n- if ((ctx \u003d BN_CTX_new()) \u003d\u003d NULL)\n- goto err;\n- if (!rsa-\u003ep || !rsa-\u003eq || !rsa-\u003edmp1 || !rsa-\u003edmq1 || !rsa-\u003eiqmp) {\n- if (!rsa-\u003ed || !rsa-\u003en) {\n- IBMCAerr(IBMCA_F_IBMCA_RSA_MOD_EXP,\n- IBMCA_R_MISSING_KEY_COMPONENTS);\n- goto err;\n- }\n- to_return \u003d ibmca_mod_exp(r0, I, rsa-\u003ed, rsa-\u003en, ctx);\n- } else {\n- to_return \u003d ibmca_mod_exp_crt(r0, I, rsa-\u003ep, rsa-\u003eq, rsa-\u003edmp1,\n- rsa-\u003edmq1, rsa-\u003eiqmp, ctx);\n- }\n- err:\n- BN_CTX_free(ctx);\n- return to_return;\n-}\n-# endif\n-\n-/* Ein kleines chinesisches \u0022Restessen\u0022 */\n-static int ibmca_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *q, const BIGNUM *dmp1,\n- const BIGNUM *dmq1, const BIGNUM *iqmp,\n- BN_CTX *ctx)\n-{\n-\n- BIGNUM *argument \u003d NULL;\n- BIGNUM *result \u003d NULL;\n- BIGNUM *key \u003d NULL;\n-\n- int to_return \u003d 0; /* expect failure */\n-\n- char *pkey \u003d NULL;\n- ICA_KEY_RSA_CRT *privKey \u003d NULL;\n- int inLen, outLen;\n-\n- int rc;\n- unsigned int offset, pSize, qSize;\n-/* SAB New variables */\n- unsigned int keyRecordSize;\n- unsigned int pbytes \u003d BN_num_bytes(p);\n- unsigned int qbytes \u003d BN_num_bytes(q);\n- unsigned int dmp1bytes \u003d BN_num_bytes(dmp1);\n- unsigned int dmq1bytes \u003d BN_num_bytes(dmq1);\n- unsigned int iqmpbytes \u003d BN_num_bytes(iqmp);\n-\n- /* Prepare the params */\n-\n- BN_CTX_start(ctx);\n- argument \u003d BN_CTX_get(ctx);\n- result \u003d BN_CTX_get(ctx);\n- key \u003d BN_CTX_get(ctx);\n-\n- if (!argument || !result || !key) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_BN_CTX_FULL);\n- goto err;\n- }\n-\n- if (!bn_wexpand(argument, p-\u003etop + q-\u003etop) ||\n- !bn_wexpand(result, p-\u003etop + q-\u003etop) ||\n- !bn_wexpand(key, sizeof(*privKey) / BN_BYTES)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_BN_EXPAND_FAIL);\n- goto err;\n- }\n-\n- privKey \u003d (ICA_KEY_RSA_CRT *)key-\u003ed;\n- /*\n- * SAB Add check for total size in bytes of the parms does not exceed the\n- * buffer space we have do this first\n- */\n- keyRecordSize \u003d pbytes + qbytes + dmp1bytes + dmq1bytes + iqmpbytes;\n- if (keyRecordSize \u003e sizeof(privKey-\u003ekeyRecord)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_OPERANDS_TO_LARGE);\n- goto err;\n- }\n-\n- if ((qbytes + dmq1bytes) \u003e 256) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_OPERANDS_TO_LARGE);\n- goto err;\n- }\n-\n- if (pbytes + dmp1bytes \u003e 256) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_OPERANDS_TO_LARGE);\n- goto err;\n- }\n-\n-/* end SAB additions */\n-\n- memset(privKey, 0, sizeof(*privKey));\n- privKey-\u003ekeyType \u003d CORRECT_ENDIANNESS(CRT_KEY_TYPE);\n- privKey-\u003ekeyLength \u003d CORRECT_ENDIANNESS(sizeof(ICA_KEY_RSA_CRT));\n- privKey-\u003emodulusBitLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(q) * 2 * 8);\n-\n- /*\n- * p,dp \u0026 qInv are 1 QWORD Larger\n- */\n- privKey-\u003epLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(p) + 8);\n- privKey-\u003eqLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(q));\n- privKey-\u003edpLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(dmp1) + 8);\n- privKey-\u003edqLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(dmq1));\n- privKey-\u003eqInvLength \u003d CORRECT_ENDIANNESS(BN_num_bytes(iqmp) + 8);\n-\n- offset \u003d (char *)privKey-\u003ekeyRecord - (char *)privKey;\n-\n- qSize \u003d BN_num_bytes(q);\n- pSize \u003d qSize + 8; /* 1 QWORD larger */\n-\n- /*\n- * SAB probably aittle redundant, but we'll verify that each of the\n- * components which make up a key record sent ot the card does not exceed\n- * the space that is allocated for it. this handles the case where even\n- * if the total length does not exceed keyrecord zied, if the operands are\n- * funny sized they could cause potential side affects on either the card\n- * or the result\n- */\n-\n- if ((pbytes \u003e pSize) || (dmp1bytes \u003e pSize) ||\n- (iqmpbytes \u003e pSize) || (qbytes \u003e qSize) || (dmq1bytes \u003e qSize)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_OPERANDS_TO_LARGE);\n- goto err;\n-\n- }\n-\n- privKey-\u003edpOffset \u003d CORRECT_ENDIANNESS(offset);\n-\n- offset +\u003d pSize;\n- privKey-\u003edqOffset \u003d CORRECT_ENDIANNESS(offset);\n-\n- offset +\u003d qSize;\n- privKey-\u003epOffset \u003d CORRECT_ENDIANNESS(offset);\n-\n- offset +\u003d pSize;\n- privKey-\u003eqOffset \u003d CORRECT_ENDIANNESS(offset);\n-\n- offset +\u003d qSize;\n- privKey-\u003eqInvOffset \u003d CORRECT_ENDIANNESS(offset);\n-\n- pkey \u003d (char *)privKey-\u003ekeyRecord;\n-\n-/* SAB first check that we don;t under flow the buffer */\n- if (pSize \u003c pbytes) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_UNDERFLOW_CONDITION);\n- goto err;\n- }\n-\n- /* pkey +\u003d pSize - BN_num_bytes(p); WROING this should be dmp1) */\n- pkey +\u003d pSize - BN_num_bytes(dmp1);\n- BN_bn2bin(dmp1, pkey);\n- pkey +\u003d BN_num_bytes(dmp1); /* move the pointer */\n-\n- BN_bn2bin(dmq1, pkey); /* Copy over dmq1 */\n-\n- pkey +\u003d qSize; /* move pointer */\n- /* set up for zero padding of next field */\n- pkey +\u003d pSize - BN_num_bytes(p);\n-\n- BN_bn2bin(p, pkey);\n- /* increment pointer by number of bytes moved */\n- pkey +\u003d BN_num_bytes(p);\n-\n- BN_bn2bin(q, pkey);\n- pkey +\u003d qSize; /* move the pointer */\n- pkey +\u003d pSize - BN_num_bytes(iqmp); /* Adjust for padding */\n- BN_bn2bin(iqmp, pkey);\n-\n- /* Prepare the argument and response */\n-\n- /*\n- * Correct endianess is used because the fields were converted above\n- */\n- outLen \u003d CORRECT_ENDIANNESS(privKey-\u003eqLength) * 2;\n-\n- if (outLen \u003e 256) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_OUTLEN_TO_LARGE);\n- goto err;\n- }\n-\n- /* SAB check for underflow here on the argeument */\n- if (outLen \u003c BN_num_bytes(a)) {\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_UNDERFLOW_CONDITION);\n- goto err;\n- }\n-\n- BN_bn2bin(a, (unsigned char *)argument-\u003ed + outLen - BN_num_bytes(a));\n- inLen \u003d outLen;\n-\n- memset(result-\u003ed, 0, outLen);\n-\n- /* Perform the operation */\n-\n- if ((rc \u003d p_icaRsaCrt(handle, inLen, (unsigned char *)argument-\u003ed,\n- privKey, \u0026outLen, (unsigned char *)result-\u003ed)) !\u003d 0)\n- {\n- printf(\u0022rc \u003d %d\u005cn\u0022, rc);\n- IBMCAerr(IBMCA_F_IBMCA_MOD_EXP_CRT, IBMCA_R_REQUEST_FAILED);\n- goto err;\n- }\n-\n- /* Convert the response */\n-\n- BN_bin2bn((unsigned char *)result-\u003ed, outLen, r);\n- to_return \u003d 1;\n-\n- err:\n- BN_CTX_end(ctx);\n- return to_return;\n-\n-}\n-\n-# ifndef OPENSSL_NO_DSA\n-/*\n- * This code was liberated and adapted from the commented-out code in\n- * dsa_ossl.c. Because of the unoptimised form of the Ibmca acceleration (it\n- * doesn't have a CRT form for RSA), this function means that an Ibmca system\n- * running with a DSA server certificate can handshake around 5 or 6 times\n- * faster/more than an equivalent system running with RSA. Just check out the\n- * \u0022signs\u0022 statistics from the RSA and DSA parts of \u0022openssl speed -engine\n- * ibmca dsa1024 rsa1024\u0022.\n- */\n-static int ibmca_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,\n- BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *in_mont)\n-{\n- BIGNUM t;\n- int to_return \u003d 0;\n-\n- BN_init(\u0026t);\n- /* let rr \u003d a1 ^ p1 mod m */\n- if (!ibmca_mod_exp(rr, a1, p1, m, ctx))\n- goto end;\n- /* let t \u003d a2 ^ p2 mod m */\n- if (!ibmca_mod_exp(\u0026t, a2, p2, m, ctx))\n- goto end;\n- /* let rr \u003d rr * t mod m */\n- if (!BN_mod_mul(rr, rr, \u0026t, m, ctx))\n- goto end;\n- to_return \u003d 1;\n- end:\n- BN_free(\u0026t);\n- return to_return;\n-}\n-\n-static int ibmca_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx)\n-{\n- return ibmca_mod_exp(r, a, p, m, ctx);\n-}\n-# endif\n-\n-/* This function is aliased to mod_exp (with the mont stuff dropped). */\n-static int ibmca_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx)\n-{\n- return ibmca_mod_exp(r, a, p, m, ctx);\n-}\n-\n-# ifndef OPENSSL_NO_DH\n-/* This function is aliased to mod_exp (with the dh and mont dropped). */\n-static int ibmca_mod_exp_dh(DH const *dh, BIGNUM *r,\n- const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- return ibmca_mod_exp(r, a, p, m, ctx);\n-}\n-# endif\n-\n-/* Random bytes are good */\n-static int ibmca_rand_bytes(unsigned char *buf, int num)\n-{\n- int to_return \u003d 0; /* assume failure */\n- unsigned int ret;\n-\n- if (handle \u003d\u003d 0) {\n- IBMCAerr(IBMCA_F_IBMCA_RAND_BYTES, IBMCA_R_NOT_INITIALISED);\n- goto err;\n- }\n-\n- ret \u003d p_icaRandomNumberGenerate(handle, num, buf);\n- if (ret \u003c 0) {\n- IBMCAerr(IBMCA_F_IBMCA_RAND_BYTES, IBMCA_R_REQUEST_FAILED);\n- goto err;\n- }\n- to_return \u003d 1;\n- err:\n- return to_return;\n-}\n-\n-static int ibmca_rand_status(void)\n-{\n- return 1;\n-}\n-\n-/*\n- * This stuff is needed if this ENGINE is being compiled into a\n- * self-contained shared-library.\n- */\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static int bind_fn(ENGINE *e, const char *id)\n-{\n- if (id \u0026\u0026 (strcmp(id, engine_ibmca_id) !\u003d 0)) /* WJH XXX */\n- return 0;\n- if (!bind_helper(e))\n- return 0;\n- return 1;\n-}\n-\n-IMPLEMENT_DYNAMIC_CHECK_FN()\n- IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)\n-# endif /* ENGINE_DYNAMIC_SUPPORT */\n-# endif /* !OPENSSL_NO_HW_IBMCA */\n-#endif /* !OPENSSL_NO_HW */\ndiff --git a/demos/engines/ibmca/hw_ibmca.ec b/demos/engines/ibmca/hw_ibmca.ec\ndeleted file mode 100644\nindex f68646d..0000000\n--- a/demos/engines/ibmca/hw_ibmca.ec\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-# configuration file for util/mkerr.pl\n-#\n-# use like this:\n-#\n-#\tperl ../../../util/mkerr.pl -conf hw_ibmca.ec \u005c\n-#\t\t-nostatic -staticloader -write *.c\n-\n-L IBMCA\t\thw_ibmca_err.h\t\t\thw_ibmca_err.c\ndiff --git a/demos/engines/ibmca/hw_ibmca_err.c b/demos/engines/ibmca/hw_ibmca_err.c\ndeleted file mode 100644\nindex 5b1911d..0000000\n--- a/demos/engines/ibmca/hw_ibmca_err.c\n+++ /dev/null\n@@ -1,148 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/*\n- * NOTE: this file was auto generated by the mkerr.pl script: any changes\n- * made to it will be overwritten when the script next updates this file,\n- * only reason strings will be preserved.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u0022hw_ibmca_err.h\u0022\n-\n-/* BEGIN ERROR CODES */\n-#ifndef OPENSSL_NO_ERR\n-static ERR_STRING_DATA IBMCA_str_functs[] \u003d {\n- {ERR_PACK(0, IBMCA_F_IBMCA_CTRL, 0), \u0022IBMCA_CTRL\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_FINISH, 0), \u0022IBMCA_FINISH\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_INIT, 0), \u0022IBMCA_INIT\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_MOD_EXP, 0), \u0022IBMCA_MOD_EXP\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_MOD_EXP_CRT, 0), \u0022IBMCA_MOD_EXP_CRT\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_RAND_BYTES, 0), \u0022IBMCA_RAND_BYTES\u0022},\n- {ERR_PACK(0, IBMCA_F_IBMCA_RSA_MOD_EXP, 0), \u0022IBMCA_RSA_MOD_EXP\u0022},\n- {0, NULL}\n-};\n-\n-static ERR_STRING_DATA IBMCA_str_reasons[] \u003d {\n- {IBMCA_R_ALREADY_LOADED, \u0022already loaded\u0022},\n- {IBMCA_R_BN_CTX_FULL, \u0022bn ctx full\u0022},\n- {IBMCA_R_BN_EXPAND_FAIL, \u0022bn expand fail\u0022},\n- {IBMCA_R_CTRL_COMMAND_NOT_IMPLEMENTED, \u0022ctrl command not implemented\u0022},\n- {IBMCA_R_DSO_FAILURE, \u0022dso failure\u0022},\n- {IBMCA_R_MEXP_LENGTH_TO_LARGE, \u0022mexp length to large\u0022},\n- {IBMCA_R_MISSING_KEY_COMPONENTS, \u0022missing key components\u0022},\n- {IBMCA_R_NOT_INITIALISED, \u0022not initialised\u0022},\n- {IBMCA_R_NOT_LOADED, \u0022not loaded\u0022},\n- {IBMCA_R_OPERANDS_TO_LARGE, \u0022operands to large\u0022},\n- {IBMCA_R_OUTLEN_TO_LARGE, \u0022outlen to large\u0022},\n- {IBMCA_R_REQUEST_FAILED, \u0022request failed\u0022},\n- {IBMCA_R_UNDERFLOW_CONDITION, \u0022underflow condition\u0022},\n- {IBMCA_R_UNDERFLOW_KEYRECORD, \u0022underflow keyrecord\u0022},\n- {IBMCA_R_UNIT_FAILURE, \u0022unit failure\u0022},\n- {0, NULL}\n-};\n-\n-#endif\n-\n-#ifdef IBMCA_LIB_NAME\n-static ERR_STRING_DATA IBMCA_lib_name[] \u003d {\n- {0, IBMCA_LIB_NAME},\n- {0, NULL}\n-};\n-#endif\n-\n-static int IBMCA_lib_error_code \u003d 0;\n-static int IBMCA_error_init \u003d 1;\n-\n-static void ERR_load_IBMCA_strings(void)\n-{\n- if (IBMCA_lib_error_code \u003d\u003d 0)\n- IBMCA_lib_error_code \u003d ERR_get_next_error_library();\n-\n- if (IBMCA_error_init) {\n- IBMCA_error_init \u003d 0;\n-#ifndef OPENSSL_NO_ERR\n- ERR_load_strings(IBMCA_lib_error_code, IBMCA_str_functs);\n- ERR_load_strings(IBMCA_lib_error_code, IBMCA_str_reasons);\n-#endif\n-\n-#ifdef IBMCA_LIB_NAME\n- IBMCA_lib_name-\u003eerror \u003d ERR_PACK(IBMCA_lib_error_code, 0, 0);\n- ERR_load_strings(0, IBMCA_lib_name);\n-#endif\n- }\n-}\n-\n-static void ERR_unload_IBMCA_strings(void)\n-{\n- if (IBMCA_error_init \u003d\u003d 0) {\n-#ifndef OPENSSL_NO_ERR\n- ERR_unload_strings(IBMCA_lib_error_code, IBMCA_str_functs);\n- ERR_unload_strings(IBMCA_lib_error_code, IBMCA_str_reasons);\n-#endif\n-\n-#ifdef IBMCA_LIB_NAME\n- ERR_unload_strings(0, IBMCA_lib_name);\n-#endif\n- IBMCA_error_init \u003d 1;\n- }\n-}\n-\n-static void ERR_IBMCA_error(int function, int reason, char *file, int line)\n-{\n- if (IBMCA_lib_error_code \u003d\u003d 0)\n- IBMCA_lib_error_code \u003d ERR_get_next_error_library();\n- ERR_PUT_error(IBMCA_lib_error_code, function, reason, file, line);\n-}\ndiff --git a/demos/engines/ibmca/hw_ibmca_err.h b/demos/engines/ibmca/hw_ibmca_err.h\ndeleted file mode 100644\nindex 10d0212..0000000\n--- a/demos/engines/ibmca/hw_ibmca_err.h\n+++ /dev/null\n@@ -1,103 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@openssl.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.openssl.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-#ifndef HEADER_IBMCA_ERR_H\n-# define HEADER_IBMCA_ERR_H\n-\n-#ifdef __cplusplus\n-extern \u0022C\u0022 {\n-#endif\n-\n-/* BEGIN ERROR CODES */\n-/*\n- * The following lines are auto generated by the script mkerr.pl. Any changes\n- * made after this point may be overwritten when the script is next run.\n- */\n-static void ERR_load_IBMCA_strings(void);\n-static void ERR_unload_IBMCA_strings(void);\n-static void ERR_IBMCA_error(int function, int reason, char *file, int line);\n-# define IBMCAerr(f,r) ERR_IBMCA_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)\n-\n-/* Error codes for the IBMCA functions. */\n-\n-/* Function codes. */\n-# define IBMCA_F_IBMCA_CTRL 100\n-# define IBMCA_F_IBMCA_FINISH 101\n-# define IBMCA_F_IBMCA_INIT 102\n-# define IBMCA_F_IBMCA_MOD_EXP 103\n-# define IBMCA_F_IBMCA_MOD_EXP_CRT 104\n-# define IBMCA_F_IBMCA_RAND_BYTES 105\n-# define IBMCA_F_IBMCA_RSA_MOD_EXP 106\n-\n-/* Reason codes. */\n-# define IBMCA_R_ALREADY_LOADED 100\n-# define IBMCA_R_BN_CTX_FULL 101\n-# define IBMCA_R_BN_EXPAND_FAIL 102\n-# define IBMCA_R_CTRL_COMMAND_NOT_IMPLEMENTED 103\n-# define IBMCA_R_DSO_FAILURE 104\n-# define IBMCA_R_MEXP_LENGTH_TO_LARGE 105\n-# define IBMCA_R_MISSING_KEY_COMPONENTS 106\n-# define IBMCA_R_NOT_INITIALISED 107\n-# define IBMCA_R_NOT_LOADED 108\n-# define IBMCA_R_OPERANDS_TO_LARGE 109\n-# define IBMCA_R_OUTLEN_TO_LARGE 110\n-# define IBMCA_R_REQUEST_FAILED 111\n-# define IBMCA_R_UNDERFLOW_CONDITION 112\n-# define IBMCA_R_UNDERFLOW_KEYRECORD 113\n-# define IBMCA_R_UNIT_FAILURE 114\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-#endif\ndiff --git a/demos/engines/ibmca/ica_openssl_api.h b/demos/engines/ibmca/ica_openssl_api.h\ndeleted file mode 100644\nindex 715bb92..0000000\n--- a/demos/engines/ibmca/ica_openssl_api.h\n+++ /dev/null\n@@ -1,183 +0,0 @@\n-\n-#ifndef __ICA_OPENSSL_API_H__\n-# define __ICA_OPENSSL_API_H__\n-\n-/**\n- ** abstract data types for API\n- **/\n-\n-# define ICA_ADAPTER_HANDLE int\n-\n-# if defined(linux) || defined (_AIX)\n-# define ICA_CALL\n-# endif\n-\n-# if defined(WIN32) || defined(_WIN32)\n-# define ICA_CALL __stdcall\n-# endif\n-\n-/* -----------------------------------------------*\n- | RSA defines and typedefs |\n- *------------------------------------------------*/\n- /*\n- * All data elements of the RSA key are in big-endian format\n- * Modulus-Exponent form of key\n- *\n- */\n-# define MAX_EXP_SIZE 256\n-# define MAX_MODULUS_SIZE 256\n-# define MAX_MODEXP_SIZE (MAX_EXP_SIZE + MAX_MODULUS_SIZE)\n-\n-# define MAX_OPERAND_SIZE MAX_EXP_SIZE\n-\n-typedef unsigned char ICA_KEY_RSA_MODEXPO_REC[MAX_MODEXP_SIZE];\n- /*\n- * All data elements of the RSA key are in big-endian format\n- * Chinese Remainder Thereom(CRT) form of key\n- * Used only for Decrypt, the encrypt form is typically Modulus-Exponent\n- *\n- */\n-# define MAX_BP_SIZE 136\n-# define MAX_BQ_SIZE 128\n-# define MAX_NP_SIZE 136\n-# define MAX_NQ_SIZE 128\n-# define MAX_QINV_SIZE 136\n-# define MAX_RSACRT_SIZE (MAX_BP_SIZE+MAX_BQ_SIZE+MAX_NP_SIZE+MAX_NQ_SIZE+MAX_QINV_SIZE)\n-\n-# define RSA_GEN_OPERAND_MAX 256/* bytes */\n-\n-typedef unsigned char ICA_KEY_RSA_CRT_REC[MAX_RSACRT_SIZE];\n-/* -----------------------------------------------*\n- | RSA key token types |\n- *------------------------------------------------*/\n-\n-# define RSA_PUBLIC_MODULUS_EXPONENT 3\n-# define RSA_PKCS_PRIVATE_CHINESE_REMAINDER 6\n-\n-# define KEYTYPE_MODEXPO 1\n-# define KEYTYPE_PKCSCRT 2\n-\n-/* -----------------------------------------------*\n- | RSA Key Token format |\n- *------------------------------------------------*/\n-\n-/*-\n- * NOTE: All the fields in the ICA_KEY_RSA_MODEXPO structure\n- * (lengths, offsets, exponents, modulus, etc.) are\n- * stored in big-endian format\n- */\n-\n-typedef struct _ICA_KEY_RSA_MODEXPO {\n- unsigned int keyType; /* RSA key type. */\n- unsigned int keyLength; /* Total length of the token. */\n- unsigned int modulusBitLength; /* Modulus n bit length. */\n- /* -- Start of the data length. */\n- unsigned int nLength; /* Modulus n \u003d p * q */\n- unsigned int expLength; /* exponent (public or private) */\n- /* e \u003d 1/d * mod(p-1)(q-1) */\n- /* -- Start of the data offsets */\n- unsigned int nOffset; /* Modulus n . */\n- unsigned int expOffset; /* exponent (public or private) */\n- unsigned char reserved[112]; /* reserved area */\n- /* -- Start of the variable -- */\n- /* -- length token data. -- */\n- ICA_KEY_RSA_MODEXPO_REC keyRecord;\n-} ICA_KEY_RSA_MODEXPO;\n-# define SZ_HEADER_MODEXPO (sizeof(ICA_KEY_RSA_MODEXPO) - sizeof(ICA_KEY_RSA_MODEXPO_REC))\n-\n-/*-\n- * NOTE: All the fields in the ICA_KEY_RSA_CRT structure\n- * (lengths, offsets, exponents, modulus, etc.) are\n- * stored in big-endian format\n- */\n-\n-typedef struct _ICA_KEY_RSA_CRT {\n- unsigned int keyType; /* RSA key type. */\n- unsigned int keyLength; /* Total length of the token. */\n- unsigned int modulusBitLength; /* Modulus n bit length. */\n- /* -- Start of the data length. */\n-# if _AIX\n- unsigned int nLength; /* Modulus n \u003d p * q */\n-# endif\n- unsigned int pLength; /* Prime number p . */\n- unsigned int qLength; /* Prime number q . */\n- unsigned int dpLength; /* dp \u003d d * mod(p-1) . */\n- unsigned int dqLength; /* dq \u003d d * mod(q-1) . */\n- unsigned int qInvLength; /* PKCS: qInv \u003d Ap/q */\n- /* -- Start of the data offsets */\n-# if _AIX\n- unsigned int nOffset; /* Modulus n . */\n-# endif\n- unsigned int pOffset; /* Prime number p . */\n- unsigned int qOffset; /* Prime number q . */\n- unsigned int dpOffset; /* dp . */\n- unsigned int dqOffset; /* dq . */\n- unsigned int qInvOffset; /* qInv for PKCS */\n-# if _AIX\n- unsigned char reserved[80]; /* reserved area */\n-# else\n- unsigned char reserved[88]; /* reserved area */\n-# endif\n- /* -- Start of the variable -- */\n- /* -- length token data. -- */\n- ICA_KEY_RSA_CRT_REC keyRecord;\n-} ICA_KEY_RSA_CRT;\n-# define SZ_HEADER_CRT (sizeof(ICA_KEY_RSA_CRT) - sizeof(ICA_KEY_RSA_CRT_REC))\n-\n-unsigned int\n-icaOpenAdapter(unsigned int adapterId, ICA_ADAPTER_HANDLE * pAdapterHandle);\n-\n-unsigned int icaCloseAdapter(ICA_ADAPTER_HANDLE adapterHandle);\n-\n-unsigned int\n-icaRsaModExpo(ICA_ADAPTER_HANDLE hAdapterHandle,\n- unsigned int inputDataLength,\n- unsigned char *pInputData,\n- ICA_KEY_RSA_MODEXPO *pKeyModExpo,\n- unsigned int *pOutputDataLength, unsigned char *pOutputData);\n-\n-unsigned int\n-icaRsaCrt(ICA_ADAPTER_HANDLE hAdapterHandle,\n- unsigned int inputDataLength,\n- unsigned char *pInputData,\n- ICA_KEY_RSA_CRT *pKeyCrt,\n- unsigned int *pOutputDataLength, unsigned char *pOutputData);\n-\n-unsigned int\n-icaRandomNumberGenerate(ICA_ADAPTER_HANDLE hAdapterHandle,\n- unsigned int outputDataLength,\n- unsigned char *pOutputData);\n-\n-/*\n- * Specific macros and definitions to not have IFDEF;s all over the main code\n- */\n-\n-# if (_AIX)\n-static const char *IBMCA_LIBNAME \u003d \u0022/lib/libica.a(shr.o)\u0022;\n-# elif (WIN32)\n-static const char *IBMCA_LIBNAME \u003d \u0022cryptica\u0022;\n-# else\n-static const char *IBMCA_LIBNAME \u003d \u0022ica\u0022;\n-# endif\n-\n-# if (WIN32)\n-/*\n- * The ICA_KEY_RSA_MODEXPO \u0026 ICA_KEY_RSA_CRT lengths and offsets must be in\n- * big-endian format.\n- *\n- */\n-# define CORRECT_ENDIANNESS(b) ( \u005c\n- (((unsigned long) (b) \u0026 0x000000ff) \u003c\u003c 24) | \u005c\n- (((unsigned long) (b) \u0026 0x0000ff00) \u003c\u003c 8) | \u005c\n- (((unsigned long) (b) \u0026 0x00ff0000) \u003e\u003e 8) | \u005c\n- (((unsigned long) (b) \u0026 0xff000000) \u003e\u003e 24) \u005c\n- )\n-# define CRT_KEY_TYPE RSA_PKCS_PRIVATE_CHINESE_REMAINDER\n-# define ME_KEY_TYPE RSA_PUBLIC_MODULUS_EXPONENT\n-# else\n-# define CORRECT_ENDIANNESS(b) (b)\n-# define CRT_KEY_TYPE KEYTYPE_PKCSCRT\n-# define ME_KEY_TYPE KEYTYPE_MODEXPO\n-# endif\n-\n-#endif /* __ICA_OPENSSL_API_H__ */\ndiff --git a/demos/engines/rsaref/Makefile.in b/demos/engines/rsaref/Makefile.in\ndeleted file mode 100644\nindex fea17a4..0000000\n--- a/demos/engines/rsaref/Makefile.in\n+++ /dev/null\n@@ -1,114 +0,0 @@\n-LIBNAME\u003d\tlibrsaref\n-SRC\u003d\t\trsaref.c\n-OBJ\u003d\t\trsaref.o\n-HEADER\u003d\t\trsaref.h\n-\n-CC\u003d\t\tgcc\n-PIC\u003d\t\t-fPIC\n-CFLAGS\u003d\t\t-g -I../../../include $(PIC) -DENGINE_DYNAMIC_SUPPORT\n-AR\u003d\t\tar r\n-RANLIB\u003d\t\tranlib\n-\n-LIB\u003d\t\t$(LIBNAME).a\n-SHLIB\u003d\t\t$(LIBNAME).so\n-\n-all:\n-\t\t@echo 'Please choose a system to build on:'\n-\t\t@echo ''\n-\t\t@echo 'tru64: Tru64 Unix, Digital Unix, Digital OSF/1'\n-\t\t@echo 'solaris: Solaris'\n-\t\t@echo 'irix: IRIX'\n-\t\t@echo 'hpux32: 32-bit HP/UX'\n-\t\t@echo 'hpux64: 64-bit HP/UX'\n-\t\t@echo 'aix: AIX'\n-\t\t@echo 'gnu: Generic GNU-based system (gcc and GNU ld)'\n-\t\t@echo ''\n-\n-FORCE.install:\n-install:\tFORCE.install\n-\t\tcd install; \u005c\n-\t\t\tmake -f unix/makefile CFLAGS\u003d'-I. -DPROTOTYPES\u003d1 -O -c' RSAREFLIB\u003dlibrsaref.a librsaref.a\n-\n-generate:\n-\t\tperl ../../../util/mkerr.pl -conf rsaref.ec \u005c\n-\t\t\t-nostatic -staticloader -write rsaref.c\n-\n-darwin:\t\tinstall $(SHLIB).darwin\n-cygwin:\t\tinstall $(SHLIB).cygwin\n-gnu:\t\tinstall $(SHLIB).gnu\n-alpha-osf1:\tinstall $(SHLIB).alpha-osf1\n-tru64:\t\tinstall $(SHLIB).tru64\n-solaris:\tinstall $(SHLIB).solaris\n-irix:\t\tinstall $(SHLIB).irix\n-hpux32:\t\tinstall $(SHLIB).hpux32\n-hpux64:\t\tinstall $(SHLIB).hpux64\n-aix:\t\tinstall $(SHLIB).aix\n-reliantunix:\tinstall $(SHLIB).reliantunix\n-\n-$(LIB):\t\t$(OBJ)\n-\t\t$(AR) $(LIB) $(OBJ)\n-\t\t- $(RANLIB) $(LIB)\n-\n-LINK_SO\u003d\t\u005c\n- ld -r -o $(LIBNAME).o $$ALLSYMSFLAGS $(LIB) install/librsaref.a \u0026\u0026 \u005c\n- (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' \u003e $(LIBNAME).exp; \u005c\n- $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc)\n-\n-$(SHLIB).darwin:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-all_load' \u005c\n-\t\tSHAREDFLAGS\u003d'-dynamiclib -install_name $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).darwin\n-$(SHLIB).cygwin:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'--whole-archive' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-Bsymbolic -Wl,--out-implib,$(LIBNAME).dll.a' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).cygwin\n-$(SHLIB).gnu:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'--whole-archive' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname\u003d$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).gnu\n-$(SHLIB).tru64:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).tru64\n-$(SHLIB).solaris:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-z allextract' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).solaris\n-$(SHLIB).irix:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname,$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).irix\n-$(SHLIB).hpux32:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-Fl' \u005c\n-\t\tSHAREDFLAGS\u003d'+vnocompatwarnings -b -z +s +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux32\n-$(SHLIB).hpux64:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'+forceload' \u005c\n-\t\tSHAREDFLAGS\u003d'-b -z +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux64\n-$(SHLIB).aix:\t$(LIB) install/librsaref.a\n-\t\tALLSYMSFLAGS\u003d'-bnogc' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -bE:$(LIBNAME).exp -bM:SRE' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).aix\n-\n-depend:\n-\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/engines/rsaref/README b/demos/engines/rsaref/README\ndeleted file mode 100644\nindex 00b1f74..0000000\n--- a/demos/engines/rsaref/README\n+++ /dev/null\n@@ -1,22 +0,0 @@\n-librsaref.so is a demonstration dynamic engine that does RSA\n-operations using the old RSAref 2.0 implementation.\n-\n-To make proper use of this engine, you must download RSAref 2.0\n-(search the web for rsaref.tar.Z for example) and unpack it in this\n-directory, so you'll end up having the subdirectories \u0022install\u0022 and\n-\u0022source\u0022 among others.\n-\n-To build, do the following:\n-\n-\tmake\n-\n-This will list a number of available targets to choose from. Most of\n-them are architecture-specific. The exception is \u0022gnu\u0022 which is to be\n-used on systems where GNU ld and gcc have been installed in such a way\n-that gcc uses GNU ld to link together programs and shared libraries.\n-\n-The make file assumes you use gcc. To change that, just reassign CC:\n-\n-\tmake CC\u003dcc\n-\n-The result is librsaref.so, which you can copy to any place you wish.\ndiff --git a/demos/engines/rsaref/build.com b/demos/engines/rsaref/build.com\ndeleted file mode 100644\nindex 72b013d..0000000\n--- a/demos/engines/rsaref/build.com\n+++ /dev/null\n@@ -1,105 +0,0 @@\n-$! BUILD.COM -- Building procedure for the RSAref engine\n-$\n-$\tif f$search(\u0022source.dir\u0022) .eqs. \u0022\u0022 -\n-\t .or. f$search(\u0022install.dir\u0022) .eqs. \u0022\u0022\n-$\tthen\n-$\t write sys$error \u0022RSAref 2.0 hasn't been properly extracted.\u0022\n-$\t exit\n-$\tendif\n-$\n-$\tif (f$getsyi(\u0022cpu\u0022).lt.128)\n-$\tthen\n-$\t arch :\u003d vax\n-$\telse\n-$\t arch \u003d f$edit( f$getsyi( \u0022ARCH_NAME\u0022), \u0022UPCASE\u0022)\n-$\t if (arch .eqs. \u0022\u0022) then arch \u003d \u0022UNK\u0022\n-$\tendif\n-$\n-$\t_save_default \u003d f$environment(\u0022default\u0022)\n-$\tset default [.install]\n-$\tfiles :\u003d desc,digit,md2c,md5c,nn,prime,-\n-\t\trsa,r_encode,r_dh,r_enhanc,r_keygen,r_random,-\n-\t\tr_stdlib\n-$\tdelete rsaref.olb;*\n-$\tlibrary/create/object rsaref.olb\n-$\tfiles_i \u003d 0\n-$ rsaref_loop:\n-$\tfiles_e \u003d f$edit(f$element(files_i,\u0022,\u0022,files),\u0022trim\u0022)\n-$\tfiles_i \u003d files_i + 1\n-$\tif files_e .eqs. \u0022,\u0022 then goto rsaref_loop_end\n-$\tcc/include\u003d([-.source],[])/define\u003dPROTOTYPES\u003d1/object\u003d[]'files_e'.obj -\n-\t\t[-.source]'files_e'.c\n-$\tlibrary/replace/object rsaref.olb 'files_e'.obj\n-$\tgoto rsaref_loop\n-$ rsaref_loop_end:\n-$\n-$\tset default [-]\n-$\tdefine/user openssl [---.include.openssl]\n-$\tcc/define\u003dENGINE_DYNAMIC_SUPPORT rsaref.c\n-$\n-$\tif arch .eqs. \u0022VAX\u0022\n-$\tthen\n-$\t macro/object\u003drsaref_vec.obj sys$input:\n-;\n-; Transfer vector for VAX shareable image\n-;\n-\t.TITLE librsaref\n-;\n-; Define macro to assist in building transfer vector entries. Each entry\n-; should take no more than 8 bytes.\n-;\n-\t.MACRO FTRANSFER_ENTRY routine\n-\t.ALIGN QUAD\n-\t.TRANSFER routine\n-\t.MASK\troutine\n-\tJMP\troutine+2\n-\t.ENDM FTRANSFER_ENTRY\n-;\n-; Place entries in own program section.\n-;\n-\t.PSECT $$LIBRSAREF,QUAD,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT\n-\n-LIBRSAREF_xfer:\n-\tFTRANSFER_ENTRY bind_engine\n-\tFTRANSFER_ENTRY v_check\n-\n-;\n-; Allocate extra storage at end of vector to allow for expansion.\n-;\n-\t.BLKB 512-\u003c.-LIBRSAREF_xfer\u003e\t; 1 page.\n-\t.END\n-$\t link/share\u003dlibrsaref.exe sys$input:/option\n-!\n-! Ensure transfer vector is at beginning of image\n-!\n-CLUSTER\u003dFIRST\n-COLLECT\u003dFIRST,$$LIBRSAREF\n-!\n-! make psects nonshareable so image can be installed.\n-!\n-PSECT_ATTR\u003d$CHAR_STRING_CONSTANTS,NOWRT\n-[]rsaref_vec.obj\n-[]rsaref.obj\n-[.install]rsaref.olb/lib\n-[---.vax.exe.crypto]libcrypto.olb/lib\n-$\telse\n-$\t if arch_name .eqs. \u0022ALPHA\u0022\n-$\t then\n-$\t\tlink/share\u003dlibrsaref.exe sys$input:/option\n-[]rsaref.obj\n-[.install]rsaref.olb/lib\n-[---.alpha.exe.crypto]libcrypto.olb/lib\n-symbol_vector\u003d(bind_engine\u003dprocedure,v_check\u003dprocedure)\n-$\t else\n-$\t\tif arch_name .eqs. \u0022IA64\u0022\n-$\t\tthen\n-$\t\t link /shareable\u003dlibrsaref.exe sys$input: /options\n-[]rsaref.obj\n-[.install]rsaref.olb/lib\n-[---.ia64.exe.crypto]libcrypto.olb/lib\n-symbol_vector\u003d(bind_engine\u003dprocedure,v_check\u003dprocedure)\n-$\t\tendif\n-$\t endif\n-$\tendif\n-$\n-$\tset default '_save_default'\ndiff --git a/demos/engines/rsaref/rsaref.c b/demos/engines/rsaref/rsaref.c\ndeleted file mode 100644\nindex d5a6e6c..0000000\n--- a/demos/engines/rsaref/rsaref.c\n+++ /dev/null\n@@ -1,658 +0,0 @@\n-/*\n- * Demo of how to construct your own engine and using it. The basis of this\n- * engine is RSAref, an old reference of the RSA algorithm which can still be\n- * found a little here and there.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u0022./source/global.h\u0022\n-#include \u0022./source/rsaref.h\u0022\n-#include \u0022./source/rsa.h\u0022\n-#include \u0022./source/des.h\u0022\n-#include \u003copenssl/err.h\u003e\n-#define OPENSSL_NO_MD2\n-#define OPENSSL_NO_MD5\n-#include \u003copenssl/evp.h\u003e\n-#include \u003copenssl/bn.h\u003e\n-#include \u003copenssl/engine.h\u003e\n-\n-#define RSAREF_LIB_NAME \u0022rsaref engine\u0022\n-#include \u0022rsaref_err.c\u0022\n-\n-/*****************************************************************************\n- *** Function declarations and global variable definitions ***\n- *****************************************************************************/\n-\n-/*****************************************************************************\n- * Constants used when creating the ENGINE\n- **/\n-static const char *engine_rsaref_id \u003d \u0022rsaref\u0022;\n-static const char *engine_rsaref_name \u003d \u0022RSAref engine support\u0022;\n-\n-/*****************************************************************************\n- * Functions to handle the engine\n- **/\n-static int rsaref_destroy(ENGINE *e);\n-static int rsaref_init(ENGINE *e);\n-static int rsaref_finish(ENGINE *e);\n-\n-/*****************************************************************************\n- * Engine commands\n- **/\n-static const ENGINE_CMD_DEFN rsaref_cmd_defns[] \u003d {\n- {0, NULL, NULL, 0}\n-};\n-\n-/*****************************************************************************\n- * RSA functions\n- **/\n-static int rsaref_private_decrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int rsaref_private_encrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int rsaref_public_encrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int rsaref_public_decrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding);\n-static int bnref_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-static int rsaref_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);\n-\n-/*****************************************************************************\n- * Our RSA method\n- **/\n-static RSA_METHOD rsaref_rsa \u003d {\n- \u0022RSAref PKCS#1 RSA\u0022,\n- rsaref_public_encrypt,\n- rsaref_public_decrypt,\n- rsaref_private_encrypt,\n- rsaref_private_decrypt,\n- rsaref_mod_exp,\n- bnref_mod_exp,\n- NULL,\n- NULL,\n- 0,\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-/*****************************************************************************\n- * Symetric cipher and digest function registrars\n- **/\n-static int rsaref_ciphers(ENGINE *e, const EVP_CIPHER **cipher,\n- const int **nids, int nid);\n-static int rsaref_digests(ENGINE *e, const EVP_MD **digest,\n- const int **nids, int nid);\n-\n-static int rsaref_cipher_nids[] \u003d\n- { NID_des_cbc, NID_des_ede3_cbc, NID_desx_cbc, 0 };\n-static int rsaref_digest_nids[] \u003d { NID_md2, NID_md5, 0 };\n-\n-/*****************************************************************************\n- * DES functions\n- **/\n-static int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl);\n-static int cipher_des_cbc_clean(EVP_CIPHER_CTX *);\n-static int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx,\n- const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in,\n- unsigned int inl);\n-static int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *);\n-static int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl);\n-static int cipher_desx_cbc_clean(EVP_CIPHER_CTX *);\n-\n-/*****************************************************************************\n- * Our DES ciphers\n- **/\n-static const EVP_CIPHER cipher_des_cbc \u003d {\n- NID_des_cbc,\n- 8, 8, 8,\n- 0 | EVP_CIPH_CBC_MODE,\n- cipher_des_cbc_init,\n- cipher_des_cbc_code,\n- cipher_des_cbc_clean,\n- sizeof(DES_CBC_CTX),\n- NULL,\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-static const EVP_CIPHER cipher_des_ede3_cbc \u003d {\n- NID_des_ede3_cbc,\n- 8, 24, 8,\n- 0 | EVP_CIPH_CBC_MODE,\n- cipher_des_ede3_cbc_init,\n- cipher_des_ede3_cbc_code,\n- cipher_des_ede3_cbc_clean,\n- sizeof(DES3_CBC_CTX),\n- NULL,\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-static const EVP_CIPHER cipher_desx_cbc \u003d {\n- NID_desx_cbc,\n- 8, 24, 8,\n- 0 | EVP_CIPH_CBC_MODE,\n- cipher_desx_cbc_init,\n- cipher_desx_cbc_code,\n- cipher_desx_cbc_clean,\n- sizeof(DESX_CBC_CTX),\n- NULL,\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-/*****************************************************************************\n- * MD functions\n- **/\n-static int digest_md2_init(EVP_MD_CTX *ctx);\n-static int digest_md2_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count);\n-static int digest_md2_final(EVP_MD_CTX *ctx, unsigned char *md);\n-static int digest_md5_init(EVP_MD_CTX *ctx);\n-static int digest_md5_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count);\n-static int digest_md5_final(EVP_MD_CTX *ctx, unsigned char *md);\n-\n-/*****************************************************************************\n- * Our MD digests\n- **/\n-static const EVP_MD digest_md2 \u003d {\n- NID_md2,\n- NID_md2WithRSAEncryption,\n- 16,\n- 0,\n- digest_md2_init,\n- digest_md2_update,\n- digest_md2_final,\n- NULL,\n- NULL,\n- EVP_PKEY_RSA_method,\n- 16,\n- sizeof(MD2_CTX)\n-};\n-\n-static const EVP_MD digest_md5 \u003d {\n- NID_md5,\n- NID_md5WithRSAEncryption,\n- 16,\n- 0,\n- digest_md5_init,\n- digest_md5_update,\n- digest_md5_final,\n- NULL,\n- NULL,\n- EVP_PKEY_RSA_method,\n- 64,\n- sizeof(MD5_CTX)\n-};\n-\n-/*****************************************************************************\n- *** Function definitions ***\n- *****************************************************************************/\n-\n-/*****************************************************************************\n- * Functions to handle the engine\n- **/\n-\n-static int bind_rsaref(ENGINE *e)\n-{\n- const RSA_METHOD *meth1;\n- if (!ENGINE_set_id(e, engine_rsaref_id)\n- || !ENGINE_set_name(e, engine_rsaref_name)\n- || !ENGINE_set_RSA(e, \u0026rsaref_rsa)\n- || !ENGINE_set_ciphers(e, rsaref_ciphers)\n- || !ENGINE_set_digests(e, rsaref_digests)\n- || !ENGINE_set_destroy_function(e, rsaref_destroy)\n- || !ENGINE_set_init_function(e, rsaref_init)\n- || !ENGINE_set_finish_function(e, rsaref_finish)\n- /* || !ENGINE_set_ctrl_function(e, rsaref_ctrl) */\n- /*\n- * || !ENGINE_set_cmd_defns(e, rsaref_cmd_defns)\n- */ )\n- return 0;\n-\n- /* Ensure the rsaref error handling is set up */\n- ERR_load_RSAREF_strings();\n- return 1;\n-}\n-\n-#ifdef ENGINE_DYNAMIC_SUPPORT\n-static int bind_helper(ENGINE *e, const char *id)\n-{\n- if (id \u0026\u0026 (strcmp(id, engine_rsaref_id) !\u003d 0))\n- return 0;\n- if (!bind_rsaref(e))\n- return 0;\n- return 1;\n-}\n-\n-IMPLEMENT_DYNAMIC_CHECK_FN()\n- IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)\n-#else\n-static ENGINE *engine_rsaref(void)\n-{\n- ENGINE *ret \u003d ENGINE_new();\n- if (!ret)\n- return NULL;\n- if (!bind_rsaref(ret)) {\n- ENGINE_free(ret);\n- return NULL;\n- }\n- return ret;\n-}\n-\n-void ENGINE_load_rsaref(void)\n-{\n- /* Copied from eng_[openssl|dyn].c */\n- ENGINE *toadd \u003d engine_rsaref();\n- if (!toadd)\n- return;\n- ENGINE_add(toadd);\n- ENGINE_free(toadd);\n- ERR_clear_error();\n-}\n-#endif\n-\n-/* Initiator which is only present to make sure this engine looks available */\n-static int rsaref_init(ENGINE *e)\n-{\n- return 1;\n-}\n-\n-/* Finisher which is only present to make sure this engine looks available */\n-static int rsaref_finish(ENGINE *e)\n-{\n- return 1;\n-}\n-\n-/* Destructor (complements the \u0022ENGINE_ncipher()\u0022 constructor) */\n-static int rsaref_destroy(ENGINE *e)\n-{\n- ERR_unload_RSAREF_strings();\n- return 1;\n-}\n-\n-/*****************************************************************************\n- * RSA functions\n- **/\n-\n-static int rsaref_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)\n-{\n- RSAREFerr(RSAREF_F_RSAREF_MOD_EXP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n- return (0);\n-}\n-\n-static int bnref_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- RSAREFerr(RSAREF_F_BNREF_MOD_EXP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n- return (0);\n-}\n-\n-/* unsigned char *to: [max] */\n-static int RSAref_bn2bin(BIGNUM *from, unsigned char *to, int max)\n-{\n- int i;\n-\n- i \u003d BN_num_bytes(from);\n- if (i \u003e max) {\n- RSAREFerr(RSAREF_F_RSAREF_BN2BIN, RSAREF_R_LEN);\n- return (0);\n- }\n-\n- memset(to, 0, (unsigned int)max);\n- if (!BN_bn2bin(from, \u0026(to[max - i])))\n- return (0);\n- return (1);\n-}\n-\n-static int RSAref_Public_eay2ref(RSA *from, R_RSA_PUBLIC_KEY * to)\n-{\n- to-\u003ebits \u003d BN_num_bits(from-\u003en);\n- if (!RSAref_bn2bin(from-\u003en, to-\u003emodulus, MAX_RSA_MODULUS_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003ee, to-\u003eexponent, MAX_RSA_MODULUS_LEN))\n- return (0);\n- return (1);\n-}\n-\n-static int RSAref_Private_eay2ref(RSA *from, R_RSA_PRIVATE_KEY * to)\n-{\n- to-\u003ebits \u003d BN_num_bits(from-\u003en);\n- if (!RSAref_bn2bin(from-\u003en, to-\u003emodulus, MAX_RSA_MODULUS_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003ee, to-\u003epublicExponent, MAX_RSA_MODULUS_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003ed, to-\u003eexponent, MAX_RSA_MODULUS_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003ep, to-\u003eprime[0], MAX_RSA_PRIME_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003eq, to-\u003eprime[1], MAX_RSA_PRIME_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003edmp1, to-\u003eprimeExponent[0], MAX_RSA_PRIME_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003edmq1, to-\u003eprimeExponent[1], MAX_RSA_PRIME_LEN))\n- return (0);\n- if (!RSAref_bn2bin(from-\u003eiqmp, to-\u003ecoefficient, MAX_RSA_PRIME_LEN))\n- return (0);\n- return (1);\n-}\n-\n-static int rsaref_private_decrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n- int i, outlen \u003d -1;\n- R_RSA_PRIVATE_KEY RSAkey;\n-\n- if (!RSAref_Private_eay2ref(rsa, \u0026RSAkey))\n- goto err;\n- if ((i \u003d\n- RSAPrivateDecrypt(to, (unsigned int *)\u0026outlen, (unsigned char *)from,\n- len, \u0026RSAkey)) !\u003d 0) {\n- RSAREFerr(RSAREF_F_RSAREF_PRIVATE_DECRYPT, i);\n- outlen \u003d -1;\n- }\n- err:\n- memset(\u0026RSAkey, 0, sizeof(RSAkey));\n- return (outlen);\n-}\n-\n-static int rsaref_private_encrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n- int i, outlen \u003d -1;\n- R_RSA_PRIVATE_KEY RSAkey;\n-\n- if (padding !\u003d RSA_PKCS1_PADDING) {\n- RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT,\n- RSA_R_UNKNOWN_PADDING_TYPE);\n- goto err;\n- }\n- if (!RSAref_Private_eay2ref(rsa, \u0026RSAkey))\n- goto err;\n- if ((i \u003d\n- RSAPrivateEncrypt(to, (unsigned int *)\u0026outlen, (unsigned char *)from,\n- len, \u0026RSAkey)) !\u003d 0) {\n- RSAREFerr(RSAREF_F_RSAREF_PRIVATE_ENCRYPT, i);\n- outlen \u003d -1;\n- }\n- err:\n- memset(\u0026RSAkey, 0, sizeof(RSAkey));\n- return (outlen);\n-}\n-\n-static int rsaref_public_decrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n- int i, outlen \u003d -1;\n- R_RSA_PUBLIC_KEY RSAkey;\n-\n- if (!RSAref_Public_eay2ref(rsa, \u0026RSAkey))\n- goto err;\n- if ((i \u003d\n- RSAPublicDecrypt(to, (unsigned int *)\u0026outlen, (unsigned char *)from,\n- len, \u0026RSAkey)) !\u003d 0) {\n- RSAREFerr(RSAREF_F_RSAREF_PUBLIC_DECRYPT, i);\n- outlen \u003d -1;\n- }\n- err:\n- memset(\u0026RSAkey, 0, sizeof(RSAkey));\n- return (outlen);\n-}\n-\n-static int rsaref_public_encrypt(int len, const unsigned char *from,\n- unsigned char *to, RSA *rsa, int padding)\n-{\n- int outlen \u003d -1;\n- int i;\n- R_RSA_PUBLIC_KEY RSAkey;\n- R_RANDOM_STRUCT rnd;\n- unsigned char buf[16];\n-\n- if (padding !\u003d RSA_PKCS1_PADDING \u0026\u0026 padding !\u003d RSA_SSLV23_PADDING) {\n- RSAREFerr(RSAREF_F_RSAREF_PUBLIC_ENCRYPT, RSA_R_UNKNOWN_PADDING_TYPE);\n- goto err;\n- }\n-\n- R_RandomInit(\u0026rnd);\n- R_GetRandomBytesNeeded((unsigned int *)\u0026i, \u0026rnd);\n- while (i \u003e 0) {\n- if (RAND_bytes(buf, 16) \u003c\u003d 0)\n- goto err;\n- R_RandomUpdate(\u0026rnd, buf, (unsigned int)((i \u003e 16) ? 16 : i));\n- i -\u003d 16;\n- }\n-\n- if (!RSAref_Public_eay2ref(rsa, \u0026RSAkey))\n- goto err;\n- if ((i \u003d\n- RSAPublicEncrypt(to, (unsigned int *)\u0026outlen, (unsigned char *)from,\n- len, \u0026RSAkey, \u0026rnd)) !\u003d 0) {\n- RSAREFerr(RSAREF_F_RSAREF_PUBLIC_ENCRYPT, i);\n- outlen \u003d -1;\n- goto err;\n- }\n- err:\n- memset(\u0026RSAkey, 0, sizeof(RSAkey));\n- R_RandomFinal(\u0026rnd);\n- memset(\u0026rnd, 0, sizeof(rnd));\n- return (outlen);\n-}\n-\n-/*****************************************************************************\n- * Symetric cipher and digest function registrars\n- **/\n-static int rsaref_ciphers(ENGINE *e, const EVP_CIPHER **cipher,\n- const int **nids, int nid)\n-{\n- int ok \u003d 1;\n- if (!cipher) {\n- /* We are returning a list of supported nids */\n- *nids \u003d rsaref_cipher_nids;\n- return (sizeof(rsaref_cipher_nids) -\n- 1) / sizeof(rsaref_cipher_nids[0]);\n- }\n- /* We are being asked for a specific cipher */\n- switch (nid) {\n- case NID_des_cbc:\n- *cipher \u003d \u0026cipher_des_cbc;\n- break;\n- case NID_des_ede3_cbc:\n- *cipher \u003d \u0026cipher_des_ede3_cbc;\n- break;\n- case NID_desx_cbc:\n- *cipher \u003d \u0026cipher_desx_cbc;\n- break;\n- default:\n- ok \u003d 0;\n- *cipher \u003d NULL;\n- break;\n- }\n- return ok;\n-}\n-\n-static int rsaref_digests(ENGINE *e, const EVP_MD **digest,\n- const int **nids, int nid)\n-{\n- int ok \u003d 1;\n- if (!digest) {\n- /* We are returning a list of supported nids */\n- *nids \u003d rsaref_digest_nids;\n- return (sizeof(rsaref_digest_nids) -\n- 1) / sizeof(rsaref_digest_nids[0]);\n- }\n- /* We are being asked for a specific digest */\n- switch (nid) {\n- case NID_md2:\n- *digest \u003d \u0026digest_md2;\n- break;\n- case NID_md5:\n- *digest \u003d \u0026digest_md5;\n- break;\n- default:\n- ok \u003d 0;\n- *digest \u003d NULL;\n- break;\n- }\n- return ok;\n-}\n-\n-/*****************************************************************************\n- * DES functions\n- **/\n-#undef data\n-#define data(ctx) ((DES_CBC_CTX *)(ctx)-\u003ecipher_data)\n-static int cipher_des_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n- DES_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, enc);\n- return 1;\n-}\n-\n-static int cipher_des_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl)\n-{\n- int ret \u003d DES_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);\n- switch (ret) {\n- case RE_LEN:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE,\n- RSAREF_R_LENGTH_NOT_BLOCK_ALIGNED);\n- break;\n- case 0:\n- break;\n- default:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE, RSAREF_R_UNKNOWN_FAULT);\n- }\n- return !ret;\n-}\n-\n-static int cipher_des_cbc_clean(EVP_CIPHER_CTX *ctx)\n-{\n- memset(data(ctx), 0, ctx-\u003ecipher-\u003ectx_size);\n- return 1;\n-}\n-\n-#undef data\n-#define data(ctx) ((DES3_CBC_CTX *)(ctx)-\u003ecipher_data)\n-static int cipher_des_ede3_cbc_init(EVP_CIPHER_CTX *ctx,\n- const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n- DES3_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, enc);\n- return 1;\n-}\n-\n-static int cipher_des_ede3_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl)\n-{\n- int ret \u003d DES3_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);\n- switch (ret) {\n- case RE_LEN:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE,\n- RSAREF_R_LENGTH_NOT_BLOCK_ALIGNED);\n- break;\n- case 0:\n- break;\n- default:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE, RSAREF_R_UNKNOWN_FAULT);\n- }\n- return !ret;\n-}\n-\n-static int cipher_des_ede3_cbc_clean(EVP_CIPHER_CTX *ctx)\n-{\n- memset(data(ctx), 0, ctx-\u003ecipher-\u003ectx_size);\n- return 1;\n-}\n-\n-#undef data\n-#define data(ctx) ((DESX_CBC_CTX *)(ctx)-\u003ecipher_data)\n-static int cipher_desx_cbc_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n- DESX_CBCInit(data(ctx), (unsigned char *)key, (unsigned char *)iv, enc);\n- return 1;\n-}\n-\n-static int cipher_desx_cbc_code(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl)\n-{\n- int ret \u003d DESX_CBCUpdate(data(ctx), out, (unsigned char *)in, inl);\n- switch (ret) {\n- case RE_LEN:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE,\n- RSAREF_R_LENGTH_NOT_BLOCK_ALIGNED);\n- break;\n- case 0:\n- break;\n- default:\n- RSAREFerr(RSAREF_F_CIPHER_DES_CBC_CODE, RSAREF_R_UNKNOWN_FAULT);\n- }\n- return !ret;\n-}\n-\n-static int cipher_desx_cbc_clean(EVP_CIPHER_CTX *ctx)\n-{\n- memset(data(ctx), 0, ctx-\u003ecipher-\u003ectx_size);\n- return 1;\n-}\n-\n-/*****************************************************************************\n- * MD functions\n- **/\n-#undef data\n-#define data(ctx) ((MD2_CTX *)(ctx)-\u003emd_data)\n-static int digest_md2_init(EVP_MD_CTX *ctx)\n-{\n- MD2Init(data(ctx));\n- return 1;\n-}\n-\n-static int digest_md2_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count)\n-{\n- MD2Update(data(ctx), (unsigned char *)data, (unsigned int)count);\n- return 1;\n-}\n-\n-static int digest_md2_final(EVP_MD_CTX *ctx, unsigned char *md)\n-{\n- MD2Final(md, data(ctx));\n- return 1;\n-}\n-\n-#undef data\n-#define data(ctx) ((MD5_CTX *)(ctx)-\u003emd_data)\n-static int digest_md5_init(EVP_MD_CTX *ctx)\n-{\n- MD5Init(data(ctx));\n- return 1;\n-}\n-\n-static int digest_md5_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count)\n-{\n- MD5Update(data(ctx), (unsigned char *)data, (unsigned int)count);\n- return 1;\n-}\n-\n-static int digest_md5_final(EVP_MD_CTX *ctx, unsigned char *md)\n-{\n- MD5Final(md, data(ctx));\n- return 1;\n-}\ndiff --git a/demos/engines/rsaref/rsaref.ec b/demos/engines/rsaref/rsaref.ec\ndeleted file mode 100644\nindex c690ae3..0000000\n--- a/demos/engines/rsaref/rsaref.ec\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-# configuration file for util/mkerr.pl\n-#\n-# use like this:\n-#\n-#\tperl ../../../util/mkerr.pl -conf rsaref.ec \u005c\n-#\t\t-nostatic -staticloader -write *.c\n-\n-L RSAREF\trsaref_err.h\t\t\trsaref_err.c\ndiff --git a/demos/engines/rsaref/rsaref_err.c b/demos/engines/rsaref/rsaref_err.c\ndeleted file mode 100644\nindex 377dcdd..0000000\n--- a/demos/engines/rsaref/rsaref_err.c\n+++ /dev/null\n@@ -1,157 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/*\n- * NOTE: this file was auto generated by the mkerr.pl script: any changes\n- * made to it will be overwritten when the script next updates this file,\n- * only reason strings will be preserved.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u0022rsaref_err.h\u0022\n-\n-/* BEGIN ERROR CODES */\n-#ifndef OPENSSL_NO_ERR\n-static ERR_STRING_DATA RSAREF_str_functs[] \u003d {\n- {ERR_PACK(0, RSAREF_F_BNREF_MOD_EXP, 0), \u0022BNREF_MOD_EXP\u0022},\n- {ERR_PACK(0, RSAREF_F_CIPHER_DES_CBC_CODE, 0), \u0022CIPHER_DES_CBC_CODE\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_BN2BIN, 0), \u0022RSAREF_BN2BIN\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_MOD_EXP, 0), \u0022RSAREF_MOD_EXP\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_PRIVATE_DECRYPT, 0),\n- \u0022RSAREF_PRIVATE_DECRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_PRIVATE_ENCRYPT, 0),\n- \u0022RSAREF_PRIVATE_ENCRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_PUBLIC_DECRYPT, 0), \u0022RSAREF_PUBLIC_DECRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSAREF_PUBLIC_ENCRYPT, 0), \u0022RSAREF_PUBLIC_ENCRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSA_BN2BIN, 0), \u0022RSA_BN2BIN\u0022},\n- {ERR_PACK(0, RSAREF_F_RSA_PRIVATE_DECRYPT, 0), \u0022RSA_PRIVATE_DECRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSA_PRIVATE_ENCRYPT, 0), \u0022RSA_PRIVATE_ENCRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSA_PUBLIC_DECRYPT, 0), \u0022RSA_PUBLIC_DECRYPT\u0022},\n- {ERR_PACK(0, RSAREF_F_RSA_PUBLIC_ENCRYPT, 0), \u0022RSA_PUBLIC_ENCRYPT\u0022},\n- {0, NULL}\n-};\n-\n-static ERR_STRING_DATA RSAREF_str_reasons[] \u003d {\n- {RSAREF_R_CONTENT_ENCODING, \u0022content encoding\u0022},\n- {RSAREF_R_DATA, \u0022data\u0022},\n- {RSAREF_R_DIGEST_ALGORITHM, \u0022digest algorithm\u0022},\n- {RSAREF_R_ENCODING, \u0022encoding\u0022},\n- {RSAREF_R_ENCRYPTION_ALGORITHM, \u0022encryption algorithm\u0022},\n- {RSAREF_R_KEY, \u0022key\u0022},\n- {RSAREF_R_KEY_ENCODING, \u0022key encoding\u0022},\n- {RSAREF_R_LEN, \u0022len\u0022},\n- {RSAREF_R_LENGTH_NOT_BLOCK_ALIGNED, \u0022length not block aligned\u0022},\n- {RSAREF_R_MODULUS_LEN, \u0022modulus len\u0022},\n- {RSAREF_R_NEED_RANDOM, \u0022need random\u0022},\n- {RSAREF_R_PRIVATE_KEY, \u0022private key\u0022},\n- {RSAREF_R_PUBLIC_KEY, \u0022public key\u0022},\n- {RSAREF_R_SIGNATURE, \u0022signature\u0022},\n- {RSAREF_R_SIGNATURE_ENCODING, \u0022signature encoding\u0022},\n- {RSAREF_R_UNKNOWN_FAULT, \u0022unknown fault\u0022},\n- {0, NULL}\n-};\n-\n-#endif\n-\n-#ifdef RSAREF_LIB_NAME\n-static ERR_STRING_DATA RSAREF_lib_name[] \u003d {\n- {0, RSAREF_LIB_NAME},\n- {0, NULL}\n-};\n-#endif\n-\n-static int RSAREF_lib_error_code \u003d 0;\n-static int RSAREF_error_init \u003d 1;\n-\n-static void ERR_load_RSAREF_strings(void)\n-{\n- if (RSAREF_lib_error_code \u003d\u003d 0)\n- RSAREF_lib_error_code \u003d ERR_get_next_error_library();\n-\n- if (RSAREF_error_init) {\n- RSAREF_error_init \u003d 0;\n-#ifndef OPENSSL_NO_ERR\n- ERR_load_strings(RSAREF_lib_error_code, RSAREF_str_functs);\n- ERR_load_strings(RSAREF_lib_error_code, RSAREF_str_reasons);\n-#endif\n-\n-#ifdef RSAREF_LIB_NAME\n- RSAREF_lib_name-\u003eerror \u003d ERR_PACK(RSAREF_lib_error_code, 0, 0);\n- ERR_load_strings(0, RSAREF_lib_name);\n-#endif\n- }\n-}\n-\n-static void ERR_unload_RSAREF_strings(void)\n-{\n- if (RSAREF_error_init \u003d\u003d 0) {\n-#ifndef OPENSSL_NO_ERR\n- ERR_unload_strings(RSAREF_lib_error_code, RSAREF_str_functs);\n- ERR_unload_strings(RSAREF_lib_error_code, RSAREF_str_reasons);\n-#endif\n-\n-#ifdef RSAREF_LIB_NAME\n- ERR_unload_strings(0, RSAREF_lib_name);\n-#endif\n- RSAREF_error_init \u003d 1;\n- }\n-}\n-\n-static void ERR_RSAREF_error(int function, int reason, char *file, int line)\n-{\n- if (RSAREF_lib_error_code \u003d\u003d 0)\n- RSAREF_lib_error_code \u003d ERR_get_next_error_library();\n- ERR_PUT_error(RSAREF_lib_error_code, function, reason, file, line);\n-}\ndiff --git a/demos/engines/rsaref/rsaref_err.h b/demos/engines/rsaref/rsaref_err.h\ndeleted file mode 100644\nindex d230503..0000000\n--- a/demos/engines/rsaref/rsaref_err.h\n+++ /dev/null\n@@ -1,109 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@openssl.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.openssl.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-#ifndef HEADER_RSAREF_ERR_H\n-# define HEADER_RSAREF_ERR_H\n-\n-#ifdef __cplusplus\n-extern \u0022C\u0022 {\n-#endif\n-\n-/* BEGIN ERROR CODES */\n-/*\n- * The following lines are auto generated by the script mkerr.pl. Any changes\n- * made after this point may be overwritten when the script is next run.\n- */\n-static void ERR_load_RSAREF_strings(void);\n-static void ERR_unload_RSAREF_strings(void);\n-static void ERR_RSAREF_error(int function, int reason, char *file, int line);\n-# define RSAREFerr(f,r) ERR_RSAREF_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)\n-/* Error codes for the RSAREF functions. */\n-\n-/* Function codes. */\n-# define RSAREF_F_BNREF_MOD_EXP 100\n-# define RSAREF_F_CIPHER_DES_CBC_CODE 112\n-# define RSAREF_F_RSAREF_BN2BIN 101\n-# define RSAREF_F_RSAREF_MOD_EXP 102\n-# define RSAREF_F_RSAREF_PRIVATE_DECRYPT 103\n-# define RSAREF_F_RSAREF_PRIVATE_ENCRYPT 104\n-# define RSAREF_F_RSAREF_PUBLIC_DECRYPT 105\n-# define RSAREF_F_RSAREF_PUBLIC_ENCRYPT 106\n-# define RSAREF_F_RSA_BN2BIN 107\n-# define RSAREF_F_RSA_PRIVATE_DECRYPT 108\n-# define RSAREF_F_RSA_PRIVATE_ENCRYPT 109\n-# define RSAREF_F_RSA_PUBLIC_DECRYPT 110\n-# define RSAREF_F_RSA_PUBLIC_ENCRYPT 111\n-\n-/* Reason codes. */\n-# define RSAREF_R_CONTENT_ENCODING 100\n-# define RSAREF_R_DATA 101\n-# define RSAREF_R_DIGEST_ALGORITHM 102\n-# define RSAREF_R_ENCODING 103\n-# define RSAREF_R_ENCRYPTION_ALGORITHM 104\n-# define RSAREF_R_KEY 105\n-# define RSAREF_R_KEY_ENCODING 106\n-# define RSAREF_R_LEN 107\n-# define RSAREF_R_LENGTH_NOT_BLOCK_ALIGNED 114\n-# define RSAREF_R_MODULUS_LEN 108\n-# define RSAREF_R_NEED_RANDOM 109\n-# define RSAREF_R_PRIVATE_KEY 110\n-# define RSAREF_R_PUBLIC_KEY 111\n-# define RSAREF_R_SIGNATURE 112\n-# define RSAREF_R_SIGNATURE_ENCODING 113\n-# define RSAREF_R_UNKNOWN_FAULT 115\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-#endif\ndiff --git a/demos/engines/zencod/Makefile.in b/demos/engines/zencod/Makefile.in\ndeleted file mode 100644\nindex f4dd7c8..0000000\n--- a/demos/engines/zencod/Makefile.in\n+++ /dev/null\n@@ -1,93 +0,0 @@\n-LIBNAME\u003d\tlibzencod\n-SRC\u003d\t\thw_zencod.c\n-OBJ\u003d\t\thw_zencod.o\n-HEADER\u003d\t\thw_zencod.h\n-\n-CC\u003d\t\tgcc\n-PIC\u003d\t\t-fPIC\n-CFLAGS\u003d\t\t-g -I../../../include $(PIC) -DENGINE_DYNAMIC_SUPPORT -DFLAT_INC\n-AR\u003d\t\tar r\n-RANLIB\u003d\t\tranlib\n-\n-LIB\u003d\t\t$(LIBNAME).a\n-SHLIB\u003d\t\t$(LIBNAME).so\n-\n-all:\n-\t\t@echo 'Please choose a system to build on:'\n-\t\t@echo ''\n-\t\t@echo 'tru64: Tru64 Unix, Digital Unix, Digital OSF/1'\n-\t\t@echo 'solaris: Solaris'\n-\t\t@echo 'irix: IRIX'\n-\t\t@echo 'hpux32: 32-bit HP/UX'\n-\t\t@echo 'hpux64: 64-bit HP/UX'\n-\t\t@echo 'aix: AIX'\n-\t\t@echo 'gnu: Generic GNU-based system (gcc and GNU ld)'\n-\t\t@echo ''\n-\n-generate:\n-\t\tperl ../../../util/mkerr.pl -conf hw_zencod.ec \u005c\n-\t\t\t-nostatic -staticloader -write hw_zencod.c\n-\n-gnu:\t\t$(SHLIB).gnu\n-tru64:\t\t$(SHLIB).tru64\n-solaris:\t$(SHLIB).solaris\n-irix:\t\t$(SHLIB).irix\n-hpux32:\t\t$(SHLIB).hpux32\n-hpux64:\t\t$(SHLIB).hpux64\n-aix:\t\t$(SHLIB).aix\n-\n-$(LIB):\t\t$(OBJ)\n-\t\t$(AR) $(LIB) $(OBJ)\n-\t\t- $(RANLIB) $(LIB)\n-\n-LINK_SO\u003d\t\u005c\n- ld -r -o $(LIBNAME).o $$ALLSYMSFLAGS $(LIB) \u0026\u0026 \u005c\n- (nm -Pg $(LIBNAME).o | grep ' [BDT] ' | cut -f1 -d' ' \u003e $(LIBNAME).exp; \u005c\n- $$SHAREDCMD $$SHAREDFLAGS -o $(SHLIB) $(LIBNAME).o -L ../../.. -lcrypto -lc)\n-\n-$(SHLIB).gnu:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'--whole-archive' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname\u003d$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).gnu\n-$(SHLIB).tru64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).tru64\n-$(SHLIB).solaris:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-z allextract' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).solaris\n-$(SHLIB).irix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-all' \u005c\n-\t\tSHAREDFLAGS\u003d'-shared -Wl,-soname,$(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).irix\n-$(SHLIB).hpux32:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-Fl' \u005c\n-\t\tSHAREDFLAGS\u003d'+vnocompatwarnings -b -z +s +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux32\n-$(SHLIB).hpux64:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'+forceload' \u005c\n-\t\tSHAREDFLAGS\u003d'-b -z +h $(SHLIB)' \u005c\n-\t\tSHAREDCMD\u003d'/usr/ccs/bin/ld'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).hpux64\n-$(SHLIB).aix:\t$(LIB)\n-\t\tALLSYMSFLAGS\u003d'-bnogc' \u005c\n-\t\tSHAREDFLAGS\u003d'-G -bE:$(LIBNAME).exp -bM:SRE' \u005c\n-\t\tSHAREDCMD\u003d'$(CC)'; \u005c\n-\t\t$(LINK_SO)\n-\t\ttouch $(SHLIB).aix\n-\n-depend:\n-\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c\ndeleted file mode 100644\nindex 1c34677..0000000\n--- a/demos/engines/zencod/hw_zencod.c\n+++ /dev/null\n@@ -1,1785 +0,0 @@\n- /*\n- * Written by Fred Donnat (frederic.donnat@zencod.com) for \u0022zencod\u0022 * engine\n- * integration in order to redirect crypto computing on a crypto * hardware\n- * accelerator zenssl32 ;-) * * Date : 25 jun 2002 * Revision : 17 Ju7 2002\n- * * Version : zencod_engine-0.9.7\n- */\n-\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * licensing@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/* ENGINE general include */\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/dso.h\u003e\n-#include \u003copenssl/engine.h\u003e\n-\n-#ifndef OPENSSL_NO_HW\n-# ifndef OPENSSL_NO_HW_ZENCOD\n-\n-# ifdef FLAT_INC\n-# include \u0022hw_zencod.h\u0022\n-# else\n-# include \u0022vendor_defns/hw_zencod.h\u0022\n-# endif\n-\n-# define ZENCOD_LIB_NAME \u0022zencod engine\u0022\n-# include \u0022hw_zencod_err.c\u0022\n-\n-# define FAIL_TO_SOFTWARE -15\n-\n-# define ZEN_LIBRARY \u0022zenbridge\u0022\n-\n-# ifdef ZENCOD_TRACING\n-# define PERROR(s) perror(s)\n-# define CHEESE() fputs(\u0022## [ZenEngine] ## \u0022 __FUNCTION__ \u0022\u005cn\u0022, stderr)\n-# else\n-# define PERROR(s)\n-# define CHEESE()\n-# endif\n-\n-/* Sorry ;) */\n-# ifndef WIN32\n-static inline void esrever(unsigned char *d, int l)\n-{\n- for (; --l \u003e 0; --l, d++) {\n- *d ^\u003d *(d + l);\n- *(d + l) ^\u003d *d;\n- *d ^\u003d *(d + l);\n- }\n-}\n-\n-static inline void ypcmem(unsigned char *d, const unsigned char *s, int l)\n-{\n- for (d +\u003d l; l--;)\n- *--d \u003d *s++;\n-}\n-# else\n-static __inline void esrever(unsigned char *d, int l)\n-{\n- for (; --l \u003e 0; --l, d++) {\n- *d ^\u003d *(d + l);\n- *(d + l) ^\u003d *d;\n- *d ^\u003d *(d + l);\n- }\n-}\n-\n-static __inline void ypcmem(unsigned char *d, const unsigned char *s, int l)\n-{\n- for (d +\u003d l; l--;)\n- *--d \u003d *s++;\n-}\n-# endif\n-\n-# define BIGNUM2ZEN(n, bn) (ptr_zencod_init_number((n), \u005c\n- (unsigned long) ((bn)-\u003etop * BN_BITS2), \u005c\n- (unsigned char *) ((bn)-\u003ed)))\n-\n-# define ZEN_BITS(n, bytes) (ptr_zencod_bytes2bits((unsigned char *) (n), (unsigned long) (bytes)))\n-# define ZEN_BYTES(bits) (ptr_zencod_bits2bytes((unsigned long) (bits)))\n-\n-/* Function for ENGINE detection and control */\n-static int zencod_destroy(ENGINE *e);\n-static int zencod_init(ENGINE *e);\n-static int zencod_finish(ENGINE *e);\n-static int zencod_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) ());\n-\n-/* BIGNUM stuff */\n-static int zencod_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx);\n-\n-/* RSA stuff */\n-# ifndef OPENSSL_NO_RSA\n-static int RSA_zencod_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);\n-static int RSA_zencod_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx);\n-# endif\n-\n-/* DSA stuff */\n-# ifndef OPENSSL_NO_DSA\n-static int DSA_zencod_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx);\n-\n-static DSA_SIG *DSA_zencod_do_sign(const unsigned char *dgst, int dlen,\n- DSA *dsa);\n-static int DSA_zencod_do_verify(const unsigned char *dgst, int dgst_len,\n- DSA_SIG *sig, DSA *dsa);\n-# endif\n-\n-/* DH stuff */\n-# ifndef OPENSSL_NO_DH\n-static int DH_zencod_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx);\n-static int DH_zencod_generate_key(DH *dh);\n-static int DH_zencod_compute_key(unsigned char *key, const BIGNUM *pub_key,\n- DH *dh);\n-# endif\n-\n-/* Rand stuff */\n-static void RAND_zencod_seed(const void *buf, int num);\n-static int RAND_zencod_rand_bytes(unsigned char *buf, int num);\n-static int RAND_zencod_rand_status(void);\n-\n-/* Digest Stuff */\n-static int engine_digests(ENGINE *e, const EVP_MD **digest, const int **nids,\n- int nid);\n-\n-/* Cipher Stuff */\n-static int engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,\n- const int **nids, int nid);\n-\n-# define ZENCOD_CMD_SO_PATH ENGINE_CMD_BASE\n-static const ENGINE_CMD_DEFN zencod_cmd_defns[] \u003d {\n- {ZENCOD_CMD_SO_PATH,\n- \u0022SO_PATH\u0022,\n- \u0022Specifies the path to the 'zenbridge' shared library\u0022,\n- ENGINE_CMD_FLAG_STRING},\n- {0, NULL, NULL, 0}\n-};\n-\n-# ifndef OPENSSL_NO_RSA\n-/*\n- * Our internal RSA_METHOD specific to zencod ENGINE providing pointers to\n- * our function\n- */\n-static RSA_METHOD zencod_rsa \u003d {\n- \u0022ZENCOD RSA method\u0022,\n- NULL,\n- NULL,\n- NULL,\n- NULL,\n- RSA_zencod_rsa_mod_exp,\n- RSA_zencod_bn_mod_exp,\n- NULL,\n- NULL,\n- 0,\n- NULL,\n- NULL,\n- NULL\n-};\n-# endif\n-\n-# ifndef OPENSSL_NO_DSA\n-/*\n- * Our internal DSA_METHOD specific to zencod ENGINE providing pointers to\n- * our function\n- */\n-static DSA_METHOD zencod_dsa \u003d {\n- \u0022ZENCOD DSA method\u0022,\n- DSA_zencod_do_sign,\n- NULL,\n- DSA_zencod_do_verify,\n- NULL,\n- DSA_zencod_bn_mod_exp,\n- NULL,\n- NULL,\n- 0,\n- NULL\n-};\n-# endif\n-\n-# ifndef OPENSSL_NO_DH\n-/*\n- * Our internal DH_METHOD specific to zencod ENGINE providing pointers to our\n- * function\n- */\n-static DH_METHOD zencod_dh \u003d {\n- \u0022ZENCOD DH method\u0022,\n- DH_zencod_generate_key,\n- DH_zencod_compute_key,\n- DH_zencod_bn_mod_exp,\n- NULL,\n- NULL,\n- 0,\n- NULL\n-};\n-# endif\n-\n-/*\n- * Our internal RAND_meth specific to zencod ZNGINE providing pointers to our\n- * function\n- */\n-static RAND_METHOD zencod_rand \u003d {\n- RAND_zencod_seed,\n- RAND_zencod_rand_bytes,\n- NULL,\n- NULL,\n- RAND_zencod_rand_bytes,\n- RAND_zencod_rand_status\n-};\n-\n-/* Constants used when creating the ENGINE */\n-static const char *engine_zencod_id \u003d \u0022zencod\u0022;\n-static const char *engine_zencod_name \u003d \u0022ZENCOD hardware engine support\u0022;\n-\n-/*\n- * This internal function is used by ENGINE_zencod () and possibly by the\n- * \u0022dynamic\u0022 ENGINE support too ;-)\n- */\n-static int bind_helper(ENGINE *e)\n-{\n-\n-# ifndef OPENSSL_NO_RSA\n- const RSA_METHOD *meth_rsa;\n-# endif\n-# ifndef OPENSSL_NO_DSA\n- const DSA_METHOD *meth_dsa;\n-# endif\n-# ifndef OPENSSL_NO_DH\n- const DH_METHOD *meth_dh;\n-# endif\n-\n- const RAND_METHOD *meth_rand;\n-\n- if (!ENGINE_set_id(e, engine_zencod_id) ||\n- !ENGINE_set_name(e, engine_zencod_name) ||\n-# ifndef OPENSSL_NO_RSA\n- !ENGINE_set_RSA(e, \u0026zencod_rsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DSA\n- !ENGINE_set_DSA(e, \u0026zencod_dsa) ||\n-# endif\n-# ifndef OPENSSL_NO_DH\n- !ENGINE_set_DH(e, \u0026zencod_dh) ||\n-# endif\n- !ENGINE_set_RAND(e, \u0026zencod_rand) ||\n- !ENGINE_set_destroy_function(e, zencod_destroy) ||\n- !ENGINE_set_init_function(e, zencod_init) ||\n- !ENGINE_set_finish_function(e, zencod_finish) ||\n- !ENGINE_set_ctrl_function(e, zencod_ctrl) ||\n- !ENGINE_set_cmd_defns(e, zencod_cmd_defns) ||\n- !ENGINE_set_digests(e, engine_digests) ||\n- !ENGINE_set_ciphers(e, engine_ciphers)) {\n- return 0;\n- }\n-# ifndef OPENSSL_NO_RSA\n- /*\n- * We know that the \u0022PKCS1_OpenSSL()\u0022 functions hook properly to the\n- * Zencod-specific mod_exp and mod_exp_crt so we use those functions. NB:\n- * We don't use ENGINE_openssl() or anything \u0022more generic\u0022 because\n- * something like the RSAref code may not hook properly, and if you own\n- * one of these cards then you have the right to do RSA operations on it\n- * anyway!\n- */\n- meth_rsa \u003d RSA_PKCS1_OpenSSL();\n-\n- zencod_rsa.rsa_pub_enc \u003d meth_rsa-\u003ersa_pub_enc;\n- zencod_rsa.rsa_pub_dec \u003d meth_rsa-\u003ersa_pub_dec;\n- zencod_rsa.rsa_priv_enc \u003d meth_rsa-\u003ersa_priv_enc;\n- zencod_rsa.rsa_priv_dec \u003d meth_rsa-\u003ersa_priv_dec;\n- /* meth_rsa-\u003ersa_mod_exp */\n- /* meth_rsa-\u003ebn_mod_exp */\n- zencod_rsa.init \u003d meth_rsa-\u003einit;\n- zencod_rsa.finish \u003d meth_rsa-\u003efinish;\n-# endif\n-\n-# ifndef OPENSSL_NO_DSA\n- /*\n- * We use OpenSSL meth to supply what we don't provide ;-*)\n- */\n- meth_dsa \u003d DSA_OpenSSL();\n-\n- /* meth_dsa-\u003edsa_do_sign */\n- zencod_dsa.dsa_sign_setup \u003d meth_dsa-\u003edsa_sign_setup;\n- /* meth_dsa-\u003edsa_do_verify */\n- zencod_dsa.dsa_mod_exp \u003d meth_dsa-\u003edsa_mod_exp;\n- /* zencod_dsa.bn_mod_exp \u003d meth_dsa-\u003ebn_mod_exp ; */\n- zencod_dsa.init \u003d meth_dsa-\u003einit;\n- zencod_dsa.finish \u003d meth_dsa-\u003efinish;\n-# endif\n-\n-# ifndef OPENSSL_NO_DH\n- /*\n- * We use OpenSSL meth to supply what we don't provide ;-*)\n- */\n- meth_dh \u003d DH_OpenSSL();\n-\n- /* zencod_dh.generate_key \u003d meth_dh-\u003egenerate_key ; */\n- /* zencod_dh.compute_key \u003d meth_dh-\u003ecompute_key ; */\n- /* zencod_dh.bn_mod_exp \u003d meth_dh-\u003ebn_mod_exp ; */\n- zencod_dh.init \u003d meth_dh-\u003einit;\n- zencod_dh.finish \u003d meth_dh-\u003efinish;\n-\n-# endif\n-\n- /*\n- * We use OpenSSL meth to supply what we don't provide ;-*)\n- */\n- meth_rand \u003d RAND_OpenSSL();\n-\n- /* meth_rand-\u003eseed ; */\n- /* zencod_rand.seed \u003d meth_rand-\u003eseed ; */\n- /* meth_rand-\u003ebytes ; */\n- /* zencod_rand.bytes \u003d meth_rand-\u003ebytes ; */\n- zencod_rand.cleanup \u003d meth_rand-\u003ecleanup;\n- zencod_rand.add \u003d meth_rand-\u003eadd;\n- /* meth_rand-\u003epseudorand ; */\n- /* zencod_rand.pseudorand \u003d meth_rand-\u003epseudorand ; */\n- /* zencod_rand.status \u003d meth_rand-\u003estatus ; */\n- /* meth_rand-\u003estatus ; */\n-\n- /* Ensure the zencod error handling is set up */\n- ERR_load_ZENCOD_strings();\n- return 1;\n-}\n-\n-/*\n- * As this is only ever called once, there's no need for locking (indeed -\n- * the lock will already be held by our caller!!!)\n- */\n-static ENGINE *ENGINE_zencod(void)\n-{\n-\n- ENGINE *eng \u003d ENGINE_new();\n-\n- if (!eng) {\n- return NULL;\n- }\n- if (!bind_helper(eng)) {\n- ENGINE_free(eng);\n- return NULL;\n- }\n-\n- return eng;\n-}\n-\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static\n-# endif\n-void ENGINE_load_zencod(void)\n-{\n- /* Copied from eng_[openssl|dyn].c */\n- ENGINE *toadd \u003d ENGINE_zencod();\n- if (!toadd)\n- return;\n- ENGINE_add(toadd);\n- ENGINE_free(toadd);\n- ERR_clear_error();\n-}\n-\n-/*\n- * This is a process-global DSO handle used for loading and unloading the\n- * ZENBRIDGE library. NB: This is only set (or unset) during an * init () or\n- * finish () call (reference counts permitting) and they're * operating with\n- * global locks, so this should be thread-safe * implicitly.\n- */\n-static DSO *zencod_dso \u003d NULL;\n-\n-static t_zencod_test *ptr_zencod_test \u003d NULL;\n-static t_zencod_bytes2bits *ptr_zencod_bytes2bits \u003d NULL;\n-static t_zencod_bits2bytes *ptr_zencod_bits2bytes \u003d NULL;\n-static t_zencod_new_number *ptr_zencod_new_number \u003d NULL;\n-static t_zencod_init_number *ptr_zencod_init_number \u003d NULL;\n-\n-static t_zencod_rsa_mod_exp *ptr_zencod_rsa_mod_exp \u003d NULL;\n-static t_zencod_rsa_mod_exp_crt *ptr_zencod_rsa_mod_exp_crt \u003d NULL;\n-static t_zencod_dsa_do_sign *ptr_zencod_dsa_do_sign \u003d NULL;\n-static t_zencod_dsa_do_verify *ptr_zencod_dsa_do_verify \u003d NULL;\n-static t_zencod_dh_generate_key *ptr_zencod_dh_generate_key \u003d NULL;\n-static t_zencod_dh_compute_key *ptr_zencod_dh_compute_key \u003d NULL;\n-static t_zencod_rand_bytes *ptr_zencod_rand_bytes \u003d NULL;\n-static t_zencod_math_mod_exp *ptr_zencod_math_mod_exp \u003d NULL;\n-\n-static t_zencod_md5_init *ptr_zencod_md5_init \u003d NULL;\n-static t_zencod_md5_update *ptr_zencod_md5_update \u003d NULL;\n-static t_zencod_md5_do_final *ptr_zencod_md5_do_final \u003d NULL;\n-static t_zencod_sha1_init *ptr_zencod_sha1_init \u003d NULL;\n-static t_zencod_sha1_update *ptr_zencod_sha1_update \u003d NULL;\n-static t_zencod_sha1_do_final *ptr_zencod_sha1_do_final \u003d NULL;\n-\n-static t_zencod_xdes_cipher *ptr_zencod_xdes_cipher \u003d NULL;\n-static t_zencod_rc4_cipher *ptr_zencod_rc4_cipher \u003d NULL;\n-\n-/*\n- * These are the static string constants for the DSO file name and the\n- * function symbol names to bind to.\n- */\n-static const char *ZENCOD_LIBNAME \u003d ZEN_LIBRARY;\n-\n-static const char *ZENCOD_Fct_0 \u003d \u0022test_device\u0022;\n-static const char *ZENCOD_Fct_1 \u003d \u0022zenbridge_bytes2bits\u0022;\n-static const char *ZENCOD_Fct_2 \u003d \u0022zenbridge_bits2bytes\u0022;\n-static const char *ZENCOD_Fct_3 \u003d \u0022zenbridge_new_number\u0022;\n-static const char *ZENCOD_Fct_4 \u003d \u0022zenbridge_init_number\u0022;\n-\n-static const char *ZENCOD_Fct_exp_1 \u003d \u0022zenbridge_rsa_mod_exp\u0022;\n-static const char *ZENCOD_Fct_exp_2 \u003d \u0022zenbridge_rsa_mod_exp_crt\u0022;\n-static const char *ZENCOD_Fct_dsa_1 \u003d \u0022zenbridge_dsa_do_sign\u0022;\n-static const char *ZENCOD_Fct_dsa_2 \u003d \u0022zenbridge_dsa_do_verify\u0022;\n-static const char *ZENCOD_Fct_dh_1 \u003d \u0022zenbridge_dh_generate_key\u0022;\n-static const char *ZENCOD_Fct_dh_2 \u003d \u0022zenbridge_dh_compute_key\u0022;\n-static const char *ZENCOD_Fct_rand_1 \u003d \u0022zenbridge_rand_bytes\u0022;\n-static const char *ZENCOD_Fct_math_1 \u003d \u0022zenbridge_math_mod_exp\u0022;\n-\n-static const char *ZENCOD_Fct_md5_1 \u003d \u0022zenbridge_md5_init\u0022;\n-static const char *ZENCOD_Fct_md5_2 \u003d \u0022zenbridge_md5_update\u0022;\n-static const char *ZENCOD_Fct_md5_3 \u003d \u0022zenbridge_md5_do_final\u0022;\n-static const char *ZENCOD_Fct_sha1_1 \u003d \u0022zenbridge_sha1_init\u0022;\n-static const char *ZENCOD_Fct_sha1_2 \u003d \u0022zenbridge_sha1_update\u0022;\n-static const char *ZENCOD_Fct_sha1_3 \u003d \u0022zenbridge_sha1_do_final\u0022;\n-\n-static const char *ZENCOD_Fct_xdes_1 \u003d \u0022zenbridge_xdes_cipher\u0022;\n-static const char *ZENCOD_Fct_rc4_1 \u003d \u0022zenbridge_rc4_cipher\u0022;\n-\n-/*\n- * Destructor (complements the \u0022ENGINE_zencod ()\u0022 constructor)\n- */\n-static int zencod_destroy(ENGINE *e)\n-{\n-\n- ERR_unload_ZENCOD_strings();\n-\n- return 1;\n-}\n-\n-/*\n- * (de)initialisation functions. Control Function\n- */\n-static int zencod_init(ENGINE *e)\n-{\n-\n- t_zencod_test *ptr_0;\n- t_zencod_bytes2bits *ptr_1;\n- t_zencod_bits2bytes *ptr_2;\n- t_zencod_new_number *ptr_3;\n- t_zencod_init_number *ptr_4;\n- t_zencod_rsa_mod_exp *ptr_exp_1;\n- t_zencod_rsa_mod_exp_crt *ptr_exp_2;\n- t_zencod_dsa_do_sign *ptr_dsa_1;\n- t_zencod_dsa_do_verify *ptr_dsa_2;\n- t_zencod_dh_generate_key *ptr_dh_1;\n- t_zencod_dh_compute_key *ptr_dh_2;\n- t_zencod_rand_bytes *ptr_rand_1;\n- t_zencod_math_mod_exp *ptr_math_1;\n- t_zencod_md5_init *ptr_md5_1;\n- t_zencod_md5_update *ptr_md5_2;\n- t_zencod_md5_do_final *ptr_md5_3;\n- t_zencod_sha1_init *ptr_sha1_1;\n- t_zencod_sha1_update *ptr_sha1_2;\n- t_zencod_sha1_do_final *ptr_sha1_3;\n- t_zencod_xdes_cipher *ptr_xdes_1;\n- t_zencod_rc4_cipher *ptr_rc4_1;\n-\n- CHEESE();\n-\n- /*\n- * We Should add some tests for non NULL parameters or bad value !!\n- * Stuff to be done ...\n- */\n-\n- if (zencod_dso !\u003d NULL) {\n- ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_ALREADY_LOADED);\n- goto err;\n- }\n- /*\n- * Trying to load the Library \u0022cryptozen\u0022\n- */\n- zencod_dso \u003d DSO_load(NULL, ZENCOD_LIBNAME, NULL, 0);\n- if (zencod_dso \u003d\u003d NULL) {\n- ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_DSO_FAILURE);\n- goto err;\n- }\n-\n- /*\n- * Trying to load Function from the Library\n- */\n-#define BINDIT(t, name) (t*)DSO_bindfunc(zencod_dso, name)\n- if ((ptr_1 \u003d BINDIT(t_zencod_bytes2bits ZENCOD_Fct_1)) \u003d\u003d NULL\n- || (ptr_2 \u003d BINDIT(t_zencod_bits2bytes ZENCOD_Fct_2)) \u003d\u003d NULL\n- || (ptr_3 \u003d BINDIT(t_zencod_new_number ZENCOD_Fct_3)) \u003d\u003d NULL\n- || (ptr_4 \u003d BINDIT(t_zencod_init_number ZENCOD_Fct_4)) \u003d\u003d NULL\n- || (ptr_exp_1 \u003d BINDIT(t_zencod_rsa_mod_exp, ZENCOD_Fct_exp_1)) \u003d\u003d NULL\n- || (ptr_exp_2 \u003d BINDIT(t_zencod_rsa_mod_exp_crt, ZENCOD_Fct_exp_2)) \u003d\u003d NULL\n- || (ptr_dsa_1 \u003d BINDIT(t_zencod_dsa_do_sign, ZENCOD_Fct_dsa_1)) \u003d\u003d NULL\n- || (ptr_dsa_2 \u003d BINDIT(t_zencod_dsa_do_verify, ZENCOD_Fct_dsa_2)) \u003d\u003d NULL\n- || (ptr_dh_1 \u003d BINDIT(t_zencod_dh_generate_key, ZENCOD_Fct_dh_1)) \u003d\u003d NULL\n- || (ptr_dh_2 \u003d BINDIT(t_zencod_dh_compute_key, ZENCOD_Fct_dh_2)) \u003d\u003d NULL\n- || (ptr_rand_1 \u003d BINDIT(t_zencod_rand_bytes, ZENCOD_Fct_rand_1)) \u003d\u003d NULL\n- || (ptr_math_1 \u003d BINDIT(t_zencod_math_mod_exp, ZENCOD_Fct_math_1)) \u003d\u003d NULL\n- || (ptr_0 \u003d BINDIT(t_zencod_test, ZENCOD_Fct_0)) \u003d\u003d NULL\n- || (ptr_md5_1 \u003d BINDIT(t_zencod_md5_init, ZENCOD_Fct_md5_1)) \u003d\u003d NULL\n- || (ptr_md5_2 \u003d BINDIT(t_zencod_md5_update, ZENCOD_Fct_md5_2)) \u003d\u003d NULL\n- || (ptr_md5_3 \u003d BINDIT(t_zencod_md5_do_final, ZENCOD_Fct_md5_3)) \u003d\u003d NULL\n- || (ptr_sha1_1 \u003d BINDIT(t_zencod_sha1_init, ZENCOD_Fct_sha1_1)) \u003d\u003d NULL\n- || (ptr_sha1_2 \u003d BINDIT(t_zencod_sha1_update, ZENCOD_Fct_sha1_2)) \u003d\u003d NULL\n- || (ptr_sha1_3 \u003d BINDIT(t_zencod_sha1_do_final, ZENCOD_Fct_sha1_3)) \u003d\u003d NULL\n- || (ptr_xdes_1 \u003d BINDIT(t_zencod_xdes_cipher, ZENCOD_Fct_xdes_1)) \u003d\u003d NULL\n- || (ptr_rc4_1 \u003d BINDIT(t_zencod_rc4_cipher, ZENCOD_Fct_rc4_1)) \u003d\u003d NULL) {\n- ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_DSO_FAILURE);\n- goto err;\n- }\n-\n- /*\n- * The function from \u0022cryptozen\u0022 Library have been correctly loaded so\n- * copy them\n- */\n- ptr_zencod_test \u003d ptr_0;\n- ptr_zencod_bytes2bits \u003d ptr_1;\n- ptr_zencod_bits2bytes \u003d ptr_2;\n- ptr_zencod_new_number \u003d ptr_3;\n- ptr_zencod_init_number \u003d ptr_4;\n- ptr_zencod_rsa_mod_exp \u003d ptr_exp_1;\n- ptr_zencod_rsa_mod_exp_crt \u003d ptr_exp_2;\n- ptr_zencod_dsa_do_sign \u003d ptr_dsa_1;\n- ptr_zencod_dsa_do_verify \u003d ptr_dsa_2;\n- ptr_zencod_dh_generate_key \u003d ptr_dh_1;\n- ptr_zencod_dh_compute_key \u003d ptr_dh_2;\n- ptr_zencod_rand_bytes \u003d ptr_rand_1;\n- ptr_zencod_math_mod_exp \u003d ptr_math_1;\n- ptr_zencod_test \u003d ptr_0;\n- ptr_zencod_md5_init \u003d ptr_md5_1;\n- ptr_zencod_md5_update \u003d ptr_md5_2;\n- ptr_zencod_md5_do_final \u003d ptr_md5_3;\n- ptr_zencod_sha1_init \u003d ptr_sha1_1;\n- ptr_zencod_sha1_update \u003d ptr_sha1_2;\n- ptr_zencod_sha1_do_final \u003d ptr_sha1_3;\n- ptr_zencod_xdes_cipher \u003d ptr_xdes_1;\n- ptr_zencod_rc4_cipher \u003d ptr_rc4_1;\n-\n- /*\n- * We should perform a test to see if there is actually any unit runnig on\n- * the system ... Even if the cryptozen library is loaded the module coul\n- * not be loaded on the system ... For now we may just open and close the\n- * device !!\n- */\n-\n- if (ptr_zencod_test() !\u003d 0) {\n- ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_UNIT_FAILURE);\n- goto err;\n- }\n-\n- return 1;\n- err:\n- DSO_free(zencod_dso);\n- zencod_dso \u003d NULL;\n- ptr_zencod_bytes2bits \u003d NULL;\n- ptr_zencod_bits2bytes \u003d NULL;\n- ptr_zencod_new_number \u003d NULL;\n- ptr_zencod_init_number \u003d NULL;\n- ptr_zencod_rsa_mod_exp \u003d NULL;\n- ptr_zencod_rsa_mod_exp_crt \u003d NULL;\n- ptr_zencod_dsa_do_sign \u003d NULL;\n- ptr_zencod_dsa_do_verify \u003d NULL;\n- ptr_zencod_dh_generate_key \u003d NULL;\n- ptr_zencod_dh_compute_key \u003d NULL;\n- ptr_zencod_rand_bytes \u003d NULL;\n- ptr_zencod_math_mod_exp \u003d NULL;\n- ptr_zencod_test \u003d NULL;\n- ptr_zencod_md5_init \u003d NULL;\n- ptr_zencod_md5_update \u003d NULL;\n- ptr_zencod_md5_do_final \u003d NULL;\n- ptr_zencod_sha1_init \u003d NULL;\n- ptr_zencod_sha1_update \u003d NULL;\n- ptr_zencod_sha1_do_final \u003d NULL;\n- ptr_zencod_xdes_cipher \u003d NULL;\n- ptr_zencod_rc4_cipher \u003d NULL;\n-\n- return 0;\n-}\n-\n-static int zencod_finish(ENGINE *e)\n-{\n-\n- CHEESE();\n-\n- /*\n- * We Should add some tests for non NULL parameters or bad value !!\n- * Stuff to be done ...\n- */\n- if (zencod_dso \u003d\u003d NULL) {\n- ZENCODerr(ZENCOD_F_ZENCOD_FINISH, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n- if (!DSO_free(zencod_dso)) {\n- ZENCODerr(ZENCOD_F_ZENCOD_FINISH, ZENCOD_R_DSO_FAILURE);\n- return 0;\n- }\n-\n- zencod_dso \u003d NULL;\n-\n- ptr_zencod_bytes2bits \u003d NULL;\n- ptr_zencod_bits2bytes \u003d NULL;\n- ptr_zencod_new_number \u003d NULL;\n- ptr_zencod_init_number \u003d NULL;\n- ptr_zencod_rsa_mod_exp \u003d NULL;\n- ptr_zencod_rsa_mod_exp_crt \u003d NULL;\n- ptr_zencod_dsa_do_sign \u003d NULL;\n- ptr_zencod_dsa_do_verify \u003d NULL;\n- ptr_zencod_dh_generate_key \u003d NULL;\n- ptr_zencod_dh_compute_key \u003d NULL;\n- ptr_zencod_rand_bytes \u003d NULL;\n- ptr_zencod_math_mod_exp \u003d NULL;\n- ptr_zencod_test \u003d NULL;\n- ptr_zencod_md5_init \u003d NULL;\n- ptr_zencod_md5_update \u003d NULL;\n- ptr_zencod_md5_do_final \u003d NULL;\n- ptr_zencod_sha1_init \u003d NULL;\n- ptr_zencod_sha1_update \u003d NULL;\n- ptr_zencod_sha1_do_final \u003d NULL;\n- ptr_zencod_xdes_cipher \u003d NULL;\n- ptr_zencod_rc4_cipher \u003d NULL;\n-\n- return 1;\n-}\n-\n-static int zencod_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) ())\n-{\n-\n- int initialised \u003d ((zencod_dso \u003d\u003d NULL) ? 0 : 1);\n-\n- CHEESE();\n-\n- /*\n- * We Should add some tests for non NULL parameters or bad value !!\n- * Stuff to be done ...\n- */\n- switch (cmd) {\n- case ZENCOD_CMD_SO_PATH:\n- if (p \u003d\u003d NULL) {\n- ZENCODerr(ZENCOD_F_ZENCOD_CTRL, ERR_R_PASSED_NULL_PARAMETER);\n- return 0;\n- }\n- if (initialised) {\n- ZENCODerr(ZENCOD_F_ZENCOD_CTRL, ZENCOD_R_ALREADY_LOADED);\n- return 0;\n- }\n- ZENCOD_LIBNAME \u003d (const char *)p;\n- return 1;\n- default:\n- break;\n- }\n-\n- ZENCODerr(ZENCOD_F_ZENCOD_CTRL, ZENCOD_R_CTRL_COMMAND_NOT_IMPLEMENTED);\n-\n- return 0;\n-}\n-\n-/*\n- * BIGNUM stuff Functions\n- */\n-static int zencod_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx)\n-{\n- zen_nb_t y, x, e, n;\n- int ret;\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_BN_MOD_EXP, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (!bn_wexpand(r, m-\u003etop + 1)) {\n- ENGINEerr(ZENCOD_F_ZENCOD_BN_MOD_EXP, ZENCOD_R_BN_EXPAND_FAIL);\n- return 0;\n- }\n-\n- memset(r-\u003ed, 0, BN_num_bytes(m));\n-\n- ptr_zencod_init_number(\u0026y, (r-\u003edmax - 1) * sizeof(BN_ULONG) * 8,\n- (unsigned char *)r-\u003ed);\n- BIGNUM2ZEN(\u0026x, a);\n- BIGNUM2ZEN(\u0026e, p);\n- BIGNUM2ZEN(\u0026n, m);\n-\n- /* Must invert x and e parameter due to BN mod exp prototype ... */\n- ret \u003d ptr_zencod_math_mod_exp(\u0026y, \u0026e, \u0026x, \u0026n);\n-\n- if (ret) {\n- PERROR(\u0022zenbridge_math_mod_exp\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_BN_MOD_EXP, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- r-\u003etop \u003d (BN_num_bits(m) + BN_BITS2 - 1) / BN_BITS2;\n-\n- return 1;\n-}\n-\n-/*\n- * RSA stuff Functions\n- */\n-# ifndef OPENSSL_NO_RSA\n-static int RSA_zencod_rsa_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa)\n-{\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (!rsa-\u003ep || !rsa-\u003eq || !rsa-\u003edmp1 || !rsa-\u003edmq1 || !rsa-\u003eiqmp) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT,\n- ZENCOD_R_BAD_KEY_COMPONENTS);\n- return 0;\n- }\n-\n- /* Do in software if argument is too large for hardware */\n- if (RSA_size(rsa) * 8 \u003e ZENBRIDGE_MAX_KEYSIZE_RSA_CRT) {\n- const RSA_METHOD *meth;\n-\n- meth \u003d RSA_PKCS1_OpenSSL();\n- return meth-\u003ersa_mod_exp(r0, i, rsa);\n- } else {\n- zen_nb_t y, x, p, q, dmp1, dmq1, iqmp;\n-\n- if (!bn_expand(r0, RSA_size(rsa) * 8)) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT,\n- ZENCOD_R_BN_EXPAND_FAIL);\n- return 0;\n- }\n- r0-\u003etop \u003d (RSA_size(rsa) * 8 + BN_BITS2 - 1) / BN_BITS2;\n-\n- BIGNUM2ZEN(\u0026x, i);\n- BIGNUM2ZEN(\u0026y, r0);\n- BIGNUM2ZEN(\u0026p, rsa-\u003ep);\n- BIGNUM2ZEN(\u0026q, rsa-\u003eq);\n- BIGNUM2ZEN(\u0026dmp1, rsa-\u003edmp1);\n- BIGNUM2ZEN(\u0026dmq1, rsa-\u003edmq1);\n- BIGNUM2ZEN(\u0026iqmp, rsa-\u003eiqmp);\n-\n- if (ptr_zencod_rsa_mod_exp_crt(\u0026y, \u0026x, \u0026p, \u0026q, \u0026dmp1, \u0026dmq1, \u0026iqmp) \u003c\n- 0) {\n- PERROR(\u0022zenbridge_rsa_mod_exp_crt\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT,\n- ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- return 1;\n- }\n-}\n-\n-/*\n- * This function is aliased to RSA_mod_exp (with the mont stuff dropped).\n- */\n-static int RSA_zencod_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n- const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx)\n-{\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- /* Do in software if argument is too large for hardware */\n- if (BN_num_bits(m) \u003e ZENBRIDGE_MAX_KEYSIZE_RSA) {\n- const RSA_METHOD *meth;\n-\n- meth \u003d RSA_PKCS1_OpenSSL();\n- return meth-\u003ebn_mod_exp(r, a, p, m, ctx, m_ctx);\n- } else {\n- zen_nb_t y, x, e, n;\n-\n- if (!bn_expand(r, BN_num_bits(m))) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_BN_EXPAND_FAIL);\n- return 0;\n- }\n- r-\u003etop \u003d (BN_num_bits(m) + BN_BITS2 - 1) / BN_BITS2;\n-\n- BIGNUM2ZEN(\u0026x, a);\n- BIGNUM2ZEN(\u0026y, r);\n- BIGNUM2ZEN(\u0026e, p);\n- BIGNUM2ZEN(\u0026n, m);\n-\n- if (ptr_zencod_rsa_mod_exp(\u0026y, \u0026x, \u0026n, \u0026e) \u003c 0) {\n- PERROR(\u0022zenbridge_rsa_mod_exp\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_RSA_MOD_EXP, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- return 1;\n- }\n-}\n-# endif /* !OPENSSL_NO_RSA */\n-\n-# ifndef OPENSSL_NO_DSA\n-/*\n- * DSA stuff Functions\n- */\n-static DSA_SIG *DSA_zencod_do_sign(const unsigned char *dgst, int dlen,\n- DSA *dsa)\n-{\n- zen_nb_t p, q, g, x, y, r, s, data;\n- DSA_SIG *sig;\n- BIGNUM *bn_r \u003d NULL;\n- BIGNUM *bn_s \u003d NULL;\n- char msg[20];\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_NOT_LOADED);\n- goto FAILED;\n- }\n-\n- if (dlen \u003e 160) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);\n- goto FAILED;\n- }\n-\n- /* Do in software if argument is too large for hardware */\n- if (BN_num_bits(dsa-\u003ep) \u003e ZENBRIDGE_MAX_KEYSIZE_DSA_SIGN ||\n- BN_num_bits(dsa-\u003eg) \u003e ZENBRIDGE_MAX_KEYSIZE_DSA_SIGN) {\n- const DSA_METHOD *meth;\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BAD_KEY_COMPONENTS);\n- meth \u003d DSA_OpenSSL();\n- return meth-\u003edsa_do_sign(dgst, dlen, dsa);\n- }\n-\n- if ((bn_s \u003d BN_new()) \u003d\u003d NULL || (bn_r \u003d BN_new()) \u003d\u003d NULL) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BAD_KEY_COMPONENTS);\n- goto FAILED;\n- }\n-\n- if (!bn_expand(bn_r, 160) || !bn_expand(bn_s, 160)) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BN_EXPAND_FAIL);\n- goto FAILED;\n- }\n-\n- bn_r-\u003etop \u003d bn_s-\u003etop \u003d (160 + BN_BITS2 - 1) / BN_BITS2;\n- BIGNUM2ZEN(\u0026p, dsa-\u003ep);\n- BIGNUM2ZEN(\u0026q, dsa-\u003eq);\n- BIGNUM2ZEN(\u0026g, dsa-\u003eg);\n- BIGNUM2ZEN(\u0026x, dsa-\u003epriv_key);\n- BIGNUM2ZEN(\u0026y, dsa-\u003epub_key);\n- BIGNUM2ZEN(\u0026r, bn_r);\n- BIGNUM2ZEN(\u0026s, bn_s);\n- q.len \u003d x.len \u003d 160;\n-\n- ypcmem(msg, dgst, 20);\n- ptr_zencod_init_number(\u0026data, 160, msg);\n-\n- if (ptr_zencod_dsa_do_sign(0, \u0026data, \u0026y, \u0026p, \u0026q, \u0026g, \u0026x, \u0026r, \u0026s) \u003c 0) {\n- PERROR(\u0022zenbridge_dsa_do_sign\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);\n- goto FAILED;\n- }\n-\n- if ((sig \u003d DSA_SIG_new()) \u003d\u003d NULL) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);\n- goto FAILED;\n- }\n- sig-\u003er \u003d bn_r;\n- sig-\u003es \u003d bn_s;\n- return sig;\n-\n- FAILED:\n- BN_free(bn_r);\n- BN_free(bn_s);\n- return NULL;\n-}\n-\n-static int DSA_zencod_do_verify(const unsigned char *dgst, int dlen,\n- DSA_SIG *sig, DSA *dsa)\n-{\n- zen_nb_t data, p, q, g, y, r, s, v;\n- char msg[20];\n- char v_data[20];\n- int ret;\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_VERIFY, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (dlen \u003e 160) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- /* Do in software if argument is too large for hardware */\n- if (BN_num_bits(dsa-\u003ep) \u003e ZENBRIDGE_MAX_KEYSIZE_DSA_SIGN ||\n- BN_num_bits(dsa-\u003eg) \u003e ZENBRIDGE_MAX_KEYSIZE_DSA_SIGN) {\n- const DSA_METHOD *meth;\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BAD_KEY_COMPONENTS);\n- meth \u003d DSA_OpenSSL();\n- return meth-\u003edsa_do_verify(dgst, dlen, sig, dsa);\n- }\n-\n- BIGNUM2ZEN(\u0026p, dsa-\u003ep);\n- BIGNUM2ZEN(\u0026q, dsa-\u003eq);\n- BIGNUM2ZEN(\u0026g, dsa-\u003eg);\n- BIGNUM2ZEN(\u0026y, dsa-\u003epub_key);\n- BIGNUM2ZEN(\u0026r, sig-\u003er);\n- BIGNUM2ZEN(\u0026s, sig-\u003es);\n- ptr_zencod_init_number(\u0026v, 160, v_data);\n- ypcmem(msg, dgst, 20);\n- ptr_zencod_init_number(\u0026data, 160, msg);\n-\n- if ((ret \u003d\n- ptr_zencod_dsa_do_verify(0, \u0026data, \u0026p, \u0026q, \u0026g, \u0026y, \u0026r, \u0026s,\n- \u0026v)) \u003c 0) {\n- PERROR(\u0022zenbridge_dsa_do_verify\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_VERIFY, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- return ((ret \u003d\u003d 0) ? 1 : ret);\n-}\n-\n-static int DSA_zencod_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m,\n- BN_CTX *ctx, BN_MONT_CTX *m_ctx)\n-{\n- CHEESE();\n-\n- return zencod_bn_mod_exp(r, a, p, m, ctx);\n-}\n-# endif /* !OPENSSL_NO_DSA */\n-\n-# ifndef OPENSSl_NO_DH\n-/*\n- * DH stuff Functions\n- */\n-static int DH_zencod_generate_key(DH *dh)\n-{\n- BIGNUM *bn_prv \u003d NULL;\n- BIGNUM *bn_pub \u003d NULL;\n- zen_nb_t y, x, g, p;\n- int generate_x;\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- /* Private key */\n- if (dh-\u003epriv_key) {\n- bn_prv \u003d dh-\u003epriv_key;\n- generate_x \u003d 0;\n- } else {\n- if ((bn_prv \u003d BN_new()) \u003d\u003d NULL) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);\n- goto FAILED;\n- }\n- generate_x \u003d 1;\n- }\n-\n- /* Public key */\n- if (dh-\u003epub_key)\n- bn_pub \u003d dh-\u003epub_key;\n- else if ((bn_pub \u003d BN_new()) \u003d\u003d NULL) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);\n- goto FAILED;\n- }\n-\n- /* Expand */\n- if (!bn_wexpand(bn_prv, dh-\u003ep-\u003edmax) || !bn_wexpand(bn_pub, dh-\u003ep-\u003edmax)) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);\n- goto FAILED;\n- }\n- bn_prv-\u003etop \u003d dh-\u003ep-\u003etop;\n- bn_pub-\u003etop \u003d dh-\u003ep-\u003etop;\n-\n- /* Convert all keys */\n- BIGNUM2ZEN(\u0026p, dh-\u003ep);\n- BIGNUM2ZEN(\u0026g, dh-\u003eg);\n- BIGNUM2ZEN(\u0026y, bn_pub);\n- BIGNUM2ZEN(\u0026x, bn_prv);\n- x.len \u003d DH_size(dh) * 8;\n-\n- /* Adjust the lengths of P and G */\n- p.len \u003d ptr_zencod_bytes2bits(p.data, ZEN_BYTES(p.len));\n- g.len \u003d ptr_zencod_bytes2bits(g.data, ZEN_BYTES(g.len));\n-\n- /* Send the request to the driver */\n- if (ptr_zencod_dh_generate_key(\u0026y, \u0026x, \u0026g, \u0026p, generate_x) \u003c 0) {\n- perror(\u0022zenbridge_dh_generate_key\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_REQUEST_FAILED);\n- goto FAILED;\n- }\n-\n- dh-\u003epriv_key \u003d bn_prv;\n- dh-\u003epub_key \u003d bn_pub;\n-\n- return 1;\n-\n- FAILED:\n- if (!dh-\u003epriv_key)\n- BN_free(bn_prv);\n- if (!dh-\u003epub_key)\n- BN_free(bn_pub);\n-\n- return 0;\n-}\n-\n-static int DH_zencod_compute_key(unsigned char *key, const BIGNUM *pub_key,\n- DH *dh)\n-{\n- zen_nb_t y, x, p, k;\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_COMPUTE, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- if (!dh-\u003epriv_key) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_COMPUTE, ZENCOD_R_BAD_KEY_COMPONENTS);\n- return 0;\n- }\n-\n- /* Convert all keys */\n- BIGNUM2ZEN(\u0026y, pub_key);\n- BIGNUM2ZEN(\u0026x, dh-\u003epriv_key);\n- BIGNUM2ZEN(\u0026p, dh-\u003ep);\n- ptr_zencod_init_number(\u0026k, p.len, key);\n-\n- /* Adjust the lengths */\n- p.len \u003d ptr_zencod_bytes2bits(p.data, ZEN_BYTES(p.len));\n- y.len \u003d ptr_zencod_bytes2bits(y.data, ZEN_BYTES(y.len));\n- x.len \u003d ptr_zencod_bytes2bits(x.data, ZEN_BYTES(x.len));\n-\n- /* Call the hardware */\n- if (ptr_zencod_dh_compute_key(\u0026k, \u0026y, \u0026x, \u0026p) \u003c 0) {\n- ENGINEerr(ZENCOD_F_ZENCOD_DH_COMPUTE, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- /* The key must be written MSB -\u003e LSB */\n- k.len \u003d ptr_zencod_bytes2bits(k.data, ZEN_BYTES(k.len));\n- esrever(key, ZEN_BYTES(k.len));\n-\n- return ZEN_BYTES(k.len);\n-}\n-\n-static int DH_zencod_bn_mod_exp(const DH *dh, BIGNUM *r, const BIGNUM *a,\n- const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,\n- BN_MONT_CTX *m_ctx)\n-{\n- CHEESE();\n-\n- return zencod_bn_mod_exp(r, a, p, m, ctx);\n-}\n-# endif /* !OPENSSL_NO_DH */\n-\n-/*\n- * RAND stuff Functions\n- */\n-static void RAND_zencod_seed(const void *buf, int num)\n-{\n- /*\n- * Nothing to do cause our crypto accelerator provide a true random\n- * generator\n- */\n-}\n-\n-static int RAND_zencod_rand_bytes(unsigned char *buf, int num)\n-{\n- zen_nb_t r;\n-\n- CHEESE();\n-\n- if (!zencod_dso) {\n- ENGINEerr(ZENCOD_F_ZENCOD_RAND, ZENCOD_R_NOT_LOADED);\n- return 0;\n- }\n-\n- ptr_zencod_init_number(\u0026r, num * 8, buf);\n-\n- if (ptr_zencod_rand_bytes(\u0026r, ZENBRIDGE_RNG_DIRECT) \u003c 0) {\n- PERROR(\u0022zenbridge_rand_bytes\u0022);\n- ENGINEerr(ZENCOD_F_ZENCOD_RAND, ZENCOD_R_REQUEST_FAILED);\n- return 0;\n- }\n-\n- return 1;\n-}\n-\n-static int RAND_zencod_rand_status(void)\n-{\n- CHEESE();\n-\n- return 1;\n-}\n-\n-/*\n- * This stuff is needed if this ENGINE is being compiled into a\n- * self-contained shared-library.\n- */\n-# ifdef ENGINE_DYNAMIC_SUPPORT\n-static int bind_fn(ENGINE *e, const char *id)\n-{\n-\n- if (id \u0026\u0026 (strcmp(id, engine_zencod_id) !\u003d 0)) {\n- return 0;\n- }\n- if (!bind_helper(e)) {\n- return 0;\n- }\n-\n- return 1;\n-}\n-\n-IMPLEMENT_DYNAMIC_CHECK_FN()\n- IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)\n-# endif /* ENGINE_DYNAMIC_SUPPORT */\n- /*\n- * Adding \u0022Digest\u0022 and \u0022Cipher\u0022 tools ...\n- * This is in development ... ;-)\n- * In orfer to code this, i refer to hw_openbsd_dev_crypto and openssl engine made by Geoff Thorpe (if i'm rigth),\n- * and evp, sha md5 definitions etc ...\n- */\n-/* First add some include ... */\n-# include \u003copenssl/evp.h\u003e\n-# include \u003copenssl/sha.h\u003e\n-# include \u003copenssl/md5.h\u003e\n-# include \u003copenssl/rc4.h\u003e\n-# include \u003copenssl/des.h\u003e\n-/* Some variables declaration ... */\n- /*\n- * DONS: Disable symetric computation except DES and 3DES, but let part\n- * of the code\n- */\n-/* static int engine_digest_nids [ ] \u003d { NID_sha1, NID_md5 } ; */\n-static int engine_digest_nids[] \u003d { };\n-\n-static int engine_digest_nids_num \u003d 0;\n-/*\n- * static int engine_cipher_nids [ ] \u003d { NID_rc4, NID_rc4_40, NID_des_cbc,\n- * NID_des_ede3_cbc } ;\n- */\n-static int engine_cipher_nids[] \u003d { NID_des_cbc, NID_des_ede3_cbc };\n-\n-static int engine_cipher_nids_num \u003d 2;\n-\n-/* Function prototype ... */\n-/* SHA stuff */\n-static int engine_sha1_init(EVP_MD_CTX *ctx);\n-static int engine_sha1_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count);\n-static int engine_sha1_final(EVP_MD_CTX *ctx, unsigned char *md);\n-\n-/* MD5 stuff */\n-static int engine_md5_init(EVP_MD_CTX *ctx);\n-static int engine_md5_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count);\n-static int engine_md5_final(EVP_MD_CTX *ctx, unsigned char *md);\n-\n-static int engine_md_cleanup(EVP_MD_CTX *ctx);\n-static int engine_md_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from);\n-\n-/* RC4 Stuff */\n-static int engine_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int engine_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl);\n-\n-/* DES Stuff */\n-static int engine_des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int engine_des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl);\n-\n-/* 3DES Stuff */\n-static int engine_des_ede3_init_key(EVP_CIPHER_CTX *ctx,\n- const unsigned char *key,\n- const unsigned char *iv, int enc);\n-static int engine_des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in,\n- unsigned int inl);\n-\n-static int engine_cipher_cleanup(EVP_CIPHER_CTX *ctx); /* cleanup ctx */\n-\n-/* The one for SHA ... */\n-static const EVP_MD engine_sha1_md \u003d {\n- NID_sha1,\n- NID_sha1WithRSAEncryption,\n- SHA_DIGEST_LENGTH,\n- EVP_MD_FLAG_ONESHOT,\n- /*\n- * 0,\n- *//*\n- * EVP_MD_FLAG_ONESHOT \u003d x0001 digest can only handle a single block *\n- * XXX: set according to device info ...\n- */\n- engine_sha1_init,\n- engine_sha1_update,\n- engine_sha1_final,\n- engine_md_copy, /* dev_crypto_sha_copy */\n- engine_md_cleanup, /* dev_crypto_sha_cleanup */\n- EVP_PKEY_RSA_method,\n- SHA_CBLOCK,\n- /* sizeof ( EVP_MD * ) + sizeof ( SHA_CTX ) */\n- sizeof(ZEN_MD_DATA)\n- /*\n- * sizeof ( MD_CTX_DATA ) The message digest data structure ...\n- */\n-};\n-\n-/* The one for MD5 ... */\n-static const EVP_MD engine_md5_md \u003d {\n- NID_md5,\n- NID_md5WithRSAEncryption,\n- MD5_DIGEST_LENGTH,\n- EVP_MD_FLAG_ONESHOT,\n- /*\n- * 0,\n- *//*\n- * EVP_MD_FLAG_ONESHOT \u003d x0001 digest can only handle a single block *\n- * XXX: set according to device info ...\n- */\n- engine_md5_init,\n- engine_md5_update,\n- engine_md5_final,\n- engine_md_copy, /* dev_crypto_md5_copy */\n- engine_md_cleanup, /* dev_crypto_md5_cleanup */\n- EVP_PKEY_RSA_method,\n- MD5_CBLOCK,\n- /* sizeof ( EVP_MD * ) + sizeof ( MD5_CTX ) */\n- sizeof(ZEN_MD_DATA)\n- /*\n- * sizeof ( MD_CTX_DATA ) The message digest data structure ...\n- */\n-};\n-\n-/* The one for RC4 ... */\n-# define EVP_RC4_KEY_SIZE 16\n-\n-/* Try something static ... */\n-typedef struct {\n- unsigned int len;\n- unsigned int first;\n- unsigned char rc4_state[260];\n-} NEW_ZEN_RC4_KEY;\n-\n-# define rc4_data(ctx) ( (EVP_RC4_KEY *) ( ctx )-\u003ecipher_data )\n-\n-static const EVP_CIPHER engine_rc4 \u003d {\n- NID_rc4,\n- 1,\n- 16, /* EVP_RC4_KEY_SIZE should be 128 bits */\n- 0, /* FIXME: key should be up to 256 bytes */\n- EVP_CIPH_VARIABLE_LENGTH,\n- engine_rc4_init_key,\n- engine_rc4_cipher,\n- engine_cipher_cleanup,\n- sizeof(NEW_ZEN_RC4_KEY),\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-/* The one for RC4_40 ... */\n-static const EVP_CIPHER engine_rc4_40 \u003d {\n- NID_rc4_40,\n- 1,\n- 5, /* 40 bits */\n- 0,\n- EVP_CIPH_VARIABLE_LENGTH,\n- engine_rc4_init_key,\n- engine_rc4_cipher,\n- engine_cipher_cleanup,\n- sizeof(NEW_ZEN_RC4_KEY),\n- NULL,\n- NULL,\n- NULL\n-};\n-\n-/* The one for DES ... */\n-\n-/* Try something static ... */\n-typedef struct {\n- unsigned char des_key[24];\n- unsigned char des_iv[8];\n-} ZEN_DES_KEY;\n-\n-static const EVP_CIPHER engine_des_cbc \u003d {\n- NID_des_cbc,\n- 8, 8, 8,\n- 0 | EVP_CIPH_CBC_MODE,\n- engine_des_init_key,\n- engine_des_cbc_cipher,\n- engine_cipher_cleanup,\n- sizeof(ZEN_DES_KEY),\n- EVP_CIPHER_set_asn1_iv,\n- EVP_CIPHER_get_asn1_iv,\n- NULL,\n- NULL\n-};\n-\n-/* The one for 3DES ... */\n-\n-/* Try something static ... */\n-typedef struct {\n- unsigned char des3_key[24];\n- unsigned char des3_iv[8];\n-} ZEN_3DES_KEY;\n-\n-# define des_data(ctx) ( (DES_EDE_KEY *) ( ctx )-\u003ecipher_data )\n-\n-static const EVP_CIPHER engine_des_ede3_cbc \u003d {\n- NID_des_ede3_cbc,\n- 8, 8, 8,\n- 0 | EVP_CIPH_CBC_MODE,\n- engine_des_ede3_init_key,\n- engine_des_ede3_cbc_cipher,\n- engine_cipher_cleanup,\n- sizeof(ZEN_3DES_KEY),\n- EVP_CIPHER_set_asn1_iv,\n- EVP_CIPHER_get_asn1_iv,\n- NULL,\n- NULL\n-};\n-\n-/* General function cloned on hw_openbsd_dev_crypto one ... */\n-static int engine_digests(ENGINE *e, const EVP_MD **digest, const int **nids,\n- int nid)\n-{\n-\n-# ifdef DEBUG_ZENCOD_MD\n- fprintf(stderr, \u0022\u005ct\u003d\u003eFunction : static int engine_digests () called !\u005cn\u0022);\n-# endif\n-\n- if (!digest) {\n- /* We are returning a list of supported nids */\n- *nids \u003d engine_digest_nids;\n- return engine_digest_nids_num;\n- }\n- /* We are being asked for a specific digest */\n- if (nid \u003d\u003d NID_md5) {\n- *digest \u003d \u0026engine_md5_md;\n- } else if (nid \u003d\u003d NID_sha1) {\n- *digest \u003d \u0026engine_sha1_md;\n- } else {\n- *digest \u003d NULL;\n- return 0;\n- }\n- return 1;\n-}\n-\n-/*\n- * SHA stuff Functions\n- */\n-static int engine_sha1_init(EVP_MD_CTX *ctx)\n-{\n-\n- int to_return \u003d 0;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d ptr_zencod_sha1_init((ZEN_MD_DATA *)ctx-\u003emd_data);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-static int engine_sha1_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count)\n-{\n-\n- zen_nb_t input;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- input.len \u003d count;\n- input.data \u003d (unsigned char *)data;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d\n- ptr_zencod_sha1_update((ZEN_MD_DATA *)ctx-\u003emd_data,\n- (const zen_nb_t *)\u0026input);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-static int engine_sha1_final(EVP_MD_CTX *ctx, unsigned char *md)\n-{\n-\n- zen_nb_t output;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- output.len \u003d SHA_DIGEST_LENGTH;\n- output.data \u003d md;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d\n- ptr_zencod_sha1_do_final((ZEN_MD_DATA *)ctx-\u003emd_data,\n- (zen_nb_t *) \u0026 output);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-/*\n- * MD5 stuff Functions\n- */\n-static int engine_md5_init(EVP_MD_CTX *ctx)\n-{\n-\n- int to_return \u003d 0;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d ptr_zencod_md5_init((ZEN_MD_DATA *)ctx-\u003emd_data);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-static int engine_md5_update(EVP_MD_CTX *ctx, const void *data,\n- unsigned long count)\n-{\n-\n- zen_nb_t input;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- input.len \u003d count;\n- input.data \u003d (unsigned char *)data;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d\n- ptr_zencod_md5_update((ZEN_MD_DATA *)ctx-\u003emd_data,\n- (const zen_nb_t *)\u0026input);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-static int engine_md5_final(EVP_MD_CTX *ctx, unsigned char *md)\n-{\n-\n- zen_nb_t output;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- output.len \u003d MD5_DIGEST_LENGTH;\n- output.data \u003d md;\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d\n- ptr_zencod_md5_do_final((ZEN_MD_DATA *)ctx-\u003emd_data,\n- (zen_nb_t *) \u0026 output);\n- to_return \u003d !to_return;\n-\n- return to_return;\n-}\n-\n-static int engine_md_cleanup(EVP_MD_CTX *ctx)\n-{\n-\n- ZEN_MD_DATA *zen_md_data \u003d (ZEN_MD_DATA *)ctx-\u003emd_data;\n-\n- OPENSSL_free(zen_md_data-\u003eHashBuffer);\n- zen_md_data-\u003eHashBufferSize \u003d 0;\n- ctx-\u003emd_data \u003d NULL;\n- return 1;\n-}\n-\n-static int engine_md_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from)\n-{\n- const ZEN_MD_DATA *from_md \u003d (ZEN_MD_DATA *)from-\u003emd_data;\n- ZEN_MD_DATA *to_md \u003d (ZEN_MD_DATA *)to-\u003emd_data;\n-\n- to_md-\u003eHashBuffer \u003d OPENSSL_malloc(from_md-\u003eHashBufferSize);\n- if (to_md-\u003eHashBuffer \u003d\u003d NULL)\n- return 0;\n- memcpy(to_md-\u003eHashBuffer, from_md-\u003eHashBuffer, from_md-\u003eHashBufferSize);\n-\n- return 1;\n-}\n-\n-/* General function cloned on hw_openbsd_dev_crypto one ... */\n-static int engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,\n- const int **nids, int nid)\n-{\n-\n- if (!cipher) {\n- /* We are returning a list of supported nids */\n- *nids \u003d engine_cipher_nids;\n- return engine_cipher_nids_num;\n- }\n- /* We are being asked for a specific cipher */\n- if (nid \u003d\u003d NID_rc4) {\n- *cipher \u003d \u0026engine_rc4;\n- } else if (nid \u003d\u003d NID_rc4_40) {\n- *cipher \u003d \u0026engine_rc4_40;\n- } else if (nid \u003d\u003d NID_des_cbc) {\n- *cipher \u003d \u0026engine_des_cbc;\n- } else if (nid \u003d\u003d NID_des_ede3_cbc) {\n- *cipher \u003d \u0026engine_des_ede3_cbc;\n- } else {\n- *cipher \u003d NULL;\n- return 0;\n- }\n-\n- return 1;\n-}\n-\n-static int engine_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n- int to_return \u003d 0;\n- int i \u003d 0;\n- int nb \u003d 0;\n- NEW_ZEN_RC4_KEY *tmp_rc4_key \u003d NULL;\n-\n- tmp_rc4_key \u003d (NEW_ZEN_RC4_KEY *) (ctx-\u003ecipher_data);\n- tmp_rc4_key-\u003efirst \u003d 0;\n- tmp_rc4_key-\u003elen \u003d ctx-\u003ekey_len;\n- tmp_rc4_key-\u003erc4_state[0] \u003d 0x00;\n- tmp_rc4_key-\u003erc4_state[2] \u003d 0x00;\n- nb \u003d 256 / ctx-\u003ekey_len;\n- for (i \u003d 0; i \u003c nb; i++) {\n- memcpy(\u0026(tmp_rc4_key-\u003erc4_state[4 + i * ctx-\u003ekey_len]), key,\n- ctx-\u003ekey_len);\n- }\n-\n- to_return \u003d 1;\n-\n- return to_return;\n-}\n-\n-static int engine_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int in_len)\n-{\n-\n- zen_nb_t output, input;\n- zen_nb_t rc4key;\n- int to_return \u003d 0;\n- NEW_ZEN_RC4_KEY *tmp_rc4_key \u003d NULL;\n-\n- /* Convert parameters ... */\n- input.len \u003d in_len;\n- input.data \u003d (unsigned char *)in;\n- output.len \u003d in_len;\n- output.data \u003d (unsigned char *)out;\n-\n- tmp_rc4_key \u003d ((NEW_ZEN_RC4_KEY *) (ctx-\u003ecipher_data));\n- rc4key.len \u003d 260;\n- rc4key.data \u003d \u0026(tmp_rc4_key-\u003erc4_state[0]);\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d\n- ptr_zencod_rc4_cipher(\u0026output, \u0026input, (const zen_nb_t *)\u0026rc4key,\n- \u0026(tmp_rc4_key-\u003erc4_state[0]),\n- \u0026(tmp_rc4_key-\u003erc4_state[3]),\n- !tmp_rc4_key-\u003efirst);\n- to_return \u003d !to_return;\n-\n- /* Update encryption state ... */\n- tmp_rc4_key-\u003efirst \u003d 1;\n- tmp_rc4_key \u003d NULL;\n-\n- return to_return;\n-}\n-\n-static int engine_des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n-\n- ZEN_DES_KEY *tmp_des_key \u003d NULL;\n- int to_return \u003d 0;\n-\n- tmp_des_key \u003d (ZEN_DES_KEY *) (ctx-\u003ecipher_data);\n- memcpy(\u0026(tmp_des_key-\u003edes_key[0]), key, 8);\n- memcpy(\u0026(tmp_des_key-\u003edes_key[8]), key, 8);\n- memcpy(\u0026(tmp_des_key-\u003edes_key[16]), key, 8);\n- memcpy(\u0026(tmp_des_key-\u003edes_iv[0]), iv, 8);\n-\n- to_return \u003d 1;\n-\n- return to_return;\n-}\n-\n-static int engine_des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in, unsigned int inl)\n-{\n-\n- zen_nb_t output, input;\n- zen_nb_t deskey_1, deskey_2, deskey_3, iv;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- input.len \u003d inl;\n- input.data \u003d (unsigned char *)in;\n- output.len \u003d inl;\n- output.data \u003d out;\n-\n- /* Set key parameters ... */\n- deskey_1.len \u003d 8;\n- deskey_2.len \u003d 8;\n- deskey_3.len \u003d 8;\n- deskey_1.data \u003d\n- (unsigned char *)((ZEN_DES_KEY *) (ctx-\u003ecipher_data))-\u003edes_key;\n- deskey_2.data \u003d\n- (unsigned char *)\u0026((ZEN_DES_KEY *) (ctx-\u003ecipher_data))-\u003edes_key[8];\n- deskey_3.data \u003d\n- (unsigned char *)\u0026((ZEN_DES_KEY *) (ctx-\u003ecipher_data))-\u003edes_key[16];\n-\n- /* Key correct iv ... */\n- memcpy(((ZEN_DES_KEY *) (ctx-\u003ecipher_data))-\u003edes_iv, ctx-\u003eiv, 8);\n- iv.len \u003d 8;\n- iv.data \u003d (unsigned char *)((ZEN_DES_KEY *) (ctx-\u003ecipher_data))-\u003edes_iv;\n-\n- if (ctx-\u003eencrypt \u003d\u003d 0) {\n- memcpy(ctx-\u003eiv, \u0026(input.data[input.len - 8]), 8);\n- }\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d ptr_zencod_xdes_cipher(\u0026output, \u0026input,\n- (zen_nb_t *) \u0026 deskey_1,\n- (zen_nb_t *) \u0026 deskey_2,\n- (zen_nb_t *) \u0026 deskey_3, \u0026iv,\n- ctx-\u003eencrypt);\n- to_return \u003d !to_return;\n-\n- /*\n- * But we need to set up the rigth iv ... Test ENCRYPT or DECRYPT mode to\n- * set iv ...\n- */\n- if (ctx-\u003eencrypt \u003d\u003d 1) {\n- memcpy(ctx-\u003eiv, \u0026(output.data[output.len - 8]), 8);\n- }\n-\n- return to_return;\n-}\n-\n-static int engine_des_ede3_init_key(EVP_CIPHER_CTX *ctx,\n- const unsigned char *key,\n- const unsigned char *iv, int enc)\n-{\n-\n- ZEN_3DES_KEY *tmp_3des_key \u003d NULL;\n- int to_return \u003d 0;\n-\n- tmp_3des_key \u003d (ZEN_3DES_KEY *) (ctx-\u003ecipher_data);\n- memcpy(\u0026(tmp_3des_key-\u003edes3_key[0]), key, 24);\n- memcpy(\u0026(tmp_3des_key-\u003edes3_iv[0]), iv, 8);\n-\n- to_return \u003d 1;\n-\n- return to_return;\n-}\n-\n-static int engine_des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n- const unsigned char *in,\n- unsigned int in_len)\n-{\n-\n- zen_nb_t output, input;\n- zen_nb_t deskey_1, deskey_2, deskey_3, iv;\n- int to_return \u003d 0;\n-\n- /* Convert parameters ... */\n- input.len \u003d in_len;\n- input.data \u003d (unsigned char *)in;\n- output.len \u003d in_len;\n- output.data \u003d out;\n-\n- /* Set key ... */\n- deskey_1.len \u003d 8;\n- deskey_2.len \u003d 8;\n- deskey_3.len \u003d 8;\n- deskey_1.data \u003d\n- (unsigned char *)((ZEN_3DES_KEY *) (ctx-\u003ecipher_data))-\u003edes3_key;\n- deskey_2.data \u003d\n- (unsigned char *)\u0026((ZEN_3DES_KEY *) (ctx-\u003ecipher_data))-\u003edes3_key[8];\n- deskey_3.data \u003d\n- (unsigned char *)\u0026((ZEN_3DES_KEY *) (ctx-\u003ecipher_data))-\u003edes3_key[16];\n-\n- /* Key correct iv ... */\n- memcpy(((ZEN_3DES_KEY *) (ctx-\u003ecipher_data))-\u003edes3_iv, ctx-\u003eiv, 8);\n- iv.len \u003d 8;\n- iv.data \u003d (unsigned char *)((ZEN_3DES_KEY *) (ctx-\u003ecipher_data))-\u003edes3_iv;\n-\n- if (ctx-\u003eencrypt \u003d\u003d 0) {\n- memcpy(ctx-\u003eiv, \u0026(input.data[input.len - 8]), 8);\n- }\n-\n- /* Test with zenbridge library ... */\n- to_return \u003d ptr_zencod_xdes_cipher(\u0026output, \u0026input,\n- (zen_nb_t *) \u0026 deskey_1,\n- (zen_nb_t *) \u0026 deskey_2,\n- (zen_nb_t *) \u0026 deskey_3, \u0026iv,\n- ctx-\u003eencrypt);\n- to_return \u003d !to_return;\n-\n- if (ctx-\u003eencrypt \u003d\u003d 1) {\n- memcpy(ctx-\u003eiv, \u0026(output.data[output.len - 8]), 8);\n- }\n-\n- return to_return;\n-}\n-\n-static int engine_cipher_cleanup(EVP_CIPHER_CTX *ctx)\n-{\n-\n- /* Set the key pointer ... */\n- if (ctx-\u003ecipher-\u003enid \u003d\u003d NID_rc4 || ctx-\u003ecipher-\u003enid \u003d\u003d NID_rc4_40) {\n- } else if (ctx-\u003ecipher-\u003enid \u003d\u003d NID_des_cbc) {\n- } else if (ctx-\u003ecipher-\u003enid \u003d\u003d NID_des_ede3_cbc) {\n- }\n-\n- return 1;\n-}\n-\n-# endif /* !OPENSSL_NO_HW_ZENCOD */\n-#endif /* !OPENSSL_NO_HW */\ndiff --git a/demos/engines/zencod/hw_zencod.ec b/demos/engines/zencod/hw_zencod.ec\ndeleted file mode 100644\nindex 1552c79..0000000\n--- a/demos/engines/zencod/hw_zencod.ec\n+++ /dev/null\n@@ -1,8 +0,0 @@\n-# configuration file for util/mkerr.pl\n-#\n-# use like this:\n-#\n-#\tperl ../../../util/mkerr.pl -conf hw_zencod.ec \u005c\n-#\t\t-nostatic -staticloader -write *.c\n-\n-L ZENCOD\thw_zencod_err.h\t\t\thw_zencod_err.c\ndiff --git a/demos/engines/zencod/hw_zencod.h b/demos/engines/zencod/hw_zencod.h\ndeleted file mode 100644\nindex 633a61a..0000000\n--- a/demos/engines/zencod/hw_zencod.h\n+++ /dev/null\n@@ -1,158 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Written by Donnat Frederic (frederic.donnat@zencod.com) from ZENCOD\n- * for \u0022zencod\u0022 ENGINE integration in OpenSSL project.\n- */\n-\n-#ifndef _HW_ZENCOD_H_\n-# define _HW_ZENCOD_H_\n-\n-# include \u003cstdio.h\u003e\n-\n-# ifdef __cplusplus\n-extern \u0022C\u0022 {\n-# endif /* __cplusplus */\n-\n-# define ZENBRIDGE_MAX_KEYSIZE_RSA 2048\n-# define ZENBRIDGE_MAX_KEYSIZE_RSA_CRT 1024\n-# define ZENBRIDGE_MAX_KEYSIZE_DSA_SIGN 1024\n-# define ZENBRIDGE_MAX_KEYSIZE_DSA_VRFY 1024\n-\n-/* Library version computation */\n-# define ZENBRIDGE_VERSION_MAJOR(x) (((x) \u003e\u003e 16) | 0xff)\n-# define ZENBRIDGE_VERSION_MINOR(x) (((x) \u003e\u003e 8) | 0xff)\n-# define ZENBRIDGE_VERSION_PATCH(x) (((x) \u003e\u003e 0) | 0xff)\n-# define ZENBRIDGE_VERSION(x, y, z) ((x) \u003c\u003c 16 | (y) \u003c\u003c 8 | (z))\n-\n- /*\n- * Memory type\n- */\n- typedef struct zencod_number_s {\n- unsigned long len;\n- unsigned char *data;\n- } zen_nb_t;\n-\n-# define KEY zen_nb_t\n-\n- /*\n- * Misc\n- */\n- typedef int t_zencod_lib_version(void);\n- typedef int t_zencod_hw_version(void);\n- typedef int t_zencod_test(void);\n- typedef int t_zencod_dump_key(FILE *stream, char *msg, KEY * key);\n-\n- /*\n- * Key management tools\n- */\n- typedef KEY *t_zencod_new_number(unsigned long len, unsigned char *data);\n- typedef int t_zencod_init_number(KEY * n, unsigned long len,\n- unsigned char *data);\n- typedef unsigned long t_zencod_bytes2bits(unsigned char *n,\n- unsigned long bytes);\n- typedef unsigned long t_zencod_bits2bytes(unsigned long bits);\n-\n- /*\n- * RSA API\n- */\n-/* Compute modular exponential : y \u003d x**e | n */\n- typedef int t_zencod_rsa_mod_exp(KEY * y, KEY * x, KEY * n, KEY * e);\n- /*\n- * Compute modular exponential : y1 \u003d (x | p)**edp | p, y2 \u003d (x | p)**edp\n- * | p, y \u003d y2 + (qinv * (y1 - y2) | p) * q\n- */\n- typedef int t_zencod_rsa_mod_exp_crt(KEY * y, KEY * x, KEY * p, KEY * q,\n- KEY * edp, KEY * edq, KEY * qinv);\n-\n- /*\n- * DSA API\n- */\n- typedef int t_zencod_dsa_do_sign(unsigned int hash, KEY * data,\n- KEY * random, KEY * p, KEY * q, KEY * g,\n- KEY * x, KEY * r, KEY * s);\n- typedef int t_zencod_dsa_do_verify(unsigned int hash, KEY * data, KEY * p,\n- KEY * q, KEY * g, KEY * y, KEY * r,\n- KEY * s, KEY * v);\n-\n- /*\n- * DH API\n- */\n- /* Key generation : compute public value y \u003d g**x | n */\n- typedef int t_zencod_dh_generate_key(KEY * y, KEY * x, KEY * g, KEY * n,\n- int gen_x);\n- typedef int t_zencod_dh_compute_key(KEY * k, KEY * y, KEY * x, KEY * n);\n-\n- /*\n- * RNG API\n- */\n-# define ZENBRIDGE_RNG_DIRECT 0\n-# define ZENBRIDGE_RNG_SHA1 1\n- typedef int t_zencod_rand_bytes(KEY * rand, unsigned int flags);\n-\n- /*\n- * Math API\n- */\n- typedef int t_zencod_math_mod_exp(KEY * r, KEY * a, KEY * e, KEY * n);\n-\n- /*\n- * Symetric API\n- */\n-/* Define a data structure for digests operations */\n- typedef struct ZEN_data_st {\n- unsigned int HashBufferSize;\n- unsigned char *HashBuffer;\n- } ZEN_MD_DATA;\n-\n- /*\n- * Functions for Digest (MD5, SHA1) stuff\n- */\n- /* output : output data buffer */\n- /* input : input data buffer */\n- /* algo : hash algorithm, MD5 or SHA1 */\n- /*-\n- * typedef int t_zencod_hash ( KEY *output, const KEY *input, int algo ) ;\n- * typedef int t_zencod_sha_hash ( KEY *output, const KEY *input, int algo ) ;\n- */\n- /* For now separate this stuff that mad it easier to test */\n- typedef int t_zencod_md5_init(ZEN_MD_DATA *data);\n- typedef int t_zencod_md5_update(ZEN_MD_DATA *data, const KEY * input);\n- typedef int t_zencod_md5_do_final(ZEN_MD_DATA *data, KEY * output);\n-\n- typedef int t_zencod_sha1_init(ZEN_MD_DATA *data);\n- typedef int t_zencod_sha1_update(ZEN_MD_DATA *data, const KEY * input);\n- typedef int t_zencod_sha1_do_final(ZEN_MD_DATA *data, KEY * output);\n-\n- /*\n- * Functions for Cipher (RC4, DES, 3DES) stuff\n- */\n-/* output : output data buffer */\n-/* input : input data buffer */\n-/* key : rc4 key data */\n-/* index_1 : value of index x from RC4 key structure */\n-/* index_2 : value of index y from RC4 key structure */\n- /*\n- * Be careful : RC4 key should be expanded before calling this method\n- * (Should we provide an expand function ??)\n- */\n- typedef int t_zencod_rc4_cipher(KEY * output, const KEY * input,\n- const KEY * key, unsigned char *index_1,\n- unsigned char *index_2, int mode);\n-\n-/* output : output data buffer */\n-/* input : input data buffer */\n-/* key_1 : des first key data */\n-/* key_2 : des second key data */\n-/* key_3 : des third key data */\n-/* iv : initial vector */\n-/* mode : xdes mode (encrypt or decrypt) */\n-/* Be careful : In DES mode key_1 \u003d key_2 \u003d key_3 (as far as i can see !!) */\n- typedef int t_zencod_xdes_cipher(KEY * output, const KEY * input,\n- const KEY * key_1, const KEY * key_2,\n- const KEY * key_3, const KEY * iv,\n- int mode);\n-\n-# undef KEY\n-\n-# ifdef __cplusplus\n-}\n-# endif /* __cplusplus */\n-#endif /* !_HW_ZENCOD_H_ */\ndiff --git a/demos/engines/zencod/hw_zencod_err.c b/demos/engines/zencod/hw_zencod_err.c\ndeleted file mode 100644\nindex db33cc8..0000000\n--- a/demos/engines/zencod/hw_zencod_err.c\n+++ /dev/null\n@@ -1,146 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@OpenSSL.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/*\n- * NOTE: this file was auto generated by the mkerr.pl script: any changes\n- * made to it will be overwritten when the script next updates this file,\n- * only reason strings will be preserved.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u0022hw_zencod_err.h\u0022\n-\n-/* BEGIN ERROR CODES */\n-#ifndef OPENSSL_NO_ERR\n-static ERR_STRING_DATA ZENCOD_str_functs[] \u003d {\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_BN_MOD_EXP, 0), \u0022ZENCOD_BN_MOD_EXP\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_CTRL, 0), \u0022ZENCOD_CTRL\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_DH_COMPUTE, 0), \u0022ZENCOD_DH_COMPUTE\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_DH_GENERATE, 0), \u0022ZENCOD_DH_GENERATE\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_DSA_DO_SIGN, 0), \u0022ZENCOD_DSA_DO_SIGN\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_DSA_DO_VERIFY, 0), \u0022ZENCOD_DSA_DO_VERIFY\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_FINISH, 0), \u0022ZENCOD_FINISH\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_INIT, 0), \u0022ZENCOD_INIT\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_RAND, 0), \u0022ZENCOD_RAND\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_RSA_MOD_EXP, 0), \u0022ZENCOD_RSA_MOD_EXP\u0022},\n- {ERR_PACK(0, ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT, 0),\n- \u0022ZENCOD_RSA_MOD_EXP_CRT\u0022},\n- {0, NULL}\n-};\n-\n-static ERR_STRING_DATA ZENCOD_str_reasons[] \u003d {\n- {ZENCOD_R_ALREADY_LOADED, \u0022already loaded\u0022},\n- {ZENCOD_R_BAD_KEY_COMPONENTS, \u0022bad key components\u0022},\n- {ZENCOD_R_BN_EXPAND_FAIL, \u0022bn expand fail\u0022},\n- {ZENCOD_R_CTRL_COMMAND_NOT_IMPLEMENTED, \u0022ctrl command not implemented\u0022},\n- {ZENCOD_R_DSO_FAILURE, \u0022dso failure\u0022},\n- {ZENCOD_R_NOT_LOADED, \u0022not loaded\u0022},\n- {ZENCOD_R_REQUEST_FAILED, \u0022request failed\u0022},\n- {ZENCOD_R_UNIT_FAILURE, \u0022unit failure\u0022},\n- {0, NULL}\n-};\n-\n-#endif\n-\n-#ifdef ZENCOD_LIB_NAME\n-static ERR_STRING_DATA ZENCOD_lib_name[] \u003d {\n- {0, ZENCOD_LIB_NAME},\n- {0, NULL}\n-};\n-#endif\n-\n-static int ZENCOD_lib_error_code \u003d 0;\n-static int ZENCOD_error_init \u003d 1;\n-\n-static void ERR_load_ZENCOD_strings(void)\n-{\n- if (ZENCOD_lib_error_code \u003d\u003d 0)\n- ZENCOD_lib_error_code \u003d ERR_get_next_error_library();\n-\n- if (ZENCOD_error_init) {\n- ZENCOD_error_init \u003d 0;\n-#ifndef OPENSSL_NO_ERR\n- ERR_load_strings(ZENCOD_lib_error_code, ZENCOD_str_functs);\n- ERR_load_strings(ZENCOD_lib_error_code, ZENCOD_str_reasons);\n-#endif\n-\n-#ifdef ZENCOD_LIB_NAME\n- ZENCOD_lib_name-\u003eerror \u003d ERR_PACK(ZENCOD_lib_error_code, 0, 0);\n- ERR_load_strings(0, ZENCOD_lib_name);\n-#endif\n- }\n-}\n-\n-static void ERR_unload_ZENCOD_strings(void)\n-{\n- if (ZENCOD_error_init \u003d\u003d 0) {\n-#ifndef OPENSSL_NO_ERR\n- ERR_unload_strings(ZENCOD_lib_error_code, ZENCOD_str_functs);\n- ERR_unload_strings(ZENCOD_lib_error_code, ZENCOD_str_reasons);\n-#endif\n-\n-#ifdef ZENCOD_LIB_NAME\n- ERR_unload_strings(0, ZENCOD_lib_name);\n-#endif\n- ZENCOD_error_init \u003d 1;\n- }\n-}\n-\n-static void ERR_ZENCOD_error(int function, int reason, char *file, int line)\n-{\n- if (ZENCOD_lib_error_code \u003d\u003d 0)\n- ZENCOD_lib_error_code \u003d ERR_get_next_error_library();\n- ERR_PUT_error(ZENCOD_lib_error_code, function, reason, file, line);\n-}\ndiff --git a/demos/engines/zencod/hw_zencod_err.h b/demos/engines/zencod/hw_zencod_err.h\ndeleted file mode 100644\nindex 94d3293..0000000\n--- a/demos/engines/zencod/hw_zencod_err.h\n+++ /dev/null\n@@ -1,100 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@openssl.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.openssl.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-#ifndef HEADER_ZENCOD_ERR_H\n-# define HEADER_ZENCOD_ERR_H\n-\n-#ifdef __cplusplus\n-extern \u0022C\u0022 {\n-#endif\n-\n-/* BEGIN ERROR CODES */\n-/*\n- * The following lines are auto generated by the script mkerr.pl. Any changes\n- * made after this point may be overwritten when the script is next run.\n- */\n-static void ERR_load_ZENCOD_strings(void);\n-static void ERR_unload_ZENCOD_strings(void);\n-static void ERR_ZENCOD_error(int function, int reason, char *file, int line);\n-# define ZENCODerr(f,r) ERR_ZENCOD_error((f),(r),OPENSSL_FILE,OPENSSL_LINE)\n-\n-/* Error codes for the ZENCOD functions. */\n-\n-/* Function codes. */\n-# define ZENCOD_F_ZENCOD_BN_MOD_EXP 100\n-# define ZENCOD_F_ZENCOD_CTRL 101\n-# define ZENCOD_F_ZENCOD_DH_COMPUTE 102\n-# define ZENCOD_F_ZENCOD_DH_GENERATE 103\n-# define ZENCOD_F_ZENCOD_DSA_DO_SIGN 104\n-# define ZENCOD_F_ZENCOD_DSA_DO_VERIFY 105\n-# define ZENCOD_F_ZENCOD_FINISH 106\n-# define ZENCOD_F_ZENCOD_INIT 107\n-# define ZENCOD_F_ZENCOD_RAND 108\n-# define ZENCOD_F_ZENCOD_RSA_MOD_EXP 109\n-# define ZENCOD_F_ZENCOD_RSA_MOD_EXP_CRT 110\n-\n-/* Reason codes. */\n-# define ZENCOD_R_ALREADY_LOADED 100\n-# define ZENCOD_R_BAD_KEY_COMPONENTS 101\n-# define ZENCOD_R_BN_EXPAND_FAIL 102\n-# define ZENCOD_R_CTRL_COMMAND_NOT_IMPLEMENTED 103\n-# define ZENCOD_R_DSO_FAILURE 104\n-# define ZENCOD_R_NOT_LOADED 105\n-# define ZENCOD_R_REQUEST_FAILED 106\n-# define ZENCOD_R_UNIT_FAILURE 107\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-#endif\ndiff --git a/demos/privkey.pem b/demos/privkey.pem\ndeleted file mode 100644\nindex ddae240..0000000\n--- a/demos/privkey.pem\n+++ /dev/null\n@@ -1,9 +0,0 @@\n------BEGIN RSA PRIVATE KEY-----\n-MIIBPAIBAAJBAN+FmbxmHVOp/RxtpMGz0DvQEBz1sDktHp19hIoMSu0YZift5MAu\n-4xAEJYvWVCshDiyOTWsUBXwZkrkt87FyctkCAwEAAQJAG/vxBGpQb6IPo1iC0RF/\n-F430BnwoBPCGLbeCOXpSgx5X+19vuTSdEqMgeNB6+aNb+XY/7mvVfCjyD6WZ0oxs\n-JQIhAPO+uL9cP40lFs62pdL3QSWsh3VNDByvOtr9LpeaxBm/AiEA6sKVfXsDQ5hd\n-SHt9U61r2r8Lcxmzi9Kw6JNqjMmzqWcCIQCKoRy+aZ8Tjdas9yDVHh+FZ90bEBkl\n-b1xQFNOdEj8aTQIhAOJWrO6INYNsWTPS6+hLYZtLamyUsQj0H+B8kNQge/mtAiEA\n-nBfvUl243qbqN8gF7Az1u33uc9FsPVvQPiBzLxZ4ixw\u003d\n------END RSA PRIVATE KEY-----\ndiff --git a/demos/selfsign.c b/demos/selfsign.c\ndeleted file mode 100644\nindex f0adba5..0000000\n--- a/demos/selfsign.c\n+++ /dev/null\n@@ -1,169 +0,0 @@\n-/* NOCW */\n-/* cc -o ssdemo -I../include selfsign.c ../libcrypto.a */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cstdlib.h\u003e\n-\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/conf.h\u003e\n-#include \u003copenssl/x509v3.h\u003e\n-\n-int mkit(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);\n-\n-int main()\n-{\n- BIO *bio_err;\n- X509 *x509 \u003d NULL;\n- EVP_PKEY *pkey \u003d NULL;\n-\n- CRYPTO_set_mem_debug(1);\n- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);\n-\n- bio_err \u003d BIO_new_fp(stderr, BIO_NOCLOSE);\n-\n- mkit(\u0026x509, \u0026pkey, 512, 0, 365);\n-\n- RSA_print_fp(stdout, pkey-\u003epkey.rsa, 0);\n- X509_print_fp(stdout, x509);\n-\n- PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);\n- PEM_write_X509(stdout, x509);\n-\n- X509_free(x509);\n- EVP_PKEY_free(pkey);\n-\n-#ifdef CUSTOM_EXT\n- /* Only needed if we add objects or custom extensions */\n- X509V3_EXT_cleanup();\n- OBJ_cleanup();\n-#endif\n-\n- CRYPTO_mem_leaks(bio_err);\n- BIO_free(bio_err);\n- return (0);\n-}\n-\n-static void callback(p, n, arg)\n-int p;\n-int n;\n-void *arg;\n-{\n- char c \u003d 'B';\n-\n- if (p \u003d\u003d 0)\n- c \u003d '.';\n- if (p \u003d\u003d 1)\n- c \u003d '+';\n- if (p \u003d\u003d 2)\n- c \u003d '*';\n- if (p \u003d\u003d 3)\n- c \u003d '\u005cn';\n- fputc(c, stderr);\n-}\n-\n-int mkit(x509p, pkeyp, bits, serial, days)\n-X509 **x509p;\n-EVP_PKEY **pkeyp;\n-int bits;\n-int serial;\n-int days;\n-{\n- X509 *x;\n- EVP_PKEY *pk;\n- RSA *rsa;\n- X509_NAME *name \u003d NULL;\n- X509_NAME_ENTRY *ne \u003d NULL;\n- X509_EXTENSION *ex \u003d NULL;\n-\n- if ((pkeyp \u003d\u003d NULL) || (*pkeyp \u003d\u003d NULL)) {\n- if ((pk \u003d EVP_PKEY_new()) \u003d\u003d NULL) {\n- abort();\n- return (0);\n- }\n- } else\n- pk \u003d *pkeyp;\n-\n- if ((x509p \u003d\u003d NULL) || (*x509p \u003d\u003d NULL)) {\n- if ((x \u003d X509_new()) \u003d\u003d NULL)\n- goto err;\n- } else\n- x \u003d *x509p;\n-\n- rsa \u003d RSA_generate_key(bits, RSA_F4, callback, NULL);\n- if (!EVP_PKEY_assign_RSA(pk, rsa)) {\n- abort();\n- goto err;\n- }\n- rsa \u003d NULL;\n-\n- X509_set_version(x, 3);\n- ASN1_INTEGER_set(X509_get_serialNumber(x), serial);\n- X509_gmtime_adj(X509_get_notBefore(x), 0);\n- X509_gmtime_adj(X509_get_notAfter(x), (long)60 * 60 * 24 * days);\n- X509_set_pubkey(x, pk);\n-\n- name \u003d X509_get_subject_name(x);\n-\n- /*\n- * This function creates and adds the entry, working out the correct\n- * string type and performing checks on its length. Normally we'd check\n- * the return value for errors...\n- */\n- X509_NAME_add_entry_by_txt(name, \u0022C\u0022, MBSTRING_ASC, \u0022UK\u0022, -1, -1, 0);\n- X509_NAME_add_entry_by_txt(name, \u0022CN\u0022,\n- MBSTRING_ASC, \u0022OpenSSL Group\u0022, -1, -1, 0);\n-\n- X509_set_issuer_name(x, name);\n-\n- /*\n- * Add extension using V3 code: we can set the config file as NULL\n- * because we wont reference any other sections. We can also set the\n- * context to NULL because none of these extensions below will need to\n- * access it.\n- */\n-\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_cert_type, \u0022server\u0022);\n- X509_add_ext(x, ex, -1);\n- X509_EXTENSION_free(ex);\n-\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_comment,\n- \u0022example comment extension\u0022);\n- X509_add_ext(x, ex, -1);\n- X509_EXTENSION_free(ex);\n-\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, NID_netscape_ssl_server_name,\n- \u0022www.openssl.org\u0022);\n-\n- X509_add_ext(x, ex, -1);\n- X509_EXTENSION_free(ex);\n-\n-#ifdef ADD_CA_CONSTRAINT\n- /* might want something like this too.... */\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints,\n- \u0022critical,CA:TRUE\u0022);\n-\n- X509_add_ext(x, ex, -1);\n- X509_EXTENSION_free(ex);\n-#endif\n-\n-#ifdef ADD_A_CUSTOM_EXTENSION\n- /* Maybe even add our own extension based on existing */\n- {\n- int nid;\n- nid \u003d OBJ_create(\u00221.2.3.4\u0022, \u0022MyAlias\u0022, \u0022My Test Alias Extension\u0022);\n- X509V3_EXT_add_alias(nid, NID_netscape_comment);\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, nid, \u0022example comment alias\u0022);\n- X509_add_ext(x, ex, -1);\n- X509_EXTENSION_free(ex);\n- }\n-#endif\n-\n- if (!X509_sign(x, pk, EVP_md5()))\n- goto err;\n-\n- *x509p \u003d x;\n- *pkeyp \u003d pk;\n- return (1);\n- err:\n- return (0);\n-}\ndiff --git a/demos/sign/Makefile.in b/demos/sign/Makefile.in\ndeleted file mode 100644\nindex f6afeb7..0000000\n--- a/demos/sign/Makefile.in\n+++ /dev/null\n@@ -1,16 +0,0 @@\n-CC\u003dcc\n-CFLAGS\u003d -g -I../../include -Wall\n-LIBS\u003d -L../.. -lcrypto\n-EXAMPLES\u003dsign\n-\n-all: $(EXAMPLES) \n-\n-sign: sign.o\n-\t$(CC) -o sign sign.o $(LIBS)\n-\n-clean:\t\n-\trm -f $(EXAMPLES) *.o\n-\n-test: all\n-\t./sign\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/sign/cert.pem b/demos/sign/cert.pem\ndeleted file mode 100644\nindex 9d7ac23..0000000\n--- a/demos/sign/cert.pem\n+++ /dev/null\n@@ -1,14 +0,0 @@\n------BEGIN CERTIFICATE-----\n-MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD\n-VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv\n-bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy\n-dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X\n-DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw\n-EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l\n-dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT\n-EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp\n-MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw\n-L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN\n-BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX\n-9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4\u003d\n------END CERTIFICATE-----\ndiff --git a/demos/sign/key.pem b/demos/sign/key.pem\ndeleted file mode 100644\nindex 239ad66..0000000\n--- a/demos/sign/key.pem\n+++ /dev/null\n@@ -1,9 +0,0 @@\n------BEGIN RSA PRIVATE KEY-----\n-MIIBPAIBAAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNwL4lYKbpzzlmC5beaQXeQ\n-2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAAQJBALjkK+jc2+iihI98riEF\n-oudmkNziSRTYjnwjx8mCoAjPWviB3c742eO3FG4/soi1jD9A5alihEOXfUzloenr\n-8IECIQD3B5+0l+68BA/6d76iUNqAAV8djGTzvxnCxycnxPQydQIhAMXt4trUI3nc\n-a+U8YL2HPFA3gmhBsSICbq2OptOCnM7hAiEA6Xi3JIQECob8YwkRj29DU3/4WYD7\n-WLPgsQpwo1GuSpECICGsnWH5oaeD9t9jbFoSfhJvv0IZmxdcLpRcpslpeWBBAiEA\n-6/5B8J0GHdJq89FHwEG/H2eVVUYu5y/aD6sgcm+0Avg\u003d\n------END RSA PRIVATE KEY-----\ndiff --git a/demos/sign/sig.txt b/demos/sign/sig.txt\ndeleted file mode 100644\nindex 5613c0e..0000000\n--- a/demos/sign/sig.txt\n+++ /dev/null\n@@ -1,158 +0,0 @@\n-From ssl-lists-owner@mincom.com Mon Sep 30 02:37:40 1996\n-Received: from cygnus.mincom.oz.au by orb.mincom.oz.au with SMTP id AA11782\n- (5.65c/IDA-1.4.4 for eay); Mon, 30 Sep 1996 11:46:21 +1000\n-Received: (from daemon@localhost) by cygnus.mincom.oz.au (8.7.5/8.7.3) id LAA18980 for ssl-users-outgoing; Mon, 30 Sep 1996 11:44:56 +1000 (EST)\n-Received: from minbne.mincom.oz.au (minbne.mincom.oz.au [192.55.196.247]) by cygnus.mincom.oz.au (8.7.5/8.7.3) with SMTP id LAA18962 for \u003cssl-users@listserv.mincom.oz.au\u003e; Mon, 30 Sep 1996 11:44:51 +1000 (EST)\n-Received: by minbne.mincom.oz.au id AA22230\n- (5.65c/IDA-1.4.4 for ssl-users@listserv.mincom.oz.au); Mon, 30 Sep 1996 11:38:41 +1000\n-Received: from brutus.neuronio.pt (brutus.neuronio.pt [193.126.253.2]) by bunyip.cc.uq.oz.au (8.7.6/8.7.3) with SMTP id LAA15824 for \u003cssl-users@mincom.com\u003e; Mon, 30 Sep 1996 11:40:07 +1000\n-Received: (from sampo@localhost) by brutus.neuronio.pt (8.6.11/8.6.11) id BAA08729; Mon, 30 Sep 1996 01:37:40 +0100\n-Date: Mon, 30 Sep 1996 01:37:40 +0100\n-Message-Id: \u003c199609300037.BAA08729@brutus.neuronio.pt\u003e\n-From: Sampo Kellomaki \u003csampo@neuronio.pt\u003e\n-To: ssl-users@mincom.com\n-Cc: sampo@brutus.neuronio.pt\n-Subject: Signing with envelope routines\n-Sender: ssl-lists-owner@mincom.com\n-Precedence: bulk\n-Status: RO\n-X-Status: D\n-\n-\n-I have been trying to figure out how to produce signatures with EVP_\n-routines. I seem to be able to read in private key and sign some\n-data ok, but I can't figure out how I am supposed to read in\n-public key so that I could verify my signature. I use self signed\n-certificate.\n-\n-I figured I should use\n-\tEVP_PKEY* pkey \u003d PEM_ASN1_read(d2i_PrivateKey, PEM_STRING_EVP_PKEY,\n-\t fp, NULL, NULL);\n-to read in private key and this seems to work Ok.\n-\n-However when I try analogous\n-\tEVP_PKEY* pkey \u003d PEM_ASN1_read(d2i_PublicKey, PEM_STRING_X509,\n-\t fp, NULL, NULL);\n-the program fails with\n-\n-error:0D09508D:asn1 encoding routines:D2I_PUBLICKEY:unknown public key type:d2i_pu.c:93\n-error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 lib:pem_lib.c:232\n-\n-I figured that the second argument to PEM_ASN1_read should match the\n-name in my PEM encoded object, hence PEM_STRING_X509.\n-PEM_STRING_EVP_PKEY seems to be somehow magical\n-because it matches whatever private key there happens to be. I could\n-not find a similar constant to use with getting the certificate, however.\n-\n-Is my approach of using PEM_ASN1_read correct? What should I pass in\n-as name? Can I use normal (or even self signed) X509 certificate for\n-verifying the signature?\n-\n-When will SSLeay documentation be written ;-)? If I would contribute\n-comments to the code, would Eric take time to review them and include\n-them in distribution?\n-\n-I'm using SSLeay-0.6.4. My program is included below along with the\n-key and cert that I use.\n-\n---Sampo\n-\n------------------------------------\n-/* sign-it.cpp - Simple test app using SSLeay envelopes to sign data\n- 29.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e */\n-\n-#include \u003cstdio.h\u003e\n-#include \u0022rsa.h\u0022\n-#include \u0022evp.h\u0022\n-#include \u0022objects.h\u0022\n-#include \u0022x509.h\u0022\n-#include \u0022err.h\u0022\n-#include \u0022pem.h\u0022\n-#include \u0022ssl.h\u0022\n-\n-void main ()\n-{\n- int err;\n- int sig_len;\n- unsigned char sig_buf [4096];\n- const char certfile[] \u003d \u0022plain-cert.pem\u0022;\n- const char keyfile[] \u003d \u0022plain-key.pem\u0022;\n- const char data[] \u003d \u0022I owe you...\u0022;\n- EVP_MD_CTX md_ctx;\n- EVP_PKEY* pkey;\n- FILE* fp;\n-\n- SSL_load_error_strings();\n- \n- /* Read private key */\n- \n- fp \u003d fopen (keyfile, \u0022r\u0022); if (fp \u003d\u003d NULL) exit (1);\n- pkey \u003d (EVP_PKEY*)PEM_ASN1_read ((char *(*)())d2i_PrivateKey,\n-\t\t\t\t PEM_STRING_EVP_PKEY,\n-\t\t\t\t fp,\n-\t\t\t\t NULL, NULL);\n- if (pkey \u003d\u003d NULL) { ERR_print_errors_fp (stderr); exit (1); }\n- fclose (fp);\n- \n- /* Do the signature */\n- \n- EVP_SignInit (\u0026md_ctx, EVP_md5());\n- EVP_SignUpdate (\u0026md_ctx, data, strlen(data));\n- sig_len \u003d sizeof(sig_buf);\n- err \u003d EVP_SignFinal (\u0026md_ctx,\n-\t\t sig_buf, \n-\t\t \u0026sig_len,\n-\t\t pkey);\n- if (err !\u003d 1) { ERR_print_errors_fp (stderr); exit (1); }\n- EVP_PKEY_free (pkey);\n- \n- /* Read public key */\n- \n- fp \u003d fopen (certfile, \u0022r\u0022); if (fp \u003d\u003d NULL) exit (1);\n- pkey \u003d (EVP_PKEY*)PEM_ASN1_read ((char *(*)())d2i_PublicKey,\n-\t\t\t\t PEM_STRING_X509,\n-\t\t\t\t fp,\n-\t\t\t\t NULL, NULL);\n- if (pkey \u003d\u003d NULL) { ERR_print_errors_fp (stderr); exit (1); }\n- fclose (fp);\n- \n- /* Verify the signature */\n- \n- EVP_VerifyInit (\u0026md_ctx, EVP_md5());\n- EVP_VerifyUpdate (\u0026md_ctx, data, strlen((char*)data));\n- err \u003d EVP_VerifyFinal (\u0026md_ctx,\n-\t\t\t sig_buf,\n-\t\t\t sig_len,\n-\t\t\t pkey);\n- if (err !\u003d 1) { ERR_print_errors_fp (stderr); exit (1); }\n- EVP_PKEY_free (pkey);\n- printf (\u0022Signature Verified Ok.\u005cn\u0022);\n-}\n-/* EOF */\n---------------- plain-cert.pem -----------------\n------BEGIN CERTIFICATE-----\n-MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD\n-VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv\n-bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy\n-dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X\n-DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw\n-EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l\n-dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT\n-EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp\n-MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw\n-L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN\n-BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX\n-9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4\u003d\n------END CERTIFICATE-----\n----------------- plain-key.pem -----------------\n------BEGIN RSA PRIVATE KEY-----\n-MIIBPAIBAAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNwL4lYKbpzzlmC5beaQXeQ\n-2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAAQJBALjkK+jc2+iihI98riEF\n-oudmkNziSRTYjnwjx8mCoAjPWviB3c742eO3FG4/soi1jD9A5alihEOXfUzloenr\n-8IECIQD3B5+0l+68BA/6d76iUNqAAV8djGTzvxnCxycnxPQydQIhAMXt4trUI3nc\n-a+U8YL2HPFA3gmhBsSICbq2OptOCnM7hAiEA6Xi3JIQECob8YwkRj29DU3/4WYD7\n-WLPgsQpwo1GuSpECICGsnWH5oaeD9t9jbFoSfhJvv0IZmxdcLpRcpslpeWBBAiEA\n-6/5B8J0GHdJq89FHwEG/H2eVVUYu5y/aD6sgcm+0Avg\u003d\n------END RSA PRIVATE KEY-----\n-------------------------------------------------\n-\ndiff --git a/demos/sign/sign.c b/demos/sign/sign.c\ndeleted file mode 100644\nindex fb0e038..0000000\n--- a/demos/sign/sign.c\n+++ /dev/null\n@@ -1,159 +0,0 @@\n-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n- * All rights reserved.\n- *\n- * This package is an SSL implementation written\n- * by Eric Young (eay@cryptsoft.com).\n- * The implementation was written so as to conform with Netscapes SSL.\n- *\n- * This library is free for commercial and non-commercial use as long as\n- * the following conditions are aheared to. The following conditions\n- * apply to all code found in this distribution, be it the RC4, RSA,\n- * lhash, DES, etc., code; not just the SSL code. The SSL documentation\n- * included with this distribution is covered by the same copyright terms\n- * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n- *\n- * Copyright remains Eric Young's, and as such any Copyright notices in\n- * the code are not to be removed.\n- * If this package is used in a product, Eric Young should be given attribution\n- * as the author of the parts of the library used.\n- * This can be in the form of a textual message at program startup or\n- * in documentation (online or textual) provided with the package.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- * 1. Redistributions of source code must retain the copyright\n- * notice, this list of conditions and the following disclaimer.\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in the\n- * documentation and/or other materials provided with the distribution.\n- * 3. All advertising materials mentioning features or use of this software\n- * must display the following acknowledgement:\n- * \u0022This product includes cryptographic software written by\n- * Eric Young (eay@cryptsoft.com)\u0022\n- * The word 'cryptographic' can be left out if the rouines from the library\n- * being used are not cryptographic related :-).\n- * 4. If you include any Windows specific code (or a derivative thereof) from\n- * the apps directory (application code) you must include an acknowledgement:\n- * \u0022This product includes software written by Tim Hudson (tjh@cryptsoft.com)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n- * SUCH DAMAGE.\n- *\n- * The licence and distribution terms for any publically available version or\n- * derivative of this code cannot be changed. i.e. this code cannot simply be\n- * copied and put under another distribution licence\n- * [including the GNU Public Licence.]\n- */\n-\n-/*\n- * sign-it.cpp - Simple test app using EVP envelopes to sign data\n- * 29.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e\n- */\n-\n-/* converted to C - eay :-) */\n-\n-/*\n- * reformated a bit and converted to use the more common functions: this was\n- * initially written at the dawn of time :-) - Steve.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003copenssl/rsa.h\u003e\n-#include \u003copenssl/evp.h\u003e\n-#include \u003copenssl/objects.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-\n-int main()\n-{\n- int err;\n- int sig_len;\n- unsigned char sig_buf[4096];\n- static char certfile[] \u003d \u0022cert.pem\u0022;\n- static char keyfile[] \u003d \u0022key.pem\u0022;\n- static char data[] \u003d \u0022I owe you...\u0022;\n- EVP_MD_CTX md_ctx;\n- EVP_PKEY *pkey;\n- FILE *fp;\n- X509 *x509;\n-\n- /*\n- * Just load the crypto library error strings, SSL_load_error_strings()\n- * loads the crypto AND the SSL ones\n- */\n- /* SSL_load_error_strings(); */\n- ERR_load_crypto_strings();\n-\n- /* Read private key */\n-\n- fp \u003d fopen(keyfile, \u0022r\u0022);\n- if (fp \u003d\u003d NULL)\n- exit(1);\n- pkey \u003d PEM_read_PrivateKey(fp, NULL, NULL, NULL);\n- fclose(fp);\n-\n- if (pkey \u003d\u003d NULL) {\n- ERR_print_errors_fp(stderr);\n- exit(1);\n- }\n-\n- /* Do the signature */\n-\n- EVP_SignInit(\u0026md_ctx, EVP_sha1());\n- EVP_SignUpdate(\u0026md_ctx, data, strlen(data));\n- sig_len \u003d sizeof(sig_buf);\n- err \u003d EVP_SignFinal(\u0026md_ctx, sig_buf, \u0026sig_len, pkey);\n-\n- if (err !\u003d 1) {\n- ERR_print_errors_fp(stderr);\n- exit(1);\n- }\n-\n- EVP_PKEY_free(pkey);\n-\n- /* Read public key */\n-\n- fp \u003d fopen(certfile, \u0022r\u0022);\n- if (fp \u003d\u003d NULL)\n- exit(1);\n- x509 \u003d PEM_read_X509(fp, NULL, NULL, NULL);\n- fclose(fp);\n-\n- if (x509 \u003d\u003d NULL) {\n- ERR_print_errors_fp(stderr);\n- exit(1);\n- }\n-\n- /* Get public key - eay */\n- pkey \u003d X509_get_pubkey(x509);\n- if (pkey \u003d\u003d NULL) {\n- ERR_print_errors_fp(stderr);\n- exit(1);\n- }\n-\n- /* Verify the signature */\n-\n- EVP_VerifyInit(\u0026md_ctx, EVP_sha1());\n- EVP_VerifyUpdate(\u0026md_ctx, data, strlen((char *)data));\n- err \u003d EVP_VerifyFinal(\u0026md_ctx, sig_buf, sig_len, pkey);\n- EVP_PKEY_free(pkey);\n-\n- if (err !\u003d 1) {\n- ERR_print_errors_fp(stderr);\n- exit(1);\n- }\n- printf(\u0022Signature Verified Ok.\u005cn\u0022);\n- return (0);\n-}\ndiff --git a/demos/sign/sign.txt b/demos/sign/sign.txt\ndeleted file mode 100644\nindex 2aa2b46..0000000\n--- a/demos/sign/sign.txt\n+++ /dev/null\n@@ -1,170 +0,0 @@\n-From ssl-lists-owner@mincom.com Mon Sep 30 22:43:15 1996\n-Received: from cygnus.mincom.oz.au by orb.mincom.oz.au with SMTP id AA12802\n- (5.65c/IDA-1.4.4 for eay); Mon, 30 Sep 1996 12:45:43 +1000\n-Received: (from daemon@localhost) by cygnus.mincom.oz.au (8.7.5/8.7.3) id MAA25922 for ssl-users-outgoing; Mon, 30 Sep 1996 12:43:43 +1000 (EST)\n-Received: from orb.mincom.oz.au (eay@orb.mincom.oz.au [192.55.197.1]) by cygnus.mincom.oz.au (8.7.5/8.7.3) with SMTP id MAA25900 for \u003cssl-users@listserv.mincom.oz.au\u003e; Mon, 30 Sep 1996 12:43:39 +1000 (EST)\n-Received: by orb.mincom.oz.au id AA12688\n- (5.65c/IDA-1.4.4 for ssl-users@listserv.mincom.oz.au); Mon, 30 Sep 1996 12:43:16 +1000\n-Date: Mon, 30 Sep 1996 12:43:15 +1000 (EST)\n-From: Eric Young \u003ceay@mincom.com\u003e\n-X-Sender: eay@orb\n-To: Sampo Kellomaki \u003csampo@neuronio.pt\u003e\n-Cc: ssl-users@mincom.com, sampo@brutus.neuronio.pt\n-Subject: Re: Signing with envelope routines\n-In-Reply-To: \u003c199609300037.BAA08729@brutus.neuronio.pt\u003e\n-Message-Id: \u003cPine.SOL.3.91.960930121504.11800Y-100000@orb\u003e\n-Mime-Version: 1.0\n-Content-Type: TEXT/PLAIN; charset\u003dUS-ASCII\n-Sender: ssl-lists-owner@mincom.com\n-Precedence: bulk\n-Status: O\n-X-Status: \n-\n-\n-On Mon, 30 Sep 1996, Sampo Kellomaki wrote:\n-\u003e I have been trying to figure out how to produce signatures with EVP_\n-\u003e routines. I seem to be able to read in private key and sign some\n-\u003e data ok, but I can't figure out how I am supposed to read in\n-\u003e public key so that I could verify my signature. I use self signed\n-\u003e certificate.\n-\n-hmm... a rather poorly documented are of the library at this point in time.\n-\n-\u003e I figured I should use\n-\u003e \tEVP_PKEY* pkey \u003d PEM_ASN1_read(d2i_PrivateKey, PEM_STRING_EVP_PKEY,\n-\u003e \t fp, NULL, NULL);\n-\u003e to read in private key and this seems to work Ok.\n-\u003e \n-\u003e However when I try analogous\n-\u003e \tEVP_PKEY* pkey \u003d PEM_ASN1_read(d2i_PublicKey, PEM_STRING_X509,\n-\u003e \t fp, NULL, NULL);\n-\n-What you should do is \n-\tX509 *x509\u003dPEM_read_X509(fp,NULL,NULL);\n-\t/* which is the same as PEM_ASN1_read(d2i_X509,PEM_STRING_X509,fp,\n-\t * NULL,NULL); */\n-Then\n-\tEVP_PKEY *pkey\u003dX509_extract_key(x509);\n-\n-There is also a X509_REQ_extract_key(req);\n-which gets the public key from a certificate request.\n-\n-I re-worked quite a bit of this when I cleaned up the dependancy on\n-RSA as the private key.\n-\n-\u003e I figured that the second argument to PEM_ASN1_read should match the\n-\u003e name in my PEM encoded object, hence PEM_STRING_X509.\n-\u003e PEM_STRING_EVP_PKEY seems to be somehow magical\n-\u003e because it matches whatever private key there happens to be. I could\n-\u003e not find a similar constant to use with getting the certificate, however.\n-\n-:-), PEM_STRING_EVP_PKEY is 'magical' :-). In theory I should be using a\n-standard such as PKCS#8 to store the private key so that the type is \n-encoded in the asn.1 encoding of the object.\n-\n-\u003e Is my approach of using PEM_ASN1_read correct? What should I pass in\n-\u003e as name? Can I use normal (or even self signed) X509 certificate for\n-\u003e verifying the signature?\n-\n-The actual public key is kept in the certificate, so basically you have \n-to load the certificate and then 'unpack' the public key from the \n-certificate.\n-\n-\u003e When will SSLeay documentation be written ;-)? If I would contribute\n-\u003e comments to the code, would Eric take time to review them and include\n-\u003e them in distribution?\n-\n-:-) After SSLv3 and PKCS#7 :-). I actually started doing a function list \n-but what I really need to do is do quite a few 'this is how you do xyz' \n-type documents. I suppose the current method is to post to ssl-users and \n-I'll respond :-).\n-\n-I'll add a 'demo' directory for the next release, I've appended a \n-modified version of your program that works, you were very close :-).\n-\n-eric\n-\n-/* sign-it.cpp - Simple test app using SSLeay envelopes to sign data\n- 29.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e */\n-\n-/* converted to C - eay :-) */\n-\n-#include \u003cstdio.h\u003e\n-#include \u0022rsa.h\u0022\n-#include \u0022evp.h\u0022\n-#include \u0022objects.h\u0022\n-#include \u0022x509.h\u0022\n-#include \u0022err.h\u0022\n-#include \u0022pem.h\u0022\n-#include \u0022ssl.h\u0022\n-\n-void main ()\n-{\n- int err;\n- int sig_len;\n- unsigned char sig_buf [4096];\n- static char certfile[] \u003d \u0022plain-cert.pem\u0022;\n- static char keyfile[] \u003d \u0022plain-key.pem\u0022;\n- static char data[] \u003d \u0022I owe you...\u0022;\n- EVP_MD_CTX md_ctx;\n- EVP_PKEY * pkey;\n- FILE * fp;\n- X509 *\tx509;\n-\n- /* Just load the crypto library error strings,\n- * SSL_load_error_strings() loads the crypto AND the SSL ones */\n- /* SSL_load_error_strings();*/\n- ERR_load_crypto_strings();\n- \n- /* Read private key */\n- \n- fp \u003d fopen (keyfile, \u0022r\u0022); if (fp \u003d\u003d NULL) exit (1);\n- pkey \u003d (EVP_PKEY*)PEM_ASN1_read ((char *(*)())d2i_PrivateKey,\n-\t\t\t\t PEM_STRING_EVP_PKEY,\n-\t\t\t\t fp,\n-\t\t\t\t NULL, NULL);\n- if (pkey \u003d\u003d NULL) { ERR_print_errors_fp (stderr); exit (1); }\n- fclose (fp);\n- \n- /* Do the signature */\n- \n- EVP_SignInit (\u0026md_ctx, EVP_md5());\n- EVP_SignUpdate (\u0026md_ctx, data, strlen(data));\n- sig_len \u003d sizeof(sig_buf);\n- err \u003d EVP_SignFinal (\u0026md_ctx,\n-\t\t sig_buf, \n-\t\t \u0026sig_len,\n-\t\t pkey);\n- if (err !\u003d 1) { ERR_print_errors_fp (stderr); exit (1); }\n- EVP_PKEY_free (pkey);\n- \n- /* Read public key */\n- \n- fp \u003d fopen (certfile, \u0022r\u0022); if (fp \u003d\u003d NULL) exit (1);\n- x509 \u003d (X509 *)PEM_ASN1_read ((char *(*)())d2i_X509,\n-\t\t\t\t PEM_STRING_X509,\n-\t\t\t\t fp, NULL, NULL);\n- if (x509 \u003d\u003d NULL) { ERR_print_errors_fp (stderr); exit (1); }\n- fclose (fp);\n- \n- /* Get public key - eay */\n- pkey\u003dX509_extract_key(x509);\n- if (pkey \u003d\u003d NULL) { ERR_print_errors_fp (stderr); exit (1); }\n-\n- /* Verify the signature */\n- \n- EVP_VerifyInit (\u0026md_ctx, EVP_md5());\n- EVP_VerifyUpdate (\u0026md_ctx, data, strlen((char*)data));\n- err \u003d EVP_VerifyFinal (\u0026md_ctx,\n-\t\t\t sig_buf,\n-\t\t\t sig_len,\n-\t\t\t pkey);\n- if (err !\u003d 1) { ERR_print_errors_fp (stderr); exit (1); }\n- EVP_PKEY_free (pkey);\n- printf (\u0022Signature Verified Ok.\u005cn\u0022);\n-}\n-\n-\n-\n-\n-\ndiff --git a/demos/spkigen.c b/demos/spkigen.c\ndeleted file mode 100644\nindex 7df8f34..0000000\n--- a/demos/spkigen.c\n+++ /dev/null\n@@ -1,171 +0,0 @@\n-/* NOCW */\n-/*-\n- * demos/spkigen.c\n- * 18-Mar-1997 - eay - A quick hack :-)\n- * version 1.1, it would probably help to save or load the\n- * private key :-)\n- */\n-#include \u003cstdio.h\u003e\n-#include \u003cstdlib.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u003copenssl/asn1.h\u003e\n-#include \u003copenssl/objects.h\u003e\n-#include \u003copenssl/evp.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-\n-/*\n- * The following two don't exist in SSLeay but they are in here as examples\n- */\n-#define PEM_write_SPKI(fp,x) \u005c\n- PEM_ASN1_write((int (*)())i2d_NETSCAPE_SPKI,\u0022SPKI\u0022,fp,\u005c\n- (char *)x,NULL,NULL,0,NULL)\n-int SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n-\n-/* These are defined in the next version of SSLeay */\n-int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key);\n-#define RSA_F4 0x10001\n-#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\u005c\n- (char *)(rsa))\n-\n-int main(argc, argv)\n-int argc;\n-char *argv[];\n-{\n- RSA *rsa \u003d NULL;\n- NETSCAPE_SPKI *spki \u003d NULL;\n- EVP_PKEY *pkey \u003d NULL;\n- char buf[128];\n- int ok \u003d 0, i;\n- FILE *fp;\n-\n- pkey \u003d EVP_PKEY_new();\n-\n- if (argc \u003c 2) {\n- /*\n- * Generate an RSA key, the random state should have been seeded with\n- * lots of calls to RAND_seed(....)\n- */\n- fprintf(stderr, \u0022generating RSA key, could take some time...\u005cn\u0022);\n- if ((rsa \u003d RSA_generate_key(512, RSA_F4, NULL)) \u003d\u003d NULL)\n- goto err;\n- } else {\n- if ((fp \u003d fopen(argv[1], \u0022r\u0022)) \u003d\u003d NULL) {\n- perror(argv[1]);\n- goto err;\n- }\n- if ((rsa \u003d PEM_read_RSAPrivateKey(fp, NULL, NULL)) \u003d\u003d NULL)\n- goto err;\n- fclose(fp);\n- }\n-\n- if (!EVP_PKEY_assign_RSA(pkey, rsa))\n- goto err;\n- rsa \u003d NULL;\n-\n- /* lets make the spki and set the public key and challenge */\n- if ((spki \u003d NETSCAPE_SPKI_new()) \u003d\u003d NULL)\n- goto err;\n-\n- if (!SPKI_set_pubkey(spki, pkey))\n- goto err;\n-\n- fprintf(stderr, \u0022please enter challenge string:\u0022);\n- fflush(stderr);\n- buf[0] \u003d '\u005c0';\n- fgets(buf, sizeof buf, stdin);\n- i \u003d strlen(buf);\n- if (i \u003e 0)\n- buf[--i] \u003d '\u005c0';\n- if (!ASN1_STRING_set((ASN1_STRING *)spki-\u003espkac-\u003echallenge, buf, i))\n- goto err;\n-\n- if (!NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()))\n- goto err;\n- PEM_write_SPKI(stdout, spki);\n- if (argc \u003c 2)\n- PEM_write_RSAPrivateKey(stdout, pkey-\u003epkey.rsa, NULL, NULL, 0, NULL);\n-\n- ok \u003d 1;\n- err:\n- if (!ok) {\n- fprintf(stderr, \u0022something bad happened....\u0022);\n- ERR_print_errors_fp(stderr);\n- }\n- NETSCAPE_SPKI_free(spki);\n- EVP_PKEY_free(pkey);\n- exit(!ok);\n-}\n-\n-/* This function is in the next version of SSLeay */\n-int EVP_PKEY_assign(pkey, type, key)\n-EVP_PKEY *pkey;\n-int type;\n-char *key;\n-{\n- if (pkey \u003d\u003d NULL)\n- return (0);\n- if (pkey-\u003epkey.ptr !\u003d NULL) {\n- if (pkey-\u003etype \u003d\u003d EVP_PKEY_RSA)\n- RSA_free(pkey-\u003epkey.rsa);\n- /* else memory leak */\n- }\n- pkey-\u003etype \u003d type;\n- pkey-\u003epkey.ptr \u003d key;\n- return (1);\n-}\n-\n-/*\n- * While I have a X509_set_pubkey() and X509_REQ_set_pubkey(),\n- * SPKI_set_pubkey() does not currently exist so here is a version of it. The\n- * next SSLeay release will probably have X509_set_pubkey(),\n- * X509_REQ_set_pubkey() and NETSCAPE_SPKI_set_pubkey() as macros calling the\n- * same function\n- */\n-int SPKI_set_pubkey(x, pkey)\n-NETSCAPE_SPKI *x;\n-EVP_PKEY *pkey;\n-{\n- int ok \u003d 0;\n- X509_PUBKEY *pk;\n- X509_ALGOR *a;\n- ASN1_OBJECT *o;\n- unsigned char *s, *p;\n- int i;\n-\n- if (x \u003d\u003d NULL)\n- return (0);\n-\n- if ((pk \u003d X509_PUBKEY_new()) \u003d\u003d NULL)\n- goto err;\n- a \u003d pk-\u003ealgor;\n-\n- /* set the algorithm id */\n- if ((o \u003d OBJ_nid2obj(pkey-\u003etype)) \u003d\u003d NULL)\n- goto err;\n- ASN1_OBJECT_free(a-\u003ealgorithm);\n- a-\u003ealgorithm \u003d o;\n-\n- /* Set the parameter list */\n- if ((a-\u003eparameter \u003d\u003d NULL) || (a-\u003eparameter-\u003etype !\u003d V_ASN1_NULL)) {\n- ASN1_TYPE_free(a-\u003eparameter);\n- a-\u003eparameter \u003d ASN1_TYPE_new();\n- a-\u003eparameter-\u003etype \u003d V_ASN1_NULL;\n- }\n- i \u003d i2d_PublicKey(pkey, NULL);\n- if ((s \u003d (unsigned char *)malloc(i + 1)) \u003d\u003d NULL)\n- goto err;\n- p \u003d s;\n- i2d_PublicKey(pkey, \u0026p);\n- if (!ASN1_BIT_STRING_set(pk-\u003epublic_key, s, i))\n- goto err;\n- free(s);\n-\n- X509_PUBKEY_free(x-\u003espkac-\u003epubkey);\n- x-\u003espkac-\u003epubkey \u003d pk;\n- pk \u003d NULL;\n- ok \u003d 1;\n- err:\n- X509_PUBKEY_free(pk);\n- return (ok);\n-}\ndiff --git a/demos/ssl/cli.cpp b/demos/ssl/cli.cpp\ndeleted file mode 100644\nindex fcc4d9d..0000000\n--- a/demos/ssl/cli.cpp\n+++ /dev/null\n@@ -1,108 +0,0 @@\n-/* cli.cpp - Minimal ssleay client for Unix\n- 30.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e */\n-\n-/* mangled to work with OpenSSL 0.9.2b\n- Simplified to be even more minimal\n- 12/98 - 4/99 Wade Scholine \u003cwades@mail.cybg.com\u003e */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cmemory.h\u003e\n-#include \u003cerrno.h\u003e\n-#include \u003csys/types.h\u003e\n-#include \u003csys/socket.h\u003e\n-#include \u003cnetinet/in.h\u003e\n-#include \u003carpa/inet.h\u003e\n-#include \u003cnetdb.h\u003e\n-\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/err.h\u003e\n-\n-\n-#define CHK_NULL(x) if ((x)\u003d\u003dNULL) exit (1)\n-#define CHK_ERR(err,s) if ((err)\u003d\u003d-1) { perror(s); exit(1); }\n-#define CHK_SSL(err) if ((err)\u003d\u003d-1) { ERR_print_errors_fp(stderr); exit(2); }\n-\n-void main ()\n-{\n- int err;\n- int sd;\n- struct sockaddr_in sa;\n- SSL_CTX* ctx;\n- SSL* ssl;\n- X509* server_cert;\n- char* str;\n- char buf [4096];\n- SSL_METHOD *meth;\n-\n- OpenSSL_add_ssl_algorithms();\n- meth \u003d TLS_client_method();\n- SSL_load_error_strings();\n- ctx \u003d SSL_CTX_new (meth); CHK_NULL(ctx);\n-\n- /* ----------------------------------------------- */\n- /* Create a socket and connect to server using normal socket calls. */\n- \n- sd \u003d socket (AF_INET, SOCK_STREAM, 0); CHK_ERR(sd, \u0022socket\u0022);\n- \n- memset(\u0026sa, 0, sizeof(sa));\n- sa.sin_family \u003d AF_INET;\n- sa.sin_addr.s_addr \u003d inet_addr (\u0022127.0.0.1\u0022); /* Server IP */\n- sa.sin_port \u003d htons (1111); /* Server Port number */\n- \n- err \u003d connect(sd, (struct sockaddr*) \u0026sa,\n-\t\tsizeof(sa)); CHK_ERR(err, \u0022connect\u0022);\n-\n- /* ----------------------------------------------- */\n- /* Now we have TCP conncetion. Start SSL negotiation. */\n- \n- ssl \u003d SSL_new (ctx); CHK_NULL(ssl); \n- SSL_set_fd (ssl, sd);\n- err \u003d SSL_connect (ssl); CHK_SSL(err);\n- \n- /* Following two steps are optional and not required for\n- data exchange to be successful. */\n- \n- /* Get the cipher - opt */\n-\n- printf (\u0022SSL connection using %s\u005cn\u0022, SSL_get_cipher (ssl));\n- \n- /* Get server's certificate (note: beware of dynamic allocation) - opt */\n-\n- server_cert \u003d SSL_get_peer_certificate (ssl); CHK_NULL(server_cert);\n- printf (\u0022Server certificate:\u005cn\u0022);\n- \n- str \u003d X509_NAME_oneline (X509_get_subject_name (server_cert),0,0);\n- CHK_NULL(str);\n- printf (\u0022\u005ct subject: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n-\n- str \u003d X509_NAME_oneline (X509_get_issuer_name (server_cert),0,0);\n- CHK_NULL(str);\n- printf (\u0022\u005ct issuer: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n-\n- /* We could do all sorts of certificate verification stuff here before\n- deallocating the certificate. */\n-\n- X509_free (server_cert);\n- \n- /* --------------------------------------------------- */\n- /* DATA EXCHANGE - Send a message and receive a reply. */\n-\n- err \u003d SSL_write (ssl, \u0022Hello World!\u0022, strlen(\u0022Hello World!\u0022)); CHK_SSL(err);\n- \n- err \u003d SSL_read (ssl, buf, sizeof(buf) - 1); CHK_SSL(err);\n- buf[err] \u003d '\u005c0';\n- printf (\u0022Got %d chars:'%s'\u005cn\u0022, err, buf);\n- SSL_shutdown (ssl); /* send SSL/TLS close_notify */\n-\n- /* Clean up. */\n-\n- close (sd);\n- SSL_free (ssl);\n- SSL_CTX_free (ctx);\n-}\n-/* EOF - cli.cpp */\ndiff --git a/demos/ssl/inetdsrv.cpp b/demos/ssl/inetdsrv.cpp\ndeleted file mode 100644\nindex 7434030..0000000\n--- a/demos/ssl/inetdsrv.cpp\n+++ /dev/null\n@@ -1,98 +0,0 @@\n-/* inetdserv.cpp - Minimal ssleay server for Unix inetd.conf\n- * 30.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e\n- * From /etc/inetd.conf:\n- * 1111 stream tcp nowait sampo /usr/users/sampo/demo/inetdserv inetdserv\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cerrno.h\u003e\n-\n-#include \u0022rsa.h\u0022\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/err.h\u003e\n-\n-#define HOME \u0022/usr/users/sampo/demo/\u0022\n-#define CERTF HOME \u0022plain-cert.pem\u0022\n-#define KEYF HOME \u0022plain-key.pem\u0022\n-\n-#define CHK_NULL(x) if ((x)\u003d\u003dNULL) exit (1)\n-#define CHK_ERR(err,s) if ((err)\u003d\u003d-1) \u005c\n- { fprintf(log, \u0022%s %d\u005cn\u0022, (s), errno); exit(1); }\n-#define CHK_SSL(err) if ((err)\u003d\u003d-1) { ERR_print_errors_fp(log); exit(2); }\n-\n-void main ()\n-{\n- int err;\n- SSL_CTX* ctx;\n- SSL* ssl;\n- X509* client_cert;\n- char* str;\n- char buf [4096];\n- FILE* log;\n- \n- log \u003d fopen (\u0022/dev/console\u0022, \u0022a\u0022); CHK_NULL(log);\n- fprintf (log, \u0022inetdserv %ld\u005cn\u0022, (long)getpid());\n- \n- SSL_load_error_strings();\n- ctx \u003d SSL_CTX_new (); CHK_NULL(ctx);\n- \n- err \u003d SSL_CTX_use_RSAPrivateKey_file (ctx, KEYF, SSL_FILETYPE_PEM);\n- CHK_SSL (err);\n- \n- err \u003d SSL_CTX_use_certificate_file (ctx, CERTF, SSL_FILETYPE_PEM);\n- CHK_SSL (err);\n-\n- /* inetd has already opened the TCP connection, so we can get right\n- down to business. */\n- \n- ssl \u003d SSL_new (ctx); CHK_NULL(ssl);\n- SSL_set_fd (ssl, fileno(stdin));\n- err \u003d SSL_accept (ssl); CHK_SSL(err);\n- \n- /* Get the cipher - opt */\n- \n- fprintf (log, \u0022SSL connection using %s\u005cn\u0022, SSL_get_cipher (ssl));\n- \n- /* Get client's certificate (note: beware of dynamic allocation) - opt */\n-\n- client_cert \u003d SSL_get_peer_certificate (ssl);\n- if (client_cert !\u003d NULL) {\n- fprintf (log, \u0022Client certificate:\u005cn\u0022);\n- \n- str \u003d X509_NAME_oneline (X509_get_subject_name (client_cert));\n- CHK_NULL(str);\n- fprintf (log, \u0022\u005ct subject: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n- \n- str \u003d X509_NAME_oneline (X509_get_issuer_name (client_cert));\n- CHK_NULL(str);\n- fprintf (log, \u0022\u005ct issuer: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n- \n- /* We could do all sorts of certificate verification stuff here before\n- deallocating the certificate. */\n- \n- X509_free (client_cert);\n- } else\n- fprintf (log, \u0022Client doe not have certificate.\u005cn\u0022);\n-\n- /* ------------------------------------------------- */\n- /* DATA EXCHANGE: Receive message and send reply */\n- \n- err \u003d SSL_read (ssl, buf, sizeof(buf) - 1); CHK_SSL(err);\n- buf[err] \u003d '\u005c0';\n- fprintf (log, \u0022Got %d chars:'%s'\u005cn\u0022, err, buf);\n- \n- err \u003d SSL_write (ssl, \u0022Loud and clear.\u0022, strlen(\u0022Loud and clear.\u0022));\n- CHK_SSL(err);\n-\n- /* Clean up. */\n-\n- fclose (log);\n- SSL_free (ssl);\n- SSL_CTX_free (ctx);\n-}\n-/* EOF - inetdserv.cpp */\ndiff --git a/demos/ssl/serv.cpp b/demos/ssl/serv.cpp\ndeleted file mode 100644\nindex 43ff88e..0000000\n--- a/demos/ssl/serv.cpp\n+++ /dev/null\n@@ -1,152 +0,0 @@\n-/* serv.cpp - Minimal ssleay server for Unix\n- 30.9.1996, Sampo Kellomaki \u003csampo@iki.fi\u003e */\n-\n-\n-/* mangled to work with OpenSSL 0.9.2b\n- Simplified to be even more minimal\n- 12/98 - 4/99 Wade Scholine \u003cwades@mail.cybg.com\u003e */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cunistd.h\u003e\n-#include \u003cstdlib.h\u003e\n-#include \u003cmemory.h\u003e\n-#include \u003cerrno.h\u003e\n-#include \u003csys/types.h\u003e\n-#include \u003csys/socket.h\u003e\n-#include \u003cnetinet/in.h\u003e\n-#include \u003carpa/inet.h\u003e\n-#include \u003cnetdb.h\u003e\n-\n-#include \u003copenssl/rsa.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/err.h\u003e\n-\n-\n-/* define HOME to be dir for key and cert files... */\n-#define HOME \u0022./\u0022\n-/* Make these what you want for cert \u0026 key files */\n-#define CERTF HOME \u0022foo-cert.pem\u0022\n-#define KEYF HOME \u0022foo-cert.pem\u0022\n-\n-\n-#define CHK_NULL(x) if ((x)\u003d\u003dNULL) exit (1)\n-#define CHK_ERR(err,s) if ((err)\u003d\u003d-1) { perror(s); exit(1); }\n-#define CHK_SSL(err) if ((err)\u003d\u003d-1) { ERR_print_errors_fp(stderr); exit(2); }\n-\n-void main ()\n-{\n- int err;\n- int listen_sd;\n- int sd;\n- struct sockaddr_in sa_serv;\n- struct sockaddr_in sa_cli;\n- size_t client_len;\n- SSL_CTX* ctx;\n- SSL* ssl;\n- X509* client_cert;\n- char* str;\n- char buf [4096];\n- SSL_METHOD *meth;\n- \n- /* SSL preliminaries. We keep the certificate and key with the context. */\n-\n- SSL_load_error_strings();\n- OpenSSL_add_ssl_algorithms();\n- meth \u003d TLS_server_method();\n- ctx \u003d SSL_CTX_new (meth);\n- if (!ctx) {\n- ERR_print_errors_fp(stderr);\n- exit(2);\n- }\n- \n- if (SSL_CTX_use_certificate_file(ctx, CERTF, SSL_FILETYPE_PEM) \u003c\u003d 0) {\n- ERR_print_errors_fp(stderr);\n- exit(3);\n- }\n- if (SSL_CTX_use_PrivateKey_file(ctx, KEYF, SSL_FILETYPE_PEM) \u003c\u003d 0) {\n- ERR_print_errors_fp(stderr);\n- exit(4);\n- }\n-\n- if (!SSL_CTX_check_private_key(ctx)) {\n- fprintf(stderr,\u0022Private key does not match the certificate public key\u005cn\u0022);\n- exit(5);\n- }\n-\n- /* ----------------------------------------------- */\n- /* Prepare TCP socket for receiving connections */\n-\n- listen_sd \u003d socket (AF_INET, SOCK_STREAM, 0); CHK_ERR(listen_sd, \u0022socket\u0022);\n- \n- memset(\u0026sa_serv, 0, sizeof(sa_serv));\n- sa_serv.sin_family \u003d AF_INET;\n- sa_serv.sin_addr.s_addr \u003d INADDR_ANY;\n- sa_serv.sin_port \u003d htons (1111); /* Server Port number */\n- \n- err \u003d bind(listen_sd, (struct sockaddr*) \u0026sa_serv,\n-\t sizeof (sa_serv)); CHK_ERR(err, \u0022bind\u0022);\n-\t \n- /* Receive a TCP connection. */\n-\t \n- err \u003d listen (listen_sd, 5); CHK_ERR(err, \u0022listen\u0022);\n- \n- client_len \u003d sizeof(sa_cli);\n- sd \u003d accept (listen_sd, (struct sockaddr*) \u0026sa_cli, \u0026client_len);\n- CHK_ERR(sd, \u0022accept\u0022);\n- close (listen_sd);\n-\n- printf (\u0022Connection from %lx, port %x\u005cn\u0022,\n-\t sa_cli.sin_addr.s_addr, sa_cli.sin_port);\n- \n- /* ----------------------------------------------- */\n- /* TCP connection is ready. Do server side SSL. */\n-\n- ssl \u003d SSL_new (ctx); CHK_NULL(ssl);\n- SSL_set_fd (ssl, sd);\n- err \u003d SSL_accept (ssl); CHK_SSL(err);\n- \n- /* Get the cipher - opt */\n- \n- printf (\u0022SSL connection using %s\u005cn\u0022, SSL_get_cipher (ssl));\n- \n- /* Get client's certificate (note: beware of dynamic allocation) - opt */\n-\n- client_cert \u003d SSL_get_peer_certificate (ssl);\n- if (client_cert !\u003d NULL) {\n- printf (\u0022Client certificate:\u005cn\u0022);\n- \n- str \u003d X509_NAME_oneline (X509_get_subject_name (client_cert), 0, 0);\n- CHK_NULL(str);\n- printf (\u0022\u005ct subject: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n- \n- str \u003d X509_NAME_oneline (X509_get_issuer_name (client_cert), 0, 0);\n- CHK_NULL(str);\n- printf (\u0022\u005ct issuer: %s\u005cn\u0022, str);\n- OPENSSL_free (str);\n- \n- /* We could do all sorts of certificate verification stuff here before\n- deallocating the certificate. */\n- \n- X509_free (client_cert);\n- } else\n- printf (\u0022Client does not have certificate.\u005cn\u0022);\n-\n- /* DATA EXCHANGE - Receive message and send reply. */\n-\n- err \u003d SSL_read (ssl, buf, sizeof(buf) - 1); CHK_SSL(err);\n- buf[err] \u003d '\u005c0';\n- printf (\u0022Got %d chars:'%s'\u005cn\u0022, err, buf);\n- \n- err \u003d SSL_write (ssl, \u0022I hear you.\u0022, strlen(\u0022I hear you.\u0022)); CHK_SSL(err);\n-\n- /* Clean up. */\n-\n- close (sd);\n- SSL_free (ssl);\n- SSL_CTX_free (ctx);\n-}\n-/* EOF - serv.cpp */\ndiff --git a/demos/ssltest-ecc/ECC-RSAcertgen.sh b/demos/ssltest-ecc/ECC-RSAcertgen.sh\ndeleted file mode 100755\nindex b31a4f1..0000000\n--- a/demos/ssltest-ecc/ECC-RSAcertgen.sh\n+++ /dev/null\n@@ -1,98 +0,0 @@\n-#!/bin/sh\n-\n-# For a list of supported curves, use \u0022apps/openssl ecparam -list_curves\u0022.\n-\n-# Path to the openssl distribution\n-OPENSSL_DIR\u003d../..\n-# Path to the openssl program\n-OPENSSL_CMD\u003d$OPENSSL_DIR/apps/openssl\n-# Option to find configuration file\n-OPENSSL_CNF\u003d\u0022-config $OPENSSL_DIR/apps/openssl.cnf\u0022\n-# Directory where certificates are stored\n-CERTS_DIR\u003d./Certs\n-# Directory where private key files are stored\n-KEYS_DIR\u003d$CERTS_DIR\n-# Directory where combo files (containing a certificate and corresponding\n-# private key together) are stored\n-COMBO_DIR\u003d$CERTS_DIR\n-# cat command\n-CAT\u003d/bin/cat\n-# rm command\n-RM\u003d/bin/rm\n-# mkdir command\n-MKDIR\u003d/bin/mkdir\n-# The certificate will expire these many days after the issue date.\n-DAYS\u003d1500\n-TEST_CA_FILE\u003drsa1024TestCA\n-\n-TEST_SERVER_CURVE\u003dsect163r1\n-TEST_SERVER_FILE\u003dsect163r1-rsaTestServer\n-TEST_SERVER_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Server (sect163r1 key signed with RSA)\u0022\n-\n-TEST_CLIENT_CURVE\u003dsect163r1\n-TEST_CLIENT_FILE\u003dsect163r1-rsaTestClient\n-TEST_CLIENT_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Client (sect163r1 key signed with RSA)\u0022\n-\n-# Generating an EC certificate involves the following main steps\n-# 1. Generating curve parameters (if needed)\n-# 2. Generating a certificate request\n-# 3. Signing the certificate request \n-# 4. [Optional] One can combine the cert and private key into a single\n-# file and also delete the certificate request\n-\n-$MKDIR -p $CERTS_DIR\n-$MKDIR -p $KEYS_DIR\n-$MKDIR -p $COMBO_DIR\n-\n-echo \u0022GENERATING A TEST SERVER CERTIFICATE (ECC key signed with RSA)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-$OPENSSL_CMD ecparam -name $TEST_SERVER_CURVE -out $TEST_SERVER_CURVE.pem\n-\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_SERVER_DN\u0022 \u005c\n- -keyout $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u005c\n- -newkey ec:$TEST_SERVER_CURVE.pem -new \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_SERVER_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-$CAT $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-echo \u0022GENERATING A TEST CLIENT CERTIFICATE (ECC key signed with RSA)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-$OPENSSL_CMD ecparam -name $TEST_CLIENT_CURVE -out $TEST_CLIENT_CURVE.pem\n-\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_CLIENT_DN\u0022 \u005c\n-\t -keyout $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u005c\n-\t -newkey ec:$TEST_CLIENT_CURVE.pem -new \u005c\n-\t -out $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_CLIENT_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-$CAT $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\ndiff --git a/demos/ssltest-ecc/ECCcertgen.sh b/demos/ssltest-ecc/ECCcertgen.sh\ndeleted file mode 100755\nindex a47b8bb..0000000\n--- a/demos/ssltest-ecc/ECCcertgen.sh\n+++ /dev/null\n@@ -1,164 +0,0 @@\n-#!/bin/sh\n-\n-# For a list of supported curves, use \u0022apps/openssl ecparam -list_curves\u0022.\n-\n-# Path to the openssl distribution\n-OPENSSL_DIR\u003d../..\n-# Path to the openssl program\n-OPENSSL_CMD\u003d$OPENSSL_DIR/apps/openssl\n-# Option to find configuration file\n-OPENSSL_CNF\u003d\u0022-config $OPENSSL_DIR/apps/openssl.cnf\u0022\n-# Directory where certificates are stored\n-CERTS_DIR\u003d./Certs\n-# Directory where private key files are stored\n-KEYS_DIR\u003d$CERTS_DIR\n-# Directory where combo files (containing a certificate and corresponding\n-# private key together) are stored\n-COMBO_DIR\u003d$CERTS_DIR\n-# cat command\n-CAT\u003d/bin/cat\n-# rm command\n-RM\u003d/bin/rm\n-# mkdir command\n-MKDIR\u003d/bin/mkdir\n-# The certificate will expire these many days after the issue date.\n-DAYS\u003d1500\n-TEST_CA_CURVE\u003dsecp160r1\n-TEST_CA_FILE\u003dsecp160r1TestCA\n-TEST_CA_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest CA (Elliptic curve secp160r1)\u0022\n-\n-TEST_SERVER_CURVE\u003dsecp160r2\n-TEST_SERVER_FILE\u003dsecp160r2TestServer\n-TEST_SERVER_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Server (Elliptic curve secp160r2)\u0022\n-\n-TEST_CLIENT_CURVE\u003dsecp160r2\n-TEST_CLIENT_FILE\u003dsecp160r2TestClient\n-TEST_CLIENT_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Client (Elliptic curve secp160r2)\u0022\n-\n-# Generating an EC certificate involves the following main steps\n-# 1. Generating curve parameters (if needed)\n-# 2. Generating a certificate request\n-# 3. Signing the certificate request \n-# 4. [Optional] One can combine the cert and private key into a single\n-# file and also delete the certificate request\n-\n-$MKDIR -p $CERTS_DIR\n-$MKDIR -p $KEYS_DIR\n-$MKDIR -p $COMBO_DIR\n-\n-echo \u0022Generating self-signed CA certificate (on curve $TEST_CA_CURVE)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-$OPENSSL_CMD ecparam -name $TEST_CA_CURVE -out $TEST_CA_CURVE.pem\n-\n-# Generate a new certificate request in $TEST_CA_FILE.req.pem. A \n-# new ecdsa (actually ECC) key pair is generated on the parameters in\n-# $TEST_CA_CURVE.pem and the private key is saved in $TEST_CA_FILE.key.pem\n-# WARNING: By using the -nodes option, we force the private key to be \n-# stored in the clear (rather than encrypted with a password).\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_CA_DN\u0022 \u005c\n- -keyout $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -newkey ec:$TEST_CA_CURVE.pem -new \u005c\n- -out $CERTS_DIR/$TEST_CA_FILE.req.pem\n-\n-# Sign the certificate request in $TEST_CA_FILE.req.pem using the\n-# private key in $TEST_CA_FILE.key.pem and include the CA extension.\n-# Make the certificate valid for 1500 days from the time of signing.\n-# The certificate is written into $TEST_CA_FILE.cert.pem\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_CA_FILE.req.pem \u005c\n- -extfile $OPENSSL_DIR/apps/openssl.cnf \u005c\n- -extensions v3_ca \u005c\n- -signkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_CA_FILE.cert.pem\n-\n-# Display the certificate\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CA_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CA_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_CA_FILE.pem\n-$CAT $KEYS_DIR/$TEST_CA_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_CA_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_CA_FILE.req.pem\n-\n-echo \u0022GENERATING A TEST SERVER CERTIFICATE (on elliptic curve $TEST_SERVER_CURVE)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-# Generate parameters for curve $TEST_SERVER_CURVE, if needed\n-$OPENSSL_CMD ecparam -name $TEST_SERVER_CURVE -out $TEST_SERVER_CURVE.pem\n-\n-# Generate a new certificate request in $TEST_SERVER_FILE.req.pem. A \n-# new ecdsa (actually ECC) key pair is generated on the parameters in\n-# $TEST_SERVER_CURVE.pem and the private key is saved in \n-# $TEST_SERVER_FILE.key.pem\n-# WARNING: By using the -nodes option, we force the private key to be \n-# stored in the clear (rather than encrypted with a password).\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_SERVER_DN\u0022 \u005c\n- -keyout $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u005c\n- -newkey ec:$TEST_SERVER_CURVE.pem -new \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-# Sign the certificate request in $TEST_SERVER_FILE.req.pem using the\n-# CA certificate in $TEST_CA_FILE.cert.pem and the CA private key in\n-# $TEST_CA_FILE.key.pem. Since we do not have an existing serial number\n-# file for this CA, create one. Make the certificate valid for $DAYS days\n-# from the time of signing. The certificate is written into \n-# $TEST_SERVER_FILE.cert.pem\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_SERVER_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-$CAT $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-echo \u0022GENERATING A TEST CLIENT CERTIFICATE (on elliptic curve $TEST_CLIENT_CURVE)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-# Generate parameters for curve $TEST_CLIENT_CURVE, if needed\n-$OPENSSL_CMD ecparam -name $TEST_CLIENT_CURVE -out $TEST_CLIENT_CURVE.pem\n-\n-# Generate a new certificate request in $TEST_CLIENT_FILE.req.pem. A \n-# new ecdsa (actually ECC) key pair is generated on the parameters in\n-# $TEST_CLIENT_CURVE.pem and the private key is saved in \n-# $TEST_CLIENT_FILE.key.pem\n-# WARNING: By using the -nodes option, we force the private key to be \n-# stored in the clear (rather than encrypted with a password).\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_CLIENT_DN\u0022 \u005c\n-\t -keyout $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u005c\n-\t -newkey ec:$TEST_CLIENT_CURVE.pem -new \u005c\n-\t -out $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\n-# Sign the certificate request in $TEST_CLIENT_FILE.req.pem using the\n-# CA certificate in $TEST_CA_FILE.cert.pem and the CA private key in\n-# $TEST_CA_FILE.key.pem. Since we do not have an existing serial number\n-# file for this CA, create one. Make the certificate valid for $DAYS days\n-# from the time of signing. The certificate is written into \n-# $TEST_CLIENT_FILE.cert.pem\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_CLIENT_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-$CAT $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\n-\n-\ndiff --git a/demos/ssltest-ecc/README b/demos/ssltest-ecc/README\ndeleted file mode 100644\nindex 71c070a..0000000\n--- a/demos/ssltest-ecc/README\n+++ /dev/null\n@@ -1,15 +0,0 @@\n-Scripts for using ECC ciphersuites with test/testssl\n-(these ciphersuites are described in the Internet Draft available at\n-http://www.ietf.org/internet-drafts/draft-ietf-tls-ecc-03.txt).\n-\n-Use ECCcertgen.sh, RSAcertgen.sh, ECC-RSAcertgen.sh to generate\n-root, client and server certs of the following types:\n-\n- ECC certs signed with ECDSA\n- RSA certs signed with RSA\n- ECC certs signed with RSA\n-\n-Afterwards, you can use ssltest.sh to run the various tests;\n-specify one of the following options:\n-\n- aecdh, ecdh-ecdsa, ecdhe-ecdsa, ecdh-rsa, ecdhe-rsa\ndiff --git a/demos/ssltest-ecc/RSAcertgen.sh b/demos/ssltest-ecc/RSAcertgen.sh\ndeleted file mode 100755\nindex 0cb0153..0000000\n--- a/demos/ssltest-ecc/RSAcertgen.sh\n+++ /dev/null\n@@ -1,121 +0,0 @@\n-#!/bin/sh\n-\n-# For a list of supported curves, use \u0022apps/openssl ecparam -list_curves\u0022.\n-\n-# Path to the openssl distribution\n-OPENSSL_DIR\u003d../..\n-# Path to the openssl program\n-OPENSSL_CMD\u003d$OPENSSL_DIR/apps/openssl\n-# Option to find configuration file\n-OPENSSL_CNF\u003d\u0022-config $OPENSSL_DIR/apps/openssl.cnf\u0022\n-# Directory where certificates are stored\n-CERTS_DIR\u003d./Certs\n-# Directory where private key files are stored\n-KEYS_DIR\u003d$CERTS_DIR\n-# Directory where combo files (containing a certificate and corresponding\n-# private key together) are stored\n-COMBO_DIR\u003d$CERTS_DIR\n-# cat command\n-CAT\u003d/bin/cat\n-# rm command\n-RM\u003d/bin/rm\n-# mkdir command\n-MKDIR\u003d/bin/mkdir\n-# The certificate will expire these many days after the issue date.\n-DAYS\u003d1500\n-TEST_CA_FILE\u003drsa1024TestCA\n-TEST_CA_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest CA (1024 bit RSA)\u0022\n-\n-TEST_SERVER_FILE\u003drsa1024TestServer\n-TEST_SERVER_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Server (1024 bit RSA)\u0022\n-\n-TEST_CLIENT_FILE\u003drsa1024TestClient\n-TEST_CLIENT_DN\u003d\u0022/C\u003dUS/ST\u003dCA/L\u003dMountain View/O\u003dSun Microsystems, Inc./OU\u003dSun Microsystems Laboratories/CN\u003dTest Client (1024 bit RSA)\u0022\n-\n-# Generating an EC certificate involves the following main steps\n-# 1. Generating curve parameters (if needed)\n-# 2. Generating a certificate request\n-# 3. Signing the certificate request \n-# 4. [Optional] One can combine the cert and private key into a single\n-# file and also delete the certificate request\n-\n-$MKDIR -p $CERTS_DIR\n-$MKDIR -p $KEYS_DIR\n-$MKDIR -p $COMBO_DIR\n-\n-echo \u0022Generating self-signed CA certificate (RSA)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_CA_DN\u0022 \u005c\n- -keyout $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -newkey rsa:1024 -new \u005c\n- -out $CERTS_DIR/$TEST_CA_FILE.req.pem\n-\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_CA_FILE.req.pem \u005c\n- -extfile $OPENSSL_DIR/apps/openssl.cnf \u005c\n- -extensions v3_ca \u005c\n- -signkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_CA_FILE.cert.pem\n-\n-# Display the certificate\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CA_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CA_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_CA_FILE.pem\n-$CAT $KEYS_DIR/$TEST_CA_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_CA_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_CA_FILE.req.pem\n-\n-echo \u0022GENERATING A TEST SERVER CERTIFICATE (RSA)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_SERVER_DN\u0022 \u005c\n- -keyout $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u005c\n- -newkey rsa:1024 -new \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_SERVER_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_SERVER_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-$CAT $KEYS_DIR/$TEST_SERVER_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_SERVER_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_SERVER_FILE.req.pem\n-\n-echo \u0022GENERATING A TEST CLIENT CERTIFICATE (RSA)\u0022\n-echo \u0022\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u0022\n-\n-$OPENSSL_CMD req $OPENSSL_CNF -nodes -subj \u0022$TEST_CLIENT_DN\u0022 \u005c\n-\t -keyout $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u005c\n-\t -newkey rsa:1024 -new \u005c\n-\t -out $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\n-$OPENSSL_CMD x509 -req -days $DAYS \u005c\n- -in $CERTS_DIR/$TEST_CLIENT_FILE.req.pem \u005c\n- -CA $CERTS_DIR/$TEST_CA_FILE.cert.pem \u005c\n- -CAkey $KEYS_DIR/$TEST_CA_FILE.key.pem \u005c\n- -out $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -CAcreateserial\n-\n-# Display the certificate \n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -text\n-\n-# Place the certificate and key in a common file\n-$OPENSSL_CMD x509 -in $CERTS_DIR/$TEST_CLIENT_FILE.cert.pem -issuer -subject \u005c\n-\t \u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-$CAT $KEYS_DIR/$TEST_CLIENT_FILE.key.pem \u003e\u003e $COMBO_DIR/$TEST_CLIENT_FILE.pem\n-\n-# Remove the cert request file (no longer needed)\n-$RM $CERTS_DIR/$TEST_CLIENT_FILE.req.pem\n-\ndiff --git a/demos/ssltest-ecc/ssltest.sh b/demos/ssltest-ecc/ssltest.sh\ndeleted file mode 100755\nindex 923ca43..0000000\n--- a/demos/ssltest-ecc/ssltest.sh\n+++ /dev/null\n@@ -1,188 +0,0 @@\n-#! /bin/sh\n-# Tests ECC cipher suites using ssltest. Requires one argument which could\n-# be aecdh or ecdh-ecdsa or ecdhe-ecdsa or ecdh-rsa or ecdhe-rsa.\n-# A second optional argument can be one of ssl2 ssl3 or tls1\n-\n-if [ \u0022$1\u0022 \u003d \u0022\u0022 ]; then\n- (echo \u0022Usage: $0 test [ protocol ]\u0022\n- echo \u0022 where test is one of aecdh, ecdh-ecdsa, ecdhe-ecdsa, ecdh-rsa, ecdhe-rsa\u0022\n- echo \u0022 and protocol (optional) is one of ssl2, ssl3, tls1\u0022\n- echo \u0022Run RSAcertgen.sh, ECC-RSAcertgen.sh, ECCcertgen.sh first.\u0022\n- ) \u003e\u00262\n- exit 1\n-fi\n-\n-\n-OPENSSL_DIR\u003d../..\n-CERTS_DIR\u003d./Certs\n-SSLTEST\u003d$OPENSSL_DIR/test/ssltest\n-# SSL protocol version to test (one of ssl2 ssl3 or tls1)\u0022\n-SSLVERSION\u003d\n-\n-# These don't really require any certificates\n-AECDH_CIPHER_LIST\u003d\u0022AECDH-AES256-SHA AECDH-AES128-SHA AECDH-DES-CBC3-SHA AECDH-RC4-SHA AECDH-NULL-SHA\u0022\n-\n-# These require ECC certificates signed with ECDSA\n-# The EC public key must be authorized for key agreement.\n-ECDH_ECDSA_CIPHER_LIST\u003d\u0022ECDH-ECDSA-AES256-SHA ECDH-ECDSA-AES128-SHA ECDH-ECDSA-DES-CBC3-SHA ECDH-ECDSA-RC4-SHA ECDH-ECDSA-NULL-SHA\u0022\n-\n-# These require ECC certificates.\n-# The EC public key must be authorized for digital signature.\n-ECDHE_ECDSA_CIPHER_LIST\u003d\u0022ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-DES-CBC3-SHA ECDHE-ECDSA-RC4-SHA ECDHE-ECDSA-NULL-SHA\u0022\n-\n-# These require ECC certificates signed with RSA.\n-# The EC public key must be authorized for key agreement.\n-ECDH_RSA_CIPHER_LIST\u003d\u0022ECDH-RSA-AES256-SHA ECDH-RSA-AES128-SHA ECDH-RSA-DES-CBC3-SHA ECDH-RSA-RC4-SHA ECDH-RSA-NULL-SHA\u0022\n-\n-# These require RSA certificates.\n-# The RSA public key must be authorized for digital signature.\n-ECDHE_RSA_CIPHER_LIST\u003d\u0022ECDHE-RSA-AES256-SHA ECDHE-RSA-AES128-SHA ECDHE-RSA-DES-CBC3-SHA ECDHE-RSA-RC4-SHA ECDHE-RSA-NULL-SHA\u0022\n-\n-# List of Elliptic curves over which we wish to test generation of\n-# ephemeral ECDH keys when using AECDH or ECDHE ciphers\n-# NOTE: secp192r1 \u003d prime192v1 and secp256r1 \u003d prime256v1\n-#ELLIPTIC_CURVE_LIST\u003d\u0022secp112r1 sect113r2 secp128r1 sect131r1 secp160k1 sect163r2 wap-wsg-idm-ecid-wtls7 c2pnb163v3 c2pnb176v3 c2tnb191v3 secp192r1 prime192v3 sect193r2 secp224r1 wap-wsg-idm-ecid-wtls10 sect239k1 prime239v2 secp256r1 prime256v1 sect283k1 secp384r1 sect409r1 secp521r1 sect571r1\u0022\n-ELLIPTIC_CURVE_LIST\u003d\u0022sect163k1 sect163r1 sect163r2 sect193r1 sect193r2 sect233k1 sect233r1 sect239k1 sect283k1 sect283r1 sect409k1 sect409r1 sect571k1 sect571r1 secp160k1 secp160r1 secp160r2 secp192k1 prime192v1 secp224k1 secp224r1 secp256k1 prime256v1 secp384r1 secp521r1\u0022\n-\n-DEFAULT_CURVE\u003d\u0022sect163r2\u0022\n-\n-if [ \u0022$2\u0022 \u003d \u0022\u0022 ]; then\n- if [ \u0022$SSL_VERSION\u0022 \u003d \u0022\u0022 ]; then\n-\tSSL_VERSION\u003d\u0022\u0022\n- else\n-\tSSL_VERSION\u003d\u0022-$SSL_VERSION\u0022\n- fi\n-else\n- SSL_VERSION\u003d\u0022-$2\u0022\n-fi\n-\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-# Anonymous cipher suites do not require key or certificate files\n-# but ssltest expects a cert file and complains if it can't\n-# open the default one.\n-SERVER_PEM\u003d$OPENSSL_DIR/apps/server.pem\n-\n-if [ \u0022$1\u0022 \u003d \u0022aecdh\u0022 ]; then\n-for cipher in $AECDH_CIPHER_LIST\n-do\n- echo \u0022Testing $cipher\u0022\n- $SSLTEST $SSL_VERSION -cert $SERVER_PEM -cipher $cipher \n-done\n-#--------------------------------------------------------------\n-for curve in $ELLIPTIC_CURVE_LIST\n-do\n- echo \u0022Testing AECDH-NULL-SHA (with $curve)\u0022\n- $SSLTEST $SSL_VERSION -cert $SERVER_PEM \u005c\n-\t-named_curve $curve -cipher AECDH-NULL-SHA\n-done\n-\n-for curve in $ELLIPTIC_CURVE_LIST\n-do\n- echo \u0022Testing AECDH-RC4-SHA (with $curve)\u0022\n- $SSLTEST $SSL_VERSION -cert $SERVER_PEM \u005c\n-\t-named_curve $curve -cipher AECDH-RC4-SHA\n-done\n-fi\n-\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-# Both ECDH-ECDSA and ECDHE-ECDSA cipher suites require \n-# the server to have an ECC certificate signed with ECDSA.\n-CA_PEM\u003d$CERTS_DIR/secp160r1TestCA.pem\n-SERVER_PEM\u003d$CERTS_DIR/secp160r2TestServer.pem\n-CLIENT_PEM\u003d$CERTS_DIR/secp160r2TestClient.pem\n-\n-if [ \u0022$1\u0022 \u003d \u0022ecdh-ecdsa\u0022 ]; then\n-for cipher in $ECDH_ECDSA_CIPHER_LIST\n-do\n- echo \u0022Testing $cipher (with server authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-cipher $cipher\n-\n- echo \u0022Testing $cipher (with server and client authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-c_cert $CLIENT_PEM -client_auth \u005c\n-\t-cipher $cipher\n-done\n-fi\n-\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-if [ \u0022$1\u0022 \u003d \u0022ecdhe-ecdsa\u0022 ]; then\n-for cipher in $ECDHE_ECDSA_CIPHER_LIST\n-do\n- echo \u0022Testing $cipher (with server authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-cipher $cipher -named_curve $DEFAULT_CURVE\n-\n- echo \u0022Testing $cipher (with server and client authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-c_cert $CLIENT_PEM -client_auth \u005c\n-\t-cipher $cipher -named_curve $DEFAULT_CURVE\n-done\n-\n-#--------------------------------------------------------------\n-for curve in $ELLIPTIC_CURVE_LIST\n-do\n- echo \u0022Testing ECDHE-ECDSA-AES128-SHA (2-way auth with $curve)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-c_cert $CLIENT_PEM -client_auth \u005c\n-\t-cipher ECDHE-ECDSA-AES128-SHA -named_curve $curve \n-done\n-fi\n-\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-# ECDH-RSA cipher suites require the server to have an ECC\n-# certificate signed with RSA.\n-CA_PEM\u003d$CERTS_DIR/rsa1024TestCA.pem\n-SERVER_PEM\u003d$CERTS_DIR/sect163r1-rsaTestServer.pem\n-CLIENT_PEM\u003d$CERTS_DIR/sect163r1-rsaTestClient.pem\n-\n-if [ \u0022$1\u0022 \u003d \u0022ecdh-rsa\u0022 ]; then\n-for cipher in $ECDH_RSA_CIPHER_LIST\n-do\n- echo \u0022Testing $cipher (with server authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-cipher $cipher\n-\n- echo \u0022Testing $cipher (with server and client authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-c_cert $CLIENT_PEM -client_auth \u005c\n-\t-cipher $cipher\n-done\n-fi\n-\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-# ECDHE-RSA cipher suites require the server to have an RSA cert.\n-CA_PEM\u003d$CERTS_DIR/rsa1024TestCA.pem\n-SERVER_PEM\u003d$CERTS_DIR/rsa1024TestServer.pem\n-CLIENT_PEM\u003d$CERTS_DIR/rsa1024TestClient.pem\n-\n-if [ \u0022$1\u0022 \u003d \u0022ecdhe-rsa\u0022 ]; then\n-for cipher in $ECDHE_RSA_CIPHER_LIST\n-do\n- echo \u0022Testing $cipher (with server authentication)\u0022\n- echo $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-cipher $cipher -named_curve $DEFAULT_CURVE\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-cipher $cipher -named_curve $DEFAULT_CURVE\n-\n- echo \u0022Testing $cipher (with server and client authentication)\u0022\n- $SSLTEST $SSL_VERSION -CAfile $CA_PEM \u005c\n-\t-cert $SERVER_PEM -server_auth \u005c\n-\t-c_cert $CLIENT_PEM -client_auth \u005c\n-\t-cipher $cipher -named_curve $DEFAULT_CURVE\n-done\n-fi\n-#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n-\n-\n-\n-\ndiff --git a/demos/state_machine/Makefile.in b/demos/state_machine/Makefile.in\ndeleted file mode 100644\nindex fde4474..0000000\n--- a/demos/state_machine/Makefile.in\n+++ /dev/null\n@@ -1,10 +0,0 @@\n-CFLAGS\u003d-I../../include -Wall -Werror -g\n-\n-all: state_machine\n-\n-state_machine: state_machine.o\n-\t$(CC) -o state_machine state_machine.o -L../.. -lssl -lcrypto\n-\n-test: state_machine\n-\t./state_machine 10000 ../../apps/server.pem ../../apps/server.pem\n-# DO NOT DELETE THIS LINE -- make depend depends on it.\ndiff --git a/demos/state_machine/state_machine.c b/demos/state_machine/state_machine.c\ndeleted file mode 100644\nindex 98802a1..0000000\n--- a/demos/state_machine/state_machine.c\n+++ /dev/null\n@@ -1,405 +0,0 @@\n-/* \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- * Copyright (c) 2000 The OpenSSL Project. All rights reserved.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- *\n- * 1. Redistributions of source code must retain the above copyright\n- * notice, this list of conditions and the following disclaimer.\n- *\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in\n- * the documentation and/or other materials provided with the\n- * distribution.\n- *\n- * 3. All advertising materials mentioning features or use of this\n- * software must display the following acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\u0022\n- *\n- * 4. The names \u0022OpenSSL Toolkit\u0022 and \u0022OpenSSL Project\u0022 must not be used to\n- * endorse or promote products derived from this software without\n- * prior written permission. For written permission, please contact\n- * openssl-core@openssl.org.\n- *\n- * 5. Products derived from this software may not be called \u0022OpenSSL\u0022\n- * nor may \u0022OpenSSL\u0022 appear in their names without prior written\n- * permission of the OpenSSL Project.\n- *\n- * 6. Redistributions of any form whatsoever must retain the following\n- * acknowledgment:\n- * \u0022This product includes software developed by the OpenSSL Project\n- * for use in the OpenSSL Toolkit (http://www.openssl.org/)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n- * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n- * OF THE POSSIBILITY OF SUCH DAMAGE.\n- * \u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n- *\n- * This product includes cryptographic software written by Eric Young\n- * (eay@cryptsoft.com). This product includes software written by Tim\n- * Hudson (tjh@cryptsoft.com).\n- *\n- */\n-\n-/*\n- * Nuron, a leader in hardware encryption technology, generously\n- * sponsored the development of this demo by Ben Laurie.\n- *\n- * See http://www.nuron.com/.\n- */\n-\n-/*\n- * the aim of this demo is to provide a fully working state-machine\n- * style SSL implementation, i.e. one where the main loop acquires\n- * some data, then converts it from or to SSL by feeding it into the\n- * SSL state machine. It then does any I/O required by the state machine\n- * and loops.\n- *\n- * In order to keep things as simple as possible, this implementation\n- * listens on a TCP socket, which it expects to get an SSL connection\n- * on (for example, from s_client) and from then on writes decrypted\n- * data to stdout and encrypts anything arriving on stdin. Verbose\n- * commentary is written to stderr.\n- *\n- * This implementation acts as a server, but it can also be done for a client. */\n-\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003cassert.h\u003e\n-#include \u003cunistd.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u003csys/types.h\u003e\n-#include \u003csys/socket.h\u003e\n-#include \u003cnetinet/in.h\u003e\n-\n-/*\n- * die_unless is intended to work like assert, except that it happens always,\n- * even if NDEBUG is defined. Use assert as a stopgap.\n- */\n-\n-#define die_unless(x) assert(x)\n-\n-typedef struct {\n- SSL_CTX *pCtx;\n- BIO *pbioRead;\n- BIO *pbioWrite;\n- SSL *pSSL;\n-} SSLStateMachine;\n-\n-void SSLStateMachine_print_error(SSLStateMachine * pMachine,\n- const char *szErr)\n-{\n- unsigned long l;\n-\n- fprintf(stderr, \u0022%s\u005cn\u0022, szErr);\n- while ((l \u003d ERR_get_error())) {\n- char buf[1024];\n-\n- ERR_error_string_n(l, buf, sizeof buf);\n- fprintf(stderr, \u0022Error %lx: %s\u005cn\u0022, l, buf);\n- }\n-}\n-\n-SSLStateMachine *SSLStateMachine_new(const char *szCertificateFile,\n- const char *szKeyFile)\n-{\n- SSLStateMachine *pMachine \u003d malloc(sizeof(*pMachine));\n- int n;\n-\n- die_unless(pMachine);\n-\n- pMachine-\u003epCtx \u003d SSL_CTX_new(TLS_server_method());\n- die_unless(pMachine-\u003epCtx);\n-\n- n \u003d SSL_CTX_use_certificate_file(pMachine-\u003epCtx, szCertificateFile,\n- SSL_FILETYPE_PEM);\n- die_unless(n \u003e 0);\n-\n- n \u003d SSL_CTX_use_PrivateKey_file(pMachine-\u003epCtx, szKeyFile,\n- SSL_FILETYPE_PEM);\n- die_unless(n \u003e 0);\n-\n- pMachine-\u003epSSL \u003d SSL_new(pMachine-\u003epCtx);\n- die_unless(pMachine-\u003epSSL);\n-\n- pMachine-\u003epbioRead \u003d BIO_new(BIO_s_mem());\n-\n- pMachine-\u003epbioWrite \u003d BIO_new(BIO_s_mem());\n-\n- SSL_set_bio(pMachine-\u003epSSL, pMachine-\u003epbioRead, pMachine-\u003epbioWrite);\n-\n- SSL_set_accept_state(pMachine-\u003epSSL);\n-\n- return pMachine;\n-}\n-\n-void SSLStateMachine_read_inject(SSLStateMachine * pMachine,\n- const unsigned char *aucBuf, int nBuf)\n-{\n- int n \u003d BIO_write(pMachine-\u003epbioRead, aucBuf, nBuf);\n- /*\n- * If it turns out this assert fails, then buffer the data here and just\n- * feed it in in churn instead. Seems to me that it should be guaranteed\n- * to succeed, though.\n- */\n- assert(n \u003d\u003d nBuf);\n- fprintf(stderr, \u0022%d bytes of encrypted data fed to state machine\u005cn\u0022, n);\n-}\n-\n-int SSLStateMachine_read_extract(SSLStateMachine * pMachine,\n- unsigned char *aucBuf, int nBuf)\n-{\n- int n;\n-\n- if (!SSL_is_init_finished(pMachine-\u003epSSL)) {\n- fprintf(stderr, \u0022Doing SSL_accept\u005cn\u0022);\n- n \u003d SSL_accept(pMachine-\u003epSSL);\n- if (n \u003d\u003d 0)\n- fprintf(stderr, \u0022SSL_accept returned zero\u005cn\u0022);\n- if (n \u003c 0) {\n- int err;\n-\n- if ((err \u003d\n- SSL_get_error(pMachine-\u003epSSL, n)) \u003d\u003d SSL_ERROR_WANT_READ) {\n- fprintf(stderr, \u0022SSL_accept wants more data\u005cn\u0022);\n- return 0;\n- }\n-\n- SSLStateMachine_print_error(pMachine, \u0022SSL_accept error\u0022);\n- exit(7);\n- }\n- return 0;\n- }\n-\n- n \u003d SSL_read(pMachine-\u003epSSL, aucBuf, nBuf);\n- if (n \u003c 0) {\n- int err \u003d SSL_get_error(pMachine-\u003epSSL, n);\n-\n- if (err \u003d\u003d SSL_ERROR_WANT_READ) {\n- fprintf(stderr, \u0022SSL_read wants more data\u005cn\u0022);\n- return 0;\n- }\n-\n- SSLStateMachine_print_error(pMachine, \u0022SSL_read error\u0022);\n- exit(8);\n- }\n-\n- fprintf(stderr, \u0022%d bytes of decrypted data read from state machine\u005cn\u0022,\n- n);\n- return n;\n-}\n-\n-int SSLStateMachine_write_can_extract(SSLStateMachine * pMachine)\n-{\n- int n \u003d BIO_pending(pMachine-\u003epbioWrite);\n- if (n)\n- fprintf(stderr, \u0022There is encrypted data available to write\u005cn\u0022);\n- else\n- fprintf(stderr, \u0022There is no encrypted data available to write\u005cn\u0022);\n-\n- return n;\n-}\n-\n-int SSLStateMachine_write_extract(SSLStateMachine * pMachine,\n- unsigned char *aucBuf, int nBuf)\n-{\n- int n;\n-\n- n \u003d BIO_read(pMachine-\u003epbioWrite, aucBuf, nBuf);\n- fprintf(stderr, \u0022%d bytes of encrypted data read from state machine\u005cn\u0022,\n- n);\n- return n;\n-}\n-\n-void SSLStateMachine_write_inject(SSLStateMachine * pMachine,\n- const unsigned char *aucBuf, int nBuf)\n-{\n- int n \u003d SSL_write(pMachine-\u003epSSL, aucBuf, nBuf);\n- /*\n- * If it turns out this assert fails, then buffer the data here and just\n- * feed it in in churn instead. Seems to me that it should be guaranteed\n- * to succeed, though.\n- */\n- assert(n \u003d\u003d nBuf);\n- fprintf(stderr, \u0022%d bytes of unencrypted data fed to state machine\u005cn\u0022, n);\n-}\n-\n-int OpenSocket(int nPort)\n-{\n- int nSocket;\n- struct sockaddr_in saServer;\n- struct sockaddr_in saClient;\n- int one \u003d 1;\n- int nSize;\n- int nFD;\n- int nLen;\n-\n- nSocket \u003d socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);\n- if (nSocket \u003c 0) {\n- perror(\u0022socket\u0022);\n- exit(1);\n- }\n-\n- if (setsockopt\n- (nSocket, SOL_SOCKET, SO_REUSEADDR, (char *)\u0026one, sizeof one) \u003c 0) {\n- perror(\u0022setsockopt\u0022);\n- exit(2);\n- }\n-\n- memset(\u0026saServer, 0, sizeof(saServer));\n- saServer.sin_family \u003d AF_INET;\n- saServer.sin_port \u003d htons(nPort);\n- nSize \u003d sizeof saServer;\n- if (bind(nSocket, (struct sockaddr *)\u0026saServer, nSize) \u003c 0) {\n- perror(\u0022bind\u0022);\n- exit(3);\n- }\n-\n- if (listen(nSocket, 512) \u003c 0) {\n- perror(\u0022listen\u0022);\n- exit(4);\n- }\n-\n- nLen \u003d sizeof saClient;\n- nFD \u003d accept(nSocket, (struct sockaddr *)\u0026saClient, \u0026nLen);\n- if (nFD \u003c 0) {\n- perror(\u0022accept\u0022);\n- exit(5);\n- }\n-\n- fprintf(stderr, \u0022Incoming accepted on port %d\u005cn\u0022, nPort);\n-\n- return nFD;\n-}\n-\n-int main(int argc, char **argv)\n-{\n- SSLStateMachine *pMachine;\n- int nPort;\n- int nFD;\n- const char *szCertificateFile;\n- const char *szKeyFile;\n- char rbuf[1];\n- int nrbuf \u003d 0;\n-\n- if (argc !\u003d 4) {\n- fprintf(stderr, \u0022%s \u003cport\u003e \u003ccertificate file\u003e \u003ckey file\u003e\u005cn\u0022, argv[0]);\n- exit(6);\n- }\n-\n- nPort \u003d atoi(argv[1]);\n- szCertificateFile \u003d argv[2];\n- szKeyFile \u003d argv[3];\n-\n- OpenSSL_add_ssl_algorithms();\n- SSL_load_error_strings();\n-\n- nFD \u003d OpenSocket(nPort);\n-\n- pMachine \u003d SSLStateMachine_new(szCertificateFile, szKeyFile);\n-\n- for (;;) {\n- fd_set rfds, wfds;\n- unsigned char buf[1024];\n- int n;\n-\n- FD_ZERO(\u0026rfds);\n- FD_ZERO(\u0026wfds);\n-\n- /* Select socket for input */\n- FD_SET(nFD, \u0026rfds);\n-\n- /* check whether there's decrypted data */\n- if (!nrbuf)\n- nrbuf \u003d SSLStateMachine_read_extract(pMachine, rbuf, 1);\n-\n- /* if there's decrypted data, check whether we can write it */\n- if (nrbuf)\n- FD_SET(1, \u0026wfds);\n-\n- /* Select socket for output */\n- if (SSLStateMachine_write_can_extract(pMachine))\n- FD_SET(nFD, \u0026wfds);\n-\n- /* Select stdin for input */\n- FD_SET(0, \u0026rfds);\n-\n- /* Wait for something to do something */\n- n \u003d select(nFD + 1, \u0026rfds, \u0026wfds, NULL, NULL);\n- assert(n \u003e 0);\n-\n- /* Socket is ready for input */\n- if (FD_ISSET(nFD, \u0026rfds)) {\n- n \u003d read(nFD, buf, sizeof buf);\n- if (n \u003d\u003d 0) {\n- fprintf(stderr, \u0022Got EOF on socket\u005cn\u0022);\n- exit(0);\n- }\n- assert(n \u003e 0);\n-\n- SSLStateMachine_read_inject(pMachine, buf, n);\n- }\n-\n- /* stdout is ready for output (and hence we have some to send it) */\n- if (FD_ISSET(1, \u0026wfds)) {\n- assert(nrbuf \u003d\u003d 1);\n- buf[0] \u003d rbuf[0];\n- nrbuf \u003d 0;\n-\n- n \u003d SSLStateMachine_read_extract(pMachine, buf + 1,\n- sizeof buf - 1);\n- if (n \u003c 0) {\n- SSLStateMachine_print_error(pMachine, \u0022read extract failed\u0022);\n- break;\n- }\n- assert(n \u003e\u003d 0);\n- ++n;\n- if (n \u003e 0) { /* FIXME: has to be true now */\n- int w;\n-\n- w \u003d write(1, buf, n);\n- /* FIXME: we should push back any unwritten data */\n- assert(w \u003d\u003d n);\n- }\n- }\n-\n- /*\n- * Socket is ready for output (and therefore we have output to send)\n- */\n- if (FD_ISSET(nFD, \u0026wfds)) {\n- int w;\n-\n- n \u003d SSLStateMachine_write_extract(pMachine, buf, sizeof buf);\n- assert(n \u003e 0);\n-\n- w \u003d write(nFD, buf, n);\n- /* FIXME: we should push back any unwritten data */\n- assert(w \u003d\u003d n);\n- }\n-\n- /* Stdin is ready for input */\n- if (FD_ISSET(0, \u0026rfds)) {\n- n \u003d read(0, buf, sizeof buf);\n- if (n \u003d\u003d 0) {\n- fprintf(stderr, \u0022Got EOF on stdin\u005cn\u0022);\n- exit(0);\n- }\n- assert(n \u003e 0);\n-\n- SSLStateMachine_write_inject(pMachine, buf, n);\n- }\n- }\n- /* not reached */\n- return 0;\n-}\ndiff --git a/demos/threads/README b/demos/threads/README\ndeleted file mode 100644\nindex d8f358b..0000000\n--- a/demos/threads/README\n+++ /dev/null\n@@ -1,7 +0,0 @@\n-This shows how to set up the OpenSSL callbacks for use in\n-multi-threaded programs.\n-\n-Two implementations, one for Win32 native and one for pthreads, are provided\n-in th-lock.c A test program is in mttest.c\n-\n-Build scripts are in pthread.sh and win32.bat\ndiff --git a/demos/threads/mttest.c b/demos/threads/mttest.c\ndeleted file mode 100644\nindex 797a2ca..0000000\n--- a/demos/threads/mttest.c\n+++ /dev/null\n@@ -1,773 +0,0 @@\n-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n- * All rights reserved.\n- *\n- * This package is an SSL implementation written\n- * by Eric Young (eay@cryptsoft.com).\n- * The implementation was written so as to conform with Netscapes SSL.\n- *\n- * This library is free for commercial and non-commercial use as long as\n- * the following conditions are aheared to. The following conditions\n- * apply to all code found in this distribution, be it the RC4, RSA,\n- * lhash, DES, etc., code; not just the SSL code. The SSL documentation\n- * included with this distribution is covered by the same copyright terms\n- * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n- *\n- * Copyright remains Eric Young's, and as such any Copyright notices in\n- * the code are not to be removed.\n- * If this package is used in a product, Eric Young should be given attribution\n- * as the author of the parts of the library used.\n- * This can be in the form of a textual message at program startup or\n- * in documentation (online or textual) provided with the package.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- * 1. Redistributions of source code must retain the copyright\n- * notice, this list of conditions and the following disclaimer.\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in the\n- * documentation and/or other materials provided with the distribution.\n- * 3. All advertising materials mentioning features or use of this software\n- * must display the following acknowledgement:\n- * \u0022This product includes cryptographic software written by\n- * Eric Young (eay@cryptsoft.com)\u0022\n- * The word 'cryptographic' can be left out if the rouines from the library\n- * being used are not cryptographic related :-).\n- * 4. If you include any Windows specific code (or a derivative thereof) from\n- * the apps directory (application code) you must include an acknowledgement:\n- * \u0022This product includes software written by Tim Hudson (tjh@cryptsoft.com)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n- * SUCH DAMAGE.\n- *\n- * The licence and distribution terms for any publically available version or\n- * derivative of this code cannot be changed. i.e. this code cannot simply be\n- * copied and put under another distribution licence\n- * [including the GNU Public Licence.]\n- */\n-\n-#include \u003cstdlib.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u003cerrno.h\u003e\n-#ifdef LINUX\n-# include \u003ctypedefs.h\u003e\n-#endif\n-#ifdef OPENSSL_SYS_WIN32\n-# include \u003cwindows.h\u003e\n-#endif\n-#ifdef PTHREADS\n-# include \u003cpthread.h\u003e\n-#endif\n-#include \u003copenssl/lhash.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/buffer.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/err.h\u003e\n-#include \u003copenssl/rand.h\u003e\n-\n-#define TEST_SERVER_CERT \u0022../../apps/server.pem\u0022\n-#define TEST_CLIENT_CERT \u0022../../apps/client.pem\u0022\n-\n-#define MAX_THREAD_NUMBER 100\n-\n-int verify_callback(int ok, X509_STORE_CTX *xs);\n-void thread_setup(void);\n-void thread_cleanup(void);\n-void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx);\n-\n-void win32_locking_callback(int mode, int type, const char *file, int line);\n-void pthreads_locking_callback(int mode, int type, const char *file, int line);\n-\n-void irix_thread_id(CRYPTO_THREADID *tid);\n-void pthreads_thread_id(CRYPTO_THREADID *tid);\n-\n-BIO *bio_err \u003d NULL;\n-BIO *bio_stdout \u003d NULL;\n-\n-static char *cipher \u003d NULL;\n-int verbose \u003d 0;\n-#ifdef FIONBIO\n-static int s_nbio \u003d 0;\n-#endif\n-\n-int thread_number \u003d 10;\n-int number_of_loops \u003d 10;\n-int reconnect \u003d 0;\n-int cache_stats \u003d 0;\n-\n-static const char rnd_seed[] \u003d\n- \u0022string to make the random number generator think it has entropy\u0022;\n-\n-int doit(char *ctx[4]);\n-static void print_stats(BIO *bio, SSL_CTX *ctx)\n-{\n- BIO_printf(bio, \u0022%4ld items in the session cache\u005cn\u0022,\n-\t SSL_CTX_sess_number(ctx));\n- BIO_printf(bio, \u0022%4d client connects (SSL_connect())\u005cn\u0022,\n-\t SSL_CTX_sess_connect(ctx));\n- BIO_printf(bio, \u0022%4d client connects that finished\u005cn\u0022,\n-\t SSL_CTX_sess_connect_good(ctx));\n- BIO_printf(bio, \u0022%4d server connects (SSL_accept())\u005cn\u0022,\n-\t SSL_CTX_sess_accept(ctx));\n- BIO_printf(bio, \u0022%4d server connects that finished\u005cn\u0022,\n-\t SSL_CTX_sess_accept_good(ctx));\n- BIO_printf(bio, \u0022%4d session cache hits\u005cn\u0022, SSL_CTX_sess_hits(ctx));\n- BIO_printf(bio, \u0022%4d session cache misses\u005cn\u0022, SSL_CTX_sess_misses(ctx));\n- BIO_printf(bio, \u0022%4d session cache timeouts\u005cn\u0022, SSL_CTX_sess_timeouts(ctx));\n-}\n-\n-static void sv_usage(void)\n-{\n- BIO_printf(bio_err, \u0022usage: ssltest [args ...]\u005cn\u0022);\n- BIO_printf(bio_err, \u0022\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -server_auth - check server certificate\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -client_auth - do client authentication\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -v - more output\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -CApath arg - PEM format directory of CA's\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -CAfile arg - PEM format file of CA's\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -threads arg - number of threads\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -loops arg - number of 'connections', per thread\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -reconnect - reuse session-id's\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -stats - server session-id cache stats\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -cert arg - server certificate/key\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -ccert arg - client certificate/key\u005cn\u0022);\n- BIO_printf(bio_err, \u0022 -ssl3 - just SSLv3n\u005cn\u0022);\n-}\n-\n-int main(int argc, char *argv[])\n-{\n- char *CApath \u003d NULL, *CAfile \u003d NULL;\n- int badop \u003d 0;\n- int ret \u003d 1;\n- int client_auth \u003d 0;\n- int server_auth \u003d 0;\n- SSL_CTX *s_ctx \u003d NULL;\n- SSL_CTX *c_ctx \u003d NULL;\n- char *scert \u003d TEST_SERVER_CERT;\n- char *ccert \u003d TEST_CLIENT_CERT;\n- const SSL_METHOD *ssl_method \u003d TLS_method();\n-\n- RAND_seed(rnd_seed, sizeof rnd_seed);\n-\n- if (bio_err \u003d\u003d NULL)\n- bio_err \u003d BIO_new_fd(2, BIO_NOCLOSE);\n- if (bio_stdout \u003d\u003d NULL)\n- bio_stdout \u003d BIO_new_fd(1, BIO_NOCLOSE);\n- argc--;\n- argv++;\n-\n- while (argc \u003e\u003d 1) {\n- if (strcmp(*argv, \u0022-server_auth\u0022) \u003d\u003d 0)\n- server_auth \u003d 1;\n- else if (strcmp(*argv, \u0022-client_auth\u0022) \u003d\u003d 0)\n- client_auth \u003d 1;\n- else if (strcmp(*argv, \u0022-reconnect\u0022) \u003d\u003d 0)\n- reconnect \u003d 1;\n- else if (strcmp(*argv, \u0022-stats\u0022) \u003d\u003d 0)\n- cache_stats \u003d 1;\n- else if (strcmp(*argv, \u0022-ssl3\u0022) \u003d\u003d 0)\n- ssl_method \u003d SSLv3_method();\n- else if (strcmp(*argv, \u0022-CApath\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- CApath \u003d *(++argv);\n- } else if (strcmp(*argv, \u0022-CAfile\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- CAfile \u003d *(++argv);\n- } else if (strcmp(*argv, \u0022-cert\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- scert \u003d *(++argv);\n- } else if (strcmp(*argv, \u0022-ccert\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- ccert \u003d *(++argv);\n- } else if (strcmp(*argv, \u0022-threads\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- thread_number \u003d atoi(*(++argv));\n- if (thread_number \u003d\u003d 0)\n- thread_number \u003d 1;\n- if (thread_number \u003e MAX_THREAD_NUMBER)\n- thread_number \u003d MAX_THREAD_NUMBER;\n- } else if (strcmp(*argv, \u0022-loops\u0022) \u003d\u003d 0) {\n- if (--argc \u003c 1)\n- goto bad;\n- number_of_loops \u003d atoi(*(++argv));\n- if (number_of_loops \u003d\u003d 0)\n- number_of_loops \u003d 1;\n- } else {\n- BIO_printf(bio_err, \u0022unknown option %s\u005cn\u0022, *argv);\n- badop \u003d 1;\n- break;\n- }\n- argc--;\n- argv++;\n- }\n- if (badop) {\n- bad:\n- sv_usage();\n- goto end;\n- }\n-\n- if (cipher \u003d\u003d NULL \u0026\u0026 OPENSSL_issetugid() \u003d\u003d 0)\n- cipher \u003d getenv(\u0022SSL_CIPHER\u0022);\n-\n- SSL_load_error_strings();\n- OpenSSL_add_ssl_algorithms();\n-\n- c_ctx \u003d SSL_CTX_new(ssl_method);\n- s_ctx \u003d SSL_CTX_new(ssl_method);\n- if ((c_ctx \u003d\u003d NULL) || (s_ctx \u003d\u003d NULL)) {\n- ERR_print_errors(bio_err);\n- goto end;\n- }\n-\n- SSL_CTX_set_session_cache_mode(s_ctx,\n- SSL_SESS_CACHE_NO_AUTO_CLEAR |\n- SSL_SESS_CACHE_SERVER);\n- SSL_CTX_set_session_cache_mode(c_ctx,\n- SSL_SESS_CACHE_NO_AUTO_CLEAR |\n- SSL_SESS_CACHE_SERVER);\n-\n- if (!SSL_CTX_use_certificate_file(s_ctx, scert, SSL_FILETYPE_PEM)) {\n- BIO_printf(bio_err, \u0022SSL_CTX_use_certificate_file (%s)\u005cn\u0022, scert);\n- ERR_print_errors(bio_err);\n- goto end;\n- } else\n- if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx, scert, SSL_FILETYPE_PEM)) {\n- BIO_printf(bio_err, \u0022SSL_CTX_use_RSAPrivateKey_file (%s)\u005cn\u0022, scert);\n- ERR_print_errors(bio_err);\n- goto end;\n- }\n-\n- if (client_auth) {\n- SSL_CTX_use_certificate_file(c_ctx, ccert, SSL_FILETYPE_PEM);\n- SSL_CTX_use_RSAPrivateKey_file(c_ctx, ccert, SSL_FILETYPE_PEM);\n- }\n-\n- if ((!SSL_CTX_load_verify_locations(s_ctx, CAfile, CApath)) ||\n- (!SSL_CTX_set_default_verify_paths(s_ctx)) ||\n- (!SSL_CTX_load_verify_locations(c_ctx, CAfile, CApath)) ||\n- (!SSL_CTX_set_default_verify_paths(c_ctx))) {\n- BIO_printf(bio_err, \u0022SSL_load_verify_locations\u005cn\u0022);\n- ERR_print_errors(bio_err);\n- goto end;\n- }\n-\n- if (client_auth) {\n- BIO_printf(bio_err, \u0022client authentication\u005cn\u0022);\n- SSL_CTX_set_verify(s_ctx,\n- SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,\n- verify_callback);\n- }\n- if (server_auth) {\n- BIO_printf(bio_err, \u0022server authentication\u005cn\u0022);\n- SSL_CTX_set_verify(c_ctx, SSL_VERIFY_PEER, verify_callback);\n- }\n-\n- thread_setup();\n- do_threads(s_ctx, c_ctx);\n- thread_cleanup();\n- end:\n-\n- if (c_ctx !\u003d NULL) {\n- BIO_printf(bio_err, \u0022Client SSL_CTX stats then free it\u005cn\u0022);\n- print_stats(bio_err, c_ctx);\n- SSL_CTX_free(c_ctx);\n- }\n- if (s_ctx !\u003d NULL) {\n- BIO_printf(bio_err, \u0022Server SSL_CTX stats then free it\u005cn\u0022);\n- print_stats(bio_err, s_ctx);\n- if (cache_stats) {\n- BIO_printf(bio_err, \u0022-----\u005cn\u0022);\n- lh_SSL_SESSION_stats_bio(SSL_CTX_sessions(s_ctx), bio_err);\n- BIO_printf(bio_err, \u0022-----\u005cn\u0022);\n- /*- lh_SSL_SESSION_node_stats_bio(SSL_CTX_sessions(s_ctx),bio_err);\n- BIO_printf(bio_err,\u0022-----\u005cn\u0022); */\n- lh_SSL_SESSION_node_usage_stats_bio(SSL_CTX_sessions(s_ctx), bio_err);\n- BIO_printf(bio_err, \u0022-----\u005cn\u0022);\n- }\n- SSL_CTX_free(s_ctx);\n- BIO_printf(bio_err, \u0022done free\u005cn\u0022);\n- }\n- exit(ret);\n- return (0);\n-}\n-\n-#define W_READ 1\n-#define W_WRITE 2\n-#define C_DONE 1\n-#define S_DONE 2\n-\n-int ndoit(SSL_CTX *ssl_ctx[2])\n-{\n- int i;\n- int ret;\n- char *ctx[4];\n- CRYPTO_THREADID thread_id;\n-\n- ctx[0] \u003d (char *)ssl_ctx[0];\n- ctx[1] \u003d (char *)ssl_ctx[1];\n-\n- if (reconnect) {\n- ctx[2] \u003d (char *)SSL_new(ssl_ctx[0]);\n- ctx[3] \u003d (char *)SSL_new(ssl_ctx[1]);\n- } else {\n- ctx[2] \u003d NULL;\n- ctx[3] \u003d NULL;\n- }\n-\n- CRYPTO_THREADID_current(\u0026thread_id);\n- BIO_printf(bio_stdout, \u0022started thread %lu\u005cn\u0022,\n-\t CRYPTO_THREADID_hash(\u0026thread_id));\n- for (i \u003d 0; i \u003c number_of_loops; i++) {\n-/*- BIO_printf(bio_err,\u0022%4d %2d ctx-\u003eref (%3d,%3d)\u005cn\u0022,\n- CRYPTO_THREADID_hash(\u0026thread_id),i,\n- ssl_ctx[0]-\u003ereferences,\n- ssl_ctx[1]-\u003ereferences); */\n-/* pthread_delay_np(\u0026tm); */\n-\n- ret \u003d doit(ctx);\n- if (ret !\u003d 0) {\n- BIO_printf(bio_stdout, \u0022error[%d] %lu - %d\u005cn\u0022,\n- i, CRYPTO_THREADID_hash(\u0026thread_id), ret);\n- return (ret);\n- }\n- }\n- BIO_printf(bio_stdout, \u0022DONE %lu\u005cn\u0022, CRYPTO_THREADID_hash(\u0026thread_id));\n- if (reconnect) {\n- SSL_free((SSL *)ctx[2]);\n- SSL_free((SSL *)ctx[3]);\n- }\n- return (0);\n-}\n-\n-int doit(char *ctx[4])\n-{\n- SSL_CTX *s_ctx, *c_ctx;\n- static char cbuf[200], sbuf[200];\n- SSL *c_ssl \u003d NULL;\n- SSL *s_ssl \u003d NULL;\n- BIO *c_to_s \u003d NULL;\n- BIO *s_to_c \u003d NULL;\n- BIO *c_bio \u003d NULL;\n- BIO *s_bio \u003d NULL;\n- int c_r, c_w, s_r, s_w;\n- int c_want, s_want;\n- int i;\n- int done \u003d 0;\n- int c_write, s_write;\n- int do_server \u003d 0, do_client \u003d 0;\n-\n- s_ctx \u003d (SSL_CTX *)ctx[0];\n- c_ctx \u003d (SSL_CTX *)ctx[1];\n-\n- if (ctx[2] !\u003d NULL)\n- s_ssl \u003d (SSL *)ctx[2];\n- else\n- s_ssl \u003d SSL_new(s_ctx);\n-\n- if (ctx[3] !\u003d NULL)\n- c_ssl \u003d (SSL *)ctx[3];\n- else\n- c_ssl \u003d SSL_new(c_ctx);\n-\n- if ((s_ssl \u003d\u003d NULL) || (c_ssl \u003d\u003d NULL))\n- goto err;\n-\n- c_to_s \u003d BIO_new(BIO_s_mem());\n- s_to_c \u003d BIO_new(BIO_s_mem());\n- if ((s_to_c \u003d\u003d NULL) || (c_to_s \u003d\u003d NULL))\n- goto err;\n-\n- c_bio \u003d BIO_new(BIO_f_ssl());\n- s_bio \u003d BIO_new(BIO_f_ssl());\n- if ((c_bio \u003d\u003d NULL) || (s_bio \u003d\u003d NULL))\n- goto err;\n-\n- SSL_set_connect_state(c_ssl);\n- SSL_set_bio(c_ssl, s_to_c, c_to_s);\n- BIO_set_ssl(c_bio, c_ssl, (ctx[2] \u003d\u003d NULL) ? BIO_CLOSE : BIO_NOCLOSE);\n-\n- SSL_set_accept_state(s_ssl);\n- SSL_set_bio(s_ssl, c_to_s, s_to_c);\n- BIO_set_ssl(s_bio, s_ssl, (ctx[3] \u003d\u003d NULL) ? BIO_CLOSE : BIO_NOCLOSE);\n-\n- c_r \u003d 0;\n- s_r \u003d 1;\n- c_w \u003d 1;\n- s_w \u003d 0;\n- c_want \u003d W_WRITE;\n- s_want \u003d 0;\n- c_write \u003d 1, s_write \u003d 0;\n-\n- /* We can always do writes */\n- for (;;) {\n- do_server \u003d 0;\n- do_client \u003d 0;\n-\n- i \u003d (int)BIO_pending(s_bio);\n- if ((i \u0026\u0026 s_r) || s_w)\n- do_server \u003d 1;\n-\n- i \u003d (int)BIO_pending(c_bio);\n- if ((i \u0026\u0026 c_r) || c_w)\n- do_client \u003d 1;\n-\n- if (do_server \u0026\u0026 verbose) {\n- if (SSL_in_init(s_ssl))\n- BIO_printf(bio_stdout, \u0022server waiting in SSL_accept - %s\u005cn\u0022,\n- SSL_state_string_long(s_ssl));\n- else if (s_write)\n- BIO_printf(bio_stdout, \u0022server:SSL_write()\u005cn\u0022);\n- else\n- BIO_printf(bio_stdout, \u0022server:SSL_read()\u005cn\u0022);\n- }\n-\n- if (do_client \u0026\u0026 verbose) {\n- if (SSL_in_init(c_ssl))\n- BIO_printf(bio_stdout, \u0022client waiting in SSL_connect - %s\u005cn\u0022,\n- SSL_state_string_long(c_ssl));\n- else if (c_write)\n- BIO_printf(bio_stdout, \u0022client:SSL_write()\u005cn\u0022);\n- else\n- BIO_printf(bio_stdout, \u0022client:SSL_read()\u005cn\u0022);\n- }\n-\n- if (!do_client \u0026\u0026 !do_server) {\n- BIO_printf(bio_stdout, \u0022ERROR IN STARTUP\u005cn\u0022);\n- break;\n- }\n- if (do_client \u0026\u0026 !(done \u0026 C_DONE)) {\n- if (c_write) {\n- i \u003d BIO_write(c_bio, \u0022hello from client\u005cn\u0022, 18);\n- if (i \u003c 0) {\n- c_r \u003d 0;\n- c_w \u003d 0;\n- if (BIO_should_retry(c_bio)) {\n- if (BIO_should_read(c_bio))\n- c_r \u003d 1;\n- if (BIO_should_write(c_bio))\n- c_w \u003d 1;\n- } else {\n- BIO_printf(bio_err, \u0022ERROR in CLIENT\u005cn\u0022);\n- ERR_print_errors_fp(stderr);\n- return (1);\n- }\n- } else if (i \u003d\u003d 0) {\n- BIO_printf(bio_err, \u0022SSL CLIENT STARTUP FAILED\u005cn\u0022);\n- return (1);\n- } else {\n- /* ok */\n- c_write \u003d 0;\n- }\n- } else {\n- i \u003d BIO_read(c_bio, cbuf, 100);\n- if (i \u003c 0) {\n- c_r \u003d 0;\n- c_w \u003d 0;\n- if (BIO_should_retry(c_bio)) {\n- if (BIO_should_read(c_bio))\n- c_r \u003d 1;\n- if (BIO_should_write(c_bio))\n- c_w \u003d 1;\n- } else {\n- BIO_printf(bio_err, \u0022ERROR in CLIENT\u005cn\u0022);\n- ERR_print_errors_fp(stderr);\n- return (1);\n- }\n- } else if (i \u003d\u003d 0) {\n- BIO_printf(bio_err, \u0022SSL CLIENT STARTUP FAILED\u005cn\u0022);\n- return (1);\n- } else {\n- done |\u003d C_DONE;\n- }\n- }\n- }\n-\n- if (do_server \u0026\u0026 !(done \u0026 S_DONE)) {\n- if (!s_write) {\n- i \u003d BIO_read(s_bio, sbuf, 100);\n- if (i \u003c 0) {\n- s_r \u003d 0;\n- s_w \u003d 0;\n- if (BIO_should_retry(s_bio)) {\n- if (BIO_should_read(s_bio))\n- s_r \u003d 1;\n- if (BIO_should_write(s_bio))\n- s_w \u003d 1;\n- } else {\n- BIO_printf(bio_err, \u0022ERROR in SERVER\u005cn\u0022);\n- ERR_print_errors_fp(stderr);\n- return (1);\n- }\n- } else if (i \u003d\u003d 0) {\n- BIO_printf(bio_err, \u0022SSL SERVER STARTUP FAILED\u005cn\u0022);\n- return (1);\n- } else {\n- s_write \u003d 1;\n- s_w \u003d 1;\n- }\n- } else {\n- i \u003d BIO_write(s_bio, \u0022hello from server\u005cn\u0022, 18);\n- if (i \u003c 0) {\n- s_r \u003d 0;\n- s_w \u003d 0;\n- if (BIO_should_retry(s_bio)) {\n- if (BIO_should_read(s_bio))\n- s_r \u003d 1;\n- if (BIO_should_write(s_bio))\n- s_w \u003d 1;\n- } else {\n- BIO_printf(bio_err, \u0022ERROR in SERVER\u005cn\u0022);\n- ERR_print_errors_fp(stderr);\n- return (1);\n- }\n- } else if (i \u003d\u003d 0) {\n- BIO_printf(bio_err, \u0022SSL SERVER STARTUP FAILED\u005cn\u0022);\n- return (1);\n- } else {\n- s_write \u003d 0;\n- s_r \u003d 1;\n- done |\u003d S_DONE;\n- }\n- }\n- }\n-\n- if ((done \u0026 S_DONE) \u0026\u0026 (done \u0026 C_DONE))\n- break;\n- }\n-\n- SSL_set_shutdown(c_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n- SSL_set_shutdown(s_ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n-\n- err:\n-#if 0\n- /*\n- * We have to set the BIO's to NULL otherwise they will be free()ed\n- * twice. Once when th s_ssl is SSL_free()ed and again when c_ssl is\n- * SSL_free()ed. This is a hack required because s_ssl and c_ssl are\n- * sharing the same BIO structure and SSL_set_bio() and SSL_free()\n- * automatically BIO_free non NULL entries. You should not normally do\n- * this or be required to do this\n- */\n-\n- if (s_ssl !\u003d NULL) {\n- s_ssl-\u003erbio \u003d NULL;\n- s_ssl-\u003ewbio \u003d NULL;\n- }\n- if (c_ssl !\u003d NULL) {\n- c_ssl-\u003erbio \u003d NULL;\n- c_ssl-\u003ewbio \u003d NULL;\n- }\n-\n- /* The SSL's are optionally freed in the following calls */\n- BIO_free(c_to_s);\n- BIO_free(s_to_c);\n-#endif\n-\n- BIO_free(c_bio);\n- BIO_free(s_bio);\n- return (0);\n-}\n-\n-int verify_callback(int ok, X509_STORE_CTX *ctx)\n-{\n- char *s, buf[256];\n-\n- if (verbose) {\n- s \u003d X509_NAME_oneline(X509_get_subject_name(ctx-\u003ecurrent_cert),\n- buf, 256);\n- if (s !\u003d NULL) {\n- if (ok)\n- BIO_printf(bio_err, \u0022depth\u003d%d %s\u005cn\u0022, ctx-\u003eerror_depth, buf);\n- else\n- BIO_printf(bio_err, \u0022depth\u003d%d error\u003d%d %s\u005cn\u0022,\n- ctx-\u003eerror_depth, ctx-\u003eerror, buf);\n- }\n- }\n- return (ok);\n-}\n-\n-#define THREAD_STACK_SIZE (16*1024)\n-\n-#ifdef OPENSSL_SYS_WIN32\n-\n-static HANDLE *lock_cs;\n-\n-void thread_setup(void)\n-{\n- int i;\n-\n- lock_cs \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- lock_cs[i] \u003d CreateMutex(NULL, FALSE, NULL);\n- }\n-\n- CRYPTO_set_locking_callback((void (*)(int, int, char *, int))\n- win32_locking_callback);\n- /* id callback defined */\n-}\n-\n-void thread_cleanup(void)\n-{\n- int i;\n-\n- CRYPTO_set_locking_callback(NULL);\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++)\n- CloseHandle(lock_cs[i]);\n- OPENSSL_free(lock_cs);\n-}\n-\n-void win32_locking_callback(int mode, int type, const char *file, int line)\n-{\n- if (mode \u0026 CRYPTO_LOCK) {\n- WaitForSingleObject(lock_cs[type], INFINITE);\n- } else {\n- ReleaseMutex(lock_cs[type]);\n- }\n-}\n-\n-void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)\n-{\n- double ret;\n- SSL_CTX *ssl_ctx[2];\n- DWORD thread_id[MAX_THREAD_NUMBER];\n- HANDLE thread_handle[MAX_THREAD_NUMBER];\n- int i;\n- SYSTEMTIME start, end;\n-\n- ssl_ctx[0] \u003d s_ctx;\n- ssl_ctx[1] \u003d c_ctx;\n-\n- GetSystemTime(\u0026start);\n- for (i \u003d 0; i \u003c thread_number; i++) {\n- thread_handle[i] \u003d CreateThread(NULL,\n- THREAD_STACK_SIZE,\n- (LPTHREAD_START_ROUTINE) ndoit,\n- (void *)ssl_ctx, 0L, \u0026(thread_id[i]));\n- }\n-\n- BIO_printf(bio_stdout, \u0022reaping\u005cn\u0022);\n- for (i \u003d 0; i \u003c thread_number; i +\u003d 50) {\n- int j;\n-\n- j \u003d (thread_number \u003c (i + 50)) ? (thread_number - i) : 50;\n-\n- if (WaitForMultipleObjects(j,\n- (CONST HANDLE *) \u0026 (thread_handle[i]),\n- TRUE, INFINITE)\n- \u003d\u003d WAIT_FAILED) {\n- BIO_printf(bio_err, \u0022WaitForMultipleObjects failed:%d\u005cn\u0022,\n- GetLastError());\n- exit(1);\n- }\n- }\n- GetSystemTime(\u0026end);\n-\n- if (start.wDayOfWeek \u003e end.wDayOfWeek)\n- end.wDayOfWeek +\u003d 7;\n- ret \u003d (end.wDayOfWeek - start.wDayOfWeek) * 24;\n-\n- ret \u003d (ret + end.wHour - start.wHour) * 60;\n- ret \u003d (ret + end.wMinute - start.wMinute) * 60;\n- ret \u003d (ret + end.wSecond - start.wSecond);\n- ret +\u003d (end.wMilliseconds - start.wMilliseconds) / 1000.0;\n-\n- BIO_printf(bio_stdout, \u0022win32 threads done - %.3f seconds\u005cn\u0022, ret);\n-}\n-\n-#endif /* OPENSSL_SYS_WIN32 */\n-\n-\n-#ifdef PTHREADS\n-\n-static pthread_mutex_t *lock_cs;\n-static long *lock_count;\n-\n-void thread_setup(void)\n-{\n- int i;\n-\n- lock_cs \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));\n- lock_count \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- lock_count[i] \u003d 0;\n- pthread_mutex_init(\u0026(lock_cs[i]), NULL);\n- }\n-\n- CRYPTO_THREADID_set_callback(pthreads_thread_id);\n- CRYPTO_set_locking_callback(pthreads_locking_callback);\n-}\n-\n-void thread_cleanup(void)\n-{\n- int i;\n-\n- CRYPTO_set_locking_callback(NULL);\n- BIO_printf(bio_err, \u0022cleanup\u005cn\u0022);\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- pthread_mutex_destroy(\u0026(lock_cs[i]));\n- BIO_printf(bio_err, \u0022%8ld:%s\u005cn\u0022, lock_count[i], CRYPTO_get_lock_name(i));\n- }\n- OPENSSL_free(lock_cs);\n- OPENSSL_free(lock_count);\n-\n- BIO_printf(bio_err, \u0022done cleanup\u005cn\u0022);\n-}\n-\n-void pthreads_locking_callback(int mode, int type, const char *file, int line)\n-{\n- if (mode \u0026 CRYPTO_LOCK) {\n- pthread_mutex_lock(\u0026(lock_cs[type]));\n- lock_count[type]++;\n- } else {\n- pthread_mutex_unlock(\u0026(lock_cs[type]));\n- }\n-}\n-\n-void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)\n-{\n- SSL_CTX *ssl_ctx[2];\n- pthread_t thread_ctx[MAX_THREAD_NUMBER];\n- int i;\n-\n- ssl_ctx[0] \u003d s_ctx;\n- ssl_ctx[1] \u003d c_ctx;\n-\n- for (i \u003d 0; i \u003c thread_number; i++) {\n- pthread_create(\u0026(thread_ctx[i]), NULL,\n- (void *(*)())ndoit, (void *)ssl_ctx);\n- }\n-\n- BIO_printf(bio_stdout, \u0022reaping\u005cn\u0022);\n- for (i \u003d 0; i \u003c thread_number; i++) {\n- pthread_join(thread_ctx[i], NULL);\n- }\n-\n-#if 0 /* We can't currently find out the reference amount */\n- BIO_printf(bio_stdout, \u0022pthreads threads done (%d,%d)\u005cn\u0022,\n- s_ctx-\u003ereferences, c_ctx-\u003ereferences);\n-#else\n- BIO_printf(bio_stdout, \u0022pthreads threads done\u005cn\u0022);\n-#endif\n-}\n-\n-void pthreads_thread_id(CRYPTO_THREADID *tid)\n-{\n- CRYPTO_THREADID_set_numeric(tid, (unsigned long)pthread_self());\n-}\n-\n-#endif /* PTHREADS */\ndiff --git a/demos/threads/pthread.sh b/demos/threads/pthread.sh\ndeleted file mode 100644\nindex ec945c4..0000000\n--- a/demos/threads/pthread.sh\n+++ /dev/null\n@@ -1,6 +0,0 @@\n-#!/bin/sh\n-#\n-# build using pthreads where it's already built into the system\n-#\n-/bin/rm -f mttest\n-gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread -ldl\ndiff --git a/demos/threads/th-lock.c b/demos/threads/th-lock.c\ndeleted file mode 100644\nindex dc58cb2..0000000\n--- a/demos/threads/th-lock.c\n+++ /dev/null\n@@ -1,194 +0,0 @@\n-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n- * All rights reserved.\n- *\n- * This package is an SSL implementation written\n- * by Eric Young (eay@cryptsoft.com).\n- * The implementation was written so as to conform with Netscapes SSL.\n- *\n- * This library is free for commercial and non-commercial use as long as\n- * the following conditions are aheared to. The following conditions\n- * apply to all code found in this distribution, be it the RC4, RSA,\n- * lhash, DES, etc., code; not just the SSL code. The SSL documentation\n- * included with this distribution is covered by the same copyright terms\n- * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n- *\n- * Copyright remains Eric Young's, and as such any Copyright notices in\n- * the code are not to be removed.\n- * If this package is used in a product, Eric Young should be given attribution\n- * as the author of the parts of the library used.\n- * This can be in the form of a textual message at program startup or\n- * in documentation (online or textual) provided with the package.\n- *\n- * Redistribution and use in source and binary forms, with or without\n- * modification, are permitted provided that the following conditions\n- * are met:\n- * 1. Redistributions of source code must retain the copyright\n- * notice, this list of conditions and the following disclaimer.\n- * 2. Redistributions in binary form must reproduce the above copyright\n- * notice, this list of conditions and the following disclaimer in the\n- * documentation and/or other materials provided with the distribution.\n- * 3. All advertising materials mentioning features or use of this software\n- * must display the following acknowledgement:\n- * \u0022This product includes cryptographic software written by\n- * Eric Young (eay@cryptsoft.com)\u0022\n- * The word 'cryptographic' can be left out if the rouines from the library\n- * being used are not cryptographic related :-).\n- * 4. If you include any Windows specific code (or a derivative thereof) from\n- * the apps directory (application code) you must include an acknowledgement:\n- * \u0022This product includes software written by Tim Hudson (tjh@cryptsoft.com)\u0022\n- *\n- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n- * SUCH DAMAGE.\n- *\n- * The licence and distribution terms for any publically available version or\n- * derivative of this code cannot be changed. i.e. this code cannot simply be\n- * copied and put under another distribution licence\n- * [including the GNU Public Licence.]\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cstdlib.h\u003e\n-#include \u003cstring.h\u003e\n-#include \u003cerrno.h\u003e\n-#ifdef LINUX\n-# include \u003ctypedefs.h\u003e\n-#endif\n-#ifdef OPENSSL_SYS_WIN32\n-# include \u003cwindows.h\u003e\n-#endif\n-#ifdef PTHREADS\n-# include \u003cpthread.h\u003e\n-#endif\n-#include \u003copenssl/lhash.h\u003e\n-#include \u003copenssl/crypto.h\u003e\n-#include \u003copenssl/buffer.h\u003e\n-#include \u0022../../e_os.h\u0022\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/ssl.h\u003e\n-#include \u003copenssl/err.h\u003e\n-\n-void CRYPTO_thread_setup(void);\n-void CRYPTO_thread_cleanup(void);\n-\n-static void win32_locking_callback(int mode, int type, char *file, int line);\n-static void pthreads_locking_callback(int mode, int type, char *file, int line);\n-static unsigned long pthreads_thread_id(void);\n-\n-/*-\n- * usage:\n- * CRYPTO_thread_setup();\n- * application code\n- * CRYPTO_thread_cleanup();\n- */\n-\n-#ifdef OPENSSL_SYS_WIN32\n-\n-static HANDLE *lock_cs;\n-\n-void CRYPTO_thread_setup(void)\n-{\n- int i;\n-\n- lock_cs \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));\n- if (!lock_cs) {\n- /* Nothing we can do about this...void function! */\n- return;\n- }\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- lock_cs[i] \u003d CreateMutex(NULL, FALSE, NULL);\n- }\n-\n- CRYPTO_set_locking_callback((void (*)(int, int, char *, int))\n- win32_locking_callback);\n- /* id callback defined */\n- return (1);\n-}\n-\n-static void CRYPTO_thread_cleanup(void)\n-{\n- int i;\n-\n- CRYPTO_set_locking_callback(NULL);\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++)\n- CloseHandle(lock_cs[i]);\n- OPENSSL_free(lock_cs);\n-}\n-\n-void win32_locking_callback(int mode, int type, char *file, int line)\n-{\n- if (mode \u0026 CRYPTO_LOCK) {\n- WaitForSingleObject(lock_cs[type], INFINITE);\n- } else {\n- ReleaseMutex(lock_cs[type]);\n- }\n-}\n-\n-#endif /* OPENSSL_SYS_WIN32 */\n-\n-/* Linux and a few others */\n-#ifdef PTHREADS\n-\n-static pthread_mutex_t *lock_cs;\n-static long *lock_count;\n-\n-void CRYPTO_thread_setup(void)\n-{\n- int i;\n-\n- lock_cs \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));\n- lock_count \u003d OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));\n- if (!lock_cs || !lock_count) {\n- /* Nothing we can do about this...void function! */\n- OPENSSL_free(lock_cs);\n- OPENSSL_free(lock_count);\n- return;\n- }\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- lock_count[i] \u003d 0;\n- pthread_mutex_init(\u0026(lock_cs[i]), NULL);\n- }\n-\n- CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);\n- CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);\n-}\n-\n-void thread_cleanup(void)\n-{\n- int i;\n-\n- CRYPTO_set_locking_callback(NULL);\n- for (i \u003d 0; i \u003c CRYPTO_num_locks(); i++) {\n- pthread_mutex_destroy(\u0026(lock_cs[i]));\n- }\n- OPENSSL_free(lock_cs);\n- OPENSSL_free(lock_count);\n-}\n-\n-void pthreads_locking_callback(int mode, int type, char *file, int line)\n-{\n- if (mode \u0026 CRYPTO_LOCK) {\n- pthread_mutex_lock(\u0026(lock_cs[type]));\n- lock_count[type]++;\n- } else {\n- pthread_mutex_unlock(\u0026(lock_cs[type]));\n- }\n-}\n-\n-unsigned long pthreads_thread_id(void)\n-{\n- unsigned long ret;\n-\n- ret \u003d (unsigned long)pthread_self();\n- return (ret);\n-}\n-\n-#endif /* PTHREADS */\ndiff --git a/demos/threads/win32.bat b/demos/threads/win32.bat\ndeleted file mode 100644\nindex ee6da80..0000000\n--- a/demos/threads/win32.bat\n+++ /dev/null\n@@ -1,4 +0,0 @@\n-del mttest.exe\n-\n-cl /O2 -DWIN32 /MD -I..\u005c..\u005cout mttest.c /Femttest ..\u005c..\u005cout\u005cssleay32.lib ..\u005c..\u005cout\u005clibeay32.lib\n-\ndiff --git a/demos/x509/README b/demos/x509/README\ndeleted file mode 100644\nindex b9e66e7..0000000\n--- a/demos/x509/README\n+++ /dev/null\n@@ -1,3 +0,0 @@\n-This directory contains examples of how to construct\n-various X509 structures. Certificates, certificate requests\n-and CRLs.\ndiff --git a/demos/x509/mkcert.c b/demos/x509/mkcert.c\ndeleted file mode 100644\nindex 1e62146..0000000\n--- a/demos/x509/mkcert.c\n+++ /dev/null\n@@ -1,169 +0,0 @@\n-/*\n- * Certificate creation. Demonstrates some certificate related operations.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cstdlib.h\u003e\n-\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/conf.h\u003e\n-#include \u003copenssl/x509v3.h\u003e\n-#ifndef OPENSSL_NO_ENGINE\n-# include \u003copenssl/engine.h\u003e\n-#endif\n-\n-int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);\n-int add_ext(X509 *cert, int nid, char *value);\n-\n-int main(int argc, char **argv)\n-{\n- BIO *bio_err;\n- X509 *x509 \u003d NULL;\n- EVP_PKEY *pkey \u003d NULL;\n-\n- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);\n-\n- bio_err \u003d BIO_new_fp(stderr, BIO_NOCLOSE);\n-\n- mkcert(\u0026x509, \u0026pkey, 512, 0, 365);\n-\n- RSA_print_fp(stdout, pkey-\u003epkey.rsa, 0);\n- X509_print_fp(stdout, x509);\n-\n- PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);\n- PEM_write_X509(stdout, x509);\n-\n- X509_free(x509);\n- EVP_PKEY_free(pkey);\n-\n-#ifndef OPENSSL_NO_ENGINE\n- ENGINE_cleanup();\n-#endif\n- CRYPTO_cleanup_all_ex_data();\n-\n- CRYPTO_mem_leaks(bio_err);\n- BIO_free(bio_err);\n- return (0);\n-}\n-\n-static void callback(int p, int n, void *arg)\n-{\n- char c \u003d 'B';\n-\n- if (p \u003d\u003d 0)\n- c \u003d '.';\n- if (p \u003d\u003d 1)\n- c \u003d '+';\n- if (p \u003d\u003d 2)\n- c \u003d '*';\n- if (p \u003d\u003d 3)\n- c \u003d '\u005cn';\n- fputc(c, stderr);\n-}\n-\n-int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days)\n-{\n- X509 *x;\n- EVP_PKEY *pk;\n- RSA *rsa;\n- X509_NAME *name \u003d NULL;\n-\n- if ((pkeyp \u003d\u003d NULL) || (*pkeyp \u003d\u003d NULL)) {\n- if ((pk \u003d EVP_PKEY_new()) \u003d\u003d NULL) {\n- abort();\n- return (0);\n- }\n- } else\n- pk \u003d *pkeyp;\n-\n- if ((x509p \u003d\u003d NULL) || (*x509p \u003d\u003d NULL)) {\n- if ((x \u003d X509_new()) \u003d\u003d NULL)\n- goto err;\n- } else\n- x \u003d *x509p;\n-\n- rsa \u003d RSA_generate_key(bits, RSA_F4, callback, NULL);\n- if (!EVP_PKEY_assign_RSA(pk, rsa)) {\n- abort();\n- goto err;\n- }\n- rsa \u003d NULL;\n-\n- X509_set_version(x, 2);\n- ASN1_INTEGER_set(X509_get_serialNumber(x), serial);\n- X509_gmtime_adj(X509_get_notBefore(x), 0);\n- X509_gmtime_adj(X509_get_notAfter(x), (long)60 * 60 * 24 * days);\n- X509_set_pubkey(x, pk);\n-\n- name \u003d X509_get_subject_name(x);\n-\n- /*\n- * This function creates and adds the entry, working out the correct\n- * string type and performing checks on its length. Normally we'd check\n- * the return value for errors...\n- */\n- X509_NAME_add_entry_by_txt(name, \u0022C\u0022, MBSTRING_ASC, \u0022UK\u0022, -1, -1, 0);\n- X509_NAME_add_entry_by_txt(name, \u0022CN\u0022,\n- MBSTRING_ASC, \u0022OpenSSL Group\u0022, -1, -1, 0);\n-\n- /*\n- * Its self signed so set the issuer name to be the same as the subject.\n- */\n- X509_set_issuer_name(x, name);\n-\n- /* Add various extensions: standard extensions */\n- add_ext(x, NID_basic_constraints, \u0022critical,CA:TRUE\u0022);\n- add_ext(x, NID_key_usage, \u0022critical,keyCertSign,cRLSign\u0022);\n-\n- add_ext(x, NID_subject_key_identifier, \u0022hash\u0022);\n-\n- /* Some Netscape specific extensions */\n- add_ext(x, NID_netscape_cert_type, \u0022sslCA\u0022);\n-\n- add_ext(x, NID_netscape_comment, \u0022example comment extension\u0022);\n-\n-#ifdef CUSTOM_EXT\n- /* Maybe even add our own extension based on existing */\n- {\n- int nid;\n- nid \u003d OBJ_create(\u00221.2.3.4\u0022, \u0022MyAlias\u0022, \u0022My Test Alias Extension\u0022);\n- X509V3_EXT_add_alias(nid, NID_netscape_comment);\n- add_ext(x, nid, \u0022example comment alias\u0022);\n- }\n-#endif\n-\n- if (!X509_sign(x, pk, EVP_sha1()))\n- goto err;\n-\n- *x509p \u003d x;\n- *pkeyp \u003d pk;\n- return (1);\n- err:\n- return (0);\n-}\n-\n-/*\n- * Add extension using V3 code: we can set the config file as NULL because we\n- * wont reference any other sections.\n- */\n-\n-int add_ext(X509 *cert, int nid, char *value)\n-{\n- X509_EXTENSION *ex;\n- X509V3_CTX ctx;\n- /* This sets the 'context' of the extensions. */\n- /* No configuration database */\n- X509V3_set_ctx_nodb(\u0026ctx);\n- /*\n- * Issuer and subject certs: both the target since it is self signed, no\n- * request and no CRL\n- */\n- X509V3_set_ctx(\u0026ctx, cert, cert, NULL, NULL, 0);\n- ex \u003d X509V3_EXT_conf_nid(NULL, \u0026ctx, nid, value);\n- if (!ex)\n- return 0;\n-\n- X509_add_ext(cert, ex, -1);\n- X509_EXTENSION_free(ex);\n- return 1;\n-}\ndiff --git a/demos/x509/mkreq.c b/demos/x509/mkreq.c\ndeleted file mode 100644\nindex 4d2ad79..0000000\n--- a/demos/x509/mkreq.c\n+++ /dev/null\n@@ -1,168 +0,0 @@\n-/*\n- * Certificate request creation. Demonstrates some request related\n- * operations.\n- */\n-\n-#include \u003cstdio.h\u003e\n-#include \u003cstdlib.h\u003e\n-\n-#include \u003copenssl/pem.h\u003e\n-#include \u003copenssl/conf.h\u003e\n-#include \u003copenssl/x509.h\u003e\n-#include \u003copenssl/x509v3.h\u003e\n-#ifndef OPENSSL_NO_ENGINE\n-# include \u003copenssl/engine.h\u003e\n-#endif\n-\n-int mkreq(X509_REQ **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days);\n-int add_ext(STACK_OF(X509_EXTENSION) *sk, int nid, char *value);\n-\n-int main(int argc, char **argv)\n-{\n- BIO *bio_err;\n- X509_REQ *req \u003d NULL;\n- EVP_PKEY *pkey \u003d NULL;\n-\n- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);\n-\n- bio_err \u003d BIO_new_fp(stderr, BIO_NOCLOSE);\n-\n- mkreq(\u0026req, \u0026pkey, 512, 0, 365);\n-\n- RSA_print_fp(stdout, pkey-\u003epkey.rsa, 0);\n- X509_REQ_print_fp(stdout, req);\n-\n- PEM_write_X509_REQ(stdout, req);\n-\n- X509_REQ_free(req);\n- EVP_PKEY_free(pkey);\n-\n-#ifndef OPENSSL_NO_ENGINE\n- ENGINE_cleanup();\n-#endif\n- CRYPTO_cleanup_all_ex_data();\n-\n- CRYPTO_mem_leaks(bio_err);\n- BIO_free(bio_err);\n- return (0);\n-}\n-\n-static void callback(int p, int n, void *arg)\n-{\n- char c \u003d 'B';\n-\n- if (p \u003d\u003d 0)\n- c \u003d '.';\n- if (p \u003d\u003d 1)\n- c \u003d '+';\n- if (p \u003d\u003d 2)\n- c \u003d '*';\n- if (p \u003d\u003d 3)\n- c \u003d '\u005cn';\n- fputc(c, stderr);\n-}\n-\n-int mkreq(X509_REQ **req, EVP_PKEY **pkeyp, int bits, int serial, int days)\n-{\n- X509_REQ *x;\n- EVP_PKEY *pk;\n- RSA *rsa;\n- X509_NAME *name \u003d NULL;\n- STACK_OF(X509_EXTENSION) *exts \u003d NULL;\n-\n- if ((pk \u003d EVP_PKEY_new()) \u003d\u003d NULL)\n- goto err;\n-\n- if ((x \u003d X509_REQ_new()) \u003d\u003d NULL)\n- goto err;\n-\n- rsa \u003d RSA_generate_key(bits, RSA_F4, callback, NULL);\n- if (!EVP_PKEY_assign_RSA(pk, rsa))\n- goto err;\n-\n- rsa \u003d NULL;\n-\n- X509_REQ_set_pubkey(x, pk);\n-\n- name \u003d X509_REQ_get_subject_name(x);\n-\n- /*\n- * This function creates and adds the entry, working out the correct\n- * string type and performing checks on its length. Normally we'd check\n- * the return value for errors...\n- */\n- X509_NAME_add_entry_by_txt(name, \u0022C\u0022, MBSTRING_ASC, \u0022UK\u0022, -1, -1, 0);\n- X509_NAME_add_entry_by_txt(name, \u0022CN\u0022,\n- MBSTRING_ASC, \u0022OpenSSL Group\u0022, -1, -1, 0);\n-\n-#ifdef REQUEST_EXTENSIONS\n- /*\n- * Certificate requests can contain extensions, which can be used to\n- * indicate the extensions the requestor would like added to their\n- * certificate. CAs might ignore them however or even choke if they are\n- * present.\n- */\n-\n- /*\n- * For request extensions they are all packed in a single attribute. We\n- * save them in a STACK and add them all at once later...\n- */\n-\n- exts \u003d sk_X509_EXTENSION_new_null();\n- /* Standard extenions */\n-\n- add_ext(exts, NID_key_usage, \u0022critical,digitalSignature,keyEncipherment\u0022);\n-\n- /*\n- * This is a typical use for request extensions: requesting a value for\n- * subject alternative name.\n- */\n-\n- add_ext(exts, NID_subject_alt_name, \u0022email:steve@openssl.org\u0022);\n-\n- /* Some Netscape specific extensions */\n- add_ext(exts, NID_netscape_cert_type, \u0022client,email\u0022);\n-\n-# ifdef CUSTOM_EXT\n- /* Maybe even add our own extension based on existing */\n- {\n- int nid;\n- nid \u003d OBJ_create(\u00221.2.3.4\u0022, \u0022MyAlias\u0022, \u0022My Test Alias Extension\u0022);\n- X509V3_EXT_add_alias(nid, NID_netscape_comment);\n- add_ext(x, nid, \u0022example comment alias\u0022);\n- }\n-# endif\n-\n- /* Now we've created the extensions we add them to the request */\n-\n- X509_REQ_add_extensions(x, exts);\n-\n- sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);\n-\n-#endif\n-\n- if (!X509_REQ_sign(x, pk, EVP_sha1()))\n- goto err;\n-\n- *req \u003d x;\n- *pkeyp \u003d pk;\n- return (1);\n- err:\n- return (0);\n-}\n-\n-/*\n- * Add extension using V3 code: we can set the config file as NULL because we\n- * wont reference any other sections.\n- */\n-\n-int add_ext(STACK_OF(X509_EXTENSION) *sk, int nid, char *value)\n-{\n- X509_EXTENSION *ex;\n- ex \u003d X509V3_EXT_conf_nid(NULL, NULL, nid, value);\n- if (!ex)\n- return 0;\n- sk_X509_EXTENSION_push(sk, ex);\n-\n- return 1;\n-}\n","s":{"c":1756843409,"u": 53096}} ],"g": 102034,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}