Index: openssl-0.9.8g/apps/ca.c
===================================================================
--- openssl-0.9.8g.orig/apps/ca.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/ca.c	2008-09-24 11:01:01.000000000 +0200
@@ -834,7 +834,7 @@
 			BIO_printf(bio_err,"there needs to be defined a directory for new certificate to be placed in\n");
 			goto err;
 			}
-#ifndef OPENSSL_SYS_VMS
+#if !(defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_NEWLIB))
 	    /* outdir is a directory spec, but access() for VMS demands a
 	       filename.  In any case, stat(), below, will catch the problem
 	       if outdir is not a directory spec, and the fopen() or open()
Index: openssl-0.9.8g/apps/Makefile
===================================================================
--- openssl-0.9.8g.orig/apps/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -313,18 +313,19 @@
 dsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 dsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 dsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-dsa.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
-dsa.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
-dsa.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
-dsa.o: ../include/openssl/err.h ../include/openssl/evp.h
-dsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-dsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-dsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-dsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-dsa.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
-dsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
-dsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-dsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h dsa.c
+dsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
+dsa.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+dsa.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+dsa.o: ../include/openssl/engine.h ../include/openssl/err.h
+dsa.o: ../include/openssl/evp.h ../include/openssl/lhash.h
+dsa.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+dsa.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+dsa.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+dsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+dsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+dsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+dsa.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+dsa.o: ../include/openssl/x509_vfy.h apps.h dsa.c
 dsaparam.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 dsaparam.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 dsaparam.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -337,11 +338,9 @@
 dsaparam.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 dsaparam.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
 dsaparam.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-dsaparam.o: ../include/openssl/rand.h ../include/openssl/rsa.h
 dsaparam.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-dsaparam.o: ../include/openssl/stack.h ../include/openssl/store.h
-dsaparam.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-dsaparam.o: ../include/openssl/ui.h ../include/openssl/x509.h
+dsaparam.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+dsaparam.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
 dsaparam.o: ../include/openssl/x509_vfy.h apps.h dsaparam.c
 ec.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 ec.o: ../include/openssl/buffer.h ../include/openssl/conf.h
@@ -430,41 +429,38 @@
 gendh.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 gendh.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 gendh.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-gendh.o: ../include/openssl/dh.h ../include/openssl/dsa.h
-gendh.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
-gendh.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
-gendh.o: ../include/openssl/engine.h ../include/openssl/err.h
-gendh.o: ../include/openssl/evp.h ../include/openssl/lhash.h
-gendh.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-gendh.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-gendh.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-gendh.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-gendh.o: ../include/openssl/rand.h ../include/openssl/rsa.h
+gendh.o: ../include/openssl/dh.h ../include/openssl/e_os2.h
+gendh.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
+gendh.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
+gendh.o: ../include/openssl/err.h ../include/openssl/evp.h
+gendh.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+gendh.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
+gendh.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+gendh.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+gendh.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
 gendh.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-gendh.o: ../include/openssl/stack.h ../include/openssl/store.h
-gendh.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-gendh.o: ../include/openssl/ui.h ../include/openssl/x509.h
+gendh.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+gendh.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
 gendh.o: ../include/openssl/x509_vfy.h apps.h gendh.c
 gendsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 gendsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 gendsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-gendsa.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
-gendsa.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
-gendsa.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
-gendsa.o: ../include/openssl/err.h ../include/openssl/evp.h
-gendsa.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-gendsa.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-gendsa.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-gendsa.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-gendsa.o: ../include/openssl/pkcs7.h ../include/openssl/safestack.h
-gendsa.o: ../include/openssl/sha.h ../include/openssl/stack.h
-gendsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-gendsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
-gendsa.o: gendsa.c
+gendsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
+gendsa.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+gendsa.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+gendsa.o: ../include/openssl/engine.h ../include/openssl/err.h
+gendsa.o: ../include/openssl/evp.h ../include/openssl/lhash.h
+gendsa.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+gendsa.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+gendsa.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+gendsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+gendsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+gendsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+gendsa.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
+gendsa.o: ../include/openssl/x509_vfy.h apps.h gendsa.c
 genrsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 genrsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 genrsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-genrsa.o: ../include/openssl/dh.h ../include/openssl/dsa.h
 genrsa.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
 genrsa.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
 genrsa.o: ../include/openssl/engine.h ../include/openssl/err.h
@@ -475,9 +471,8 @@
 genrsa.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
 genrsa.o: ../include/openssl/rand.h ../include/openssl/rsa.h
 genrsa.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-genrsa.o: ../include/openssl/stack.h ../include/openssl/store.h
-genrsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-genrsa.o: ../include/openssl/ui.h ../include/openssl/x509.h
+genrsa.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
+genrsa.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
 genrsa.o: ../include/openssl/x509_vfy.h apps.h genrsa.c
 nseq.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 nseq.o: ../include/openssl/buffer.h ../include/openssl/conf.h
@@ -634,12 +629,11 @@
 req.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 req.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
 req.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-req.o: ../include/openssl/rand.h ../include/openssl/rsa.h
-req.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-req.o: ../include/openssl/stack.h ../include/openssl/store.h
+req.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+req.o: ../include/openssl/sha.h ../include/openssl/stack.h
 req.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
-req.o: ../include/openssl/ui.h ../include/openssl/x509.h
-req.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h req.c
+req.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+req.o: ../include/openssl/x509v3.h apps.h req.c
 rsa.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 rsa.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 rsa.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -656,20 +650,21 @@
 rsa.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
 rsa.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h rsa.c
 rsautl.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-rsautl.o: ../include/openssl/buffer.h ../include/openssl/conf.h
-rsautl.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-rsautl.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
-rsautl.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
-rsautl.o: ../include/openssl/err.h ../include/openssl/evp.h
-rsautl.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-rsautl.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-rsautl.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-rsautl.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-rsautl.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
-rsautl.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-rsautl.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-rsautl.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
-rsautl.o: ../include/openssl/x509_vfy.h apps.h rsautl.c
+rsautl.o: ../include/openssl/bn.h ../include/openssl/buffer.h
+rsautl.o: ../include/openssl/conf.h ../include/openssl/crypto.h
+rsautl.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+rsautl.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+rsautl.o: ../include/openssl/engine.h ../include/openssl/err.h
+rsautl.o: ../include/openssl/evp.h ../include/openssl/lhash.h
+rsautl.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+rsautl.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+rsautl.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+rsautl.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+rsautl.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+rsautl.o: ../include/openssl/sha.h ../include/openssl/stack.h
+rsautl.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
+rsautl.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
+rsautl.o: rsautl.c
 s_cb.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_cb.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_cb.o: ../include/openssl/comp.h ../include/openssl/conf.h
@@ -711,29 +706,8 @@
 s_client.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
 s_client.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
 s_client.o: s_apps.h s_client.c timeouts.h
-s_server.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-s_server.o: ../include/openssl/bn.h ../include/openssl/buffer.h
-s_server.o: ../include/openssl/comp.h ../include/openssl/conf.h
-s_server.o: ../include/openssl/crypto.h ../include/openssl/dh.h
-s_server.o: ../include/openssl/dsa.h ../include/openssl/dtls1.h
-s_server.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
-s_server.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
-s_server.o: ../include/openssl/engine.h ../include/openssl/err.h
-s_server.o: ../include/openssl/evp.h ../include/openssl/kssl.h
-s_server.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-s_server.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-s_server.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-s_server.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-s_server.o: ../include/openssl/pkcs7.h ../include/openssl/pq_compat.h
-s_server.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
-s_server.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
-s_server.o: ../include/openssl/sha.h ../include/openssl/ssl.h
-s_server.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
-s_server.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
-s_server.o: ../include/openssl/store.h ../include/openssl/symhacks.h
-s_server.o: ../include/openssl/tls1.h ../include/openssl/txt_db.h
-s_server.o: ../include/openssl/ui.h ../include/openssl/x509.h
-s_server.o: ../include/openssl/x509_vfy.h apps.h s_apps.h s_server.c timeouts.h
+s_server.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
+s_server.o: s_server.c
 s_socket.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 s_socket.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 s_socket.o: ../include/openssl/comp.h ../include/openssl/conf.h
@@ -814,24 +788,25 @@
 speed.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 speed.o: ../include/openssl/cast.h ../include/openssl/conf.h
 speed.o: ../include/openssl/crypto.h ../include/openssl/des.h
-speed.o: ../include/openssl/des_old.h ../include/openssl/dsa.h
-speed.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
-speed.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
-speed.o: ../include/openssl/engine.h ../include/openssl/err.h
-speed.o: ../include/openssl/evp.h ../include/openssl/hmac.h
-speed.o: ../include/openssl/idea.h ../include/openssl/lhash.h
-speed.o: ../include/openssl/md2.h ../include/openssl/md4.h
-speed.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
-speed.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-speed.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-speed.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
-speed.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
-speed.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
-speed.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-speed.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-speed.o: ../include/openssl/txt_db.h ../include/openssl/ui.h
-speed.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h
-speed.o: ../include/openssl/x509_vfy.h apps.h speed.c testdsa.h testrsa.h
+speed.o: ../include/openssl/des_old.h ../include/openssl/dh.h
+speed.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
+speed.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
+speed.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
+speed.o: ../include/openssl/err.h ../include/openssl/evp.h
+speed.o: ../include/openssl/hmac.h ../include/openssl/idea.h
+speed.o: ../include/openssl/lhash.h ../include/openssl/md2.h
+speed.o: ../include/openssl/md4.h ../include/openssl/md5.h
+speed.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+speed.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
+speed.o: ../include/openssl/rand.h ../include/openssl/rc2.h
+speed.o: ../include/openssl/rc4.h ../include/openssl/ripemd.h
+speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+speed.o: ../include/openssl/sha.h ../include/openssl/stack.h
+speed.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
+speed.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h
+speed.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h speed.c
+speed.o: testdsa.h testrsa.h
 spkac.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 spkac.o: ../include/openssl/buffer.h ../include/openssl/conf.h
 spkac.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
@@ -882,16 +857,17 @@
 x509.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 x509.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-x509.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
-x509.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
-x509.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
-x509.o: ../include/openssl/err.h ../include/openssl/evp.h
-x509.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-x509.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-x509.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-x509.o: ../include/openssl/pem.h ../include/openssl/pem2.h
-x509.o: ../include/openssl/pkcs7.h ../include/openssl/rsa.h
-x509.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-x509.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-x509.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
-x509.o: ../include/openssl/x509_vfy.h ../include/openssl/x509v3.h apps.h x509.c
+x509.o: ../include/openssl/dh.h ../include/openssl/dsa.h
+x509.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+x509.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+x509.o: ../include/openssl/engine.h ../include/openssl/err.h
+x509.o: ../include/openssl/evp.h ../include/openssl/lhash.h
+x509.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+x509.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+x509.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
+x509.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
+x509.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+x509.o: ../include/openssl/sha.h ../include/openssl/stack.h
+x509.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
+x509.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
+x509.o: ../include/openssl/x509v3.h apps.h x509.c
Index: openssl-0.9.8g/apps/s_client.c
===================================================================
--- openssl-0.9.8g.orig/apps/s_client.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/s_client.c	2008-09-24 11:01:01.000000000 +0200
@@ -137,6 +137,8 @@
 #include "s_apps.h"
 #include "timeouts.h"
 
+#ifndef OPENSSL_SYS_NEWLIB
+
 #ifdef OPENSSL_SYS_WINCE
 /* Windows CE incorrectly defines fileno as returning void*, so to avoid problems below... */
 #ifdef fileno
@@ -1430,3 +1432,4 @@
 	(void)BIO_flush(bio);
 	}
 
+#endif
Index: openssl-0.9.8g/apps/speed.c
===================================================================
--- openssl-0.9.8g.orig/apps/speed.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/speed.c	2008-09-24 11:01:01.000000000 +0200
@@ -113,7 +113,7 @@
 #elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
 # define TIMES
 #endif
-#if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
+#if !defined(OPENSSL_SYS_NEWLIB) && !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
 # define TIMEB
 #endif
 
@@ -237,6 +237,11 @@
  */
 
 /* The following if from times(3) man page.  It may need to be changed */
+#ifdef OPENSSL_SYS_NEWLIB
+#define HZ 1000000.0
+#endif
+
+
 #ifndef HZ
 # if defined(_SC_CLK_TCK) \
      && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
@@ -254,7 +259,7 @@
 # endif
 #endif
 
-#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
+# if !defined(OPENSSL_SYS_NEWLIB) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
 # define HAVE_FORK 1
 #endif
 
@@ -307,6 +312,10 @@
 static int rnd_fake = 0;
 #endif
 
+#ifdef OPENSSL_SYS_NEWLIB
+#undef SIGALRM
+#endif
+
 #ifdef SIGALRM
 #if defined(__STDC__) || defined(sgi) || defined(_AIX)
 #define SIGRETTYPE void
@@ -2675,6 +2684,10 @@
 	OPENSSL_EXIT(mret);
 	}
 
+#ifdef OPENSSL_SYS_NEWLIB
+#undef SIGALRM
+#endif
+
 static void print_message(const char *s, long num, int length)
 	{
 #ifdef SIGALRM
Index: openssl-0.9.8g/apps/s_server.c
===================================================================
--- openssl-0.9.8g.orig/apps/s_server.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/s_server.c	2008-09-24 11:01:01.000000000 +0200
@@ -127,6 +127,7 @@
 
 #include <sys/stat.h>
 #include <openssl/e_os2.h>
+#ifndef OPENSSL_SYS_NEWLIB
 #ifdef OPENSSL_NO_STDIO
 #define APPS_WIN16
 #endif
@@ -2287,3 +2288,5 @@
 		return 0;
 	return 1;
 	}
+
+#endif
Index: openssl-0.9.8g/apps/s_time.c
===================================================================
--- openssl-0.9.8g.orig/apps/s_time.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/apps/s_time.c	2008-09-24 11:01:01.000000000 +0200
@@ -117,6 +117,8 @@
 
 /* The following if from times(3) man page.  It may need to be changed
 */
+#ifndef OPENSSL_SYS_NEWLIB
+
 #ifndef HZ
 # ifdef _SC_CLK_TCK
 #  define HZ ((double)sysconf(_SC_CLK_TCK))
@@ -732,4 +734,5 @@
 	return serverCon;
 	}
 
+#endif
 
