I've created another patch against openssl-0.9.3 (see below) to get the
examples in the following demos directories to work ... bio, eay,
maurice, prime, sign, but not ssl which is in C++... I've got it to
compile cleanly, but it will take a bit more work to debug it... but
it's definitely a great way of learning more about OpenSSL !!!
The patch also includes a Makefile for each directory with a test:
where I can...
I am building under intel Redhat linux 5.2
Hope this is useful... should I continue to hand these "fixes" in ?
Constructive Criticism gratefully received !
cheers,
Sean [EMAIL PROTECTED]
-------------------------------------------------------------
diff -Naur openssl-0.9.3/demos/bio/Makefile
openssl-0.9.3-work/demos/bio/Makefile
--- openssl-0.9.3/demos/bio/Makefile Thu Jan 1 01:00:00 1970
+++ openssl-0.9.3-work/demos/bio/Makefile Thu May 27 19:29:37 1999
@@ -0,0 +1,16 @@
+CC=cc
+CFLAGS= -g -I../../include
+LIBS= -L../.. ../../libssl.a ../../libcrypto.a
+EXAMPLES=saccept sconnect
+
+all: $(EXAMPLES)
+
+saccept: saccept.o
+ $(CC) -o saccept saccept.o $(LIBS)
+
+sconnect: sconnect.o
+ $(CC) -o sconnect sconnect.o $(LIBS)
+
+clean:
+ rm -f $(EXAMPLES) *.o
+
diff -Naur openssl-0.9.3/demos/bio/sconnect.c
openssl-0.9.3-work/demos/bio/sconnect.c
--- openssl-0.9.3/demos/bio/sconnect.c Fri Apr 23 23:13:05 1999
+++ openssl-0.9.3-work/demos/bio/sconnect.c Thu May 27 15:13:23 1999
@@ -9,6 +9,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
diff -Naur openssl-0.9.3/demos/eay/Makefile
openssl-0.9.3-work/demos/eay/Makefile
--- openssl-0.9.3/demos/eay/Makefile Thu Jan 1 01:00:00 1970
+++ openssl-0.9.3-work/demos/eay/Makefile Thu May 27 17:50:42 1999
@@ -0,0 +1,24 @@
+CC=cc
+CFLAGS= -g -I../../include
+#LIBS= -L../.. -lcrypto -lssl
+LIBS= -L../.. ../../libssl.a ../../libcrypto.a
+
+# the file conn.c requires a file "proxy.h" which I couldn't find...
+#EXAMPLES=base64 conn loadrsa
+EXAMPLES=base64 loadrsa
+
+all: $(EXAMPLES)
+
+base64: base64.o
+ $(CC) -o base64 base64.o $(LIBS)
+#
+# sorry... can't find "proxy.h"
+#conn: conn.o
+# $(CC) -o conn conn.o $(LIBS)
+
+loadrsa: loadrsa.o
+ $(CC) -o loadrsa loadrsa.o $(LIBS)
+
+clean:
+ rm -f $(EXAMPLES) *.o
+
diff -Naur openssl-0.9.3/demos/eay/conn.c
openssl-0.9.3-work/demos/eay/conn.c
--- openssl-0.9.3/demos/eay/conn.c Fri Apr 23 23:13:06 1999
+++ openssl-0.9.3-work/demos/eay/conn.c Thu May 27 17:46:21 1999
@@ -9,7 +9,7 @@
#include <stdlib.h>
#include <openssl/err.h>
#include <openssl/bio.h>
-#include "proxy.h"
+/* #include "proxy.h" */
extern int errno;
diff -Naur openssl-0.9.3/demos/maurice/Makefile
openssl-0.9.3-work/demos/maurice/Makefile
--- openssl-0.9.3/demos/maurice/Makefile Sat Jan 2 19:03:46 1999
+++ openssl-0.9.3-work/demos/maurice/Makefile Thu May 27 17:18:31 1999
@@ -1,5 +1,5 @@
CC=cc
-CFLAGS= -g -I../../include
+CFLAGS= -g -I../../include -Wall
LIBS= -L../.. -lcrypto
EXAMPLES=example1 example2 example3 example4
@@ -20,3 +20,40 @@
clean:
rm -f $(EXAMPLES) *.o
+test: all
+ @echo
+ @echo Example 1 Demonstrates the sealing and opening APIs
+ @echo Doing the encrypt side...
+ ./example1 <README >t.t
+ @echo Doing the decrypt side...
+ ./example1 -d <t.t >t.2
+ diff t.2 README
+ rm -f t.t t.2
+ @echo example1 is OK
+
+ @echo
+ @echo Example2 Demonstrates rsa encryption and decryption
+ @echo and it should just print \"This the clear text\"
+ ./example2
+
+ @echo
+ @echo Example3 Demonstrates the use of symmetric block ciphers
+ @echo in this case it uses EVP_des_ede3_cbc
+ @echo i.e. triple DES in Cipher Block Chaining mode
+ @echo Doing the encrypt side...
+ ./example3 ThisIsThePassword <README >t.t
+ @echo Doing the decrypt side...
+ ./example3 -d ThisIsThePassword <t.t >t.2
+ diff t.2 README
+ rm -f t.t t.2
+ @echo example3 is OK
+
+ @echo
+ @echo Example4 Demonstrates base64 encoding and decoding
+ @echo Doing the encrypt side...
+ ./example4 <README >t.t
+ @echo Doing the decrypt side...
+ ./example4 -d <t.t >t.2
+ diff t.2 README
+ rm -f t.t t.2
+ @echo example4 is OK
diff -Naur openssl-0.9.3/demos/maurice/example2.c
openssl-0.9.3-work/demos/maurice/example2.c
--- openssl-0.9.3/demos/maurice/example2.c Fri Apr 23 23:13:08 1999
+++ openssl-0.9.3-work/demos/maurice/example2.c Thu May 27 16:12:20 1999
@@ -33,7 +33,6 @@
EVP_PKEY *pubKey;
EVP_PKEY *privKey;
int len;
- FILE *fp;
ERR_load_crypto_strings();
@@ -72,6 +71,5 @@
EVP_PKEY_free(pubKey);
free(buf);
free(buf2);
+ return 0;
}
-
-
diff -Naur openssl-0.9.3/demos/maurice/example3.c
openssl-0.9.3-work/demos/maurice/example3.c
--- openssl-0.9.3/demos/maurice/example3.c Mon Dec 21 10:52:47 1998
+++ openssl-0.9.3-work/demos/maurice/example3.c Thu May 27 16:15:55 1999
@@ -8,9 +8,10 @@
*/
#include <stdio.h>
+#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <evp.h>
+#include <openssl/evp.h>
#define STDIN 0
#define STDOUT 1
@@ -47,9 +48,9 @@
{
char buf[BUFLEN];
char ebuf[BUFLEN + 8];
- unsigned int ebuflen, rc;
+ unsigned int ebuflen; /* rc; */
unsigned char iv[EVP_MAX_IV_LENGTH], key[EVP_MAX_KEY_LENGTH];
- unsigned int ekeylen, net_ekeylen;
+ /* unsigned int ekeylen, net_ekeylen; */
EVP_CIPHER_CTX ectx;
memcpy(iv, INIT_VECTOR, sizeof(iv));
@@ -82,5 +83,3 @@
write(STDOUT, ebuf, ebuflen);
}
-
-
diff -Naur openssl-0.9.3/demos/maurice/example4.c
openssl-0.9.3-work/demos/maurice/example4.c
--- openssl-0.9.3/demos/maurice/example4.c Mon Dec 21 10:52:47 1998
+++ openssl-0.9.3-work/demos/maurice/example4.c Thu May 27 16:19:04 1999
@@ -8,9 +8,10 @@
*/
#include <stdio.h>
+#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <evp.h>
+#include <openssl/evp.h>
#define STDIN 0
#define STDOUT 1
@@ -44,7 +45,7 @@
{
char buf[BUFLEN];
char ebuf[BUFLEN+24];
- unsigned int ebuflen, rc;
+ unsigned int ebuflen;
EVP_ENCODE_CTX ectx;
EVP_EncodeInit(&ectx);
@@ -78,7 +79,7 @@
{
char buf[BUFLEN];
char ebuf[BUFLEN+24];
- unsigned int ebuflen, rc;
+ unsigned int ebuflen;
EVP_ENCODE_CTX ectx;
EVP_DecodeInit(&ectx);
diff -Naur openssl-0.9.3/demos/prime/Makefile
openssl-0.9.3-work/demos/prime/Makefile
--- openssl-0.9.3/demos/prime/Makefile Thu Jan 1 01:00:00 1970
+++ openssl-0.9.3-work/demos/prime/Makefile Thu May 27 19:30:30 1999
@@ -0,0 +1,20 @@
+CC=cc
+CFLAGS= -g -I../../include -Wall
+LIBS= -L../.. -lcrypto
+EXAMPLES=prime
+
+all: $(EXAMPLES)
+
+prime: prime.o
+ $(CC) -o prime prime.o $(LIBS)
+
+clean:
+ rm -f $(EXAMPLES) *.o
+
+test: all
+ @echo Test creating a 128-bit prime
+ ./prime 128
+ @echo Test creating a 256-bit prime
+ ./prime 256
+ @echo Test creating a 512-bit prime
+ ./prime 512
diff -Naur openssl-0.9.3/demos/sign/Makefile
openssl-0.9.3-work/demos/sign/Makefile
--- openssl-0.9.3/demos/sign/Makefile Thu Jan 1 01:00:00 1970
+++ openssl-0.9.3-work/demos/sign/Makefile Thu May 27 17:56:52 1999
@@ -0,0 +1,15 @@
+CC=cc
+CFLAGS= -g -I../../include -Wall
+LIBS= -L../.. -lcrypto
+EXAMPLES=sign
+
+all: $(EXAMPLES)
+
+sign: sign.o
+ $(CC) -o sign sign.o $(LIBS)
+
+clean:
+ rm -f $(EXAMPLES) *.o
+
+test: all
+ ./sign
diff -Naur openssl-0.9.3/demos/sign/sign.c
openssl-0.9.3-work/demos/sign/sign.c
--- openssl-0.9.3/demos/sign/sign.c Fri Apr 23 23:13:11 1999
+++ openssl-0.9.3-work/demos/sign/sign.c Thu May 27 17:57:27 1999
@@ -70,7 +70,7 @@
#include <openssl/pem.h>
#include <openssl/ssl.h>
-void main ()
+int main ()
{
int err;
int sig_len;
@@ -134,4 +134,5 @@
if (err != 1) { ERR_print_errors_fp (stderr); exit (1); }
EVP_PKEY_free (pkey);
printf ("Signature Verified Ok.\n");
+ return(0);
}
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]