Index: openssl-0.9.8g/bench/dummy_rand.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/bench/dummy_rand.c	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,55 @@
+#include <openssl/rand.h>
+#include <stdlib.h>
+
+static void dummy_rand_cleanup(void);
+static void dummy_rand_seed(const void *buf, int num);
+static void dummy_rand_add(const void *buf, int num, double add_entropy);
+static int dummy_rand_bytes(unsigned char *buf, int num);
+static int dummy_rand_pseudo_bytes(unsigned char *buf, int num);
+static int dummy_rand_status(void);
+
+RAND_METHOD rand_dummy_meth={
+	dummy_rand_seed,
+	dummy_rand_bytes,
+	dummy_rand_cleanup,
+	dummy_rand_add,
+	dummy_rand_pseudo_bytes,
+	dummy_rand_status
+	}; 
+
+RAND_METHOD *RAND_dummy(void)
+{
+  return(&rand_dummy_meth);
+}
+
+static void dummy_rand_cleanup(void)
+{
+}
+
+static void dummy_rand_add(const void *buf, int num, double add)
+{
+}
+
+static void dummy_rand_seed(const void *buf, int num)
+{
+}
+
+static int dummy_rand_bytes(unsigned char *buf, int num)
+{
+  int i;
+  for (i=0; i < num; i++)
+    buf[i] = (unsigned char)rand();
+  return 1;
+}
+
+/* pseudo-random bytes that are guaranteed to be unique but not
+   unpredictable */
+static int dummy_rand_pseudo_bytes(unsigned char *buf, int num) 
+{
+  return dummy_rand_bytes(buf, num);
+}
+
+static int dummy_rand_status(void)
+{
+  return 1;
+}
Index: openssl-0.9.8g/bench/Makefile
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/bench/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,139 @@
+#
+#  bench/Makefile
+#
+
+DIR=		bench
+TOP=		..
+CC=		cc
+INCLUDES=	-I$(TOP) -I../include -I../apps
+CFLAG=		-g -static
+MAKEFILE=	Makefile
+PERL=		perl
+RM=		rm -f
+
+PEX_LIBS=
+EX_LIBS= 
+EXE_EXT= 
+
+SHLIB_TARGET=
+
+CFLAGS= -DMONOLITH $(INCLUDES) $(CFLAG)
+
+GENERAL=Makefile
+
+DLIBCRYPTO=../libcrypto.a
+LIBCRYPTO=-L.. -lcrypto
+
+
+EXE= speed-avr32
+
+E_EXE=	speed-avr32
+
+
+E_OBJ=	speed-avr32.o dummy_rand.o
+
+E_SRC=	speed-avr32.c dummy_rand.c
+
+SRC=$(E_SRC)
+
+HEADER=
+
+ALL=    $(GENERAL) $(SRC) $(HEADER)
+
+top:
+	@(cd ..; $(MAKE) DIRS=$(DIR) all)
+
+all:	exe
+
+exe:	$(EXE)
+
+
+files:
+	$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
+
+install:
+
+tags:
+	ctags $(SRC)
+
+tests:
+
+links:
+
+lint:
+	lint -DLINT $(INCLUDES) $(SRC)>fluff
+
+depend:
+	@if [ -z "$(THIS)" ]; then \
+	    $(MAKE) -f $(TOP)/Makefile reflect THIS=$@; \
+	else \
+	    $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(SRC); \
+	fi
+
+dclean:
+	$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
+	mv -f Makefile.new $(MAKEFILE)
+
+clean:
+	rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE)
+
+
+$(DLIBCRYPTO):
+	(cd ..; $(MAKE) DIRS=crypto all)
+
+$(EXE): $(E_OBJ) $(DLIBCRYPTO) Makefile
+	$(RM) $(EXE)
+	shlib_target=; if [ -n "$(SHARED_LIBS)" ]; then \
+		shlib_target="$(SHLIB_TARGET)"; \
+	fi; \
+	LIBRARIES="$(LIBKRB5) $(LIBCRYPTO)" ; \
+	$(MAKE) -f $(TOP)/Makefile.shared -e \
+		APPNAME=$(EXE) OBJECTS="$(E_OBJ)" \
+		LIBDEPS="$(PEX_LIBS) $$LIBRARIES $(EX_LIBS)" \
+		link_app.$${shlib_target}
+
+
+
+CFLAGS  += -D__FLASH_WS__
+CFLAGS  += -D__SETUP_OSC__
+CFLAGS += -DHZ=66000000
+CFLAGS += -DOPENSSL_NO_MD2 -DOPENSSL_NO_MD4
+CFLAGS += -DOPENSSL_NO_MD5 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_SHA
+CFLAGS += -DOPENSSL_NO_RIPEMD  -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_HMAC
+CFLAGS += -DOPENSSL_NO_SHA -DOPENSSL_NO_RC4 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RC2
+CFLAGS += -DOPENSSL_NO_IDEA -DOPENSSL_NO_SEED -DOPENSSL_NO_BF
+CFLAGS += -DOPENSSL_NO_CAST -DOPENSSL_NO_DSA -DOPENSSL_NO_ECDSA
+CFLAGS += -DOPENSSL_NO_ENGINE -DRSA_NULL
+CFLAGS += -DOPENSSL_NO_ECDH -DOPENSSL_NO_EC
+#CFLAGS += -DOPENSSL_NO_DES
+#CFLAGS += -DOPENSSL_NO_AES
+#CFLAGS += -DOPENSSL_NO_RSA
+
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+dummy_rand.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
+dummy_rand.o: ../include/openssl/ossl_typ.h ../include/openssl/rand.h
+dummy_rand.o: dummy_rand.c
+speed-avr32.o: ../apps/./testdsa.h ../apps/./testrsa.h ../include/openssl/aes.h
+speed-avr32.o: ../include/openssl/asn1.h ../include/openssl/bio.h
+speed-avr32.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
+speed-avr32.o: ../include/openssl/buffer.h ../include/openssl/cast.h
+speed-avr32.o: ../include/openssl/crypto.h ../include/openssl/des.h
+speed-avr32.o: ../include/openssl/des_old.h ../include/openssl/dsa.h
+speed-avr32.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+speed-avr32.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+speed-avr32.o: ../include/openssl/err.h ../include/openssl/evp.h
+speed-avr32.o: ../include/openssl/hmac.h ../include/openssl/idea.h
+speed-avr32.o: ../include/openssl/lhash.h ../include/openssl/md2.h
+speed-avr32.o: ../include/openssl/md4.h ../include/openssl/md5.h
+speed-avr32.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+speed-avr32.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+speed-avr32.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
+speed-avr32.o: ../include/openssl/rand.h ../include/openssl/rc2.h
+speed-avr32.o: ../include/openssl/rc4.h ../include/openssl/ripemd.h
+speed-avr32.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+speed-avr32.o: ../include/openssl/sha.h ../include/openssl/stack.h
+speed-avr32.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
+speed-avr32.o: ../include/openssl/ui_compat.h ../include/openssl/x509.h
+speed-avr32.o: ../include/openssl/x509_vfy.h speed-avr32.c
Index: openssl-0.9.8g/bench/speed-avr32.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/bench/speed-avr32.c	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,2966 @@
+/* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to.  The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    "This product includes cryptographic software written by
+ *     Eric Young (eay@cryptsoft.com)"
+ *    The word 'cryptographic' can be left out if the rouines from the library
+ *    being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ *    the apps directory (application code) you must include an acknowledgement:
+ *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed.  i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * Portions of the attached software ("Contribution") are developed by
+ * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
+ *
+ * The Contribution is licensed pursuant to the OpenSSL open source
+ * license provided above.
+ *
+ * The ECDH and ECDSA speed test software is originally written by
+ * Sumit Gupta of Sun Microsystems Laboratories.
+ *
+ */
+
+/* most of this code has been pilfered from my libdes speed.c program */
+
+
+#undef SECONDS
+#define SECONDS		3
+#define RSA_SECONDS	10
+#define DSA_SECONDS	10
+#define ECDSA_SECONDS   10
+#define ECDH_SECONDS    10
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <math.h>
+//#include "apps.h"
+#define MAIN main
+#ifdef OPENSSL_NO_STDIO
+#define APPS_WIN16
+#endif
+#include <openssl/crypto.h>
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#if !defined(OPENSSL_SYS_MSDOS)
+#include OPENSSL_UNISTD
+#endif
+
+#ifndef OPENSSL_SYS_NETWARE
+#include <signal.h>
+#endif
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
+# define USE_TOD
+#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
+# define TIMES
+#endif
+#if !defined(OPENSSL_SYS_NEWLIB) && !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
+# define TIMEB
+#endif
+
+#if defined(OPENSSL_SYS_NETWARE)
+#undef TIMES
+#undef TIMEB
+#include <time.h>
+#endif
+
+#ifndef _IRIX
+# include <time.h>
+#endif
+#ifdef TIMES
+# include <sys/types.h>
+# include <sys/times.h>
+#endif
+#ifdef USE_TOD
+# include <sys/time.h>
+# include <sys/resource.h>
+#endif
+
+/* Depending on the VMS version, the tms structure is perhaps defined.
+   The __TMS macro will show if it was.  If it wasn't defined, we should
+   undefine TIMES, since that tells the rest of the program how things
+   should be handled.				-- Richard Levitte */
+#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
+#undef TIMES
+#endif
+
+#ifdef TIMEB
+#include <sys/timeb.h>
+#endif
+
+#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE)
+#error "It seems neither struct tms nor struct timeb is supported in this platform!"
+#endif
+
+#if defined(sun) || defined(__ultrix)
+#define _POSIX_SOURCE
+#include <limits.h>
+#include <sys/param.h>
+#endif
+
+#include <openssl/bn.h>
+#ifndef OPENSSL_NO_DES
+#include <openssl/des.h>
+#endif
+#ifndef OPENSSL_NO_AES
+#include <openssl/aes.h>
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+#include <openssl/camellia.h>
+#endif
+#ifndef OPENSSL_NO_MD2
+#include <openssl/md2.h>
+#endif
+#ifndef OPENSSL_NO_MDC2
+#include <openssl/mdc2.h>
+#endif
+#ifndef OPENSSL_NO_MD4
+#include <openssl/md4.h>
+#endif
+#ifndef OPENSSL_NO_MD5
+#include <openssl/md5.h>
+#endif
+#ifndef OPENSSL_NO_HMAC
+#include <openssl/hmac.h>
+#endif
+#include <openssl/evp.h>
+#ifndef OPENSSL_NO_SHA
+#include <openssl/sha.h>
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+#include <openssl/ripemd.h>
+#endif
+#ifndef OPENSSL_NO_RC4
+#include <openssl/rc4.h>
+#endif
+#ifndef OPENSSL_NO_RC5
+#include <openssl/rc5.h>
+#endif
+#ifndef OPENSSL_NO_RC2
+#include <openssl/rc2.h>
+#endif
+#ifndef OPENSSL_NO_IDEA
+#include <openssl/idea.h>
+#endif
+#ifndef OPENSSL_NO_SEED
+#include <openssl/seed.h>
+#endif
+#ifndef OPENSSL_NO_BF
+#include <openssl/blowfish.h>
+#endif
+#ifndef OPENSSL_NO_CAST
+#include <openssl/cast.h>
+#endif
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#include "./testrsa.h"
+#endif
+#include <openssl/x509.h>
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#include "./testdsa.h"
+#endif
+#ifndef OPENSSL_NO_ECDSA
+#include <openssl/ecdsa.h>
+#endif
+#ifndef OPENSSL_NO_ECDH
+#include <openssl/ecdh.h>
+#endif
+
+/*
+ * The following "HZ" timing stuff should be sync'd up with the code in
+ * crypto/tmdiff.[ch]. That appears to try to do the same job, though I think
+ * this code is more up to date than libcrypto's so there may be features to
+ * migrate over first. This is used in two places further down AFAICS.
+ * The point is that nothing in openssl actually *uses* that tmdiff stuff, so
+ * either speed.c should be using it or it should go because it's obviously not
+ * useful enough. Anyone want to do a janitorial job on this?
+ */
+
+/* The following if from times(3) man page.  It may need to be changed */
+
+#undef BIO_flush
+#undef BIO_printf
+#define BIO_flush fflush
+#define BIO_printf fprintf
+#define bio_err stderr
+
+//#define fprintf(...) /* */
+//#define printf(...) /* */
+
+#ifndef HZ
+# if defined(_SC_CLK_TCK) \
+     && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
+#  define HZ sysconf(_SC_CLK_TCK)
+# else
+#  ifndef CLK_TCK
+#   ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
+#    define HZ	100.0
+#   else /* _BSD_CLK_TCK_ */
+#    define HZ ((double)_BSD_CLK_TCK_)
+#   endif
+#  else /* CLK_TCK */
+#   define HZ ((double)CLK_TCK)
+#  endif
+# endif
+#endif
+
+# if !defined(OPENSSL_SYS_NEWLIB) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
+# define HAVE_FORK 1
+#endif
+
+#undef BUFSIZE
+#define BUFSIZE	((long)1024*8+1)
+int run=0;
+
+static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
+static int mr=0;
+static int usertime=1;
+
+static double Time_F(int s);
+static void print_message(const char *s,long num,int length);
+static void pkey_print_message(const char *str, const char *str2,
+	long num, int bits, int sec);
+static void print_result(int alg,int run_no,int count,double time_used);
+#ifdef HAVE_FORK
+static int do_multi(int multi);
+#endif
+
+#define ALGOR_NUM	28
+#define SIZE_NUM	5
+#define RSA_NUM		4
+#define DSA_NUM		3
+
+#define EC_NUM       16
+#define MAX_ECDH_SIZE 256
+
+static const char *names[ALGOR_NUM]={
+  "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4",
+  "des cbc","des ede3","idea cbc","seed cbc",
+  "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc",
+  "aes-128 cbc","aes-192 cbc","aes-256 cbc",
+  "camellia-128 cbc","camellia-192 cbc","camellia-256 cbc",
+  "evp","sha256","sha512",
+  "aes-128 ige","aes-192 ige","aes-256 ige"};
+static double results[ALGOR_NUM][SIZE_NUM];
+static int lengths[SIZE_NUM]={16,64,256,1024,8*1024};
+static double rsa_results[RSA_NUM][2];
+static double dsa_results[DSA_NUM][2];
+#ifndef OPENSSL_NO_ECDSA
+static double ecdsa_results[EC_NUM][2];
+#endif
+#ifndef OPENSSL_NO_ECDH
+static double ecdh_results[EC_NUM][1];
+#endif
+
+#if 1 /*defined(OPENSSL_NO_DSA) && !(defined(OPENSSL_NO_ECDSA) && defined(OPENSSL_NO_ECDH))*/
+static const char rnd_seed[] = "string to make the random number generator think it has entropy";
+static int rnd_fake = 0;
+#endif
+
+#ifdef OPENSSL_SYS_NEWLIB
+#undef SIGALRM
+#endif
+
+#ifdef SIGALRM
+#if defined(__STDC__) || defined(sgi) || defined(_AIX)
+#define SIGRETTYPE void
+#else
+#define SIGRETTYPE int
+#endif
+
+static SIGRETTYPE sig_done(int sig);
+static SIGRETTYPE sig_done(int sig)
+	{
+	signal(SIGALRM,sig_done);
+	run=0;
+#ifdef LINT
+	sig=sig;
+#endif
+	}
+#endif
+
+#define START	0
+#define STOP	1
+
+#if defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_NEWLIB)
+
+   /* for NetWare the best we can do is use clock() which returns the
+    * time, in hundredths of a second, since the NLM began executing
+   */
+static double Time_F(int s)
+	{
+	double ret;
+
+   static clock_t tstart,tend;
+
+   if (s == START)
+   {
+      tstart=clock();
+      return(0);
+   }
+   else
+   {
+      tend=clock();
+      ret=(double)((double)(tend)-(double)(tstart))/(double)HZ;
+      return((ret < 0.001)?0.001:ret);
+   }
+   }
+
+#else
+
+static double Time_F(int s)
+	{
+	double ret;
+
+#ifdef USE_TOD
+	if(usertime)
+		{
+		static struct rusage tstart,tend;
+
+		getrusage_used = 1;
+		if (s == START)
+			{
+			getrusage(RUSAGE_SELF,&tstart);
+			return(0);
+			}
+		else
+			{
+			long i;
+
+			getrusage(RUSAGE_SELF,&tend);
+			i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
+			ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
+			  +((double)i)/1000000.0;
+			return((ret < 0.001)?0.001:ret);
+			}
+		}
+	else
+		{
+		static struct timeval tstart,tend;
+		long i;
+
+		gettimeofday_used = 1;
+		if (s == START)
+			{
+			gettimeofday(&tstart,NULL);
+			return(0);
+			}
+		else
+			{
+			gettimeofday(&tend,NULL);
+			i=(long)tend.tv_usec-(long)tstart.tv_usec;
+			ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
+			return((ret < 0.001)?0.001:ret);
+			}
+		}
+#else  /* ndef USE_TOD */
+
+# ifdef TIMES
+	if (usertime)
+		{
+		static struct tms tstart,tend;
+
+		times_used = 1;
+		if (s == START)
+			{
+			times(&tstart);
+			return(0);
+			}
+		else
+			{
+			times(&tend);
+			ret = HZ;
+			ret=(double)(tend.tms_utime-tstart.tms_utime) / ret;
+			return((ret < 1e-3)?1e-3:ret);
+			}
+		}
+# endif /* times() */
+# if defined(TIMES) && defined(TIMEB)
+	else
+# endif
+# ifdef OPENSSL_SYS_VXWORKS
+                {
+		static unsigned long tick_start, tick_end;
+
+		if( s == START )
+			{
+			tick_start = tickGet();
+			return 0;
+			}
+		else
+			{
+			tick_end = tickGet();
+			ret = (double)(tick_end - tick_start) / (double)sysClkRateGet();
+			return((ret < 0.001)?0.001:ret);
+			}
+                }
+# elif defined(TIMEB)
+		{
+		static struct timeb tstart,tend;
+		long i;
+
+		ftime_used = 1;
+		if (s == START)
+			{
+			ftime(&tstart);
+			return(0);
+			}
+		else
+			{
+			ftime(&tend);
+			i=(long)tend.millitm-(long)tstart.millitm;
+			ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
+			return((ret < 0.001)?0.001:ret);
+			}
+		}
+# endif
+#endif
+	}
+#endif /* if defined(OPENSSL_SYS_NETWARE) */
+
+
+#ifndef OPENSSL_NO_ECDH
+static const int KDF1_SHA1_len = 20;
+static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
+	{
+#ifndef OPENSSL_NO_SHA
+	if (*outlen < SHA_DIGEST_LENGTH)
+		return NULL;
+	else
+		*outlen = SHA_DIGEST_LENGTH;
+	return SHA1(in, inlen, out);
+#else
+	return NULL;
+#endif	/* OPENSSL_NO_SHA */
+	}
+#endif	/* OPENSSL_NO_ECDH */
+
+extern RAND_METHOD rand_dummy_meth;
+
+int MAIN(int, char **);
+
+int MAIN(int argc, char **argv)
+	{
+#ifndef OPENSSL_NO_ENGINE
+	ENGINE *e = NULL;
+#endif
+	unsigned char *buf=NULL,*buf2=NULL;
+	int mret=1;
+	long count=5000,save_count=0;
+	int i,j,k;
+#if !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_DSA)
+	long rsa_count;
+#endif
+#ifndef OPENSSL_NO_RSA
+	unsigned rsa_num;
+#endif
+	unsigned char md[EVP_MAX_MD_SIZE];
+#ifndef OPENSSL_NO_MD2
+	unsigned char md2[MD2_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_MDC2
+	unsigned char mdc2[MDC2_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_MD4
+	unsigned char md4[MD4_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_MD5
+	unsigned char md5[MD5_DIGEST_LENGTH];
+	unsigned char hmac[MD5_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_SHA
+	unsigned char sha[SHA_DIGEST_LENGTH];
+#ifndef OPENSSL_NO_SHA256
+	unsigned char sha256[SHA256_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_SHA512
+	unsigned char sha512[SHA512_DIGEST_LENGTH];
+#endif
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+	unsigned char rmd160[RIPEMD160_DIGEST_LENGTH];
+#endif
+#ifndef OPENSSL_NO_RC4
+	RC4_KEY rc4_ks;
+#endif
+#ifndef OPENSSL_NO_RC5
+	RC5_32_KEY rc5_ks;
+#endif
+#ifndef OPENSSL_NO_RC2
+	RC2_KEY rc2_ks;
+#endif
+#ifndef OPENSSL_NO_IDEA
+	IDEA_KEY_SCHEDULE idea_ks;
+#endif
+#ifndef OPENSSL_NO_SEED
+	SEED_KEY_SCHEDULE seed_ks;
+#endif
+#ifndef OPENSSL_NO_BF
+	BF_KEY bf_ks;
+#endif
+#ifndef OPENSSL_NO_CAST
+	CAST_KEY cast_ks;
+#endif
+	static const unsigned char key16[16]=
+		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
+#ifndef OPENSSL_NO_AES
+	static const unsigned char key24[24]=
+		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
+		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
+	static const unsigned char key32[32]=
+		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
+		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
+		 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+	static const unsigned char ckey24[24]=
+		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
+		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
+	static const unsigned char ckey32[32]=
+		{0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
+		 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,
+		 0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,
+		 0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56};
+#endif
+#ifndef OPENSSL_NO_AES
+#define MAX_BLOCK_SIZE 128
+#else
+#define MAX_BLOCK_SIZE 64
+#endif
+	unsigned char DES_iv[8];
+	unsigned char iv[MAX_BLOCK_SIZE/8];
+#ifndef OPENSSL_NO_DES
+	DES_cblock *buf_as_des_cblock = NULL;
+	static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
+	static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
+	static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
+	DES_key_schedule sch;
+	DES_key_schedule sch2;
+	DES_key_schedule sch3;
+#endif
+#ifndef OPENSSL_NO_AES
+	AES_KEY aes_ks1, aes_ks2, aes_ks3;
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+	CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3;
+#endif
+#define	D_MD2		0
+#define	D_MDC2		1
+#define	D_MD4		2
+#define	D_MD5		3
+#define	D_HMAC		4
+#define	D_SHA1		5
+#define D_RMD160	6
+#define	D_RC4		7
+#define	D_CBC_DES	8
+#define	D_EDE3_DES	9
+#define	D_CBC_IDEA	10
+#define	D_CBC_SEED	11
+#define	D_CBC_RC2	12
+#define	D_CBC_RC5	13
+#define	D_CBC_BF	14
+#define	D_CBC_CAST	15
+#define D_CBC_128_AES	16
+#define D_CBC_192_AES	17
+#define D_CBC_256_AES	18
+#define D_CBC_128_CML   19
+#define D_CBC_192_CML   20
+#define D_CBC_256_CML   21
+#define D_EVP		22
+#define D_SHA256	23
+#define D_SHA512	24
+#define D_IGE_128_AES   25
+#define D_IGE_192_AES   26
+#define D_IGE_256_AES   27
+	double d=0.0;
+	long c[ALGOR_NUM][SIZE_NUM];
+#define	R_DSA_512	0
+#define	R_DSA_1024	1
+#define	R_DSA_2048	2
+#define	R_RSA_512	0
+#define	R_RSA_1024	1
+#define	R_RSA_2048	2
+#define	R_RSA_4096	3
+
+#define R_EC_P160    0
+#define R_EC_P192    1
+#define R_EC_P224    2
+#define R_EC_P256    3
+#define R_EC_P384    4
+#define R_EC_P521    5
+#define R_EC_K163    6
+#define R_EC_K233    7
+#define R_EC_K283    8
+#define R_EC_K409    9
+#define R_EC_K571    10
+#define R_EC_B163    11
+#define R_EC_B233    12
+#define R_EC_B283    13
+#define R_EC_B409    14
+#define R_EC_B571    15
+
+#ifndef OPENSSL_NO_RSA
+	RSA *rsa_key[RSA_NUM];
+	long rsa_c[RSA_NUM][2];
+	static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096};
+	static unsigned char *rsa_data[RSA_NUM] =
+            {test512,test1024,test2048,0/*test4096*/};
+	static int rsa_data_length[RSA_NUM]={
+		sizeof(test512),sizeof(test1024),
+		sizeof(test2048),sizeof(test4096)};
+#endif
+#ifndef OPENSSL_NO_DSA
+	DSA *dsa_key[DSA_NUM];
+	long dsa_c[DSA_NUM][2];
+	static unsigned int dsa_bits[DSA_NUM]={512,1024,2048};
+#endif
+#ifndef OPENSSL_NO_EC
+	/* We only test over the following curves as they are representative,
+	 * To add tests over more curves, simply add the curve NID
+	 * and curve name to the following arrays and increase the
+	 * EC_NUM value accordingly.
+	 */
+	static unsigned int test_curves[EC_NUM] =
+	{
+	/* Prime Curves */
+	NID_secp160r1,
+	NID_X9_62_prime192v1,
+	NID_secp224r1,
+	NID_X9_62_prime256v1,
+	NID_secp384r1,
+	NID_secp521r1,
+	/* Binary Curves */
+	NID_sect163k1,
+	NID_sect233k1,
+	NID_sect283k1,
+	NID_sect409k1,
+	NID_sect571k1,
+	NID_sect163r2,
+	NID_sect233r1,
+	NID_sect283r1,
+	NID_sect409r1,
+	NID_sect571r1
+	};
+	static const char * test_curves_names[EC_NUM] =
+	{
+	/* Prime Curves */
+	"secp160r1",
+	"nistp192",
+	"nistp224",
+	"nistp256",
+	"nistp384",
+	"nistp521",
+	/* Binary Curves */
+	"nistk163",
+	"nistk233",
+	"nistk283",
+	"nistk409",
+	"nistk571",
+	"nistb163",
+	"nistb233",
+	"nistb283",
+	"nistb409",
+	"nistb571"
+	};
+	static int test_curves_bits[EC_NUM] =
+        {
+        160, 192, 224, 256, 384, 521,
+        163, 233, 283, 409, 571,
+        163, 233, 283, 409, 571
+        };
+
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+	unsigned char ecdsasig[256];
+	unsigned int ecdsasiglen;
+	EC_KEY *ecdsa[EC_NUM];
+	long ecdsa_c[EC_NUM][2];
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+	EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM];
+	unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE];
+	int secret_size_a, secret_size_b;
+	int ecdh_checks = 0;
+	int secret_idx = 0;
+	long ecdh_c[EC_NUM][2];
+#endif
+
+	int rsa_doit[RSA_NUM];
+	int dsa_doit[DSA_NUM];
+#ifndef OPENSSL_NO_ECDSA
+	int ecdsa_doit[EC_NUM];
+#endif
+#ifndef OPENSSL_NO_ECDH
+        int ecdh_doit[EC_NUM];
+#endif
+	int doit[ALGOR_NUM];
+	int pr_header=0;
+	const EVP_CIPHER *evp_cipher=NULL;
+	const EVP_MD *evp_md=NULL;
+	int decrypt=0;
+#ifdef HAVE_FORK
+	int multi=0;
+#endif
+
+#ifndef TIMES
+	usertime=-1;
+#endif
+
+	//apps_startup();
+	memset(results, 0, sizeof(results));
+#ifndef OPENSSL_NO_DSA
+	memset(dsa_key,0,sizeof(dsa_key));
+#endif
+#ifndef OPENSSL_NO_ECDSA
+	for (i=0; i<EC_NUM; i++) ecdsa[i] = NULL;
+#endif
+#ifndef OPENSSL_NO_ECDH
+	for (i=0; i<EC_NUM; i++)
+		{
+		ecdh_a[i] = NULL;
+		ecdh_b[i] = NULL;
+		}
+#endif
+
+
+	//if (bio_err == NULL)
+	//	if ((bio_err=BIO_new(BIO_s_file())) != NULL)
+	//		BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
+
+	//if (!load_config(bio_err, NULL))
+	//	goto end;
+
+#ifndef OPENSSL_NO_RSA
+	memset(rsa_key,0,sizeof(rsa_key));
+	for (i=0; i<RSA_NUM; i++)
+		rsa_key[i]=NULL;
+#endif
+
+
+	if ((buf=(unsigned char *)/*OPENSSL_*/malloc((int)BUFSIZE)) == NULL)
+		{
+                    fprintf(stderr, "out of memory");
+                    //BIO_printf(bio_err,"out of memory\n");
+                    goto end;
+		}
+#ifndef OPENSSL_NO_DES
+	buf_as_des_cblock = (DES_cblock *)buf;
+#endif
+	if ((buf2=(unsigned char *)/*OPENSSL_*/malloc((int)BUFSIZE)) == NULL)
+		{
+                    fprintf(stderr, "out of memory");
+                    //BIO_printf(bio_err,"out of memory\n");
+                    goto end;
+		}
+
+	memset(c,0,sizeof(c));
+	memset(DES_iv,0,sizeof(DES_iv));
+	memset(iv,0,sizeof(iv));
+
+	for (i=0; i<ALGOR_NUM; i++)
+		doit[i]=0;
+	for (i=0; i<RSA_NUM; i++)
+		rsa_doit[i]=0;
+	for (i=0; i<DSA_NUM; i++)
+		dsa_doit[i]=0;
+#ifndef OPENSSL_NO_ECDSA
+	for (i=0; i<EC_NUM; i++)
+		ecdsa_doit[i]=0;
+#endif
+#ifndef OPENSSL_NO_ECDH
+	for (i=0; i<EC_NUM; i++)
+		ecdh_doit[i]=0;
+#endif
+
+
+	j=0;
+	argc--;
+	argv++;
+	while (argc)
+		{
+		if	((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
+			{
+			usertime = 0;
+			j--;	/* Otherwise, -elapsed gets confused with
+				   an algorithm. */
+			}
+		else /*if	((argc > 0) && (strcmp(*argv,"-evp") == 0))
+			{
+			argc--;
+			argv++;
+			if(argc == 0)
+				{
+				BIO_printf(bio_err,"no EVP given\n");
+				goto end;
+				}
+			evp_cipher=EVP_get_cipherbyname(*argv);
+			if(!evp_cipher)
+				{
+				evp_md=EVP_get_digestbyname(*argv);
+				}
+			if(!evp_cipher && !evp_md)
+				{
+				BIO_printf(bio_err,"%s is an unknown cipher or digest\n",*argv);
+				goto end;
+				}
+			doit[D_EVP]=1;
+			}
+                        else */if (argc > 0 && !strcmp(*argv,"-decrypt"))
+			{
+			decrypt=1;
+			j--;	/* Otherwise, -elapsed gets confused with
+				   an algorithm. */
+			}
+#ifndef OPENSSL_NO_ENGINE
+		else if	((argc > 0) && (strcmp(*argv,"-engine") == 0))
+			{
+			argc--;
+			argv++;
+			if(argc == 0)
+				{
+				BIO_printf(bio_err,"no engine given\n");
+				goto end;
+				}
+                        e = setup_engine(bio_err, *argv, 0);
+			/* j will be increased again further down.  We just
+			   don't want speed to confuse an engine with an
+			   algorithm, especially when none is given (which
+			   means all of them should be run) */
+			j--;
+			}
+#endif
+#ifdef HAVE_FORK
+		else if	((argc > 0) && (strcmp(*argv,"-multi") == 0))
+			{
+			argc--;
+			argv++;
+			if(argc == 0)
+				{
+				BIO_printf(bio_err,"no multi count given\n");
+				goto end;
+				}
+			multi=atoi(argv[0]);
+			if(multi <= 0)
+			    {
+				BIO_printf(bio_err,"bad multi count\n");
+				goto end;
+				}
+			j--;	/* Otherwise, -mr gets confused with
+				   an algorithm. */
+			}
+#endif
+		else if (argc > 0 && !strcmp(*argv,"-mr"))
+			{
+			mr=1;
+			j--;	/* Otherwise, -mr gets confused with
+				   an algorithm. */
+			}
+		else
+#ifndef OPENSSL_NO_MD2
+		if	(strcmp(*argv,"md2") == 0) doit[D_MD2]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_MDC2
+			if (strcmp(*argv,"mdc2") == 0) doit[D_MDC2]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_MD4
+			if (strcmp(*argv,"md4") == 0) doit[D_MD4]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_MD5
+			if (strcmp(*argv,"md5") == 0) doit[D_MD5]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_MD5
+			if (strcmp(*argv,"hmac") == 0) doit[D_HMAC]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_SHA
+			if (strcmp(*argv,"sha1") == 0) doit[D_SHA1]=1;
+		else
+			if (strcmp(*argv,"sha") == 0)	doit[D_SHA1]=1,
+							doit[D_SHA256]=1,
+							doit[D_SHA512]=1;
+		else
+#ifndef OPENSSL_NO_SHA256
+			if (strcmp(*argv,"sha256") == 0) doit[D_SHA256]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_SHA512
+			if (strcmp(*argv,"sha512") == 0) doit[D_SHA512]=1;
+		else
+#endif
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+			if (strcmp(*argv,"ripemd") == 0) doit[D_RMD160]=1;
+		else
+			if (strcmp(*argv,"rmd160") == 0) doit[D_RMD160]=1;
+		else
+			if (strcmp(*argv,"ripemd160") == 0) doit[D_RMD160]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_RC4
+			if (strcmp(*argv,"rc4") == 0) doit[D_RC4]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_DES
+			if (strcmp(*argv,"des-cbc") == 0) doit[D_CBC_DES]=1;
+		else	if (strcmp(*argv,"des-ede3") == 0) doit[D_EDE3_DES]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_AES
+			if (strcmp(*argv,"aes-128-cbc") == 0) doit[D_CBC_128_AES]=1;
+		else	if (strcmp(*argv,"aes-192-cbc") == 0) doit[D_CBC_192_AES]=1;
+		else	if (strcmp(*argv,"aes-256-cbc") == 0) doit[D_CBC_256_AES]=1;
+		else    if (strcmp(*argv,"aes-128-ige") == 0) doit[D_IGE_128_AES]=1;
+		else	if (strcmp(*argv,"aes-192-ige") == 0) doit[D_IGE_192_AES]=1;
+		else	if (strcmp(*argv,"aes-256-ige") == 0) doit[D_IGE_256_AES]=1;
+                else
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+			if (strcmp(*argv,"camellia-128-cbc") == 0) doit[D_CBC_128_CML]=1;
+		else    if (strcmp(*argv,"camellia-192-cbc") == 0) doit[D_CBC_192_CML]=1;
+		else    if (strcmp(*argv,"camellia-256-cbc") == 0) doit[D_CBC_256_CML]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_RSA
+#if 0 /* was: #ifdef RSAref */
+			if (strcmp(*argv,"rsaref") == 0)
+			{
+			RSA_set_default_openssl_method(RSA_PKCS1_RSAref());
+			j--;
+			}
+		else
+#endif
+#ifndef RSA_NULL
+			if (strcmp(*argv,"openssl") == 0)
+			{
+			RSA_set_default_method(RSA_PKCS1_SSLeay());
+			j--;
+			}
+		else
+#endif
+#endif /* !OPENSSL_NO_RSA */
+		     if (strcmp(*argv,"dsa512") == 0) dsa_doit[R_DSA_512]=2;
+		else if (strcmp(*argv,"dsa1024") == 0) dsa_doit[R_DSA_1024]=2;
+		else if (strcmp(*argv,"dsa2048") == 0) dsa_doit[R_DSA_2048]=2;
+		else if (strcmp(*argv,"rsa512") == 0) rsa_doit[R_RSA_512]=2;
+		else if (strcmp(*argv,"rsa1024") == 0) rsa_doit[R_RSA_1024]=2;
+		else if (strcmp(*argv,"rsa2048") == 0) rsa_doit[R_RSA_2048]=2;
+		else if (strcmp(*argv,"rsa4096") == 0) rsa_doit[R_RSA_4096]=2;
+		else
+#ifndef OPENSSL_NO_RC2
+		     if (strcmp(*argv,"rc2-cbc") == 0) doit[D_CBC_RC2]=1;
+		else if (strcmp(*argv,"rc2") == 0) doit[D_CBC_RC2]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_RC5
+		     if (strcmp(*argv,"rc5-cbc") == 0) doit[D_CBC_RC5]=1;
+		else if (strcmp(*argv,"rc5") == 0) doit[D_CBC_RC5]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_IDEA
+		     if (strcmp(*argv,"idea-cbc") == 0) doit[D_CBC_IDEA]=1;
+		else if (strcmp(*argv,"idea") == 0) doit[D_CBC_IDEA]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_SEED
+		     if (strcmp(*argv,"seed-cbc") == 0) doit[D_CBC_SEED]=1;
+		else if (strcmp(*argv,"seed") == 0) doit[D_CBC_SEED]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_BF
+		     if (strcmp(*argv,"bf-cbc") == 0) doit[D_CBC_BF]=1;
+		else if (strcmp(*argv,"blowfish") == 0) doit[D_CBC_BF]=1;
+		else if (strcmp(*argv,"bf") == 0) doit[D_CBC_BF]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_CAST
+		     if (strcmp(*argv,"cast-cbc") == 0) doit[D_CBC_CAST]=1;
+		else if (strcmp(*argv,"cast") == 0) doit[D_CBC_CAST]=1;
+		else if (strcmp(*argv,"cast5") == 0) doit[D_CBC_CAST]=1;
+		else
+#endif
+#ifndef OPENSSL_NO_DES
+			if (strcmp(*argv,"des") == 0)
+			{
+			doit[D_CBC_DES]=1;
+			doit[D_EDE3_DES]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_AES
+			if (strcmp(*argv,"aes") == 0)
+			{
+			doit[D_CBC_128_AES]=1;
+			doit[D_CBC_192_AES]=1;
+			doit[D_CBC_256_AES]=1;
+			doit[D_IGE_128_AES]=1;
+			doit[D_IGE_192_AES]=1;
+			doit[D_IGE_256_AES]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+			if (strcmp(*argv,"camellia") == 0)
+			{
+			doit[D_CBC_128_CML]=1;
+			doit[D_CBC_192_CML]=1;
+			doit[D_CBC_256_CML]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_RSA
+			if (strcmp(*argv,"rsa") == 0)
+			{
+			rsa_doit[R_RSA_512]=1;
+			rsa_doit[R_RSA_1024]=1;
+			rsa_doit[R_RSA_2048]=1;
+			rsa_doit[R_RSA_4096]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_DSA
+			if (strcmp(*argv,"dsa") == 0)
+			{
+			dsa_doit[R_DSA_512]=1;
+			dsa_doit[R_DSA_1024]=1;
+			dsa_doit[R_DSA_2048]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_ECDSA
+		     if (strcmp(*argv,"ecdsap160") == 0) ecdsa_doit[R_EC_P160]=2;
+		else if (strcmp(*argv,"ecdsap192") == 0) ecdsa_doit[R_EC_P192]=2;
+		else if (strcmp(*argv,"ecdsap224") == 0) ecdsa_doit[R_EC_P224]=2;
+		else if (strcmp(*argv,"ecdsap256") == 0) ecdsa_doit[R_EC_P256]=2;
+		else if (strcmp(*argv,"ecdsap384") == 0) ecdsa_doit[R_EC_P384]=2;
+		else if (strcmp(*argv,"ecdsap521") == 0) ecdsa_doit[R_EC_P521]=2;
+		else if (strcmp(*argv,"ecdsak163") == 0) ecdsa_doit[R_EC_K163]=2;
+		else if (strcmp(*argv,"ecdsak233") == 0) ecdsa_doit[R_EC_K233]=2;
+		else if (strcmp(*argv,"ecdsak283") == 0) ecdsa_doit[R_EC_K283]=2;
+		else if (strcmp(*argv,"ecdsak409") == 0) ecdsa_doit[R_EC_K409]=2;
+		else if (strcmp(*argv,"ecdsak571") == 0) ecdsa_doit[R_EC_K571]=2;
+		else if (strcmp(*argv,"ecdsab163") == 0) ecdsa_doit[R_EC_B163]=2;
+		else if (strcmp(*argv,"ecdsab233") == 0) ecdsa_doit[R_EC_B233]=2;
+		else if (strcmp(*argv,"ecdsab283") == 0) ecdsa_doit[R_EC_B283]=2;
+		else if (strcmp(*argv,"ecdsab409") == 0) ecdsa_doit[R_EC_B409]=2;
+		else if (strcmp(*argv,"ecdsab571") == 0) ecdsa_doit[R_EC_B571]=2;
+		else if (strcmp(*argv,"ecdsa") == 0)
+			{
+			for (i=0; i < EC_NUM; i++)
+				ecdsa_doit[i]=1;
+			}
+		else
+#endif
+#ifndef OPENSSL_NO_ECDH
+		     if (strcmp(*argv,"ecdhp160") == 0) ecdh_doit[R_EC_P160]=2;
+		else if (strcmp(*argv,"ecdhp192") == 0) ecdh_doit[R_EC_P192]=2;
+		else if (strcmp(*argv,"ecdhp224") == 0) ecdh_doit[R_EC_P224]=2;
+		else if (strcmp(*argv,"ecdhp256") == 0) ecdh_doit[R_EC_P256]=2;
+		else if (strcmp(*argv,"ecdhp384") == 0) ecdh_doit[R_EC_P384]=2;
+		else if (strcmp(*argv,"ecdhp521") == 0) ecdh_doit[R_EC_P521]=2;
+		else if (strcmp(*argv,"ecdhk163") == 0) ecdh_doit[R_EC_K163]=2;
+		else if (strcmp(*argv,"ecdhk233") == 0) ecdh_doit[R_EC_K233]=2;
+		else if (strcmp(*argv,"ecdhk283") == 0) ecdh_doit[R_EC_K283]=2;
+		else if (strcmp(*argv,"ecdhk409") == 0) ecdh_doit[R_EC_K409]=2;
+		else if (strcmp(*argv,"ecdhk571") == 0) ecdh_doit[R_EC_K571]=2;
+		else if (strcmp(*argv,"ecdhb163") == 0) ecdh_doit[R_EC_B163]=2;
+		else if (strcmp(*argv,"ecdhb233") == 0) ecdh_doit[R_EC_B233]=2;
+		else if (strcmp(*argv,"ecdhb283") == 0) ecdh_doit[R_EC_B283]=2;
+		else if (strcmp(*argv,"ecdhb409") == 0) ecdh_doit[R_EC_B409]=2;
+		else if (strcmp(*argv,"ecdhb571") == 0) ecdh_doit[R_EC_B571]=2;
+		else if (strcmp(*argv,"ecdh") == 0)
+			{
+			for (i=0; i < EC_NUM; i++)
+				ecdh_doit[i]=1;
+			}
+		else
+#endif
+			{
+                        BIO_printf(bio_err,"Error: bad option or value\n");
+			BIO_printf(bio_err,"\n");
+			BIO_printf(bio_err,"Available values:\n");
+#ifndef OPENSSL_NO_MD2
+			BIO_printf(bio_err,"md2      ");
+#endif
+#ifndef OPENSSL_NO_MDC2
+			BIO_printf(bio_err,"mdc2     ");
+#endif
+#ifndef OPENSSL_NO_MD4
+			BIO_printf(bio_err,"md4      ");
+#endif
+#ifndef OPENSSL_NO_MD5
+			BIO_printf(bio_err,"md5      ");
+#ifndef OPENSSL_NO_HMAC
+			BIO_printf(bio_err,"hmac     ");
+#endif
+#endif
+#ifndef OPENSSL_NO_SHA1
+			BIO_printf(bio_err,"sha1     ");
+#endif
+#ifndef OPENSSL_NO_SHA256
+			BIO_printf(bio_err,"sha256   ");
+#endif
+#ifndef OPENSSL_NO_SHA512
+			BIO_printf(bio_err,"sha512   ");
+#endif
+#ifndef OPENSSL_NO_RIPEMD160
+			BIO_printf(bio_err,"rmd160");
+#endif
+#if !defined(OPENSSL_NO_MD2) || !defined(OPENSSL_NO_MDC2) || \
+    !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \
+    !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160)
+			BIO_printf(bio_err,"\n");
+#endif
+
+#ifndef OPENSSL_NO_IDEA
+			BIO_printf(bio_err,"idea-cbc ");
+#endif
+#ifndef OPENSSL_NO_SEED
+			BIO_printf(bio_err,"seed-cbc ");
+#endif
+#ifndef OPENSSL_NO_RC2
+			BIO_printf(bio_err,"rc2-cbc  ");
+#endif
+#ifndef OPENSSL_NO_RC5
+			BIO_printf(bio_err,"rc5-cbc  ");
+#endif
+#ifndef OPENSSL_NO_BF
+			BIO_printf(bio_err,"bf-cbc");
+#endif
+#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \
+    !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5)
+			BIO_printf(bio_err,"\n");
+#endif
+#ifndef OPENSSL_NO_DES
+			BIO_printf(bio_err,"des-cbc  des-ede3 ");
+#endif
+#ifndef OPENSSL_NO_AES
+			BIO_printf(bio_err,"aes-128-cbc aes-192-cbc aes-256-cbc ");
+			BIO_printf(bio_err,"aes-128-ige aes-192-ige aes-256-ige ");
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+			BIO_printf(bio_err,"\n");
+			BIO_printf(bio_err,"camellia-128-cbc camellia-192-cbc camellia-256-cbc ");
+#endif
+#ifndef OPENSSL_NO_RC4
+			BIO_printf(bio_err,"rc4");
+#endif
+			BIO_printf(bio_err,"\n");
+
+#ifndef OPENSSL_NO_RSA
+			BIO_printf(bio_err,"rsa512   rsa1024  rsa2048  rsa4096\n");
+#endif
+
+#ifndef OPENSSL_NO_DSA
+			BIO_printf(bio_err,"dsa512   dsa1024  dsa2048\n");
+#endif
+#ifndef OPENSSL_NO_ECDSA
+			BIO_printf(bio_err,"ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n");
+			BIO_printf(bio_err,"ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n");
+			BIO_printf(bio_err,"ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n");
+			BIO_printf(bio_err,"ecdsa\n");
+#endif
+#ifndef OPENSSL_NO_ECDH
+			BIO_printf(bio_err,"ecdhp160  ecdhp192  ecdhp224  ecdhp256  ecdhp384  ecdhp521\n");
+			BIO_printf(bio_err,"ecdhk163  ecdhk233  ecdhk283  ecdhk409  ecdhk571\n");
+			BIO_printf(bio_err,"ecdhb163  ecdhb233  ecdhb283  ecdhb409  ecdhb571\n");
+			BIO_printf(bio_err,"ecdh\n");
+#endif
+
+#ifndef OPENSSL_NO_IDEA
+			BIO_printf(bio_err,"idea     ");
+#endif
+#ifndef OPENSSL_NO_SEED
+			BIO_printf(bio_err,"seed     ");
+#endif
+#ifndef OPENSSL_NO_RC2
+			BIO_printf(bio_err,"rc2      ");
+#endif
+#ifndef OPENSSL_NO_DES
+			BIO_printf(bio_err,"des      ");
+#endif
+#ifndef OPENSSL_NO_AES
+			BIO_printf(bio_err,"aes      ");
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+			BIO_printf(bio_err,"camellia ");
+#endif
+#ifndef OPENSSL_NO_RSA
+			BIO_printf(bio_err,"rsa      ");
+#endif
+#ifndef OPENSSL_NO_BF
+			BIO_printf(bio_err,"blowfish");
+#endif
+#if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || \
+    !defined(OPENSSL_NO_RC2) || !defined(OPENSSL_NO_DES) || \
+    !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_BF) || \
+    !defined(OPENSSL_NO_AES) || !defined(OPENSSL_NO_CAMELLIA)
+			BIO_printf(bio_err,"\n");
+#endif
+
+			BIO_printf(bio_err,"\n");
+			BIO_printf(bio_err,"Available options:\n");
+#if defined(TIMES) || defined(USE_TOD)
+			BIO_printf(bio_err,"-elapsed        measure time in real time instead of CPU user time.\n");
+#endif
+#ifndef OPENSSL_NO_ENGINE
+			BIO_printf(bio_err,"-engine e       use engine e, possibly a hardware device.\n");
+#endif
+			BIO_printf(bio_err,"-evp e          use EVP e.\n");
+			BIO_printf(bio_err,"-decrypt        time decryption instead of encryption (only EVP).\n");
+			BIO_printf(bio_err,"-mr             produce machine readable output.\n");
+#ifdef HAVE_FORK
+			BIO_printf(bio_err,"-multi n        run n benchmarks in parallel.\n");
+#endif
+			goto end;
+			}
+		argc--;
+		argv++;
+		j++;
+		}
+
+#ifdef HAVE_FORK
+	if(multi && do_multi(multi))
+		goto show_res;
+#endif
+
+	if (j == 0)
+		{
+		for (i=0; i<ALGOR_NUM; i++)
+			{
+			if (i != D_EVP)
+				doit[i]=1;
+			}
+		for (i=0; i<RSA_NUM; i++)
+			rsa_doit[i]=1;
+		for (i=0; i<DSA_NUM; i++)
+			dsa_doit[i]=1;
+		}
+	for (i=0; i<ALGOR_NUM; i++)
+		if (doit[i]) pr_header++;
+
+	if (usertime == 0 && !mr)
+                BIO_printf(bio_err,"You have chosen to measure elapsed time instead of user CPU time.\n");
+	if (usertime <= 0 && !mr)
+		{
+		BIO_printf(bio_err,"To get the most accurate results, try to run this\n");
+		BIO_printf(bio_err,"program when this computer is idle.\n");
+		}
+
+
+#ifndef OPENSSL_NO_DSA
+	dsa_key[0]=get_dsa512();
+	dsa_key[1]=get_dsa1024();
+	dsa_key[2]=get_dsa2048();
+#endif
+
+#ifndef OPENSSL_NO_DES
+	DES_set_key_unchecked(&key,&sch);
+	DES_set_key_unchecked(&key2,&sch2);
+	DES_set_key_unchecked(&key3,&sch3);
+#endif
+#ifndef OPENSSL_NO_AES
+	AES_set_encrypt_key(key16,128,&aes_ks1);
+	AES_set_encrypt_key(key24,192,&aes_ks2);
+	AES_set_encrypt_key(key32,256,&aes_ks3);
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+	Camellia_set_key(key16,128,&camellia_ks1);
+	Camellia_set_key(ckey24,192,&camellia_ks2);
+	Camellia_set_key(ckey32,256,&camellia_ks3);
+#endif
+#ifndef OPENSSL_NO_IDEA
+	idea_set_encrypt_key(key16,&idea_ks);
+#endif
+#ifndef OPENSSL_NO_SEED
+	SEED_set_key(key16,&seed_ks);
+#endif
+#ifndef OPENSSL_NO_RC4
+	RC4_set_key(&rc4_ks,16,key16);
+#endif
+#ifndef OPENSSL_NO_RC2
+	RC2_set_key(&rc2_ks,16,key16,128);
+#endif
+#ifndef OPENSSL_NO_RC5
+	RC5_32_set_key(&rc5_ks,16,key16,12);
+#endif
+#ifndef OPENSSL_NO_BF
+	BF_set_key(&bf_ks,16,key16);
+#endif
+#ifndef OPENSSL_NO_CAST
+	CAST_set_key(&cast_ks,16,key16);
+#endif
+#ifndef OPENSSL_NO_RSA
+	memset(rsa_c,0,sizeof(rsa_c));
+#endif
+#ifndef SIGALRM
+//#ifndef OPENSSL_NO_DES
+//	BIO_printf(bio_err,"First we calculate the approximate speed ...\n");
+//	count=10;
+//	do	{
+//		long it;
+//		count*=2;
+//		Time_F(START);
+//		for (it=count; it; it--)
+//			DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
+//				&sch,DES_ENCRYPT);
+//		d=Time_F(STOP);
+//		} while (d <3);
+	save_count=count;
+	c[D_MD2][0]=count/10;
+	c[D_MDC2][0]=count/10;
+	c[D_MD4][0]=count;
+	c[D_MD5][0]=count;
+	c[D_HMAC][0]=count;
+	c[D_SHA1][0]=count;
+	c[D_RMD160][0]=count;
+	c[D_RC4][0]=count*5;
+	c[D_CBC_DES][0]=count;
+	c[D_EDE3_DES][0]=count/3;
+	c[D_CBC_IDEA][0]=count;
+	c[D_CBC_SEED][0]=count;
+	c[D_CBC_RC2][0]=count;
+	c[D_CBC_RC5][0]=count;
+	c[D_CBC_BF][0]=count;
+	c[D_CBC_CAST][0]=count;
+	c[D_CBC_128_AES][0]=count;
+	c[D_CBC_192_AES][0]=count;
+	c[D_CBC_256_AES][0]=count;
+	c[D_CBC_128_CML][0]=count;
+	c[D_CBC_192_CML][0]=count;
+	c[D_CBC_256_CML][0]=count;
+	c[D_SHA256][0]=count;
+	c[D_SHA512][0]=count;
+	c[D_IGE_128_AES][0]=count;
+	c[D_IGE_192_AES][0]=count;
+	c[D_IGE_256_AES][0]=count;
+
+	for (i=1; i<SIZE_NUM; i++)
+		{
+		c[D_MD2][i]=c[D_MD2][0]*4*lengths[0]/lengths[i];
+		c[D_MDC2][i]=c[D_MDC2][0]*4*lengths[0]/lengths[i];
+		c[D_MD4][i]=c[D_MD4][0]*4*lengths[0]/lengths[i];
+		c[D_MD5][i]=c[D_MD5][0]*4*lengths[0]/lengths[i];
+		c[D_HMAC][i]=c[D_HMAC][0]*4*lengths[0]/lengths[i];
+		c[D_SHA1][i]=c[D_SHA1][0]*4*lengths[0]/lengths[i];
+		c[D_RMD160][i]=c[D_RMD160][0]*4*lengths[0]/lengths[i];
+		c[D_SHA256][i]=c[D_SHA256][0]*4*lengths[0]/lengths[i];
+		c[D_SHA512][i]=c[D_SHA512][0]*4*lengths[0]/lengths[i];
+		}
+	for (i=1; i<SIZE_NUM; i++)
+		{
+		long l0,l1;
+
+		l0=(long)lengths[i-1];
+		l1=(long)lengths[i];
+		c[D_RC4][i]=c[D_RC4][i-1]*l0/l1;
+		c[D_CBC_DES][i]=c[D_CBC_DES][i-1]*l0/l1;
+		c[D_EDE3_DES][i]=c[D_EDE3_DES][i-1]*l0/l1;
+		c[D_CBC_IDEA][i]=c[D_CBC_IDEA][i-1]*l0/l1;
+		c[D_CBC_SEED][i]=c[D_CBC_SEED][i-1]*l0/l1;
+		c[D_CBC_RC2][i]=c[D_CBC_RC2][i-1]*l0/l1;
+		c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
+		c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
+		c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
+		c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
+		c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
+		c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
+		c[D_CBC_128_CML][i]=c[D_CBC_128_CML][i-1]*l0/l1;
+		c[D_CBC_192_CML][i]=c[D_CBC_192_CML][i-1]*l0/l1;
+		c[D_CBC_256_CML][i]=c[D_CBC_256_CML][i-1]*l0/l1;
+		c[D_IGE_128_AES][i]=c[D_IGE_128_AES][i-1]*l0/l1;
+		c[D_IGE_192_AES][i]=c[D_IGE_192_AES][i-1]*l0/l1;
+		c[D_IGE_256_AES][i]=c[D_IGE_256_AES][i-1]*l0/l1;
+		}
+#ifndef OPENSSL_NO_RSA
+	rsa_c[R_RSA_512][0]=count/2000;
+	rsa_c[R_RSA_512][1]=count/400;
+	for (i=1; i<RSA_NUM; i++)
+		{
+		rsa_c[i][0]=rsa_c[i-1][0]/8;
+		rsa_c[i][1]=rsa_c[i-1][1]/4;
+		/*if ((rsa_doit[i] <= 1) && (rsa_c[i][0] == 0))
+			rsa_doit[i]=0;
+		else
+                {*/
+			if (rsa_c[i][0] == 0)
+				{
+				rsa_c[i][0]=1;
+				rsa_c[i][1]=20;
+				}
+                }
+                /*}*/
+#endif
+
+#ifndef OPENSSL_NO_DSA
+	dsa_c[R_DSA_512][0]=count/1000;
+	dsa_c[R_DSA_512][1]=count/1000/2;
+	for (i=1; i<DSA_NUM; i++)
+		{
+		dsa_c[i][0]=dsa_c[i-1][0]/4;
+		dsa_c[i][1]=dsa_c[i-1][1]/4;
+		if ((dsa_doit[i] <= 1) && (dsa_c[i][0] == 0))
+			dsa_doit[i]=0;
+		else
+			{
+			if (dsa_c[i] == 0)
+				{
+				dsa_c[i][0]=1;
+				dsa_c[i][1]=1;
+				}
+			}
+		}
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+	ecdsa_c[R_EC_P160][0]=count/1000;
+	ecdsa_c[R_EC_P160][1]=count/1000/2;
+	for (i=R_EC_P192; i<=R_EC_P521; i++)
+		{
+		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
+		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
+		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
+			ecdsa_doit[i]=0;
+		else
+			{
+			if (ecdsa_c[i] == 0)
+				{
+				ecdsa_c[i][0]=1;
+				ecdsa_c[i][1]=1;
+				}
+			}
+		}
+	ecdsa_c[R_EC_K163][0]=count/1000;
+	ecdsa_c[R_EC_K163][1]=count/1000/2;
+	for (i=R_EC_K233; i<=R_EC_K571; i++)
+		{
+		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
+		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
+		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
+			ecdsa_doit[i]=0;
+		else
+			{
+			if (ecdsa_c[i] == 0)
+				{
+				ecdsa_c[i][0]=1;
+				ecdsa_c[i][1]=1;
+				}
+			}
+		}
+	ecdsa_c[R_EC_B163][0]=count/1000;
+	ecdsa_c[R_EC_B163][1]=count/1000/2;
+	for (i=R_EC_B233; i<=R_EC_B571; i++)
+		{
+		ecdsa_c[i][0]=ecdsa_c[i-1][0]/2;
+		ecdsa_c[i][1]=ecdsa_c[i-1][1]/2;
+		if ((ecdsa_doit[i] <= 1) && (ecdsa_c[i][0] == 0))
+			ecdsa_doit[i]=0;
+		else
+			{
+			if (ecdsa_c[i] == 0)
+				{
+				ecdsa_c[i][0]=1;
+				ecdsa_c[i][1]=1;
+				}
+			}
+		}
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+	ecdh_c[R_EC_P160][0]=count/1000;
+	ecdh_c[R_EC_P160][1]=count/1000;
+	for (i=R_EC_P192; i<=R_EC_P521; i++)
+		{
+		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
+		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
+		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
+			ecdh_doit[i]=0;
+		else
+			{
+			if (ecdh_c[i] == 0)
+				{
+				ecdh_c[i][0]=1;
+				ecdh_c[i][1]=1;
+				}
+			}
+		}
+	ecdh_c[R_EC_K163][0]=count/1000;
+	ecdh_c[R_EC_K163][1]=count/1000;
+	for (i=R_EC_K233; i<=R_EC_K571; i++)
+		{
+		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
+		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
+		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
+			ecdh_doit[i]=0;
+		else
+			{
+			if (ecdh_c[i] == 0)
+				{
+				ecdh_c[i][0]=1;
+				ecdh_c[i][1]=1;
+				}
+			}
+		}
+	ecdh_c[R_EC_B163][0]=count/1000;
+	ecdh_c[R_EC_B163][1]=count/1000;
+	for (i=R_EC_B233; i<=R_EC_B571; i++)
+		{
+		ecdh_c[i][0]=ecdh_c[i-1][0]/2;
+		ecdh_c[i][1]=ecdh_c[i-1][1]/2;
+		if ((ecdh_doit[i] <= 1) && (ecdh_c[i][0] == 0))
+			ecdh_doit[i]=0;
+		else
+			{
+			if (ecdh_c[i] == 0)
+				{
+				ecdh_c[i][0]=1;
+				ecdh_c[i][1]=1;
+				}
+			}
+		}
+#endif
+
+#define COND(d)	(count < (d))
+#define COUNT(d) (d)
+//#else
+///* not worth fixing */
+//# error "You cannot disable DES on systems without SIGALRM."
+//#endif /* OPENSSL_NO_DES */
+#else
+#define COND(c)	(run)
+#define COUNT(d) (count)
+	signal(SIGALRM,sig_done);
+#endif /* SIGALRM */
+
+#ifndef OPENSSL_NO_MD2
+	if (doit[D_MD2])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_MD2],c[D_MD2][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_MD2][j]); count++)
+				EVP_Digest(buf,(unsigned long)lengths[j],&(md2[0]),NULL,EVP_md2(),NULL);
+			d=Time_F(STOP);
+			print_result(D_MD2,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_MDC2
+	if (doit[D_MDC2])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_MDC2],c[D_MDC2][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_MDC2][j]); count++)
+				EVP_Digest(buf,(unsigned long)lengths[j],&(mdc2[0]),NULL,EVP_mdc2(),NULL);
+			d=Time_F(STOP);
+			print_result(D_MDC2,j,count,d);
+			}
+		}
+#endif
+
+#ifndef OPENSSL_NO_MD4
+	if (doit[D_MD4])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_MD4],c[D_MD4][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_MD4][j]); count++)
+				EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md4[0]),NULL,EVP_md4(),NULL);
+			d=Time_F(STOP);
+			print_result(D_MD4,j,count,d);
+			}
+		}
+#endif
+
+#ifndef OPENSSL_NO_MD5
+	if (doit[D_MD5])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_MD5],c[D_MD5][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_MD5][j]); count++)
+				EVP_Digest(&(buf[0]),(unsigned long)lengths[j],&(md5[0]),NULL,EVP_get_digestbyname("md5"),NULL);
+			d=Time_F(STOP);
+			print_result(D_MD5,j,count,d);
+			}
+		}
+#endif
+
+#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC)
+	if (doit[D_HMAC])
+		{
+		HMAC_CTX hctx;
+
+		HMAC_CTX_init(&hctx);
+		HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
+			16,EVP_md5(), NULL);
+
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_HMAC],c[D_HMAC][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_HMAC][j]); count++)
+				{
+				HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
+				HMAC_Update(&hctx,buf,lengths[j]);
+				HMAC_Final(&hctx,&(hmac[0]),NULL);
+				}
+			d=Time_F(STOP);
+			print_result(D_HMAC,j,count,d);
+			}
+		HMAC_CTX_cleanup(&hctx);
+		}
+#endif
+#ifndef OPENSSL_NO_SHA
+	if (doit[D_SHA1])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_SHA1],c[D_SHA1][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_SHA1][j]); count++)
+				EVP_Digest(buf,(unsigned long)lengths[j],&(sha[0]),NULL,EVP_sha1(),NULL);
+			d=Time_F(STOP);
+			print_result(D_SHA1,j,count,d);
+			}
+		}
+
+#ifndef OPENSSL_NO_SHA256
+	if (doit[D_SHA256])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_SHA256],c[D_SHA256][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_SHA256][j]); count++)
+				SHA256(buf,lengths[j],sha256);
+			d=Time_F(STOP);
+			print_result(D_SHA256,j,count,d);
+			}
+		}
+#endif
+
+#ifndef OPENSSL_NO_SHA512
+	if (doit[D_SHA512])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_SHA512],c[D_SHA512][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_SHA512][j]); count++)
+				SHA512(buf,lengths[j],sha512);
+			d=Time_F(STOP);
+			print_result(D_SHA512,j,count,d);
+			}
+		}
+#endif
+
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+	if (doit[D_RMD160])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_RMD160],c[D_RMD160][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_RMD160][j]); count++)
+				EVP_Digest(buf,(unsigned long)lengths[j],&(rmd160[0]),NULL,EVP_ripemd160(),NULL);
+			d=Time_F(STOP);
+			print_result(D_RMD160,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_RC4
+	if (doit[D_RC4])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_RC4],c[D_RC4][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_RC4][j]); count++)
+				RC4(&rc4_ks,(unsigned int)lengths[j],
+					buf,buf);
+			d=Time_F(STOP);
+			print_result(D_RC4,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_DES
+	if (doit[D_CBC_DES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
+				DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
+						 &DES_iv,DES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_DES,j,count,d);
+			}
+		}
+
+	if (doit[D_EDE3_DES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
+				DES_ede3_cbc_encrypt(buf,buf,lengths[j],
+						     &sch,&sch2,&sch3,
+						     &DES_iv,DES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_EDE3_DES,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_AES
+	if (doit[D_CBC_128_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_128_AES],c[D_CBC_128_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_128_AES][j]); count++)
+				AES_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&aes_ks1,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_128_AES,j,count,d);
+			}
+		}
+	if (doit[D_CBC_192_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_192_AES],c[D_CBC_192_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_192_AES][j]); count++)
+				AES_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&aes_ks2,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_192_AES,j,count,d);
+			}
+		}
+	if (doit[D_CBC_256_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_256_AES],c[D_CBC_256_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_256_AES][j]); count++)
+				AES_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&aes_ks3,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_256_AES,j,count,d);
+			}
+		}
+
+	if (doit[D_IGE_128_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_IGE_128_AES],c[D_IGE_128_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_IGE_128_AES][j]); count++)
+				AES_ige_encrypt(buf,buf2,
+					(unsigned long)lengths[j],&aes_ks1,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_IGE_128_AES,j,count,d);
+			}
+		}
+	if (doit[D_IGE_192_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_IGE_192_AES],c[D_IGE_192_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_IGE_192_AES][j]); count++)
+				AES_ige_encrypt(buf,buf2,
+					(unsigned long)lengths[j],&aes_ks2,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_IGE_192_AES,j,count,d);
+			}
+		}
+	if (doit[D_IGE_256_AES])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_IGE_256_AES],c[D_IGE_256_AES][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_IGE_256_AES][j]); count++)
+				AES_ige_encrypt(buf,buf2,
+					(unsigned long)lengths[j],&aes_ks3,
+					iv,AES_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_IGE_256_AES,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_CAMELLIA
+	if (doit[D_CBC_128_CML])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_128_CML],c[D_CBC_128_CML][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_128_CML][j]); count++)
+				Camellia_cbc_encrypt(buf,buf,
+				        (unsigned long)lengths[j],&camellia_ks1,
+				        iv,CAMELLIA_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_128_CML,j,count,d);
+			}
+		}
+	if (doit[D_CBC_192_CML])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_192_CML],c[D_CBC_192_CML][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_192_CML][j]); count++)
+				Camellia_cbc_encrypt(buf,buf,
+				        (unsigned long)lengths[j],&camellia_ks2,
+				        iv,CAMELLIA_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_192_CML,j,count,d);
+			}
+		}
+	if (doit[D_CBC_256_CML])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_256_CML],c[D_CBC_256_CML][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_256_CML][j]); count++)
+				Camellia_cbc_encrypt(buf,buf,
+				        (unsigned long)lengths[j],&camellia_ks3,
+				        iv,CAMELLIA_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_256_CML,j,count,d);
+			}
+		}
+
+#endif
+#ifndef OPENSSL_NO_IDEA
+	if (doit[D_CBC_IDEA])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_IDEA],c[D_CBC_IDEA][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_IDEA][j]); count++)
+				idea_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&idea_ks,
+					iv,IDEA_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_IDEA,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_SEED
+	if (doit[D_CBC_SEED])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_SEED],c[D_CBC_SEED][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_SEED][j]); count++)
+				SEED_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&seed_ks,iv,1);
+			d=Time_F(STOP);
+			print_result(D_CBC_SEED,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_RC2
+	if (doit[D_CBC_RC2])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_RC2],c[D_CBC_RC2][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_RC2][j]); count++)
+				RC2_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&rc2_ks,
+					iv,RC2_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_RC2,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_RC5
+	if (doit[D_CBC_RC5])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_RC5],c[D_CBC_RC5][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_RC5][j]); count++)
+				RC5_32_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&rc5_ks,
+					iv,RC5_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_RC5,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_BF
+	if (doit[D_CBC_BF])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_BF],c[D_CBC_BF][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_BF][j]); count++)
+				BF_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&bf_ks,
+					iv,BF_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_BF,j,count,d);
+			}
+		}
+#endif
+#ifndef OPENSSL_NO_CAST
+	if (doit[D_CBC_CAST])
+		{
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			print_message(names[D_CBC_CAST],c[D_CBC_CAST][j],lengths[j]);
+			Time_F(START);
+			for (count=0,run=1; COND(c[D_CBC_CAST][j]); count++)
+				CAST_cbc_encrypt(buf,buf,
+					(unsigned long)lengths[j],&cast_ks,
+					iv,CAST_ENCRYPT);
+			d=Time_F(STOP);
+			print_result(D_CBC_CAST,j,count,d);
+			}
+		}
+#endif
+
+
+//	if (doit[D_EVP])
+//		{
+//		for (j=0; j<SIZE_NUM; j++)
+//			{
+//			if (evp_cipher)
+//				{
+//				EVP_CIPHER_CTX ctx;
+//				int outl;
+//
+//				names[D_EVP]=OBJ_nid2ln(evp_cipher->nid);
+//				/* -O3 -fschedule-insns messes up an
+//				 * optimization here!  names[D_EVP]
+//				 * somehow becomes NULL */
+//				print_message(names[D_EVP],save_count,
+//					lengths[j]);
+//
+//				EVP_CIPHER_CTX_init(&ctx);
+//				if(decrypt)
+//					EVP_DecryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
+//				else
+//					EVP_EncryptInit_ex(&ctx,evp_cipher,NULL,key16,iv);
+//				EVP_CIPHER_CTX_set_padding(&ctx, 0);
+//
+//				Time_F(START);
+//				if(decrypt)
+//					for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
+//						EVP_DecryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
+//				else
+//					for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
+//						EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]);
+//				if(decrypt)
+//					EVP_DecryptFinal_ex(&ctx,buf,&outl);
+//				else
+//					EVP_EncryptFinal_ex(&ctx,buf,&outl);
+//				d=Time_F(STOP);
+//				EVP_CIPHER_CTX_cleanup(&ctx);
+//				}
+//			if (evp_md)
+//				{
+//				names[D_EVP]=OBJ_nid2ln(evp_md->type);
+//				print_message(names[D_EVP],save_count,
+//					lengths[j]);
+//
+//				Time_F(START);
+//				for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++)
+//					EVP_Digest(buf,lengths[j],&(md[0]),NULL,evp_md,NULL);
+//
+//				d=Time_F(STOP);
+//				}
+//			print_result(D_EVP,j,count,d);
+//			}
+//		}
+
+        RAND_set_rand_method(&rand_dummy_meth);
+
+        RAND_seed(rnd_seed, sizeof rnd_seed);
+	RAND_pseudo_bytes(buf,36);
+#ifndef OPENSSL_NO_RSA
+	for (j=0; j<RSA_NUM; j++)
+		{
+		int ret;
+		const unsigned char *p;
+
+		if (!rsa_doit[j]) continue;
+
+		p=rsa_data[j];
+		rsa_key[j]=d2i_RSAPrivateKey(NULL,&p,rsa_data_length[j]);
+                rsa_key[j]->flags |= (RSA_FLAG_NO_CONSTTIME | RSA_FLAG_NO_BLINDING);
+		if (rsa_key[j] == NULL)
+			{
+                            BIO_printf(bio_err,"internal error loading RSA key number %d\n",j);
+                            goto end;
+			}
+		ret=RSA_sign(NID_md5_sha1, buf,36, buf2, &rsa_num, rsa_key[j]);
+		if (ret == 0)
+			{
+			BIO_printf(bio_err,"RSA sign failure.  No RSA sign will be done.\n");
+			//ERR_print_errors(bio_err);
+			rsa_count=1;
+			}
+		else
+			{
+			pkey_print_message("private","rsa",
+				rsa_c[j][0],rsa_bits[j],
+				RSA_SECONDS);
+/*			RSA_blinding_on(rsa_key[j],NULL); */
+			Time_F(START);
+			for (count=0,run=1; COND(rsa_c[j][0]); count++)
+				{
+				ret=RSA_sign(NID_md5_sha1, buf,36, buf2,
+					&rsa_num, rsa_key[j]);
+				if (ret == 0)
+					{
+					BIO_printf(bio_err,
+						"RSA sign failure\n");
+					//ERR_print_errors(bio_err);
+					count=1;
+					break;
+					}
+				}
+			d=Time_F(STOP);
+			BIO_printf(bio_err,mr ? "+R1:%ld:%d:%.2f\n"
+				   : "%ld %d bit private RSA's in %.2fs\n",
+				   count,rsa_bits[j],d);
+			rsa_results[j][0]=d/(double)count;
+			rsa_count=count;
+			}
+
+#if 1
+		ret=RSA_verify(NID_md5_sha1, buf,36, buf2, rsa_num, rsa_key[j]);
+		if (ret <= 0)
+			{
+			BIO_printf(bio_err,"RSA verify failure.  No RSA verify will be done.\n");
+			//ERR_print_errors(bio_err);
+			rsa_doit[j] = 0;
+			}
+		else
+			{
+			pkey_print_message("public","rsa",
+				rsa_c[j][1],rsa_bits[j],
+				RSA_SECONDS);
+			Time_F(START);
+			for (count=0,run=1; COND(rsa_c[j][1]); count++)
+				{
+				ret=RSA_verify(NID_md5_sha1, buf,36, buf2,
+					rsa_num, rsa_key[j]);
+				if (ret == 0)
+					{
+					BIO_printf(bio_err,
+						"RSA verify failure\n");
+					//ERR_print_errors(bio_err);
+					count=1;
+					break;
+					}
+				}
+			d=Time_F(STOP);
+			BIO_printf(bio_err,mr ? "+R2:%ld:%d:%.2f\n"
+				   : "%ld %d bit public RSA's in %.2fs\n",
+				   count,rsa_bits[j],d);
+			rsa_results[j][1]=d/(double)count;
+			}
+#endif
+
+//		if (rsa_count </*=*/ 1)
+//			{
+//			/* if longer than 10s, don't do any more */
+//			for (j++; j<RSA_NUM; j++)
+//				rsa_doit[j]=0;
+//			}
+		if (rsa_key[j] != NULL)
+                    RSA_free(rsa_key[j]);
+
+		}
+#endif
+
+	RAND_pseudo_bytes(buf,20);
+#ifndef OPENSSL_NO_DSA
+	if (RAND_status() != 1)
+		{
+		RAND_seed(rnd_seed, sizeof rnd_seed);
+		rnd_fake = 1;
+		}
+	for (j=0; j<DSA_NUM; j++)
+		{
+		unsigned int kk;
+		int ret;
+
+		if (!dsa_doit[j]) continue;
+/*		DSA_generate_key(dsa_key[j]); */
+/*		DSA_sign_setup(dsa_key[j],NULL); */
+		ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
+			&kk,dsa_key[j]);
+		if (ret == 0)
+			{
+			BIO_printf(bio_err,"DSA sign failure.  No DSA sign will be done.\n");
+			ERR_print_errors(bio_err);
+			rsa_count=1;
+			}
+		else
+			{
+			pkey_print_message("sign","dsa",
+				dsa_c[j][0],dsa_bits[j],
+				DSA_SECONDS);
+			Time_F(START);
+			for (count=0,run=1; COND(dsa_c[j][0]); count++)
+				{
+				ret=DSA_sign(EVP_PKEY_DSA,buf,20,buf2,
+					&kk,dsa_key[j]);
+				if (ret == 0)
+					{
+					BIO_printf(bio_err,
+						"DSA sign failure\n");
+					ERR_print_errors(bio_err);
+					count=1;
+					break;
+					}
+				}
+			d=Time_F(STOP);
+			BIO_printf(bio_err,mr ? "+R3:%ld:%d:%.2f\n"
+				   : "%ld %d bit DSA signs in %.2fs\n",
+				   count,dsa_bits[j],d);
+			dsa_results[j][0]=d/(double)count;
+			rsa_count=count;
+			}
+
+		ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
+			kk,dsa_key[j]);
+		if (ret <= 0)
+			{
+			BIO_printf(bio_err,"DSA verify failure.  No DSA verify will be done.\n");
+			ERR_print_errors(bio_err);
+			dsa_doit[j] = 0;
+			}
+		else
+			{
+			pkey_print_message("verify","dsa",
+				dsa_c[j][1],dsa_bits[j],
+				DSA_SECONDS);
+			Time_F(START);
+			for (count=0,run=1; COND(dsa_c[j][1]); count++)
+				{
+				ret=DSA_verify(EVP_PKEY_DSA,buf,20,buf2,
+					kk,dsa_key[j]);
+				if (ret <= 0)
+					{
+					BIO_printf(bio_err,
+						"DSA verify failure\n");
+					ERR_print_errors(bio_err);
+					count=1;
+					break;
+					}
+				}
+			d=Time_F(STOP);
+			BIO_printf(bio_err,mr ? "+R4:%ld:%d:%.2f\n"
+				   : "%ld %d bit DSA verify in %.2fs\n",
+				   count,dsa_bits[j],d);
+			dsa_results[j][1]=d/(double)count;
+			}
+
+		if (rsa_count <= 1)
+			{
+			/* if longer than 10s, don't do any more */
+			for (j++; j<DSA_NUM; j++)
+				dsa_doit[j]=0;
+			}
+		}
+	if (rnd_fake) RAND_cleanup();
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+	if (RAND_status() != 1)
+		{
+		RAND_seed(rnd_seed, sizeof rnd_seed);
+		rnd_fake = 1;
+		}
+	for (j=0; j<EC_NUM; j++)
+		{
+		int ret;
+
+		if (!ecdsa_doit[j]) continue; /* Ignore Curve */
+		ecdsa[j] = EC_KEY_new_by_curve_name(test_curves[j]);
+		if (ecdsa[j] == NULL)
+			{
+			BIO_printf(bio_err,"ECDSA failure.\n");
+			ERR_print_errors(bio_err);
+			rsa_count=1;
+			}
+		else
+			{
+#if 1
+			EC_KEY_precompute_mult(ecdsa[j], NULL);
+#endif
+			/* Perform ECDSA signature test */
+			EC_KEY_generate_key(ecdsa[j]);
+			ret = ECDSA_sign(0, buf, 20, ecdsasig,
+				&ecdsasiglen, ecdsa[j]);
+			if (ret == 0)
+				{
+				BIO_printf(bio_err,"ECDSA sign failure.  No ECDSA sign will be done.\n");
+				ERR_print_errors(bio_err);
+				rsa_count=1;
+				}
+			else
+				{
+				pkey_print_message("sign","ecdsa",
+					ecdsa_c[j][0],
+					test_curves_bits[j],
+					ECDSA_SECONDS);
+
+				Time_F(START);
+				for (count=0,run=1; COND(ecdsa_c[j][0]);
+					count++)
+					{
+					ret=ECDSA_sign(0, buf, 20,
+						ecdsasig, &ecdsasiglen,
+						ecdsa[j]);
+					if (ret == 0)
+						{
+						BIO_printf(bio_err, "ECDSA sign failure\n");
+						ERR_print_errors(bio_err);
+						count=1;
+						break;
+						}
+					}
+				d=Time_F(STOP);
+
+				BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" :
+					"%ld %d bit ECDSA signs in %.2fs \n",
+					count, test_curves_bits[j], d);
+				ecdsa_results[j][0]=d/(double)count;
+				rsa_count=count;
+				}
+
+			/* Perform ECDSA verification test */
+			ret=ECDSA_verify(0, buf, 20, ecdsasig,
+				ecdsasiglen, ecdsa[j]);
+			if (ret != 1)
+				{
+				BIO_printf(bio_err,"ECDSA verify failure.  No ECDSA verify will be done.\n");
+				ERR_print_errors(bio_err);
+				ecdsa_doit[j] = 0;
+				}
+			else
+				{
+				pkey_print_message("verify","ecdsa",
+				ecdsa_c[j][1],
+				test_curves_bits[j],
+				ECDSA_SECONDS);
+				Time_F(START);
+				for (count=0,run=1; COND(ecdsa_c[j][1]); count++)
+					{
+					ret=ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]);
+					if (ret != 1)
+						{
+						BIO_printf(bio_err, "ECDSA verify failure\n");
+						ERR_print_errors(bio_err);
+						count=1;
+						break;
+						}
+					}
+				d=Time_F(STOP);
+				BIO_printf(bio_err, mr? "+R6:%ld:%d:%.2f\n"
+						: "%ld %d bit ECDSA verify in %.2fs\n",
+				count, test_curves_bits[j], d);
+				ecdsa_results[j][1]=d/(double)count;
+				}
+
+			if (rsa_count <= 1)
+				{
+				/* if longer than 10s, don't do any more */
+				for (j++; j<EC_NUM; j++)
+				ecdsa_doit[j]=0;
+				}
+			}
+		}
+	if (rnd_fake) RAND_cleanup();
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+	if (RAND_status() != 1)
+		{
+		RAND_seed(rnd_seed, sizeof rnd_seed);
+		rnd_fake = 1;
+		}
+	for (j=0; j<EC_NUM; j++)
+		{
+		if (!ecdh_doit[j]) continue;
+		ecdh_a[j] = EC_KEY_new_by_curve_name(test_curves[j]);
+		ecdh_b[j] = EC_KEY_new_by_curve_name(test_curves[j]);
+		if ((ecdh_a[j] == NULL) || (ecdh_b[j] == NULL))
+			{
+			BIO_printf(bio_err,"ECDH failure.\n");
+			//ERR_print_errors(bio_err);
+			rsa_count=1;
+			}
+		else
+			{
+			/* generate two ECDH key pairs */
+			if (!EC_KEY_generate_key(ecdh_a[j]) ||
+				!EC_KEY_generate_key(ecdh_b[j]))
+				{
+				BIO_printf(bio_err,"ECDH key generation failure.\n");
+				//ERR_print_errors(bio_err);
+				rsa_count=1;
+				}
+			else
+				{
+				/* If field size is not more than 24 octets, then use SHA-1 hash of result;
+				 * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
+				 */
+				int field_size, outlen;
+				void *(*kdf)(const void *in, size_t inlen, void *out, size_t *xoutlen);
+				field_size = EC_GROUP_get_degree(EC_KEY_get0_group(ecdh_a[j]));
+				if (field_size <= 24 * 8)
+					{
+					outlen = KDF1_SHA1_len;
+					kdf = KDF1_SHA1;
+					}
+				else
+					{
+					outlen = (field_size+7)/8;
+					kdf = NULL;
+					}
+				secret_size_a = ECDH_compute_key(secret_a, outlen,
+					EC_KEY_get0_public_key(ecdh_b[j]),
+					ecdh_a[j], kdf);
+				secret_size_b = ECDH_compute_key(secret_b, outlen,
+					EC_KEY_get0_public_key(ecdh_a[j]),
+					ecdh_b[j], kdf);
+				if (secret_size_a != secret_size_b)
+					ecdh_checks = 0;
+				else
+					ecdh_checks = 1;
+
+				for (secret_idx = 0;
+				    (secret_idx < secret_size_a)
+					&& (ecdh_checks == 1);
+				    secret_idx++)
+					{
+					if (secret_a[secret_idx] != secret_b[secret_idx])
+					ecdh_checks = 0;
+					}
+
+				if (ecdh_checks == 0)
+					{
+					BIO_printf(bio_err,"ECDH computations don't match.\n");
+					//ERR_print_errors(bio_err);
+					rsa_count=1;
+					}
+
+				pkey_print_message("","ecdh",
+				ecdh_c[j][0],
+				test_curves_bits[j],
+				ECDH_SECONDS);
+				Time_F(START);
+				for (count=0,run=1; COND(ecdh_c[j][0]); count++)
+					{
+					ECDH_compute_key(secret_a, outlen,
+					EC_KEY_get0_public_key(ecdh_b[j]),
+					ecdh_a[j], kdf);
+					}
+				d=Time_F(STOP);
+				BIO_printf(bio_err, mr ? "+R7:%ld:%d:%.2f\n" :"%ld %d-bit ECDH ops in %.2fs\n",
+				count, test_curves_bits[j], d);
+				ecdh_results[j][0]=d/(double)count;
+				rsa_count=count;
+				}
+			}
+
+
+		if (rsa_count </*=*/ 1)
+			{
+			/* if longer than 10s, don't do any more */
+			for (j++; j<EC_NUM; j++)
+			ecdh_doit[j]=0;
+			}
+		}
+	if (rnd_fake) RAND_cleanup();
+#endif
+#ifdef HAVE_FORK
+show_res:
+#endif
+	if(!mr)
+		{
+		fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_VERSION));
+        fprintf(stdout,"%s\n",SSLeay_version(SSLEAY_BUILT_ON));
+		printf("options:");
+		printf("%s ",BN_options());
+#ifndef OPENSSL_NO_MD2
+		printf("%s ",MD2_options());
+#endif
+#ifndef OPENSSL_NO_RC4
+		printf("%s ",RC4_options());
+#endif
+#ifndef OPENSSL_NO_DES
+		printf("%s ",DES_options());
+#endif
+#ifndef OPENSSL_NO_AES
+		printf("%s ",AES_options());
+#endif
+#ifndef OPENSSL_NO_IDEA
+		printf("%s ",idea_options());
+#endif
+#ifndef OPENSSL_NO_BF
+		printf("%s ",BF_options());
+#endif
+		fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
+		printf("available timing options: ");
+#ifdef TIMES
+		printf("TIMES ");
+#endif
+#ifdef TIMEB
+		printf("TIMEB ");
+#endif
+#ifdef USE_TOD
+		printf("USE_TOD ");
+#endif
+#ifdef HZ
+#define as_string(s) (#s)
+		{
+		double dbl = HZ;
+		printf("HZ=%g", dbl);
+		}
+# ifdef _SC_CLK_TCK
+		printf(" [sysconf value]");
+# endif
+#endif
+		printf("\n");
+		printf("timing function used: %s%s%s%s%s%s%s\n",
+		       (ftime_used ? "ftime" : ""),
+		       (ftime_used + times_used > 1 ? "," : ""),
+		       (times_used ? "times" : ""),
+		       (ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
+		       (gettimeofday_used ? "gettimeofday" : ""),
+		       (ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
+		       (getrusage_used ? "getrusage" : ""));
+		}
+
+	if (pr_header)
+		{
+		if(mr)
+			fprintf(stdout,"+H");
+		else
+			{
+			fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n");
+			fprintf(stdout,"type        ");
+			}
+		for (j=0;  j<SIZE_NUM; j++)
+			fprintf(stdout,mr ? ":%d" : "%7d bytes",lengths[j]);
+		fprintf(stdout,"\n");
+		}
+
+	for (k=0; k<ALGOR_NUM; k++)
+		{
+		if (!doit[k]) continue;
+		if(mr)
+			fprintf(stdout,"+F:%d:%s",k,names[k]);
+		else
+			fprintf(stdout,"%-13s",names[k]);
+		for (j=0; j<SIZE_NUM; j++)
+			{
+			if (results[k][j] > 10000 && !mr)
+				fprintf(stdout," %11.2fk",results[k][j]/1e3);
+			else
+				fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]);
+			}
+		fprintf(stdout,"\n");
+		}
+#ifndef OPENSSL_NO_RSA
+	j=1;
+	for (k=0; k<RSA_NUM; k++)
+		{
+		if (!rsa_doit[k]) continue;
+		if (j && !mr)
+			{
+			printf("%18ssign    verify    sign/s verify/s\n"," ");
+			j=0;
+			}
+		if(mr)
+			fprintf(stdout,"+F2:%u:%u:%f:%f\n",
+				k,rsa_bits[k],rsa_results[k][0],
+				rsa_results[k][1]);
+		else
+			fprintf(stdout,"rsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
+				rsa_bits[k],rsa_results[k][0],rsa_results[k][1],
+				1.0/rsa_results[k][0],1.0/rsa_results[k][1]);
+		}
+#endif
+#ifndef OPENSSL_NO_DSA
+	j=1;
+	for (k=0; k<DSA_NUM; k++)
+		{
+		if (!dsa_doit[k]) continue;
+		if (j && !mr)
+			{
+			printf("%18ssign    verify    sign/s verify/s\n"," ");
+			j=0;
+			}
+		if(mr)
+			fprintf(stdout,"+F3:%u:%u:%f:%f\n",
+				k,dsa_bits[k],dsa_results[k][0],dsa_results[k][1]);
+		else
+			fprintf(stdout,"dsa %4u bits %8.6fs %8.6fs %8.1f %8.1f\n",
+				dsa_bits[k],dsa_results[k][0],dsa_results[k][1],
+				1.0/dsa_results[k][0],1.0/dsa_results[k][1]);
+		}
+#endif
+#ifndef OPENSSL_NO_ECDSA
+	j=1;
+	for (k=0; k<EC_NUM; k++)
+		{
+		if (!ecdsa_doit[k]) continue;
+		if (j && !mr)
+			{
+			printf("%30ssign    verify    sign/s verify/s\n"," ");
+			j=0;
+			}
+
+		if (mr)
+			fprintf(stdout,"+F4:%u:%u:%f:%f\n",
+				k, test_curves_bits[k],
+				ecdsa_results[k][0],ecdsa_results[k][1]);
+		else
+			fprintf(stdout,
+				"%4u bit ecdsa (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
+				test_curves_bits[k],
+				test_curves_names[k],
+				ecdsa_results[k][0],ecdsa_results[k][1],
+				1.0/ecdsa_results[k][0],1.0/ecdsa_results[k][1]);
+		}
+#endif
+
+
+#ifndef OPENSSL_NO_ECDH
+	j=1;
+	for (k=0; k<EC_NUM; k++)
+		{
+		if (!ecdh_doit[k]) continue;
+		if (j && !mr)
+			{
+			printf("%30sop      op/s\n"," ");
+			j=0;
+			}
+		if (mr)
+			fprintf(stdout,"+F5:%u:%u:%f:%f\n",
+				k, test_curves_bits[k],
+				ecdh_results[k][0], 1.0/ecdh_results[k][0]);
+
+		else
+			fprintf(stdout,"%4u bit ecdh (%s) %8.4fs %8.1f\n",
+				test_curves_bits[k],
+				test_curves_names[k],
+				ecdh_results[k][0], 1.0/ecdh_results[k][0]);
+		}
+#endif
+
+	mret=0;
+
+end:
+	//ERR_print_errors(bio_err);
+	if (buf != NULL) /*OPENSSL_*/free(buf);
+	if (buf2 != NULL) /*OPENSSL_*/free(buf2);
+#ifndef OPENSSL_NO_DSA
+	for (i=0; i<DSA_NUM; i++)
+		if (dsa_key[i] != NULL)
+			DSA_free(dsa_key[i]);
+#endif
+
+#ifndef OPENSSL_NO_ECDSA
+	for (i=0; i<EC_NUM; i++)
+		if (ecdsa[i] != NULL)
+			EC_KEY_free(ecdsa[i]);
+#endif
+#ifndef OPENSSL_NO_ECDH
+	for (i=0; i<EC_NUM; i++)
+	{
+		if (ecdh_a[i] != NULL)
+			EC_KEY_free(ecdh_a[i]);
+		if (ecdh_b[i] != NULL)
+			EC_KEY_free(ecdh_b[i]);
+	}
+#endif
+
+	//apps_shutdown();
+	//OPENSSL_EXIT(mret);
+	}
+
+#ifdef OPENSSL_SYS_NEWLIB
+#undef SIGALRM
+#endif
+
+static void print_message(const char *s, long num, int length)
+	{
+#ifdef SIGALRM
+	BIO_printf(bio_err,mr ? "+DT:%s:%d:%d\n"
+		   : "Doing %s for %ds on %d size blocks: ",s,SECONDS,length);
+	(void)BIO_flush(bio_err);
+	alarm(SECONDS);
+#else
+	BIO_printf(bio_err,mr ? "+DN:%s:%ld:%d\n"
+		   : "Doing %s %ld times on %d size blocks: ",s,num,length);
+	(void)BIO_flush(bio_err);
+#endif
+#ifdef LINT
+	num=num;
+#endif
+	}
+
+static void pkey_print_message(const char *str, const char *str2, long num,
+	int bits, int tm)
+	{
+#ifdef SIGALRM
+	BIO_printf(bio_err,mr ? "+DTP:%d:%s:%s:%d\n"
+			   : "Doing %d bit %s %s's for %ds: ",bits,str,str2,tm);
+	(void)BIO_flush(bio_err);
+	alarm(RSA_SECONDS);
+#else
+	BIO_printf(bio_err,mr ? "+DNP:%ld:%d:%s:%s\n"
+			   : "Doing %ld %d bit %s %s's: ",num,bits,str,str2);
+	(void)BIO_flush(bio_err);
+#endif
+#ifdef LINT
+	num=num;
+#endif
+	}
+
+static void print_result(int alg,int run_no,int count,double time_used)
+	{
+	BIO_printf(bio_err,mr ? "+R:%d:%s:%f\n"
+		   : "%d %s's in %.2fs\n",count,names[alg],time_used);
+	results[alg][run_no]=((double)count)/time_used*lengths[run_no];
+	}
+
+#ifdef HAVE_FORK
+static char *sstrsep(char **string, const char *delim)
+    {
+    char isdelim[256];
+    char *token = *string;
+
+    if (**string == 0)
+        return NULL;
+
+    memset(isdelim, 0, sizeof isdelim);
+    isdelim[0] = 1;
+
+    while (*delim)
+        {
+        isdelim[(unsigned char)(*delim)] = 1;
+        delim++;
+        }
+
+    while (!isdelim[(unsigned char)(**string)])
+        {
+        (*string)++;
+        }
+
+    if (**string)
+        {
+        **string = 0;
+        (*string)++;
+        }
+
+    return token;
+    }
+
+static int do_multi(int multi)
+	{
+	int n;
+	int fd[2];
+	int *fds;
+	static char sep[]=":";
+
+	fds=malloc(multi*sizeof *fds);
+	for(n=0 ; n < multi ; ++n)
+		{
+		pipe(fd);
+		if(fork())
+			{
+			close(fd[1]);
+			fds[n]=fd[0];
+			}
+		else
+			{
+			close(fd[0]);
+			close(1);
+			dup(fd[1]);
+			close(fd[1]);
+			mr=1;
+			usertime=0;
+			return 0;
+			}
+		printf("Forked child %d\n",n);
+		}
+
+	/* for now, assume the pipe is long enough to take all the output */
+	for(n=0 ; n < multi ; ++n)
+		{
+		FILE *f;
+		char buf[1024];
+		char *p;
+
+		f=fdopen(fds[n],"r");
+		while(fgets(buf,sizeof buf,f))
+			{
+			p=strchr(buf,'\n');
+			if(p)
+				*p='\0';
+			if(buf[0] != '+')
+				{
+				fprintf(stderr,"Don't understand line '%s' from child %d\n",
+						buf,n);
+				continue;
+				}
+			printf("Got: %s from %d\n",buf,n);
+			if(!strncmp(buf,"+F:",3))
+				{
+				int alg;
+				int j;
+
+				p=buf+3;
+				alg=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+				for(j=0 ; j < SIZE_NUM ; ++j)
+					results[alg][j]+=atof(sstrsep(&p,sep));
+				}
+			else if(!strncmp(buf,"+F2:",4))
+				{
+				int k;
+				double d;
+
+				p=buf+4;
+				k=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
+				else
+					rsa_results[k][0]=d;
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
+				else
+					rsa_results[k][1]=d;
+				}
+			else if(!strncmp(buf,"+F2:",4))
+				{
+				int k;
+				double d;
+
+				p=buf+4;
+				k=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
+				else
+					rsa_results[k][0]=d;
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
+				else
+					rsa_results[k][1]=d;
+				}
+			else if(!strncmp(buf,"+F3:",4))
+				{
+				int k;
+				double d;
+
+				p=buf+4;
+				k=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					dsa_results[k][0]=1/(1/dsa_results[k][0]+1/d);
+				else
+					dsa_results[k][0]=d;
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					dsa_results[k][1]=1/(1/dsa_results[k][1]+1/d);
+				else
+					dsa_results[k][1]=d;
+				}
+#ifndef OPENSSL_NO_ECDSA
+			else if(!strncmp(buf,"+F4:",4))
+				{
+				int k;
+				double d;
+
+				p=buf+4;
+				k=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					ecdsa_results[k][0]=1/(1/ecdsa_results[k][0]+1/d);
+				else
+					ecdsa_results[k][0]=d;
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					ecdsa_results[k][1]=1/(1/ecdsa_results[k][1]+1/d);
+				else
+					ecdsa_results[k][1]=d;
+				}
+#endif
+
+#ifndef OPENSSL_NO_ECDH
+			else if(!strncmp(buf,"+F5:",4))
+				{
+				int k;
+				double d;
+
+				p=buf+4;
+				k=atoi(sstrsep(&p,sep));
+				sstrsep(&p,sep);
+
+				d=atof(sstrsep(&p,sep));
+				if(n)
+					ecdh_results[k][0]=1/(1/ecdh_results[k][0]+1/d);
+				else
+					ecdh_results[k][0]=d;
+
+				}
+#endif
+
+			else if(!strncmp(buf,"+H:",3))
+				{
+				}
+			else
+				fprintf(stderr,"Unknown type '%s' from child %d\n",buf,n);
+			}
+		}
+	return 1;
+	}
+#endif
+
+#ifdef __AVR32__
+#include <avr32/io.h>
+
+int _init_startup (){
+#ifdef __SETUP_OSC__
+  /* Setup OSC0. */
+  AVR32_PM.oscctrl0 = 7;
+
+  /* Set OSC0 as main clock. */
+  AVR32_PM.mcctrl = ( AVR32_PM_MCCTRL_OSC0EN_MASK |
+                      (1 << AVR32_PM_MCCTRL_MCSEL_OFFSET) );
+#endif
+
+#ifdef __AVR32_UC__
+  /* Set flashc master type to last default to save one cycle for
+     each branch. */
+  volatile  avr32_hmatrix_scfg_t scfg = AVR32_HMATRIX.SCFG[0];
+  scfg.defmstr_type =
+    AVR32_HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT;
+  AVR32_HMATRIX.SCFG[0] = scfg;
+
+  /* Set to one waitstate. */
+#ifdef __FLASH_WS__
+  AVR32_FLASHC.fcr |= AVR32_FLASHC_FCR_FWS_MASK | 0x10000000;
+#endif
+#endif
+}
+#endif
+
Index: openssl-0.9.8g/Configure
===================================================================
--- openssl-0.9.8g.orig/Configure	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/Configure	2008-09-24 11:01:01.000000000 +0200
@@ -120,6 +120,7 @@
 
 my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o::::md5-x86_64.o:::rc4-x86_64.o::";
 my $ia64_asm=":bn-ia64.o::aes_core.o aes_cbc.o aes-ia64.o:::sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o::";
+my $avr32_asm="::asm/des-avr32.o asm/des_cbc.o fcrypt_b.o:aes_core.o aes_cbc.o asm/aes-avr32.o:::::::";
 
 my $no_asm="::::::::::";
 
@@ -170,6 +171,8 @@
 
 # Basic configs that should work on any (32 and less bit) box
 "gcc",		"gcc:-O3::(unknown):::BN_LLONG:::",
+"avr32-gcc",	"avr32-gcc:-mpart=\$(PROCESSOR) -DBN_NO_MUL_COMBA -DBN_NO_SQR_COMBA -DBN_NO_RECURSION -DBN_NO_CONSTTIME -DBN_DIV2W -DDES_CTABLES_IN_DATA -DAES_CTABLES_IN_DATA -DNO_CHMOD -DNO_STRINGS_H -DOPENSSL_NO_DGRAM -DOPENSSL_NO_SOCK -DOPENSSL_SYSNAME_NEWLIB -O3 -fno-common -g -fdata-sections -ffunction-sections -ffast-math::(unknown)::-g -mpart=\${PROCESSOR} -O3 -Wl,--gc-sections,--direct-data:BN_LLONG:${avr32_asm}",
+"avr32-gcc-size",	"avr32-gcc:-mpart=\$(PROCESSOR) -DBN_NO_MUL_COMBA -DBN_NO_SQR_COMBA -DBN_NO_RECURSION -DBN_NO_CONSTTIME  -DBN_DIV2W  -DNO_CHMOD -DNO_STRINGS_H -DOPENSSL_NO_DGRAM -DOPENSSL_NO_SOCK -DOPENSSL_SYSNAME_NEWLIB -Os -fno-common -g -fdata-sections -ffunction-sections -ffast-math::(unknown)::-Os -g -mrelax -mpart=\$(PROCESSOR) -Wl,--gc-sections,--direct-data:BN_LLONG:${avr32_asm}",
 "cc",		"cc:-O::(unknown)::::::",
 
 ####VOS Configurations
@@ -319,6 +322,7 @@
 "linux-ia32-icc",	"icc:-DL_ENDIAN -DTERMIO -O2 -no_cpprt::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-KPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-elf",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-aout",	"gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i486 -Wall::(unknown):::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
+"linux-avr32",	"avr32-linux-gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG BF_PTR:${avr32_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 ####
 "linux-generic64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "linux-ppc64",	"gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL::linux_ppc64.o::::::::::dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
@@ -742,6 +746,10 @@
 				{
 				$prefix=$1;
 				}
+			elsif (/^--processor=(.*)$/)
+				{
+				$processor=$1;
+				}
 			elsif (/^--openssldir=(.*)$/)
 				{
 				$openssldir=$1;
Index: openssl-0.9.8g/crypto/aes/asm/aes-avr32.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/crypto/aes/asm/aes-avr32.S	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,1106 @@
+	.global	AES_encrypt
+	.global	AES_decrypt
+
+
+/*One Round
+t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];
+t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];
+t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];
+t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7] ;  */
+
+#define		AES_MAXNR 14
+#define		TE0	r4
+#define		TE1	r5
+#define		TE2	r6
+#define		TE3	r7
+#define		TD0	r4
+#define		TD1	r5
+#define		TD2	r6
+#define		TD3	r7
+#define		TE4	r4
+#define		TD4	r4
+
+#define		RK	r10
+#define		tmp	lr
+
+	.macro	RoundOddEncrypt s0, s1, s2, s3, t0, t1, t2, t3
+
+	ld.w		\t0, TE0[\s0:t << 2]
+	ld.w		\t3, TE1[\s0:u << 2]
+	ld.w		\t2, TE2[\s0:l << 2]
+	ld.w		tmp, RK[16]
+	ld.w		\t1, TE3[\s0:b << 2]
+
+	ld.w		\s0, TE1[\s1:u << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TE2[\s1:l << 2]
+	eor		\t0, \s0
+	ld.w		\s0, RK[28]
+	eor		\t3, tmp
+	ld.w		tmp, TE3[\s1:b << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[24]
+	eor		\t2, tmp
+	ld.w		tmp, TE0[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[20]
+	eor		\t1, tmp
+	ld.w		tmp, TE2[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TE3[\s2:b << 2]	
+	ld.w		\s1, TE0[\s2:t << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TE1[\s2:u << 2]		
+	eor		\t3, \s0
+	eor		\t2, \s1
+	ld.w		\s0, TE3[\s3:b << 2]	
+	ld.w		\s1, TE0[\s3:t << 2]		
+	eor		\t1, tmp		
+
+	ld.w		\s2, TE1[\s3:u << 2]		
+	eor		\t0, \s0
+	ld.w		tmp, TE2[\s3:l << 2]			
+	eor		\t3, \s1
+	eor		\t2, \s2
+	eor		\t1, tmp		
+	sub		RK, -32
+	.endm
+		
+	.macro	RoundEvenEncrypt s0, s1, s2, s3, t0, t1, t2, t3
+		
+	ld.w		\t0, TE0[\s0:t << 2]
+	ld.w		\t3, TE1[\s0:u << 2]
+	ld.w		\t2, TE2[\s0:l << 2]
+	ld.w		tmp, RK[0]
+	ld.w		\t1, TE3[\s0:b << 2]
+
+	ld.w		\s0, TE1[\s1:u << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TE2[\s1:l << 2]
+	eor		\t0, \s0
+	ld.w		\s0, RK[12]
+	eor		\t3, tmp
+	ld.w		tmp, TE3[\s1:b << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[8]
+	eor		\t2, tmp
+	ld.w		tmp, TE0[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[4]
+	eor		\t1, tmp
+	ld.w		tmp, TE2[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TE3[\s2:b << 2]	
+	ld.w		\s1, TE0[\s2:t << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TE1[\s2:u << 2]		
+	eor		\t3, \s0
+	eor		\t2, \s1
+	ld.w		\s0, TE3[\s3:b << 2]	
+	ld.w		\s1, TE0[\s3:t << 2]		
+	eor		\t1, tmp		
+
+	ld.w		\s2, TE1[\s3:u << 2]		
+	eor		\t0, \s0
+	ld.w		tmp, TE2[\s3:l << 2]			
+	eor		\t3, \s1
+	eor		\t2, \s2
+	eor		\t1, tmp		
+	.endm	
+	
+	.macro	RoundLastEncrypt s0, s1, s2, s3, t0, t1, t2, t3
+		
+	ld.w		\t0, TE4[\s0:t << 2]
+	ld.w		\t3, TE4[\s0:u << 2]
+	ld.w		\t2, TE4[\s0:l << 2]
+	ld.w		tmp, RK[0]
+	ld.w		\t1, TE4[\s0:b << 2]
+	andh		\t0, 0xFF00, COH
+	andh		\t3, 0x00FF, COH
+	andl		\t2, 0xFF00, COH
+	andl		\t1, 0x00FF, COH
+			
+	ld.w		\s0, TE4[\s1:u << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TE4[\s1:l << 2]
+	andh		\s0, 0x00FF, COH 
+	eor		\t0, \s0
+	ld.w		\s0, RK[12]
+	andl		tmp, 0xFF00, COH 
+	eor		\t3, tmp
+	ld.w		tmp, TE4[\s1:b << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[8]
+	andl		tmp, 0x00FF, COH 
+	eor		\t2, tmp
+	ld.w		tmp, TE4[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[4]
+	andh		tmp, 0xFF00, COH 
+	eor		\t1, tmp
+	ld.w		tmp, TE4[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TE4[\s2:b << 2]	
+	ld.w		\s1, TE4[\s2:t << 2]
+
+	andl		tmp, 0xFF00, COH 
+	eor		\t0, tmp
+	ld.w		tmp, TE4[\s2:u << 2]		
+	andl		\s0, 0x00FF, COH 
+	eor		\t3, \s0
+	andh		\s1, 0xFF00, COH 
+	eor		\t2, \s1
+	ld.w		\s0, TE4[\s3:b << 2]	
+	ld.w		\s1, TE4[\s3:t << 2]		
+	andh		tmp, 0x00FF, COH 
+	eor		\t1, tmp		
+
+	ld.w		\s2, TE4[\s3:u << 2]		
+	andl		\s0, 0x00FF, COH 
+	eor		\t0, \s0
+	ld.w		tmp, TE4[\s3:l << 2]			
+	andh		\s1, 0xFF00, COH 
+	eor		\t3, \s1
+	andh		\s2, 0x00FF, COH 
+	eor		\t2, \s2
+	andl		tmp, 0xFF00, COH 
+	eor		\t1, tmp		
+	.endm	
+
+	.macro	RoundOddDecrypt	s0, s1, s2, s3, t0, t1, t2, t3
+		
+	ld.w		\t0, TD0[\s0:t << 2]
+	ld.w		\t3, TD3[\s0:b << 2]
+	ld.w		\t2, TD2[\s0:l << 2]
+	ld.w		tmp, RK[16]
+	ld.w		\t1, TD1[\s0:u << 2]
+
+	ld.w		\s0, TD3[\s1:b << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TD2[\s1:l << 2]
+	eor		\t0, \s0
+	ld.w		\s0, RK[28]
+	eor		\t3, tmp
+	ld.w		tmp, TD1[\s1:u << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[24]
+	eor		\t2, tmp
+	ld.w		tmp, TD0[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[20]
+	eor		\t1, tmp
+	ld.w		tmp, TD2[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TD1[\s2:u << 2]	
+	ld.w		\s1, TD0[\s2:t << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TD3[\s2:b << 2]		
+	eor		\t3, \s0
+	eor		\t2, \s1
+	ld.w		\s0, TD1[\s3:u << 2]	
+	ld.w		\s1, TD0[\s3:t << 2]		
+	eor		\t1, tmp		
+
+	ld.w		\s2, TD3[\s3:b << 2]		
+	eor		\t0, \s0
+	ld.w		tmp, TD2[\s3:l << 2]			
+	eor		\t3, \s1
+	eor		\t2, \s2
+	eor		\t1, tmp		
+	sub		RK, -32
+	.endm	
+		
+	.macro	RoundEvenDecrypt s0, s1, s2, s3, t0, t1, t2, t3
+		
+	ld.w		\t0, TD0[\s0:t << 2]
+	ld.w		\t3, TD3[\s0:b << 2]
+	ld.w		\t2, TD2[\s0:l << 2]
+	ld.w		tmp, RK[0]
+	ld.w		\t1, TD1[\s0:u << 2]
+
+	ld.w		\s0, TD3[\s1:b << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TD2[\s1:l << 2]
+	eor		\t0, \s0
+	ld.w		\s0, RK[12]
+	eor		\t3, tmp
+	ld.w		tmp, TD1[\s1:u << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[8]
+	eor		\t2, tmp
+	ld.w		tmp, TD0[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[4]
+	eor		\t1, tmp
+	ld.w		tmp, TD2[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TD1[\s2:u << 2]	
+	ld.w		\s1, TD0[\s2:t << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TD3[\s2:b << 2]		
+	eor		\t3, \s0
+	eor		\t2, \s1
+	ld.w		\s0, TD1[\s3:u << 2]	
+	ld.w		\s1, TD0[\s3:t << 2]		
+	eor		\t1, tmp		
+
+	ld.w		\s2, TD3[\s3:b << 2]		
+	eor		\t0, \s0
+	ld.w		tmp, TD2[\s3:l << 2]			
+	eor		\t3, \s1
+	eor		\t2, \s2
+	eor		\t1, tmp		
+	.endm
+		
+	.macro	RoundLastDecrypt s0, s1, s2, s3, t0, t1, t2, t3
+		
+	ld.w		\t0, TD4[\s0:t << 2]
+	ld.w		\t3, TD4[\s0:b << 2]
+	ld.w		\t2, TD4[\s0:l << 2]
+	ld.w		tmp, RK[0]
+	ld.w		\t1, TD4[\s0:u << 2]
+	andh		\t0, 0xFF00, COH
+	andl		\t3, 0x00FF, COH
+	andl		\t2, 0xFF00, COH
+	andh		\t1, 0x00FF, COH
+			
+	ld.w		\s0, TD4[\s1:b << 2]
+	eor		\t0, tmp
+	ld.w		tmp, TD4[\s1:l << 2]
+	andl		\s0, 0x00FF, COH 
+	eor		\t0, \s0
+	ld.w		\s0, RK[12]
+	andl		tmp, 0xFF00, COH 
+	eor		\t3, tmp
+	ld.w		tmp, TD4[\s1:u << 2]
+	eor		\t3, \s0
+	ld.w		\s0, RK[8]
+	andh		tmp, 0x00FF, COH 
+	eor		\t2, tmp
+	ld.w		tmp, TD4[\s1:t << 2]
+	eor		\t2, \s0
+	ld.w		\s0, RK[4]
+	andh		tmp, 0xFF00, COH 
+	eor		\t1, tmp
+	ld.w		tmp, TD4[\s2:l << 2]	
+	eor		\t1, \s0
+	 			
+	ld.w		\s0, TD4[\s2:u << 2]	
+	ld.w		\s1, TD4[\s2:t << 2]
+
+	andl		tmp, 0xFF00, COH 
+	eor		\t0, tmp
+	ld.w		tmp, TD4[\s2:b << 2]		
+	andh		\s0, 0x00FF, COH 
+	eor		\t3, \s0
+	andh		\s1, 0xFF00, COH 
+	eor		\t2, \s1
+	ld.w		\s0, TD4[\s3:u << 2]	
+	ld.w		\s1, TD4[\s3:t << 2]		
+	andl		tmp, 0x00FF, COH 
+	eor		\t1, tmp		
+
+	ld.w		\s2, TD4[\s3:b << 2]		
+	andh		\s0, 0x00FF, COH 
+	eor		\t0, \s0
+	ld.w		tmp, TD4[\s3:l << 2]			
+	andh		\s1, 0xFF00, COH 
+	eor		\t3, \s1
+	andl		\s2, 0x00FF, COH 
+	eor		\t2, \s2
+	andl		tmp, 0xFF00, COH 
+	eor		\t1, tmp		
+	.endm	
+
+
+	.text
+	.align 2
+/* void AES_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) */
+AES_encrypt:	
+	pushm		r0-r3, r4-r7, lr
+
+/*	s0 = GETU32(pt     ) ^ rk[0];
+	s1 = GETU32(pt +  4) ^ rk[1];
+	s2 = GETU32(pt +  8) ^ rk[2];
+	\s3 = GETU32(pt + 12) ^ rk[3]; */
+	ldm		RK, r0-r3	
+	lda.w		TE0, AES_Te0
+	ld.w		lr, r12[0]
+	lda.w		TE1, AES_Te1
+	eor		r3, lr		// r3 = *pt ^ rk[0] 
+	ld.w		lr, r12[4]
+	lda.w		TE2, AES_Te2
+	eor		r2, lr		// r2 = *(pt + 4) ^ rk[1]
+	ld.w		lr, r12[8]
+	lda.w		TE3, AES_Te3
+	eor		r1, lr		// r1 = *(pt + 8) ^ rk[2]
+	ld.w		lr, r12[12]
+
+	ld.w		r9, RK[4*4*(AES_MAXNR+1)]
+	st.w		--sp, r11	
+	eor		r0, lr		// r0 = *(pt + 12) ^ rk[3]
+	lsr		r9, 1
+	st.w		--sp, r9	
+
+encryption_rounds:
+	RoundOddEncrypt	r3, r2, r1, r0, r8, r9, r11, r12
+	ld.w		lr, sp[0]
+	sub		lr, 1
+	st.w		sp[0], lr
+	breq		last_encryption_round	
+	RoundEvenEncrypt r8, r9, r11, r12, r3, r2, r1, r0
+	rjmp		encryption_rounds
+	
+last_encryption_round:	
+	lda.w		TE4, AES_Te4
+	RoundLastEncrypt r8, r9, r11, r12, r3, r2, r1, r0
+	ld.w		lr, sp[4] // lr = out
+	sub		sp, -8
+	stm		lr, r0-r3
+	popm		r0-r3, r4-r7, pc
+	
+	
+/* void AES_decrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key) */
+AES_decrypt:	
+	pushm		r0-r3, r4-r7, lr
+
+/*	s0 = GETU32(pt     ) ^ rk[0];
+	s1 = GETU32(pt +  4) ^ rk[1];
+	s2 = GETU32(pt +  8) ^ rk[2];
+	s3 = GETU32(pt + 12) ^ rk[3];*/
+	ldm		RK, r0-r3	
+	lda.w		TD0, AES_Td0
+	ld.w		lr, r12[0]
+	lda.w		TD1, AES_Td1
+	eor		r3, lr		// r3 = *ct ^ rk[0] 
+	ld.w		lr, r12[4]
+	lda.w		TD2, AES_Td2
+	eor		r2, lr		// r2 = *(ct + 4) ^ rk[1]
+	ld.w		lr, r12[8]
+	lda.w		TD3, AES_Td3
+	eor		r1, r1, lr << 0	// r1 = *(ct + 8) ^ rk[2]
+	ld.w		lr, r12[12]
+
+	ld.w		r9, RK[4*4*(AES_MAXNR+1)]
+	st.w		--sp, r11	
+	eor		r0, lr		// r0 = *(ct + 12) ^ rk[3]
+	lsr		r9, 1
+	st.w		--sp, r9	
+
+decryption_rounds:
+	RoundOddDecrypt	r3, r2, r1, r0, r8, r9, r11, r12
+	ld.w		lr, sp[0]
+	sub		lr, 1
+	st.w		sp[0], lr
+	breq		last_decryption_round	
+	RoundEvenDecrypt r8, r9, r11, r12, r3, r2, r1, r0
+	rjmp		decryption_rounds
+	
+last_decryption_round:	
+	lda.w		TD4, AES_Td4
+	RoundLastDecrypt r8, r9, r11, r12, r3, r2, r1, r0
+	ld.w		lr, sp[4] // lr = out
+	sub		sp, -8
+	stm		lr, r0-r3
+	popm		r0-r3, r4-r7, pc
+			
+
+#ifdef AES_CTABLES_IN_DATA
+	.data
+#endif
+	.align	2
+	.global	AES_Te0
+	.type	AES_Te0,@object
+	.size   AES_Te0, 1024
+AES_Te0:	
+        .word    0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d
+        .word    0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554
+        .word    0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d
+        .word    0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a
+        .word    0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87
+        .word    0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b
+        .word    0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea
+        .word    0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b
+        .word    0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a
+        .word    0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f
+        .word    0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108
+        .word    0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f
+        .word    0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e
+        .word    0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5
+        .word    0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d
+        .word    0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f
+        .word    0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e
+        .word    0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb
+        .word    0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce
+        .word    0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497
+        .word    0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c
+        .word    0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed
+        .word    0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b
+        .word    0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a
+        .word    0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16
+        .word    0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594
+        .word    0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81
+        .word    0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3
+        .word    0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a
+        .word    0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504
+        .word    0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163
+        .word    0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d
+        .word    0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f
+        .word    0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739
+        .word    0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47
+        .word    0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395
+        .word    0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f
+        .word    0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883
+        .word    0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c
+        .word    0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76
+        .word    0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e
+        .word    0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4
+        .word    0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6
+        .word    0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b
+        .word    0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7
+        .word    0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0
+        .word    0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25
+        .word    0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818
+        .word    0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72
+        .word    0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651
+        .word    0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21
+        .word    0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85
+        .word    0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa
+        .word    0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12
+        .word    0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0
+        .word    0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9
+        .word    0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133
+        .word    0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7
+        .word    0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920
+        .word    0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a
+        .word    0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17
+        .word    0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8
+        .word    0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11
+        .word    0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a
+
+	.global	AES_Te1
+	.type	AES_Te1,@object
+	.size   AES_Te1, 1024
+AES_Te1:	
+        .word    0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b
+        .word    0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5
+        .word    0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b
+        .word    0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676
+        .word    0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d
+        .word    0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0
+        .word    0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf
+        .word    0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0
+        .word    0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626
+        .word    0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc
+        .word    0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1
+        .word    0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515
+        .word    0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3
+        .word    0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a
+        .word    0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2
+        .word    0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575
+        .word    0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a
+        .word    0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0
+        .word    0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3
+        .word    0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484
+        .word    0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded
+        .word    0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b
+        .word    0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939
+        .word    0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf
+        .word    0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb
+        .word    0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585
+        .word    0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f
+        .word    0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8
+        .word    0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f
+        .word    0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5
+        .word    0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121
+        .word    0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2
+        .word    0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec
+        .word    0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717
+        .word    0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d
+        .word    0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373
+        .word    0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc
+        .word    0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888
+        .word    0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414
+        .word    0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb
+        .word    0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a
+        .word    0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c
+        .word    0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262
+        .word    0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979
+        .word    0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d
+        .word    0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9
+        .word    0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea
+        .word    0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808
+        .word    0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e
+        .word    0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6
+        .word    0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f
+        .word    0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a
+        .word    0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666
+        .word    0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e
+        .word    0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9
+        .word    0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e
+        .word    0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111
+        .word    0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494
+        .word    0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9
+        .word    0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf
+        .word    0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d
+        .word    0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868
+        .word    0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f
+        .word    0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616
+
+	.global	AES_Te2
+	.type	AES_Te2,@object
+	.size   AES_Te2, 1024
+AES_Te2:	
+        .word    0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b
+        .word    0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5
+        .word    0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b
+        .word    0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76
+        .word    0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d
+        .word    0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0
+        .word    0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af
+        .word    0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0
+        .word    0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26
+        .word    0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc
+        .word    0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1
+        .word    0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15
+        .word    0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3
+        .word    0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a
+        .word    0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2
+        .word    0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75
+        .word    0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a
+        .word    0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0
+        .word    0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3
+        .word    0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384
+        .word    0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed
+        .word    0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b
+        .word    0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239
+        .word    0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf
+        .word    0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb
+        .word    0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185
+        .word    0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f
+        .word    0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8
+        .word    0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f
+        .word    0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5
+        .word    0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221
+        .word    0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2
+        .word    0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec
+        .word    0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17
+        .word    0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d
+        .word    0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673
+        .word    0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc
+        .word    0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88
+        .word    0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814
+        .word    0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb
+        .word    0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a
+        .word    0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c
+        .word    0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462
+        .word    0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279
+        .word    0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d
+        .word    0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9
+        .word    0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea
+        .word    0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008
+        .word    0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e
+        .word    0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6
+        .word    0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f
+        .word    0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a
+        .word    0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66
+        .word    0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e
+        .word    0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9
+        .word    0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e
+        .word    0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211
+        .word    0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394
+        .word    0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9
+        .word    0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df
+        .word    0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d
+        .word    0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068
+        .word    0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f
+        .word    0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16
+
+	.global	AES_Te3
+	.type	AES_Te3,@object
+	.size   AES_Te3, 1024
+AES_Te3:	
+        .word    0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6
+        .word    0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491
+        .word    0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56
+        .word    0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec
+        .word    0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa
+        .word    0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb
+        .word    0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45
+        .word    0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b
+        .word    0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c
+        .word    0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83
+        .word    0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9
+        .word    0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a
+        .word    0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d
+        .word    0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f
+        .word    0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf
+        .word    0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea
+        .word    0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34
+        .word    0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b
+        .word    0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d
+        .word    0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713
+        .word    0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1
+        .word    0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6
+        .word    0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72
+        .word    0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85
+        .word    0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed
+        .word    0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411
+        .word    0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe
+        .word    0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b
+        .word    0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05
+        .word    0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1
+        .word    0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342
+        .word    0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf
+        .word    0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3
+        .word    0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e
+        .word    0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a
+        .word    0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6
+        .word    0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3
+        .word    0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b
+        .word    0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28
+        .word    0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad
+        .word    0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14
+        .word    0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8
+        .word    0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4
+        .word    0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2
+        .word    0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da
+        .word    0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049
+        .word    0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf
+        .word    0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810
+        .word    0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c
+        .word    0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197
+        .word    0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e
+        .word    0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f
+        .word    0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc
+        .word    0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c
+        .word    0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069
+        .word    0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927
+        .word    0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322
+        .word    0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733
+        .word    0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9
+        .word    0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5
+        .word    0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a
+        .word    0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0
+        .word    0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e
+        .word    0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c
+
+	.global	AES_Te4
+	.type	AES_Te4,@object
+	.size   AES_Te4, 1024
+AES_Te4:	
+        .word    0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b
+        .word    0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5
+        .word    0x30303030, 0x01010101, 0x67676767, 0x2b2b2b2b
+        .word    0xfefefefe, 0xd7d7d7d7, 0xabababab, 0x76767676
+        .word    0xcacacaca, 0x82828282, 0xc9c9c9c9, 0x7d7d7d7d
+        .word    0xfafafafa, 0x59595959, 0x47474747, 0xf0f0f0f0
+        .word    0xadadadad, 0xd4d4d4d4, 0xa2a2a2a2, 0xafafafaf
+        .word    0x9c9c9c9c, 0xa4a4a4a4, 0x72727272, 0xc0c0c0c0
+        .word    0xb7b7b7b7, 0xfdfdfdfd, 0x93939393, 0x26262626
+        .word    0x36363636, 0x3f3f3f3f, 0xf7f7f7f7, 0xcccccccc
+        .word    0x34343434, 0xa5a5a5a5, 0xe5e5e5e5, 0xf1f1f1f1
+        .word    0x71717171, 0xd8d8d8d8, 0x31313131, 0x15151515
+        .word    0x04040404, 0xc7c7c7c7, 0x23232323, 0xc3c3c3c3
+        .word    0x18181818, 0x96969696, 0x05050505, 0x9a9a9a9a
+        .word    0x07070707, 0x12121212, 0x80808080, 0xe2e2e2e2
+        .word    0xebebebeb, 0x27272727, 0xb2b2b2b2, 0x75757575
+        .word    0x09090909, 0x83838383, 0x2c2c2c2c, 0x1a1a1a1a
+        .word    0x1b1b1b1b, 0x6e6e6e6e, 0x5a5a5a5a, 0xa0a0a0a0
+        .word    0x52525252, 0x3b3b3b3b, 0xd6d6d6d6, 0xb3b3b3b3
+        .word    0x29292929, 0xe3e3e3e3, 0x2f2f2f2f, 0x84848484
+        .word    0x53535353, 0xd1d1d1d1, 0x00000000, 0xedededed
+        .word    0x20202020, 0xfcfcfcfc, 0xb1b1b1b1, 0x5b5b5b5b
+        .word    0x6a6a6a6a, 0xcbcbcbcb, 0xbebebebe, 0x39393939
+        .word    0x4a4a4a4a, 0x4c4c4c4c, 0x58585858, 0xcfcfcfcf
+        .word    0xd0d0d0d0, 0xefefefef, 0xaaaaaaaa, 0xfbfbfbfb
+        .word    0x43434343, 0x4d4d4d4d, 0x33333333, 0x85858585
+        .word    0x45454545, 0xf9f9f9f9, 0x02020202, 0x7f7f7f7f
+        .word    0x50505050, 0x3c3c3c3c, 0x9f9f9f9f, 0xa8a8a8a8
+        .word    0x51515151, 0xa3a3a3a3, 0x40404040, 0x8f8f8f8f
+        .word    0x92929292, 0x9d9d9d9d, 0x38383838, 0xf5f5f5f5
+        .word    0xbcbcbcbc, 0xb6b6b6b6, 0xdadadada, 0x21212121
+        .word    0x10101010, 0xffffffff, 0xf3f3f3f3, 0xd2d2d2d2
+        .word    0xcdcdcdcd, 0x0c0c0c0c, 0x13131313, 0xecececec
+        .word    0x5f5f5f5f, 0x97979797, 0x44444444, 0x17171717
+        .word    0xc4c4c4c4, 0xa7a7a7a7, 0x7e7e7e7e, 0x3d3d3d3d
+        .word    0x64646464, 0x5d5d5d5d, 0x19191919, 0x73737373
+        .word    0x60606060, 0x81818181, 0x4f4f4f4f, 0xdcdcdcdc
+        .word    0x22222222, 0x2a2a2a2a, 0x90909090, 0x88888888
+        .word    0x46464646, 0xeeeeeeee, 0xb8b8b8b8, 0x14141414
+        .word    0xdededede, 0x5e5e5e5e, 0x0b0b0b0b, 0xdbdbdbdb
+        .word    0xe0e0e0e0, 0x32323232, 0x3a3a3a3a, 0x0a0a0a0a
+        .word    0x49494949, 0x06060606, 0x24242424, 0x5c5c5c5c
+        .word    0xc2c2c2c2, 0xd3d3d3d3, 0xacacacac, 0x62626262
+        .word    0x91919191, 0x95959595, 0xe4e4e4e4, 0x79797979
+        .word    0xe7e7e7e7, 0xc8c8c8c8, 0x37373737, 0x6d6d6d6d
+        .word    0x8d8d8d8d, 0xd5d5d5d5, 0x4e4e4e4e, 0xa9a9a9a9
+        .word    0x6c6c6c6c, 0x56565656, 0xf4f4f4f4, 0xeaeaeaea
+        .word    0x65656565, 0x7a7a7a7a, 0xaeaeaeae, 0x08080808
+        .word    0xbabababa, 0x78787878, 0x25252525, 0x2e2e2e2e
+        .word    0x1c1c1c1c, 0xa6a6a6a6, 0xb4b4b4b4, 0xc6c6c6c6
+        .word    0xe8e8e8e8, 0xdddddddd, 0x74747474, 0x1f1f1f1f
+        .word    0x4b4b4b4b, 0xbdbdbdbd, 0x8b8b8b8b, 0x8a8a8a8a
+        .word    0x70707070, 0x3e3e3e3e, 0xb5b5b5b5, 0x66666666
+        .word    0x48484848, 0x03030303, 0xf6f6f6f6, 0x0e0e0e0e
+        .word    0x61616161, 0x35353535, 0x57575757, 0xb9b9b9b9
+        .word    0x86868686, 0xc1c1c1c1, 0x1d1d1d1d, 0x9e9e9e9e
+        .word    0xe1e1e1e1, 0xf8f8f8f8, 0x98989898, 0x11111111
+        .word    0x69696969, 0xd9d9d9d9, 0x8e8e8e8e, 0x94949494
+        .word    0x9b9b9b9b, 0x1e1e1e1e, 0x87878787, 0xe9e9e9e9
+        .word    0xcececece, 0x55555555, 0x28282828, 0xdfdfdfdf
+        .word    0x8c8c8c8c, 0xa1a1a1a1, 0x89898989, 0x0d0d0d0d
+        .word    0xbfbfbfbf, 0xe6e6e6e6, 0x42424242, 0x68686868
+        .word    0x41414141, 0x99999999, 0x2d2d2d2d, 0x0f0f0f0f
+        .word    0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616
+
+	.global	AES_Td0
+	.type	AES_Td0,@object
+	.size   AES_Td0, 1024
+AES_Td0:	
+        .word    0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96
+        .word    0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393
+        .word    0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25
+        .word    0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f
+        .word    0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1
+        .word    0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6
+        .word    0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da
+        .word    0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844
+        .word    0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd
+        .word    0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4
+        .word    0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45
+        .word    0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94
+        .word    0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7
+        .word    0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a
+        .word    0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5
+        .word    0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c
+        .word    0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1
+        .word    0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a
+        .word    0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75
+        .word    0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051
+        .word    0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46
+        .word    0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff
+        .word    0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77
+        .word    0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb
+        .word    0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000
+        .word    0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e
+        .word    0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927
+        .word    0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a
+        .word    0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e
+        .word    0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16
+        .word    0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d
+        .word    0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8
+        .word    0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd
+        .word    0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34
+        .word    0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163
+        .word    0xd731dcca, 0x42638510, 0x13972240, 0x84c61120
+        .word    0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d
+        .word    0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0
+        .word    0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422
+        .word    0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef
+        .word    0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36
+        .word    0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4
+        .word    0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662
+        .word    0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5
+        .word    0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3
+        .word    0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b
+        .word    0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8
+        .word    0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6
+        .word    0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6
+        .word    0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0
+        .word    0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815
+        .word    0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f
+        .word    0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df
+        .word    0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f
+        .word    0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e
+        .word    0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713
+        .word    0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89
+        .word    0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c
+        .word    0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf
+        .word    0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86
+        .word    0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f
+        .word    0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541
+        .word    0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190
+        .word    0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742
+
+	.global	AES_Td1
+	.type	AES_Td1,@object
+	.size   AES_Td1, 1024
+AES_Td1:	
+        .word    0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e
+        .word    0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303
+        .word    0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c
+        .word    0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3
+        .word    0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0
+        .word    0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9
+        .word    0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259
+        .word    0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8
+        .word    0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971
+        .word    0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a
+        .word    0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f
+        .word    0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b
+        .word    0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8
+        .word    0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab
+        .word    0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708
+        .word    0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682
+        .word    0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2
+        .word    0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe
+        .word    0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb
+        .word    0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10
+        .word    0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd
+        .word    0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015
+        .word    0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e
+        .word    0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee
+        .word    0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000
+        .word    0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72
+        .word    0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39
+        .word    0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e
+        .word    0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91
+        .word    0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a
+        .word    0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17
+        .word    0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9
+        .word    0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60
+        .word    0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e
+        .word    0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1
+        .word    0xcad731dc, 0x10426385, 0x40139722, 0x2084c611
+        .word    0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1
+        .word    0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3
+        .word    0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964
+        .word    0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390
+        .word    0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b
+        .word    0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf
+        .word    0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46
+        .word    0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af
+        .word    0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512
+        .word    0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb
+        .word    0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a
+        .word    0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8
+        .word    0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c
+        .word    0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266
+        .word    0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8
+        .word    0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6
+        .word    0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604
+        .word    0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551
+        .word    0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41
+        .word    0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647
+        .word    0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c
+        .word    0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1
+        .word    0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737
+        .word    0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db
+        .word    0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340
+        .word    0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95
+        .word    0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1
+        .word    0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857
+
+	.global	AES_Td2
+	.type	AES_Td2,@object
+	.size   AES_Td2, 1024
+AES_Td2:	
+        .word    0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27
+        .word    0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3
+        .word    0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502
+        .word    0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562
+        .word    0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe
+        .word    0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3
+        .word    0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552
+        .word    0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9
+        .word    0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9
+        .word    0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce
+        .word    0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253
+        .word    0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908
+        .word    0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b
+        .word    0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655
+        .word    0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337
+        .word    0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16
+        .word    0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69
+        .word    0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6
+        .word    0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6
+        .word    0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e
+        .word    0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6
+        .word    0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050
+        .word    0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9
+        .word    0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8
+        .word    0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000
+        .word    0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a
+        .word    0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d
+        .word    0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436
+        .word    0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b
+        .word    0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12
+        .word    0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b
+        .word    0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e
+        .word    0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f
+        .word    0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb
+        .word    0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4
+        .word    0xdccad731, 0x85104263, 0x22401397, 0x112084c6
+        .word    0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729
+        .word    0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1
+        .word    0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9
+        .word    0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233
+        .word    0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4
+        .word    0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad
+        .word    0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e
+        .word    0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3
+        .word    0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25
+        .word    0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b
+        .word    0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f
+        .word    0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15
+        .word    0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0
+        .word    0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2
+        .word    0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7
+        .word    0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791
+        .word    0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496
+        .word    0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665
+        .word    0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b
+        .word    0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6
+        .word    0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13
+        .word    0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47
+        .word    0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7
+        .word    0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844
+        .word    0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3
+        .word    0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d
+        .word    0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456
+        .word    0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8
+
+	.global	AES_Td3
+	.type	AES_Td3,@object
+	.size   AES_Td3, 1024
+AES_Td3:	
+        .word    0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a
+        .word    0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b
+        .word    0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5
+        .word    0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5
+        .word    0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d
+        .word    0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b
+        .word    0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95
+        .word    0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e
+        .word    0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27
+        .word    0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d
+        .word    0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562
+        .word    0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9
+        .word    0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752
+        .word    0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66
+        .word    0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3
+        .word    0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced
+        .word    0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e
+        .word    0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4
+        .word    0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4
+        .word    0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd
+        .word    0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d
+        .word    0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60
+        .word    0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767
+        .word    0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79
+        .word    0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000
+        .word    0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c
+        .word    0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736
+        .word    0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24
+        .word    0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b
+        .word    0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c
+        .word    0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12
+        .word    0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814
+        .word    0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3
+        .word    0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b
+        .word    0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8
+        .word    0x31dccad7, 0x63851042, 0x97224013, 0xc6112084
+        .word    0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7
+        .word    0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077
+        .word    0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247
+        .word    0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22
+        .word    0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698
+        .word    0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f
+        .word    0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254
+        .word    0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582
+        .word    0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf
+        .word    0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb
+        .word    0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883
+        .word    0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef
+        .word    0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629
+        .word    0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035
+        .word    0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533
+        .word    0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17
+        .word    0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4
+        .word    0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46
+        .word    0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb
+        .word    0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d
+        .word    0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb
+        .word    0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a
+        .word    0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73
+        .word    0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678
+        .word    0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2
+        .word    0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff
+        .word    0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064
+        .word    0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0
+
+	.global	AES_Td4
+	.type	AES_Td4,@object
+	.size   AES_Td4, 1024
+AES_Td4:	
+        .word    0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5
+        .word    0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838
+        .word    0xbfbfbfbf, 0x40404040, 0xa3a3a3a3, 0x9e9e9e9e
+        .word    0x81818181, 0xf3f3f3f3, 0xd7d7d7d7, 0xfbfbfbfb
+        .word    0x7c7c7c7c, 0xe3e3e3e3, 0x39393939, 0x82828282
+        .word    0x9b9b9b9b, 0x2f2f2f2f, 0xffffffff, 0x87878787
+        .word    0x34343434, 0x8e8e8e8e, 0x43434343, 0x44444444
+        .word    0xc4c4c4c4, 0xdededede, 0xe9e9e9e9, 0xcbcbcbcb
+        .word    0x54545454, 0x7b7b7b7b, 0x94949494, 0x32323232
+        .word    0xa6a6a6a6, 0xc2c2c2c2, 0x23232323, 0x3d3d3d3d
+        .word    0xeeeeeeee, 0x4c4c4c4c, 0x95959595, 0x0b0b0b0b
+        .word    0x42424242, 0xfafafafa, 0xc3c3c3c3, 0x4e4e4e4e
+        .word    0x08080808, 0x2e2e2e2e, 0xa1a1a1a1, 0x66666666
+        .word    0x28282828, 0xd9d9d9d9, 0x24242424, 0xb2b2b2b2
+        .word    0x76767676, 0x5b5b5b5b, 0xa2a2a2a2, 0x49494949
+        .word    0x6d6d6d6d, 0x8b8b8b8b, 0xd1d1d1d1, 0x25252525
+        .word    0x72727272, 0xf8f8f8f8, 0xf6f6f6f6, 0x64646464
+        .word    0x86868686, 0x68686868, 0x98989898, 0x16161616
+        .word    0xd4d4d4d4, 0xa4a4a4a4, 0x5c5c5c5c, 0xcccccccc
+        .word    0x5d5d5d5d, 0x65656565, 0xb6b6b6b6, 0x92929292
+        .word    0x6c6c6c6c, 0x70707070, 0x48484848, 0x50505050
+        .word    0xfdfdfdfd, 0xedededed, 0xb9b9b9b9, 0xdadadada
+        .word    0x5e5e5e5e, 0x15151515, 0x46464646, 0x57575757
+        .word    0xa7a7a7a7, 0x8d8d8d8d, 0x9d9d9d9d, 0x84848484
+        .word    0x90909090, 0xd8d8d8d8, 0xabababab, 0x00000000
+        .word    0x8c8c8c8c, 0xbcbcbcbc, 0xd3d3d3d3, 0x0a0a0a0a
+        .word    0xf7f7f7f7, 0xe4e4e4e4, 0x58585858, 0x05050505
+        .word    0xb8b8b8b8, 0xb3b3b3b3, 0x45454545, 0x06060606
+        .word    0xd0d0d0d0, 0x2c2c2c2c, 0x1e1e1e1e, 0x8f8f8f8f
+        .word    0xcacacaca, 0x3f3f3f3f, 0x0f0f0f0f, 0x02020202
+        .word    0xc1c1c1c1, 0xafafafaf, 0xbdbdbdbd, 0x03030303
+        .word    0x01010101, 0x13131313, 0x8a8a8a8a, 0x6b6b6b6b
+        .word    0x3a3a3a3a, 0x91919191, 0x11111111, 0x41414141
+        .word    0x4f4f4f4f, 0x67676767, 0xdcdcdcdc, 0xeaeaeaea
+        .word    0x97979797, 0xf2f2f2f2, 0xcfcfcfcf, 0xcececece
+        .word    0xf0f0f0f0, 0xb4b4b4b4, 0xe6e6e6e6, 0x73737373
+        .word    0x96969696, 0xacacacac, 0x74747474, 0x22222222
+        .word    0xe7e7e7e7, 0xadadadad, 0x35353535, 0x85858585
+        .word    0xe2e2e2e2, 0xf9f9f9f9, 0x37373737, 0xe8e8e8e8
+        .word    0x1c1c1c1c, 0x75757575, 0xdfdfdfdf, 0x6e6e6e6e
+        .word    0x47474747, 0xf1f1f1f1, 0x1a1a1a1a, 0x71717171
+        .word    0x1d1d1d1d, 0x29292929, 0xc5c5c5c5, 0x89898989
+        .word    0x6f6f6f6f, 0xb7b7b7b7, 0x62626262, 0x0e0e0e0e
+        .word    0xaaaaaaaa, 0x18181818, 0xbebebebe, 0x1b1b1b1b
+        .word    0xfcfcfcfc, 0x56565656, 0x3e3e3e3e, 0x4b4b4b4b
+        .word    0xc6c6c6c6, 0xd2d2d2d2, 0x79797979, 0x20202020
+        .word    0x9a9a9a9a, 0xdbdbdbdb, 0xc0c0c0c0, 0xfefefefe
+        .word    0x78787878, 0xcdcdcdcd, 0x5a5a5a5a, 0xf4f4f4f4
+        .word    0x1f1f1f1f, 0xdddddddd, 0xa8a8a8a8, 0x33333333
+        .word    0x88888888, 0x07070707, 0xc7c7c7c7, 0x31313131
+        .word    0xb1b1b1b1, 0x12121212, 0x10101010, 0x59595959
+        .word    0x27272727, 0x80808080, 0xecececec, 0x5f5f5f5f
+        .word    0x60606060, 0x51515151, 0x7f7f7f7f, 0xa9a9a9a9
+        .word    0x19191919, 0xb5b5b5b5, 0x4a4a4a4a, 0x0d0d0d0d
+        .word    0x2d2d2d2d, 0xe5e5e5e5, 0x7a7a7a7a, 0x9f9f9f9f
+        .word    0x93939393, 0xc9c9c9c9, 0x9c9c9c9c, 0xefefefef
+        .word    0xa0a0a0a0, 0xe0e0e0e0, 0x3b3b3b3b, 0x4d4d4d4d
+        .word    0xaeaeaeae, 0x2a2a2a2a, 0xf5f5f5f5, 0xb0b0b0b0
+        .word    0xc8c8c8c8, 0xebebebeb, 0xbbbbbbbb, 0x3c3c3c3c
+        .word    0x83838383, 0x53535353, 0x99999999, 0x61616161
+        .word    0x17171717, 0x2b2b2b2b, 0x04040404, 0x7e7e7e7e
+        .word    0xbabababa, 0x77777777, 0xd6d6d6d6, 0x26262626
+        .word    0xe1e1e1e1, 0x69696969, 0x14141414, 0x63636363
+        .word    0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d
+
Index: openssl-0.9.8g/crypto/aes/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/aes/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/aes/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -90,7 +90,7 @@
 	mv -f Makefile.new $(MAKEFILE)
 
 clean:
-	rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
+	rm -f asm/*.o *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
Index: openssl-0.9.8g/crypto/asn1/t_x509.c
===================================================================
--- openssl-0.9.8g.orig/crypto/asn1/t_x509.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/asn1/t_x509.c	2008-09-24 11:01:01.000000000 +0200
@@ -264,6 +264,10 @@
 	return(ret);
 	}
 
+#ifdef OPENSSL_NO_SHA
+#define SHA_DIGEST_LENGTH 20
+#endif
+
 int X509_ocspid_print (BIO *bp, X509 *x)
 	{
 	unsigned char *der=NULL ;
Index: openssl-0.9.8g/crypto/asn1/x_info.c
===================================================================
--- openssl-0.9.8g.orig/crypto/asn1/x_info.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/asn1/x_info.c	2008-09-24 11:01:01.000000000 +0200
@@ -73,7 +73,9 @@
 		return(NULL);
 		}
  
+#ifndef OPENSSL_NO_EVP
         ret->enc_cipher.cipher=NULL;
+#endif
         ret->enc_len=0;
         ret->enc_data=NULL;
  
Index: openssl-0.9.8g/crypto/bio/bss_conn.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bio/bss_conn.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bio/bss_conn.c	2008-09-24 11:01:01.000000000 +0200
@@ -63,7 +63,6 @@
 #include <openssl/bio.h>
 
 #ifndef OPENSSL_NO_SOCK
-
 #ifdef OPENSSL_SYS_WIN16
 #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */
 #else
Index: openssl-0.9.8g/crypto/bio/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/bio/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bio/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -170,13 +170,6 @@
 bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 bss_conn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 bss_conn.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_conn.c
-bss_dgram.o: ../../e_os.h ../../include/openssl/bio.h
-bss_dgram.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-bss_dgram.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
-bss_dgram.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
-bss_dgram.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-bss_dgram.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-bss_dgram.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_dgram.c
 bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
 bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
Index: openssl-0.9.8g/crypto/bn/bn_asm.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_asm.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_asm.c	2008-09-24 11:01:01.000000000 +0200
@@ -219,7 +219,6 @@
 #endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
 
 #if defined(BN_LLONG) && defined(BN_DIV2W)
-
 BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
 	{
 	return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
@@ -821,17 +820,16 @@
 	r[7]=c2;
 	}
 #else /* !BN_MUL_COMBA */
-
 /* hmm... is it faster just to do a multiply? */
 #undef bn_sqr_comba4
-void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a)
+void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
 	{
 	BN_ULONG t[8];
 	bn_sqr_normal(r,a,4,t);
 	}
 
 #undef bn_sqr_comba8
-void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a)
+void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
 	{
 	BN_ULONG t[16];
 	bn_sqr_normal(r,a,8,t);
Index: openssl-0.9.8g/crypto/bn/bn_div.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_div.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_div.c	2008-09-24 11:01:01.000000000 +0200
@@ -187,10 +187,12 @@
 	BN_ULONG d0,d1;
 	int num_n,div_n;
 
+#ifndef BN_NO_CONSTTIME
 	if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0))
 		{
 		return BN_div_no_branch(dv, rm, num, divisor, ctx);
 		}
+#endif
 
 	bn_check_top(dv);
 	bn_check_top(rm);
Index: openssl-0.9.8g/crypto/bn/bn_exp.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_exp.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_exp.c	2008-09-24 11:01:01.000000000 +0200
@@ -379,11 +379,12 @@
 	BIGNUM *val[TABLE_SIZE];
 	BN_MONT_CTX *mont=NULL;
 
+#ifndef BN_NO_CONSTTIME
 	if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)
 		{
 		return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);
 		}
-
+#endif
 	bn_check_top(a);
 	bn_check_top(p);
 	bn_check_top(m);
Index: openssl-0.9.8g/crypto/bn/bn_gcd.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_gcd.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_gcd.c	2008-09-24 11:01:01.000000000 +0200
@@ -212,10 +212,12 @@
 	BIGNUM *ret=NULL;
 	int sign;
 
+#ifndef BN_NO_CONSTTIME
 	if ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(n, BN_FLG_CONSTTIME) != 0))
 		{
 		return BN_mod_inverse_no_branch(in, a, n, ctx);
 		}
+#endif
 
 	bn_check_top(a);
 	bn_check_top(n);
Index: openssl-0.9.8g/crypto/bn/bn.h
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn.h	2008-09-24 11:01:01.000000000 +0200
@@ -94,9 +94,15 @@
 /* #define BN_DEBUG */
 /* #define BN_DEBUG_RAND */
 
+#ifndef BN_NO_MUL_COMBA
 #define BN_MUL_COMBA
+#endif
+#ifndef BN_NO_SQR_COMBA
 #define BN_SQR_COMBA
+#endif
+#ifndef BN_NO_RECURSION
 #define BN_RECURSION
+#endif
 
 /* This next option uses the C libraries (2 word)/(1 word) function.
  * If it is not defined, I use my C version (which is slower).
@@ -219,6 +225,7 @@
 #endif
 
 #ifdef EIGHT_BIT
+#error
 #ifndef BN_DIV2W
 #define BN_DIV2W
 #endif
@@ -406,7 +413,11 @@
 int	BN_rand_range(BIGNUM *rnd, BIGNUM *range);
 int	BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
 int	BN_num_bits(const BIGNUM *a);
+#if defined(__GNUC__)
+#define BN_num_bits_word(w) (BN_BITS2 - __builtin_clz(w)) 
+#else
 int	BN_num_bits_word(BN_ULONG);
+#endif
 BIGNUM *BN_new(void);
 void	BN_init(BIGNUM *);
 void	BN_clear_free(BIGNUM *a);
Index: openssl-0.9.8g/crypto/bn/bn_lcl.h
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_lcl.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_lcl.h	2008-09-24 11:01:01.000000000 +0200
@@ -301,6 +301,36 @@
 #endif
 
 #ifdef BN_LLONG
+#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) && defined(__AVR32__)
+#define mul_add(r,a,w,c) {                      \
+    BN_ULLONG t;                                  \
+    asm ( "add    %0, %1, %2\n"                   \
+          "srcs   %m0\n"                          \
+          "macu.d %0, %3, %4\n"                   \
+          : "=&r"(t)                              \
+          : "r"(r), "r"(c), "r"(w), "r"(a)        \
+          : "cc");                                \
+    (r)= Lw(t);                                   \
+    (c)= Hw(t);                                   \
+ }
+  
+#define mul(r,a,w,c) {                          \
+    BN_ULLONG t = c;                            \
+    asm ( "macu.d %0, %1, %2\n"                 \
+          : "+r"(t)                            \
+          : "r"(w), "r"(a));                    \
+    (r)= Lw(t);                                 \
+    (c)= Hw(t);                                 \
+  }
+  
+#define sqr(r0,r1,a) {                          \
+    BN_ULLONG t;                                \
+    t=(BN_ULLONG)(a)*(a);                       \
+    (r0)=Lw(t);                                 \
+    (r1)=Hw(t);                                 \
+  }
+
+#else
 #define mul_add(r,a,w,c) { \
 	BN_ULLONG t; \
 	t=(BN_ULLONG)w * (a) + (r) + (c); \
@@ -310,7 +340,7 @@
 
 #define mul(r,a,w,c) { \
 	BN_ULLONG t; \
-	t=(BN_ULLONG)w * (a) + (c); \
+	t=(BN_ULLONG)w * (a) + (c);             \
 	(r)= Lw(t); \
 	(c)= Hw(t); \
 	}
@@ -322,6 +352,7 @@
 	(r1)=Hw(t); \
 	}
 
+#endif
 #elif defined(BN_UMULT_LOHI)
 #define mul_add(r,a,w,c) {		\
 	BN_ULONG high,low,ret,tmp=(a);	\
Index: openssl-0.9.8g/crypto/bn/bn_lib.c
===================================================================
--- openssl-0.9.8g.orig/crypto/bn/bn_lib.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/bn/bn_lib.c	2008-09-24 11:01:01.000000000 +0200
@@ -158,6 +158,7 @@
 	return(data);
 	}
 
+#ifndef BN_num_bits_word
 int BN_num_bits_word(BN_ULONG l)
 	{
 	static const char bits[256]={
@@ -244,6 +245,7 @@
 			}
 		}
 	}
+#endif
 
 int BN_num_bits(const BIGNUM *a)
 	{
Index: openssl-0.9.8g/crypto/conf/conf.h
===================================================================
--- openssl-0.9.8g.orig/crypto/conf/conf.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/conf/conf.h	2008-09-24 11:01:01.000000000 +0200
@@ -121,13 +121,14 @@
 LHASH *CONF_load(LHASH *conf,const char *file,long *eline);
 #ifndef OPENSSL_NO_FP_API
 LHASH *CONF_load_fp(LHASH *conf, FILE *fp,long *eline);
+int CONF_dump_fp(LHASH *conf, FILE *out);
+int NCONF_dump_fp(const CONF *conf, FILE *out);
 #endif
 LHASH *CONF_load_bio(LHASH *conf, BIO *bp,long *eline);
 STACK_OF(CONF_VALUE) *CONF_get_section(LHASH *conf,const char *section);
 char *CONF_get_string(LHASH *conf,const char *group,const char *name);
 long CONF_get_number(LHASH *conf,const char *group,const char *name);
 void CONF_free(LHASH *conf);
-int CONF_dump_fp(LHASH *conf, FILE *out);
 int CONF_dump_bio(LHASH *conf, BIO *out);
 
 void OPENSSL_config(const char *config_name);
@@ -161,7 +162,6 @@
 char *NCONF_get_string(const CONF *conf,const char *group,const char *name);
 int NCONF_get_number_e(const CONF *conf,const char *group,const char *name,
 		       long *result);
-int NCONF_dump_fp(const CONF *conf, FILE *out);
 int NCONF_dump_bio(const CONF *conf, BIO *out);
 
 #if 0 /* The following function has no error checking,
Index: openssl-0.9.8g/crypto/cryptlib.c
===================================================================
--- openssl-0.9.8g.orig/crypto/cryptlib.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/cryptlib.c	2008-09-24 11:01:01.000000000 +0200
@@ -68,7 +68,7 @@
  * 
  * Copyright remains Eric Young's, and as such any Copyright notices in
  * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
+5~ * If this package is used in a product, Eric Young should be given attribution
  * as the author of the parts of the library used.
  * This can be in the form of a textual message at program startup or
  * in documentation (online or textual) provided with the package.
@@ -740,9 +740,11 @@
 void OPENSSL_showfatal (const char *fmta,...)
 { va_list ap;
 
+#ifndef OPENSSL_NO_STDIO
     va_start (ap,fmta);
     vfprintf (stderr,fmta,ap);
     va_end (ap);
+#endif
 }
 int OPENSSL_isservice (void) { return 0; }
 #endif
@@ -755,4 +757,8 @@
 	abort();
 	}
 
-void *OPENSSL_stderr(void)	{ return stderr; }
+void *OPENSSL_stderr(void)	{ 
+#ifndef OPENSSL_NO_STDIO
+  return stderr; 
+#endif
+}
Index: openssl-0.9.8g/crypto/des/asm/des-avr32.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/crypto/des/asm/des-avr32.S	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,309 @@
+	.global	DES_encrypt1
+	.global	DES_encrypt2	
+	.global	DES_encrypt3	
+	.global	DES_decrypt3	
+			
+	.macro	DesEncrypt L, R, s, S, u /*hi*/, t /*lo*/, tmp, mask, to_u, to_t, spt0, spt1
+	ld.d	\t, \s[\S<<3]
+	eor	\u, \R
+	eor	\t, \R
+	lsl	\tmp, \t, 28
+	or	\t, \tmp, \t >> 4
+	and	\u, \mask, \u >> 2	
+	and	\t, \mask, \t >> 2	
+	or	\u, \to_u	
+	or	\t, \to_t	
+	ld.w	\tmp, \spt0[\u:b << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt0[\u:l << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt1[\u:u << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt1[\u:t << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt0[\t:b << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt0[\t:l << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt1[\t:u << 2]
+	eor	\L, \tmp
+	ld.w	\tmp, \spt1[\t:t << 2]
+	eor	\L, \tmp
+	.endm
+	
+	.macro	PermOp a, b, tmp, n, m
+	eor	\tmp, \b, \a >> \n
+	andh	\tmp, hi(\m)
+	andl	\tmp, lo(\m)
+	eor	\b, \tmp
+	eor	\a, \a, \tmp << \n
+	.endm		
+
+	.macro IP l, r, tmp
+	PermOp		\r, \l, \tmp,  4, 0x0f0f0f0f	
+	PermOp		\l, \r, \tmp, 16, 0x0000ffff	
+	PermOp		\r, \l, \tmp,  2, 0x33333333
+	PermOp		\l, \r, \tmp,  8, 0x00ff00ff	
+	PermOp		\r, \l, \tmp,  1, 0x55555555	
+	.endm
+
+	.macro FP l, r, tmp
+	PermOp		\l, \r, \tmp,  1, 0x55555555	
+	PermOp		\r, \l, \tmp,  8, 0x00ff00ff	
+	PermOp		\l, \r, \tmp,  2, 0x33333333
+	PermOp		\r, \l, \tmp, 16, 0x0000ffff	
+	PermOp		\l, \r, \tmp,  4, 0x0f0f0f0f	
+	.endm
+	
+	.text
+	.align 2
+/* void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) */
+DES_encrypt1:	
+	pushm		r0-r3, r4-r7, lr
+	
+	/*	
+	r=data[0];
+	l=data[1];
+	*/
+	ld.d		r8, r12[0] /* r8 = l, r9 = r */
+
+	/* 
+	IP(r,l); 
+	*/
+	IP	r9, r8, r0
+
+	/*
+	r=ROTATE(r,29)&0xffffffffL;
+	l=ROTATE(l,29)&0xffffffffL;
+	*/
+	lsl		r0, r8, 3
+	or		r8, r0, r8 >> 29  		
+	lsl		r0, r9, 3
+	or		r9, r0, r9 >> 29  		
+
+	/* Setup mask and table offset values. */
+	mov		r3, 0x3f3f
+	or		r3, r3, r3 << 16
+	mov		r4, (2 << 14) | (0 << 6)
+	or		r4, r4, r4 << 16
+	mov		r5, (3 << 14) | (1 << 6)
+	or		r5, r5, r5 << 16
+
+	/* Load DES_SPtrans pointer, we also need pointer to
+	   DES_SPtrans[4] */
+	lda.w		r6, DES_SPtrans
+	sub		r7, r6, -(64*4*4)
+	
+	cp.w		r10, 0
+	movne		lr, 1
+	movne		r10, 0
+	moveq		lr, -1
+	moveq		r10, 15
+	
+DES_encrypt1_loop:
+	DesEncrypt	/*L*/r8,/*R*/r9,/*s*/r11,/*S*/r10,/*u*/r1,/*t*/r0,/*tmp*/r2,/*mask*/r3,/*to_u*/r4,/*to_t*/r5,/*spt0*/r6,/*spt1*/r7  
+	add		r10, lr
+	DesEncrypt	/*R*/r9,/*L*/r8,/*s*/r11,/*S*/r10,/*u*/r1,/*t*/r0,/*tmp*/r2,/*mask*/r3,/*to_u*/r4,/*to_t*/r5,/*spt0*/r6,/*spt1*/r7  
+	add		r10, lr
+	/* If bit 4 is set it means that r10 is either -1 or 16
+	   in which case the algorithm is finished and the loop should exit. */	
+	bld		r10, 4
+	brne		DES_encrypt1_loop	
+
+	/*
+	r=ROTATE(r,3)&0xffffffffL;
+	l=ROTATE(l,3)&0xffffffffL;
+
+	Note we also move l and r into r1 and r0 respectively 	
+	*/
+	lsl		r1, r8, 29
+	or		r1, r1, r8 >> 3  		
+	lsl		r0, r9, 29
+	or		r0, r0, r9 >> 3  		
+
+	/* 
+	FP(r,l); 
+	*/
+	FP		r0, r1, r2
+
+	/*
+	data[0]=l;
+	data[1]=r;
+	*/
+	st.d		r12[0], r0			
+	popm		r0-r3, r4-r7, pc
+	
+	
+/*void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) */
+DES_encrypt2:	
+	pushm		r0-r3, r4-r7, lr
+	
+	/*	
+	r=data[0];
+	l=data[1];
+	*/
+	ld.d		r8, r12[0] /* r8 = l, r9 = r */
+
+	/*
+	r=ROTATE(r,29)&0xffffffffL;
+	l=ROTATE(l,29)&0xffffffffL;
+	*/
+	lsl		r0, r8, 3
+	or		r8, r0, r8 >> 29  		
+	lsl		r0, r9, 3
+	or		r9, r0, r9 >> 29  		
+
+	/* Setup mask and table offset values. */
+	mov		r3, 0x3f3f
+	or		r3, r3, r3 << 16
+	mov		r4, (2 << 14) | (0 << 6)
+	or		r4, r4, r4 << 16
+	mov		r5, (3 << 14) | (1 << 6)
+	or		r5, r5, r5 << 16
+
+	/* Load DES_SPtrans pointer, we also need pointer to
+	   DES_SPtrans[4] */
+	lda.w		r6, DES_SPtrans
+	sub		r7, r6, -(64*4*4)
+	
+	cp.w		r10, 0
+	movne		lr, 1
+	movne		r10, 0
+	moveq		lr, -1
+	moveq		r10, 15
+	
+DES_encrypt2_loop:
+	DesEncrypt	/*L*/r8,/*R*/r9,/*s*/r11,/*S*/r10,/*u*/r1,/*t*/r0,/*tmp*/r2,/*mask*/r3,/*to_u*/r4,/*to_t*/r5,/*spt0*/r6,/*spt1*/r7  
+	add		r10, lr
+	DesEncrypt	/*R*/r9,/*L*/r8,/*s*/r11,/*S*/r10,/*u*/r1,/*t*/r0,/*tmp*/r2,/*mask*/r3,/*to_u*/r4,/*to_t*/r5,/*spt0*/r6,/*spt1*/r7  
+	add		r10, lr
+	/* If bit 4 is set it means that r10 is either -1 or 16
+	   in which case the algorithm is finished and the loop should exit. */	
+	bld		r10, 4
+	brne		DES_encrypt2_loop	
+
+	/*
+	r=ROTATE(r,3)&0xffffffffL;
+	l=ROTATE(l,3)&0xffffffffL;
+
+	Note we also move l and r into r1 and r0 respectively 
+	*/	
+	lsl		r1, r8, 29
+	or		r1, r1, r8 >> 3  		
+	lsl		r0, r9, 29
+	or		r0, r0, r9 >> 3  		
+
+	/*
+	data[0]=l;
+	data[1]=r;
+	*/
+	st.d		r12[0], r0			
+	popm		r0-r3, r4-r7, pc
+
+
+/* void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
+		     DES_key_schedule *ks2, DES_key_schedule *ks3) */
+DES_encrypt3:	
+	pushm		r0-r3, lr
+	
+	/*	
+	l=data[0];
+	r=data[1];
+	*/
+	ld.d		r0, r12[0] /* r0 = r, r1 = l */
+
+	mov		r2, r10
+	mov		r3, r9
+
+	/* 
+	IP(l,r); 
+	*/
+	IP		r1, r0, lr
+		
+	/*	
+	data[0] = l;
+	data[1] = r;
+	*/
+	st.d		r12[0], r0	
+
+	mov		r10, 1
+	call		DES_encrypt2
+	mov		r10, 0
+	mov		r11, r2
+	call		DES_encrypt2
+	mov		r10, 1
+	mov		r11, r3
+	call		DES_encrypt2
+	
+	/*	
+	l=data[0];
+	r=data[1];
+	*/
+	ld.d		r0, r12[0] /* r0 = r, r1 = l */
+
+	/* 
+	FP(r,l); 
+	*/
+	FP		r0, r1, lr
+		
+	/*	
+	data[0] = l;
+	data[1] = r;
+	*/
+	st.d		r12[0], r0	
+
+	popm		r0-r3, pc
+
+/* void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
+		     DES_key_schedule *ks2, DES_key_schedule *ks3) */
+DES_decrypt3:	
+	pushm		r0-r3, lr
+	
+	/*	
+	l=data[0];
+	r=data[1];
+	*/
+	ld.d		r0, r12[0] /* r0 = r, r1 = l */
+
+	mov		r2, r10
+	mov		r3, r11
+	mov		r11, r9
+
+	/* 
+	IP(l,r); 
+	*/
+	IP		r1, r0, lr
+		
+	/*	
+	data[0] = l;
+	data[1] = r;
+	*/
+	st.d		r12[0], r0	
+
+	mov		r10, 0
+	call		DES_encrypt2
+	mov		r10, 1
+	mov		r11, r2
+	call		DES_encrypt2
+	mov		r10, 0
+	mov		r11, r3
+	call		DES_encrypt2
+	
+	/*	
+	l=data[0];
+	r=data[1];
+	*/
+	ld.d		r0, r12[0] /* r0 = r, r1 = l */
+
+	/* 
+	FP(r,l); 
+	*/
+	FP		r0, r1, lr
+		
+	/*	
+	data[0] = l;
+	data[1] = r;
+	*/
+	st.d		r12[0], r0	
+
+	popm		r0-r3, pc
Index: openssl-0.9.8g/crypto/des/asm/des_cbc.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ openssl-0.9.8g/crypto/des/asm/des_cbc.c	2008-09-24 11:01:01.000000000 +0200
@@ -0,0 +1,191 @@
+#include "../des_locl.h"
+
+#ifndef DES_DEFAULT_OPTIONS
+
+void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
+		     DES_key_schedule *_schedule, DES_cblock *ivec, int enc)
+	{
+	register DES_LONG tin0,tin1;
+	register DES_LONG tout0,tout1,xor0,xor1;
+	register long l=length;
+	DES_LONG tin[2];
+	unsigned char *iv;
+
+	iv = &(*ivec)[0];
+
+	if (enc)
+		{
+		c2l(iv,tout0);
+		c2l(iv,tout1);
+		for (l-=8; l>=0; l-=8)
+			{
+			c2l(in,tin0);
+			c2l(in,tin1);
+			tin0^=tout0; tin[0]=tin0;
+			tin1^=tout1; tin[1]=tin1;
+			DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
+			tout0=tin[0]; l2c(tout0,out);
+			tout1=tin[1]; l2c(tout1,out);
+			}
+		if (l != -8)
+			{
+			c2ln(in,tin0,tin1,l+8);
+			tin0^=tout0; tin[0]=tin0;
+			tin1^=tout1; tin[1]=tin1;
+			DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
+			tout0=tin[0]; l2c(tout0,out);
+			tout1=tin[1]; l2c(tout1,out);
+			}
+		iv = &(*ivec)[0];
+		l2c(tout0,iv);
+		l2c(tout1,iv);
+		}
+	else
+		{
+		c2l(iv,xor0);
+		c2l(iv,xor1);
+		for (l-=8; l>=0; l-=8)
+			{
+			c2l(in,tin0); tin[0]=tin0;
+			c2l(in,tin1); tin[1]=tin1;
+			DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
+			tout0=tin[0]^xor0;
+			tout1=tin[1]^xor1;
+			l2c(tout0,out);
+			l2c(tout1,out);
+			xor0=tin0;
+			xor1=tin1;
+			}
+		if (l != -8)
+			{
+			c2l(in,tin0); tin[0]=tin0;
+			c2l(in,tin1); tin[1]=tin1;
+			DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
+			tout0=tin[0]^xor0;
+			tout1=tin[1]^xor1;
+			l2cn(tout0,tout1,out,l+8);
+			xor0=tin0;
+			xor1=tin1;
+			}
+		iv = &(*ivec)[0];
+		l2c(xor0,iv);
+		l2c(xor1,iv);
+		}
+	tin0=tin1=tout0=tout1=xor0=xor1=0;
+	tin[0]=tin[1]=0;
+	}
+
+
+void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
+			  long length, DES_key_schedule *ks1,
+			  DES_key_schedule *ks2, DES_key_schedule *ks3,
+			  DES_cblock *ivec, int enc)
+	{
+	register DES_LONG tin0,tin1;
+	register DES_LONG tout0,tout1,xor0,xor1;
+	register const unsigned char *in;
+	unsigned char *out;
+	register long l=length;
+	DES_LONG tin[2];
+	unsigned char *iv;
+
+	in=input;
+	out=output;
+	iv = &(*ivec)[0];
+
+	if (enc)
+		{
+		c2l(iv,tout0);
+		c2l(iv,tout1);
+		for (l-=8; l>=0; l-=8)
+			{
+			c2l(in,tin0);
+			c2l(in,tin1);
+			tin0^=tout0;
+			tin1^=tout1;
+
+			tin[0]=tin0;
+			tin[1]=tin1;
+			DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
+			tout0=tin[0];
+			tout1=tin[1];
+
+			l2c(tout0,out);
+			l2c(tout1,out);
+			}
+		if (l != -8)
+			{
+			c2ln(in,tin0,tin1,l+8);
+			tin0^=tout0;
+			tin1^=tout1;
+
+			tin[0]=tin0;
+			tin[1]=tin1;
+			DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
+			tout0=tin[0];
+			tout1=tin[1];
+
+			l2c(tout0,out);
+			l2c(tout1,out);
+			}
+		iv = &(*ivec)[0];
+		l2c(tout0,iv);
+		l2c(tout1,iv);
+		}
+	else
+		{
+		register DES_LONG t0,t1;
+
+		c2l(iv,xor0);
+		c2l(iv,xor1);
+		for (l-=8; l>=0; l-=8)
+			{
+			c2l(in,tin0);
+			c2l(in,tin1);
+
+			t0=tin0;
+			t1=tin1;
+
+			tin[0]=tin0;
+			tin[1]=tin1;
+			DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
+			tout0=tin[0];
+			tout1=tin[1];
+
+			tout0^=xor0;
+			tout1^=xor1;
+			l2c(tout0,out);
+			l2c(tout1,out);
+			xor0=t0;
+			xor1=t1;
+			}
+		if (l != -8)
+			{
+			c2l(in,tin0);
+			c2l(in,tin1);
+			
+			t0=tin0;
+			t1=tin1;
+
+			tin[0]=tin0;
+			tin[1]=tin1;
+			DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
+			tout0=tin[0];
+			tout1=tin[1];
+		
+			tout0^=xor0;
+			tout1^=xor1;
+			l2cn(tout0,tout1,out,l+8);
+			xor0=t0;
+			xor1=t1;
+			}
+
+		iv = &(*ivec)[0];
+		l2c(xor0,iv);
+		l2c(xor1,iv);
+		}
+	tin0=tin1=tout0=tout1=xor0=xor1=0;
+	tin[0]=tin[1]=0;
+	}
+
+#endif /* DES_DEFAULT_OPTIONS */
Index: openssl-0.9.8g/crypto/des/des_locl.h
===================================================================
--- openssl-0.9.8g.orig/crypto/des/des_locl.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/des/des_locl.h	2008-09-24 11:01:01.000000000 +0200
@@ -421,7 +421,11 @@
 	PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
 	}
 
+#ifdef DES_CTABLES_IN_DATA
+extern DES_LONG DES_SPtrans[8][64];
+#else
 extern const DES_LONG DES_SPtrans[8][64];
+#endif
 
 void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
 		 DES_LONG Eswap0, DES_LONG Eswap1);
Index: openssl-0.9.8g/crypto/des/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/des/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/des/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -116,7 +116,7 @@
 	mv -f Makefile.new $(MAKEFILE)
 
 clean:
-	rm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
+	rm asm/*.o -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
Index: openssl-0.9.8g/crypto/des/spr.h
===================================================================
--- openssl-0.9.8g.orig/crypto/des/spr.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/des/spr.h	2008-09-24 11:01:01.000000000 +0200
@@ -56,7 +56,11 @@
  * [including the GNU Public Licence.]
  */
 
+#ifdef DES_CTABLES_IN_DATA
+OPENSSL_GLOBAL DES_LONG DES_SPtrans[8][64]={
+#else
 OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64]={
+#endif
 {
 /* nibble 0 */
 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
Index: openssl-0.9.8g/crypto/dsa/dsa_depr.c
===================================================================
--- openssl-0.9.8g.orig/crypto/dsa/dsa_depr.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/dsa/dsa_depr.c	2008-09-24 11:01:01.000000000 +0200
@@ -71,8 +71,8 @@
 
 static void *dummy=&dummy;
 
+#include <openssl/e_os2.h>
 #ifndef OPENSSL_NO_SHA
-
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
Index: openssl-0.9.8g/crypto/ec/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/ec/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/ec/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -95,7 +95,6 @@
 ec2_smpl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 ec2_smpl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
 ec2_smpl.o: ../../include/openssl/symhacks.h ec2_smpl.c ec2_smpt.c ec_lcl.h
-ec2_smpt.o: ec2_smpt.c
 ec_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
 ec_asn1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
 ec_asn1.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
Index: openssl-0.9.8g/crypto/ecdh/ech_ossl.c
===================================================================
--- openssl-0.9.8g.orig/crypto/ecdh/ech_ossl.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/ecdh/ech_ossl.c	2008-09-24 11:01:01.000000000 +0200
@@ -75,7 +75,7 @@
 
 #include "ech_locl.h"
 #include <openssl/err.h>
-#include <openssl/sha.h>
+//#include <openssl/sha.h>
 #include <openssl/obj_mac.h>
 #include <openssl/bn.h>
 
Index: openssl-0.9.8g/crypto/ecdh/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/ecdh/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/ecdh/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -106,6 +106,6 @@
 ech_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
 ech_ossl.o: ../../include/openssl/opensslconf.h
 ech_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-ech_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-ech_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-ech_ossl.o: ../cryptlib.h ech_locl.h ech_ossl.c
+ech_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
+ech_ossl.o: ../../include/openssl/symhacks.h ../cryptlib.h ech_locl.h
+ech_ossl.o: ech_ossl.c
Index: openssl-0.9.8g/crypto/evp/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/evp/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/evp/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -245,7 +245,6 @@
 e_null.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
 e_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
 e_null.o: ../cryptlib.h e_null.c
-e_old.o: e_old.c
 e_rc2.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
 e_rc2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
 e_rc2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
Index: openssl-0.9.8g/crypto/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -186,7 +186,7 @@
 mem_dbg.o: ../include/openssl/stack.h ../include/openssl/symhacks.h cryptlib.h
 mem_dbg.o: mem_dbg.c
 o_dir.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
-o_dir.o: LPdir_unix.c o_dir.c o_dir.h
+o_dir.o: o_dir.c o_dir.h
 o_str.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
 o_str.o: o_str.c o_str.h
 o_time.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h o_time.c
Index: openssl-0.9.8g/crypto/o_dir.c
===================================================================
--- openssl-0.9.8g.orig/crypto/o_dir.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/o_dir.c	2008-09-24 11:01:01.000000000 +0200
@@ -70,7 +70,20 @@
 #include "o_dir.h"
 
 #define LPDIR_H
-#if defined OPENSSL_SYS_UNIX || defined DJGPP
+#if defined OPENSSL_SYS_NEWLIB
+struct OPENSSL_dir_context_st {
+    //void *dummy;
+};
+
+const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory){
+    return NULL;
+}
+
+int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx){
+    return 1;
+}
+
+#elif defined OPENSSL_SYS_UNIX || defined DJGPP
 #include "LPdir_unix.c"
 #elif defined OPENSSL_SYS_VMS
 #include "LPdir_vms.c"
Index: openssl-0.9.8g/crypto/opensslconf.h
===================================================================
--- openssl-0.9.8g.orig/crypto/opensslconf.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/opensslconf.h	2008-09-24 11:01:01.000000000 +0200
@@ -25,6 +25,9 @@
 #ifndef OPENSSL_NO_SEED
 # define OPENSSL_NO_SEED
 #endif
+#ifndef OPENSSL_NO_THREAD
+# define OPENSSL_NO_THREAD
+#endif
 #ifndef OPENSSL_NO_TLSEXT
 # define OPENSSL_NO_TLSEXT
 #endif
@@ -60,6 +63,9 @@
 # if defined(OPENSSL_NO_SEED) && !defined(NO_SEED)
 #  define NO_SEED
 # endif
+# if defined(OPENSSL_NO_THREAD) && !defined(NO_THREAD)
+#  define NO_THREAD
+# endif
 # if defined(OPENSSL_NO_TLSEXT) && !defined(NO_TLSEXT)
 #  define NO_TLSEXT
 # endif
@@ -125,7 +131,7 @@
 
 #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
 #define CONFIG_HEADER_BN_H
-#undef BN_LLONG
+#define BN_LLONG
 
 /* Should we define BN_DIV2W here? */
 
Index: openssl-0.9.8g/crypto/pem/pem.h
===================================================================
--- openssl-0.9.8g.orig/crypto/pem/pem.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/pem/pem.h	2008-09-24 11:01:01.000000000 +0200
@@ -353,6 +353,7 @@
 
 #define DECLARE_PEM_read_fp(name, type) /**/
 #define DECLARE_PEM_write_fp(name, type) /**/
+#define DECLARE_PEM_write_fp_const(name, type) /**/
 #define DECLARE_PEM_write_cb_fp(name, type) /**/
 
 #else
Index: openssl-0.9.8g/crypto/rand/md_rand.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rand/md_rand.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rand/md_rand.c	2008-09-24 11:01:01.000000000 +0200
@@ -152,6 +152,7 @@
 int rand_predictable=0;
 #endif
 
+#ifndef OPENSSL_NO_EVP
 const char RAND_version[]="RAND" OPENSSL_VERSION_PTEXT;
 
 static void ssleay_rand_cleanup(void);
@@ -496,6 +497,7 @@
 	CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
 
 	EVP_MD_CTX_cleanup(&m);
+
 	if (ok)
 		return(1);
 	else
@@ -570,3 +572,4 @@
 	
 	return ret;
 	}
+#endif
Index: openssl-0.9.8g/crypto/rand/rand_egd.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rand/rand_egd.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rand/rand_egd.c	2008-09-24 11:01:01.000000000 +0200
@@ -95,7 +95,7 @@
  *   RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
  */
 
-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS)
+#if defined(OPENSSL_SYS_NEWLIB) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS)
 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
 	{
 	return(-1);
Index: openssl-0.9.8g/crypto/rand/rand_lib.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rand/rand_lib.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rand/rand_lib.c	2008-09-24 11:01:01.000000000 +0200
@@ -102,7 +102,9 @@
 			funct_ref = e;
 		else
 #endif
+#ifndef OPENSSL_NO_EVP
 			default_RAND_meth = RAND_SSLeay();
+#endif
 		}
 	return default_RAND_meth;
 	}
Index: openssl-0.9.8g/crypto/rand/rand_unix.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rand/rand_unix.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rand/rand_unix.c	2008-09-24 11:01:01.000000000 +0200
@@ -116,7 +116,7 @@
 #include <openssl/rand.h>
 #include "rand_lcl.h"
 
-#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE))
+#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_NEWLIB))
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -322,7 +322,7 @@
 #endif /* !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)) */
 
 
-#if defined(OPENSSL_SYS_VXWORKS)
+#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NEWLIB)
 int RAND_poll(void)
 	{
 	return 0;
Index: openssl-0.9.8g/crypto/rsa/Makefile
===================================================================
--- openssl-0.9.8g.orig/crypto/rsa/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rsa/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -167,9 +167,8 @@
 rsa_oaep.o: ../../include/openssl/opensslconf.h
 rsa_oaep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
 rsa_oaep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
-rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
-rsa_oaep.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
-rsa_oaep.o: ../cryptlib.h rsa_oaep.c
+rsa_oaep.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
+rsa_oaep.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_oaep.c
 rsa_pk1.o: ../../e_os.h ../../include/openssl/asn1.h
 rsa_pk1.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
 rsa_pk1.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
@@ -188,8 +187,8 @@
 rsa_pss.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
 rsa_pss.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
 rsa_pss.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
-rsa_pss.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
-rsa_pss.o: ../../include/openssl/symhacks.h ../cryptlib.h rsa_pss.c
+rsa_pss.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
+rsa_pss.o: ../cryptlib.h rsa_pss.c
 rsa_saos.o: ../../e_os.h ../../include/openssl/asn1.h
 rsa_saos.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
 rsa_saos.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
Index: openssl-0.9.8g/crypto/rsa/rsa_oaep.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rsa/rsa_oaep.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rsa/rsa_oaep.c	2008-09-24 11:01:01.000000000 +0200
@@ -26,7 +26,8 @@
 #include <openssl/rsa.h>
 #include <openssl/evp.h>
 #include <openssl/rand.h>
-#include <openssl/sha.h>
+//#include <openssl/sha.h>
+#define SHA_DIGEST_LENGTH 20
 
 int MGF1(unsigned char *mask, long len,
 	const unsigned char *seed, long seedlen);
Index: openssl-0.9.8g/crypto/rsa/rsa_pss.c
===================================================================
--- openssl-0.9.8g.orig/crypto/rsa/rsa_pss.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/rsa/rsa_pss.c	2008-09-24 11:01:01.000000000 +0200
@@ -62,7 +62,7 @@
 #include <openssl/rsa.h>
 #include <openssl/evp.h>
 #include <openssl/rand.h>
-#include <openssl/sha.h>
+//#include <openssl/sha.h>
 
 static const unsigned char zeroes[] = {0,0,0,0,0,0,0,0};
 
Index: openssl-0.9.8g/crypto/ui/ui_openssl.c
===================================================================
--- openssl-0.9.8g.orig/crypto/ui/ui_openssl.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/ui/ui_openssl.c	2008-09-24 11:01:01.000000000 +0200
@@ -212,6 +212,12 @@
 #undef SGTTY
 #endif
 
+#if defined(OPENSSL_SYS_NEWLIB)
+# undef  TERMIOS
+# undef  TERMIO
+# undef  SGTTY
+#endif
+
 #ifdef TERMIOS
 # include <termios.h>
 # define TTY_STRUCT		struct termios
@@ -236,7 +242,7 @@
 # define TTY_set(tty,data)	ioctl(tty,TIOCSETP,data)
 #endif
 
-#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_SUNOS)
+#if !defined(OPENSSL_SYS_NEWLIB) && !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_SUNOS)
 # include <sys/ioctl.h>
 #endif
 
@@ -260,7 +266,7 @@
 	typedef int sig_atomic_t;
 #endif
 
-#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE)
+#if defined(OPENSSL_SYS_NEWLIB) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(MAC_OS_GUSI_SOURCE) || defined(OPENSSL_SYS_NETWARE)
 /*
  * This one needs work. As a matter of fact the code is unoperational
  * and this is only a trick to get it compiled.
@@ -473,7 +479,7 @@
 	CRYPTO_w_lock(CRYPTO_LOCK_UI);
 	is_a_tty = 1;
 
-#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
+#if defined(OPENSSL_SYS_NEWLIB) || defined(OPENSSL_SYS_MACINTOSH_CLASSIC) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
 	tty_in=stdin;
 	tty_out=stderr;
 #else
Index: openssl-0.9.8g/crypto/uid.c
===================================================================
--- openssl-0.9.8g.orig/crypto/uid.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/uid.c	2008-09-24 11:01:01.000000000 +0200
@@ -65,7 +65,7 @@
 	return issetugid();
 	}
 
-#elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
+#elif defined(OPENSSL_SYS_NEWLIB) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
 
 int OPENSSL_issetugid(void)
 	{
Index: openssl-0.9.8g/crypto/x509/x509.h
===================================================================
--- openssl-0.9.8g.orig/crypto/x509/x509.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/x509/x509.h	2008-09-24 11:01:01.000000000 +0200
@@ -69,9 +69,9 @@
 #ifndef OPENSSL_NO_BUFFER
 #include <openssl/buffer.h>
 #endif
-#ifndef OPENSSL_NO_EVP
+//#ifndef OPENSSL_NO_EVP
 #include <openssl/evp.h>
-#endif
+//#endif
 #ifndef OPENSSL_NO_BIO
 #include <openssl/bio.h>
 #endif
@@ -476,14 +476,15 @@
 	int references;
 	} X509_PKEY;
 
-#ifndef OPENSSL_NO_EVP
 typedef struct X509_info_st
 	{
 	X509 *x509;
 	X509_CRL *crl;
 	X509_PKEY *x_pkey;
 
+#ifndef OPENSSL_NO_EVP
 	EVP_CIPHER_INFO enc_cipher;
+#endif
 	int enc_len;
 	char *enc_data;
 
@@ -491,7 +492,6 @@
 	} X509_INFO;
 
 DECLARE_STACK_OF(X509_INFO)
-#endif
 
 /* The next 2 structures and their 8 routines were sent to me by
  * Pat Richard <patr@x509.com> and are used to manipulate
Index: openssl-0.9.8g/crypto/x509v3/x509v3.h
===================================================================
--- openssl-0.9.8g.orig/crypto/x509v3/x509v3.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/crypto/x509v3/x509v3.h	2008-09-24 11:01:01.000000000 +0200
@@ -592,7 +592,9 @@
 void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,
 								 int ml);
 int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent);
+#ifndef OPENSSL_NO_FP_API
 int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);
+#endif
 
 int X509V3_extensions_print(BIO *out, char *title, STACK_OF(X509_EXTENSION) *exts, unsigned long flag, int indent);
 
Index: openssl-0.9.8g/e_os2.h
===================================================================
--- openssl-0.9.8g.orig/e_os2.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/e_os2.h	2008-09-24 11:01:01.000000000 +0200
@@ -157,6 +157,11 @@
 # define OPENSSL_SYS_OS2
 #endif
 
+/* --------------------------------- Newlib ---------------------------------- */
+#ifdef OPENSSL_SYSNAME_NEWLIB
+#define OPENSSL_SYS_NEWLIB
+#endif
+
 /* --------------------------------- Unix ---------------------------------- */
 #ifdef OPENSSL_SYS_UNIX
 # if defined(linux) || defined(__linux__) || defined(OPENSSL_SYSNAME_LINUX)
Index: openssl-0.9.8g/e_os.h
===================================================================
--- openssl-0.9.8g.orig/e_os.h	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/e_os.h	2008-09-24 11:01:01.000000000 +0200
@@ -94,6 +94,12 @@
 #  define NO_SYSLOG
 #endif
   
+#if defined(OPENSSL_SYS_NEWLIB)
+#      define NO_SYS_PARAM_H
+  //#      define NO_CHMOD
+#      define NO_SYSLOG
+#endif
+
 #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
 # if macintosh==1
 #  ifndef MAC_OS_GUSI_SOURCE
@@ -425,7 +431,12 @@
 /*************/
 
 #ifdef USE_SOCKETS
-#  if defined(WINDOWS) || defined(MSDOS)
+#  if defined(OPENSSL_SYS_NEWLIB)
+#      define SSLeay_Write(a,b,c)	(-1)
+#      define SSLeay_Read(a,b,c)	(-1)
+#      define SHUTDOWN(fd)		close(fd)
+#      define SHUTDOWN2(fd)		close(fd)
+#  elif defined(WINDOWS) || defined(MSDOS)
       /* windows world */
 
 #    ifdef OPENSSL_NO_SOCK
Index: openssl-0.9.8g/ssl/bio_ssl.c
===================================================================
--- openssl-0.9.8g.orig/ssl/bio_ssl.c	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/ssl/bio_ssl.c	2008-09-24 11:01:01.000000000 +0200
@@ -534,12 +534,14 @@
 	{
 	BIO *ret=NULL,*con=NULL,*ssl=NULL;
 
+#ifndef OPENSSL_NO_SOCK
 	if ((con=BIO_new(BIO_s_connect())) == NULL)
 		return(NULL);
 	if ((ssl=BIO_new_ssl(ctx,1)) == NULL)
 		goto err;
 	if ((ret=BIO_push(ssl,con)) == NULL)
 		goto err;
+#endif
 	return(ret);
 err:
 	if (con != NULL) BIO_free(con);
Index: openssl-0.9.8g/ssl/Makefile
===================================================================
--- openssl-0.9.8g.orig/ssl/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/ssl/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -634,20 +634,20 @@
 s3_srvr.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 s3_srvr.o: ../include/openssl/ecdsa.h ../include/openssl/err.h
 s3_srvr.o: ../include/openssl/evp.h ../include/openssl/hmac.h
-s3_srvr.o: ../include/openssl/krb5_asn.h ../include/openssl/kssl.h
-s3_srvr.o: ../include/openssl/lhash.h ../include/openssl/md5.h
-s3_srvr.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-s3_srvr.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-s3_srvr.o: ../include/openssl/ossl_typ.h ../include/openssl/pem.h
-s3_srvr.o: ../include/openssl/pem2.h ../include/openssl/pkcs7.h
-s3_srvr.o: ../include/openssl/pq_compat.h ../include/openssl/pqueue.h
-s3_srvr.o: ../include/openssl/rand.h ../include/openssl/rsa.h
-s3_srvr.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-s3_srvr.o: ../include/openssl/ssl.h ../include/openssl/ssl2.h
-s3_srvr.o: ../include/openssl/ssl23.h ../include/openssl/ssl3.h
-s3_srvr.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-s3_srvr.o: ../include/openssl/tls1.h ../include/openssl/x509.h
-s3_srvr.o: ../include/openssl/x509_vfy.h kssl_lcl.h s3_srvr.c ssl_locl.h
+s3_srvr.o: ../include/openssl/kssl.h ../include/openssl/lhash.h
+s3_srvr.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
+s3_srvr.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
+s3_srvr.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+s3_srvr.o: ../include/openssl/pem.h ../include/openssl/pem2.h
+s3_srvr.o: ../include/openssl/pkcs7.h ../include/openssl/pq_compat.h
+s3_srvr.o: ../include/openssl/pqueue.h ../include/openssl/rand.h
+s3_srvr.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+s3_srvr.o: ../include/openssl/sha.h ../include/openssl/ssl.h
+s3_srvr.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
+s3_srvr.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
+s3_srvr.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+s3_srvr.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h kssl_lcl.h
+s3_srvr.o: s3_srvr.c ssl_locl.h
 ssl_algs.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 ssl_algs.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 ssl_algs.o: ../include/openssl/comp.h ../include/openssl/crypto.h
Index: openssl-0.9.8g/test/Makefile
===================================================================
--- openssl-0.9.8g.orig/test/Makefile	2008-09-24 11:00:04.000000000 +0200
+++ openssl-0.9.8g/test/Makefile	2008-09-24 11:01:01.000000000 +0200
@@ -445,8 +445,9 @@
 bntest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h bntest.c
 casttest.o: ../e_os.h ../include/openssl/cast.h ../include/openssl/e_os2.h
 casttest.o: ../include/openssl/opensslconf.h casttest.c
-destest.o: ../include/openssl/des.h ../include/openssl/des_old.h
-destest.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
+destest.o: ../include/openssl/crypto.h ../include/openssl/des.h
+destest.o: ../include/openssl/des_old.h ../include/openssl/e_os2.h
+destest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
 destest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
 destest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
 destest.o: ../include/openssl/ui.h ../include/openssl/ui_compat.h destest.c
@@ -476,41 +477,69 @@
 ecdhtest.o: ../include/openssl/sha.h ../include/openssl/stack.h
 ecdhtest.o: ../include/openssl/symhacks.h ecdhtest.c
 ecdsatest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
-ecdsatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
-ecdsatest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+ecdsatest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
+ecdsatest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
+ecdsatest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
+ecdsatest.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
 ecdsatest.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
 ecdsatest.o: ../include/openssl/err.h ../include/openssl/evp.h
 ecdsatest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
 ecdsatest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
 ecdsatest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-ecdsatest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
-ecdsatest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
-ecdsatest.o: ecdsatest.c
+ecdsatest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
+ecdsatest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+ecdsatest.o: ../include/openssl/sha.h ../include/openssl/stack.h
+ecdsatest.o: ../include/openssl/store.h ../include/openssl/symhacks.h
+ecdsatest.o: ../include/openssl/ui.h ../include/openssl/x509.h
+ecdsatest.o: ../include/openssl/x509_vfy.h ecdsatest.c
 ectest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-ectest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
-ectest.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
-ectest.o: ../include/openssl/engine.h ../include/openssl/err.h
+ectest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
+ectest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
+ectest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
+ectest.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
+ectest.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
+ectest.o: ../include/openssl/err.h ../include/openssl/evp.h
 ectest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
 ectest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
 ectest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-ectest.o: ../include/openssl/rand.h ../include/openssl/safestack.h
-ectest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h ectest.c
-enginetest.o: ../include/openssl/bio.h ../include/openssl/buffer.h
-enginetest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-enginetest.o: ../include/openssl/engine.h ../include/openssl/err.h
-enginetest.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
+ectest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
+ectest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+ectest.o: ../include/openssl/sha.h ../include/openssl/stack.h
+ectest.o: ../include/openssl/store.h ../include/openssl/symhacks.h
+ectest.o: ../include/openssl/ui.h ../include/openssl/x509.h
+ectest.o: ../include/openssl/x509_vfy.h ectest.c
+enginetest.o: ../include/openssl/asn1.h ../include/openssl/bio.h
+enginetest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
+enginetest.o: ../include/openssl/crypto.h ../include/openssl/dh.h
+enginetest.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
+enginetest.o: ../include/openssl/ec.h ../include/openssl/ecdh.h
+enginetest.o: ../include/openssl/ecdsa.h ../include/openssl/engine.h
+enginetest.o: ../include/openssl/err.h ../include/openssl/evp.h
+enginetest.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
+enginetest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
 enginetest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-enginetest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
-enginetest.o: ../include/openssl/symhacks.h enginetest.c
+enginetest.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
+enginetest.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
+enginetest.o: ../include/openssl/sha.h ../include/openssl/stack.h
+enginetest.o: ../include/openssl/store.h ../include/openssl/symhacks.h
+enginetest.o: ../include/openssl/ui.h ../include/openssl/x509.h
+enginetest.o: ../include/openssl/x509_vfy.h enginetest.c
 evp_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
+evp_test.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 evp_test.o: ../include/openssl/conf.h ../include/openssl/crypto.h
-evp_test.o: ../include/openssl/e_os2.h ../include/openssl/engine.h
-evp_test.o: ../include/openssl/err.h ../include/openssl/evp.h
-evp_test.o: ../include/openssl/lhash.h ../include/openssl/obj_mac.h
-evp_test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-evp_test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-evp_test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
-evp_test.o: ../include/openssl/symhacks.h evp_test.c
+evp_test.o: ../include/openssl/dh.h ../include/openssl/dsa.h
+evp_test.o: ../include/openssl/e_os2.h ../include/openssl/ec.h
+evp_test.o: ../include/openssl/ecdh.h ../include/openssl/ecdsa.h
+evp_test.o: ../include/openssl/engine.h ../include/openssl/err.h
+evp_test.o: ../include/openssl/evp.h ../include/openssl/lhash.h
+evp_test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+evp_test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+evp_test.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
+evp_test.o: ../include/openssl/rand.h ../include/openssl/rsa.h
+evp_test.o: ../include/openssl/safestack.h ../include/openssl/sha.h
+evp_test.o: ../include/openssl/stack.h ../include/openssl/store.h
+evp_test.o: ../include/openssl/symhacks.h ../include/openssl/ui.h
+evp_test.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h evp_test.c
 exptest.o: ../e_os.h ../include/openssl/bio.h ../include/openssl/bn.h
 exptest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
 exptest.o: ../include/openssl/err.h ../include/openssl/lhash.h
@@ -519,39 +548,42 @@
 exptest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 exptest.o: ../include/openssl/symhacks.h exptest.c
 hmactest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-hmactest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-hmactest.o: ../include/openssl/evp.h ../include/openssl/hmac.h
-hmactest.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
-hmactest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-hmactest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-hmactest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
-hmactest.o: ../include/openssl/symhacks.h hmactest.c
+hmactest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+hmactest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+hmactest.o: ../include/openssl/hmac.h ../include/openssl/md5.h
+hmactest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+hmactest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+hmactest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
+hmactest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h hmactest.c
 ideatest.o: ../e_os.h ../include/openssl/e_os2.h ../include/openssl/idea.h
 ideatest.o: ../include/openssl/opensslconf.h ideatest.c
 igetest.o: ../include/openssl/aes.h ../include/openssl/e_os2.h
 igetest.o: ../include/openssl/opensslconf.h ../include/openssl/ossl_typ.h
 igetest.o: ../include/openssl/rand.h igetest.c
 md2test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-md2test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-md2test.o: ../include/openssl/evp.h ../include/openssl/md2.h
-md2test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-md2test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-md2test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
-md2test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h md2test.c
+md2test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+md2test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+md2test.o: ../include/openssl/md2.h ../include/openssl/obj_mac.h
+md2test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
+md2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+md2test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+md2test.o: ../include/openssl/symhacks.h md2test.c
 md4test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-md4test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-md4test.o: ../include/openssl/evp.h ../include/openssl/md4.h
-md4test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-md4test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-md4test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
-md4test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h md4test.c
+md4test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+md4test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+md4test.o: ../include/openssl/md4.h ../include/openssl/obj_mac.h
+md4test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
+md4test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+md4test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+md4test.o: ../include/openssl/symhacks.h md4test.c
 md5test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-md5test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-md5test.o: ../include/openssl/evp.h ../include/openssl/md5.h
-md5test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
-md5test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
-md5test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
-md5test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h md5test.c
+md5test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+md5test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+md5test.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
+md5test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
+md5test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+md5test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+md5test.o: ../include/openssl/symhacks.h md5test.c
 mdc2test.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
 mdc2test.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h
 mdc2test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
@@ -571,12 +603,13 @@
 rc5test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 rc5test.o: ../include/openssl/symhacks.h rc5test.c
 rmdtest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-rmdtest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-rmdtest.o: ../include/openssl/evp.h ../include/openssl/obj_mac.h
-rmdtest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-rmdtest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-rmdtest.o: ../include/openssl/ripemd.h ../include/openssl/safestack.h
-rmdtest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h rmdtest.c
+rmdtest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+rmdtest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+rmdtest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+rmdtest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+rmdtest.o: ../include/openssl/ossl_typ.h ../include/openssl/ripemd.h
+rmdtest.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+rmdtest.o: ../include/openssl/symhacks.h rmdtest.c
 rsa_test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 rsa_test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
 rsa_test.o: ../include/openssl/e_os2.h ../include/openssl/err.h
@@ -586,19 +619,21 @@
 rsa_test.o: ../include/openssl/safestack.h ../include/openssl/stack.h
 rsa_test.o: ../include/openssl/symhacks.h rsa_test.c
 sha1test.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-sha1test.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-sha1test.o: ../include/openssl/evp.h ../include/openssl/obj_mac.h
-sha1test.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-sha1test.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-sha1test.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-sha1test.o: ../include/openssl/stack.h ../include/openssl/symhacks.h sha1test.c
+sha1test.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+sha1test.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+sha1test.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+sha1test.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+sha1test.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
+sha1test.o: ../include/openssl/sha.h ../include/openssl/stack.h
+sha1test.o: ../include/openssl/symhacks.h sha1test.c
 shatest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
-shatest.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
-shatest.o: ../include/openssl/evp.h ../include/openssl/obj_mac.h
-shatest.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
-shatest.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
-shatest.o: ../include/openssl/safestack.h ../include/openssl/sha.h
-shatest.o: ../include/openssl/stack.h ../include/openssl/symhacks.h shatest.c
+shatest.o: ../include/openssl/bn.h ../include/openssl/crypto.h
+shatest.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
+shatest.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
+shatest.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
+shatest.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
+shatest.o: ../include/openssl/sha.h ../include/openssl/stack.h
+shatest.o: ../include/openssl/symhacks.h shatest.c
 ssltest.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
 ssltest.o: ../include/openssl/bn.h ../include/openssl/buffer.h
 ssltest.o: ../include/openssl/comp.h ../include/openssl/conf.h
@@ -618,6 +653,7 @@
 ssltest.o: ../include/openssl/sha.h ../include/openssl/ssl.h
 ssltest.o: ../include/openssl/ssl2.h ../include/openssl/ssl23.h
 ssltest.o: ../include/openssl/ssl3.h ../include/openssl/stack.h
-ssltest.o: ../include/openssl/symhacks.h ../include/openssl/tls1.h
+ssltest.o: ../include/openssl/store.h ../include/openssl/symhacks.h
+ssltest.o: ../include/openssl/tls1.h ../include/openssl/ui.h
 ssltest.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h
 ssltest.o: ../include/openssl/x509v3.h ssltest.c