Compare commits
	
		
			1 Commits
		
	
	
		
			OpenSSL-en
			...
			OpenSSL_0_
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					35b3515490 | 
							
								
								
									
										12
									
								
								.cvsignore
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								.cvsignore
									
									
									
									
									
								
							@@ -1,15 +1,3 @@
 | 
				
			|||||||
Makefile.ssl
 | 
					Makefile.ssl
 | 
				
			||||||
MINFO
 | 
					MINFO
 | 
				
			||||||
makefile.one
 | 
					makefile.one
 | 
				
			||||||
tmp
 | 
					 | 
				
			||||||
out
 | 
					 | 
				
			||||||
outinc
 | 
					 | 
				
			||||||
rehash.time
 | 
					 | 
				
			||||||
testlog
 | 
					 | 
				
			||||||
make.log
 | 
					 | 
				
			||||||
maketest.log
 | 
					 | 
				
			||||||
cctest
 | 
					 | 
				
			||||||
cctest.c
 | 
					 | 
				
			||||||
cctest.a
 | 
					 | 
				
			||||||
libcrypto.so.*
 | 
					 | 
				
			||||||
libssl.so.*
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										620
									
								
								FAQ
									
									
									
									
									
								
							
							
						
						
									
										620
									
								
								FAQ
									
									
									
									
									
								
							@@ -1,620 +0,0 @@
 | 
				
			|||||||
OpenSSL  -  Frequently Asked Questions
 | 
					 | 
				
			||||||
--------------------------------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[MISC] Miscellaneous questions
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Which is the current version of OpenSSL?
 | 
					 | 
				
			||||||
* Where is the documentation?
 | 
					 | 
				
			||||||
* How can I contact the OpenSSL developers?
 | 
					 | 
				
			||||||
* Where can I get a compiled version of OpenSSL?
 | 
					 | 
				
			||||||
* Why aren't tools like 'autoconf' and 'libtool' used?
 | 
					 | 
				
			||||||
* What is an 'engine' version?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[LEGAL] Legal questions
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Do I need patent licenses to use OpenSSL?
 | 
					 | 
				
			||||||
* Can I use OpenSSL with GPL software? 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[USER] Questions on using the OpenSSL applications
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why do I get a "PRNG not seeded" error message?
 | 
					 | 
				
			||||||
* Why do I get an "unable to write 'random state'" error message?
 | 
					 | 
				
			||||||
* How do I create certificates or certificate requests?
 | 
					 | 
				
			||||||
* Why can't I create certificate requests?
 | 
					 | 
				
			||||||
* Why does <SSL program> fail with a certificate verify error?
 | 
					 | 
				
			||||||
* Why can I only use weak ciphers when I connect to a server using OpenSSL?
 | 
					 | 
				
			||||||
* How can I create DSA certificates?
 | 
					 | 
				
			||||||
* Why can't I make an SSL connection using a DSA certificate?
 | 
					 | 
				
			||||||
* How can I remove the passphrase on a private key?
 | 
					 | 
				
			||||||
* Why can't I use OpenSSL certificates with SSL client authentication?
 | 
					 | 
				
			||||||
* Why does my browser give a warning about a mismatched hostname?
 | 
					 | 
				
			||||||
* How do I install a CA certificate into a browser?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[BUILD] Questions about building and testing OpenSSL
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the linker complain about undefined symbols?
 | 
					 | 
				
			||||||
* Why does the OpenSSL test fail with "bc: command not found"?
 | 
					 | 
				
			||||||
* Why does the OpenSSL test fail with "bc: 1 no implemented"?
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail with "ar: command not found"?
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail on Win32 with VC++?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[PROG] Questions about programming with OpenSSL
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Is OpenSSL thread-safe?
 | 
					 | 
				
			||||||
* I've compiled a program under Windows and it crashes: why?
 | 
					 | 
				
			||||||
* How do I read or write a DER encoded buffer using the ASN1 functions?
 | 
					 | 
				
			||||||
* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?
 | 
					 | 
				
			||||||
* I've called <some function> and it fails, why?
 | 
					 | 
				
			||||||
* I just get a load of numbers for the error output, what do they mean?
 | 
					 | 
				
			||||||
* Why do I get errors about unknown algorithms?
 | 
					 | 
				
			||||||
* Why can't the OpenSSH configure script detect OpenSSL?
 | 
					 | 
				
			||||||
* Can I use OpenSSL's SSL library with non-blocking I/O?
 | 
					 | 
				
			||||||
* Why doesn't my server application receive a client certificate?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
===============================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[MISC] ========================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Which is the current version of OpenSSL?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The current version is available from <URL: http://www.openssl.org>.
 | 
					 | 
				
			||||||
OpenSSL 0.9.6c was released on December 21st, 2001.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
In addition to the current stable release, you can also access daily
 | 
					 | 
				
			||||||
snapshots of the OpenSSL development version at <URL:
 | 
					 | 
				
			||||||
ftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Where is the documentation?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OpenSSL is a library that provides cryptographic functionality to
 | 
					 | 
				
			||||||
applications such as secure web servers.  Be sure to read the
 | 
					 | 
				
			||||||
documentation of the application you want to use.  The INSTALL file
 | 
					 | 
				
			||||||
explains how to install this library.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OpenSSL includes a command line utility that can be used to perform a
 | 
					 | 
				
			||||||
variety of cryptographic functions.  It is described in the openssl(1)
 | 
					 | 
				
			||||||
manpage.  Documentation for developers is currently being written.  A
 | 
					 | 
				
			||||||
few manual pages already are available; overviews over libcrypto and
 | 
					 | 
				
			||||||
libssl are given in the crypto(3) and ssl(3) manpages.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The OpenSSL manpages are installed in /usr/local/ssl/man/ (or a
 | 
					 | 
				
			||||||
different directory if you specified one as described in INSTALL).
 | 
					 | 
				
			||||||
In addition, you can read the most current versions at
 | 
					 | 
				
			||||||
<URL: http://www.openssl.org/docs/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
For information on parts of libcrypto that are not yet documented, you
 | 
					 | 
				
			||||||
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
 | 
					 | 
				
			||||||
predecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>.  Much
 | 
					 | 
				
			||||||
of this still applies to OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There is some documentation about certificate extensions and PKCS#12
 | 
					 | 
				
			||||||
in doc/openssl.txt
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The original SSLeay documentation is included in OpenSSL as
 | 
					 | 
				
			||||||
doc/ssleay.txt.  It may be useful when none of the other resources
 | 
					 | 
				
			||||||
help, but please note that it reflects the obsolete version SSLeay
 | 
					 | 
				
			||||||
0.6.6.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How can I contact the OpenSSL developers?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The README file describes how to submit bug reports and patches to
 | 
					 | 
				
			||||||
OpenSSL.  Information on the OpenSSL mailing lists is available from
 | 
					 | 
				
			||||||
<URL: http://www.openssl.org>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Where can I get a compiled version of OpenSSL?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Some applications that use OpenSSL are distributed in binary form.
 | 
					 | 
				
			||||||
When using such an application, you don't need to install OpenSSL
 | 
					 | 
				
			||||||
yourself; the application will include the required parts (e.g. DLLs).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you want to install OpenSSL on a Windows system and you don't have
 | 
					 | 
				
			||||||
a C compiler, read the "Mingw32" section of INSTALL.W32 for information
 | 
					 | 
				
			||||||
on how to obtain and install the free GNU C compiler.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
A number of Linux and *BSD distributions include OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why aren't tools like 'autoconf' and 'libtool' used?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
autoconf will probably be used in future OpenSSL versions. If it was
 | 
					 | 
				
			||||||
less Unix-centric, it might have been used much earlier.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* What is an 'engine' version?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
With version 0.9.6 OpenSSL was extended to interface to external crypto
 | 
					 | 
				
			||||||
hardware. This was realized in a special release '0.9.6-engine'. With
 | 
					 | 
				
			||||||
version 0.9.7 (not yet released) the changes were merged into the main
 | 
					 | 
				
			||||||
development line, so that the special release is no longer necessary.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[LEGAL] =======================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Do I need patent licenses to use OpenSSL?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The patents section of the README file lists patents that may apply to
 | 
					 | 
				
			||||||
you if you want to use OpenSSL.  For information on intellectual
 | 
					 | 
				
			||||||
property rights, please consult a lawyer.  The OpenSSL team does not
 | 
					 | 
				
			||||||
offer legal advice.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You can configure OpenSSL so as not to use RC5 and IDEA by using
 | 
					 | 
				
			||||||
 ./config no-rc5 no-idea
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Can I use OpenSSL with GPL software?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On many systems including the major Linux and BSD distributions, yes (the
 | 
					 | 
				
			||||||
GPL does not place restrictions on using libraries that are part of the
 | 
					 | 
				
			||||||
normal operating system distribution).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On other systems, the situation is less clear. Some GPL software copyright
 | 
					 | 
				
			||||||
holders claim that you infringe on their rights if you use OpenSSL with
 | 
					 | 
				
			||||||
their software on operating systems that don't normally include OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you develop open source software that uses OpenSSL, you may find it
 | 
					 | 
				
			||||||
useful to choose an other license than the GPL, or state explicitly that
 | 
					 | 
				
			||||||
"This program is released under the GPL with the additional exemption that
 | 
					 | 
				
			||||||
compiling, linking, and/or using OpenSSL is allowed."  If you are using
 | 
					 | 
				
			||||||
GPL software developed by others, you may want to ask the copyright holder
 | 
					 | 
				
			||||||
for permission to use their software with OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[USER] ========================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why do I get a "PRNG not seeded" error message?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Cryptographic software needs a source of unpredictable data to work
 | 
					 | 
				
			||||||
correctly.  Many open source operating systems provide a "randomness
 | 
					 | 
				
			||||||
device" that serves this purpose.  On other systems, applications have
 | 
					 | 
				
			||||||
to call the RAND_add() or RAND_seed() function with appropriate data
 | 
					 | 
				
			||||||
before generating keys or performing public key encryption.
 | 
					 | 
				
			||||||
(These functions initialize the pseudo-random number generator, PRNG.)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Some broken applications do not do this.  As of version 0.9.5, the
 | 
					 | 
				
			||||||
OpenSSL functions that need randomness report an error if the random
 | 
					 | 
				
			||||||
number generator has not been seeded with at least 128 bits of
 | 
					 | 
				
			||||||
randomness.  If this error occurs, please contact the author of the
 | 
					 | 
				
			||||||
application you are using.  It is likely that it never worked
 | 
					 | 
				
			||||||
correctly.  OpenSSL 0.9.5 and later make the error visible by refusing
 | 
					 | 
				
			||||||
to perform potentially insecure encryption.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On systems without /dev/urandom and /dev/random, it is a good idea to
 | 
					 | 
				
			||||||
use the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for
 | 
					 | 
				
			||||||
details.  Starting with version 0.9.7, OpenSSL will automatically look
 | 
					 | 
				
			||||||
for an EGD socket at /var/run/egd-pool, /dev/egd-pool, /etc/egd-pool and
 | 
					 | 
				
			||||||
/etc/entropy.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Most components of the openssl command line utility automatically try
 | 
					 | 
				
			||||||
to seed the random number generator from a file.  The name of the
 | 
					 | 
				
			||||||
default seeding file is determined as follows: If environment variable
 | 
					 | 
				
			||||||
RANDFILE is set, then it names the seeding file.  Otherwise if
 | 
					 | 
				
			||||||
environment variable HOME is set, then the seeding file is $HOME/.rnd.
 | 
					 | 
				
			||||||
If neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will
 | 
					 | 
				
			||||||
use file .rnd in the current directory while OpenSSL 0.9.6a uses no
 | 
					 | 
				
			||||||
default seeding file at all.  OpenSSL 0.9.6b and later will behave
 | 
					 | 
				
			||||||
similarly to 0.9.6a, but will use a default of "C:\" for HOME on
 | 
					 | 
				
			||||||
Windows systems if the environment variable has not been set.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If the default seeding file does not exist or is too short, the "PRNG
 | 
					 | 
				
			||||||
not seeded" error message may occur.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The openssl command line utility will write back a new state to the
 | 
					 | 
				
			||||||
default seeding file (and create this file if necessary) unless
 | 
					 | 
				
			||||||
there was no sufficient seeding.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Pointing $RANDFILE to an Entropy Gathering Daemon socket does not work.
 | 
					 | 
				
			||||||
Use the "-rand" option of the OpenSSL command line tools instead.
 | 
					 | 
				
			||||||
The $RANDFILE environment variable and $HOME/.rnd are only used by the
 | 
					 | 
				
			||||||
OpenSSL command line tools. Applications using the OpenSSL library
 | 
					 | 
				
			||||||
provide their own configuration options to specify the entropy source,
 | 
					 | 
				
			||||||
please check out the documentation coming the with application.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
For Solaris 2.6, Tim Nibbe <tnibbe@sprint.net> and others have suggested
 | 
					 | 
				
			||||||
installing the SUNski package from Sun patch 105710-01 (Sparc) which
 | 
					 | 
				
			||||||
adds a /dev/random device and make sure it gets used, usually through
 | 
					 | 
				
			||||||
$RANDFILE.  There are probably similar patches for the other Solaris
 | 
					 | 
				
			||||||
versions.  However, be warned that /dev/random is usually a blocking
 | 
					 | 
				
			||||||
device, which may have some effects on OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why do I get an "unable to write 'random state'" error message?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Sometimes the openssl command line utility does not abort with
 | 
					 | 
				
			||||||
a "PRNG not seeded" error message, but complains that it is
 | 
					 | 
				
			||||||
"unable to write 'random state'".  This message refers to the
 | 
					 | 
				
			||||||
default seeding file (see previous answer).  A possible reason
 | 
					 | 
				
			||||||
is that no default filename is known because neither RANDFILE
 | 
					 | 
				
			||||||
nor HOME is set.  (Versions up to 0.9.6 used file ".rnd" in the
 | 
					 | 
				
			||||||
current directory in this case, but this has changed with 0.9.6a.)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How do I create certificates or certificate requests?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Check out the CA.pl(1) manual page. This provides a simple wrapper round
 | 
					 | 
				
			||||||
the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
 | 
					 | 
				
			||||||
out the manual pages for the individual utilities and the certificate
 | 
					 | 
				
			||||||
extensions documentation (currently in doc/openssl.txt).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why can't I create certificate requests?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You typically get the error:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	unable to find 'distinguished_name' in config
 | 
					 | 
				
			||||||
	problems making Certificate Request
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This is because it can't find the configuration file. Check out the
 | 
					 | 
				
			||||||
DIAGNOSTICS section of req(1) for more information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does <SSL program> fail with a certificate verify error?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This problem is usually indicated by log messages saying something like
 | 
					 | 
				
			||||||
"unable to get local issuer certificate" or "self signed certificate".
 | 
					 | 
				
			||||||
When a certificate is verified its root CA must be "trusted" by OpenSSL
 | 
					 | 
				
			||||||
this typically means that the CA certificate must be placed in a directory
 | 
					 | 
				
			||||||
or file and the relevant program configured to read it. The OpenSSL program
 | 
					 | 
				
			||||||
'verify' behaves in a similar way and issues similar error messages: check
 | 
					 | 
				
			||||||
the verify(1) program manual page for more information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why can I only use weak ciphers when I connect to a server using OpenSSL?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This is almost certainly because you are using an old "export grade" browser
 | 
					 | 
				
			||||||
which only supports weak encryption. Upgrade your browser to support 128 bit
 | 
					 | 
				
			||||||
ciphers.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How can I create DSA certificates?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Check the CA.pl(1) manual page for a DSA certificate example.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why can't I make an SSL connection to a server using a DSA certificate?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Typically you'll see a message saying there are no shared ciphers when
 | 
					 | 
				
			||||||
the same setup works fine with an RSA certificate. There are two possible
 | 
					 | 
				
			||||||
causes. The client may not support connections to DSA servers most web
 | 
					 | 
				
			||||||
browsers (including Netscape and MSIE) only support connections to servers
 | 
					 | 
				
			||||||
supporting RSA cipher suites. The other cause is that a set of DH parameters
 | 
					 | 
				
			||||||
has not been supplied to the server. DH parameters can be created with the
 | 
					 | 
				
			||||||
dhparam(1) command and loaded using the SSL_CTX_set_tmp_dh() for example:
 | 
					 | 
				
			||||||
check the source to s_server in apps/s_server.c for an example.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How can I remove the passphrase on a private key?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Firstly you should be really *really* sure you want to do this. Leaving
 | 
					 | 
				
			||||||
a private key unencrypted is a major security risk. If you decide that
 | 
					 | 
				
			||||||
you do have to do this check the EXAMPLES sections of the rsa(1) and
 | 
					 | 
				
			||||||
dsa(1) manual pages.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why can't I use OpenSSL certificates with SSL client authentication?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
What will typically happen is that when a server requests authentication
 | 
					 | 
				
			||||||
it will either not include your certificate or tell you that you have
 | 
					 | 
				
			||||||
no client certificates (Netscape) or present you with an empty list box
 | 
					 | 
				
			||||||
(MSIE). The reason for this is that when a server requests a client
 | 
					 | 
				
			||||||
certificate it includes a list of CAs names which it will accept. Browsers
 | 
					 | 
				
			||||||
will only let you select certificates from the list on the grounds that
 | 
					 | 
				
			||||||
there is little point presenting a certificate which the server will
 | 
					 | 
				
			||||||
reject.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The solution is to add the relevant CA certificate to your servers "trusted
 | 
					 | 
				
			||||||
CA list". How you do this depends on the server software in uses. You can
 | 
					 | 
				
			||||||
print out the servers list of acceptable CAs using the OpenSSL s_client tool:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
openssl s_client -connect www.some.host:443 -prexit
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If your server only requests certificates on certain URLs then you may need
 | 
					 | 
				
			||||||
to manually issue an HTTP GET command to get the list when s_client connects:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
GET /some/page/needing/a/certificate.html
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If your CA does not appear in the list then this confirms the problem.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does my browser give a warning about a mismatched hostname?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Browsers expect the server's hostname to match the value in the commonName
 | 
					 | 
				
			||||||
(CN) field of the certificate. If it does not then you get a warning.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How do I install a CA certificate into a browser?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The usual way is to send the DER encoded certificate to the browser as
 | 
					 | 
				
			||||||
MIME type application/x-x509-ca-cert, for example by clicking on an appropriate
 | 
					 | 
				
			||||||
link. On MSIE certain extensions such as .der or .cacert may also work, or you
 | 
					 | 
				
			||||||
can import the certificate using the certificate import wizard.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You can convert a certificate to DER form using the command:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
openssl x509 -in ca.pem -outform DER -out ca.der
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Occasionally someone suggests using a command such as:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
openssl pkcs12 -export -out cacert.p12 -in cacert.pem -inkey cakey.pem
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DO NOT DO THIS! This command will give away your CAs private key and
 | 
					 | 
				
			||||||
reduces its security to zero: allowing anyone to forge certificates in
 | 
					 | 
				
			||||||
whatever name they choose.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[BUILD] =======================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the linker complain about undefined symbols?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Maybe the compilation was interrupted, and make doesn't notice that
 | 
					 | 
				
			||||||
something is missing.  Run "make clean; make".
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you used ./Configure instead of ./config, make sure that you
 | 
					 | 
				
			||||||
selected the right target.  File formats may differ slightly between
 | 
					 | 
				
			||||||
OS versions (for example sparcv8/sparcv9, or a.out/elf).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
In case you get errors about the following symbols, use the config
 | 
					 | 
				
			||||||
option "no-asm", as described in INSTALL:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 BF_cbc_encrypt, BF_decrypt, BF_encrypt, CAST_cbc_encrypt,
 | 
					 | 
				
			||||||
 CAST_decrypt, CAST_encrypt, RC4, RC5_32_cbc_encrypt, RC5_32_decrypt,
 | 
					 | 
				
			||||||
 RC5_32_encrypt, bn_add_words, bn_div_words, bn_mul_add_words,
 | 
					 | 
				
			||||||
 bn_mul_comba4, bn_mul_comba8, bn_mul_words, bn_sqr_comba4,
 | 
					 | 
				
			||||||
 bn_sqr_comba8, bn_sqr_words, bn_sub_words, des_decrypt3,
 | 
					 | 
				
			||||||
 des_ede3_cbc_encrypt, des_encrypt, des_encrypt2, des_encrypt3,
 | 
					 | 
				
			||||||
 des_ncbc_encrypt, md5_block_asm_host_order, sha1_block_asm_data_order
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If none of these helps, you may want to try using the current snapshot.
 | 
					 | 
				
			||||||
If the problem persists, please submit a bug report.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the OpenSSL test fail with "bc: command not found"?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You didn't install "bc", the Unix calculator.  If you want to run the
 | 
					 | 
				
			||||||
tests, get GNU bc from ftp://ftp.gnu.org or from your OS distributor.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the OpenSSL test fail with "bc: 1 no implemented"?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On some SCO installations or versions, bc has a bug that gets triggered
 | 
					 | 
				
			||||||
when you run the test suite (using "make test").  The message returned is
 | 
					 | 
				
			||||||
"bc: 1 not implemented".
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The best way to deal with this is to find another implementation of bc
 | 
					 | 
				
			||||||
and compile/install it.  GNU bc (see http://www.gnu.org/software/software.html
 | 
					 | 
				
			||||||
for download instructions) can be safely used, for example.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
On some Alpha installations running Tru64 Unix and Compaq C, the compilation
 | 
					 | 
				
			||||||
of crypto/sha/sha_dgst.c fails with the message 'Fatal:  Insufficient virtual
 | 
					 | 
				
			||||||
memory to continue compilation.'  As far as the tests have shown, this may be
 | 
					 | 
				
			||||||
a compiler bug.  What happens is that it eats up a lot of resident memory
 | 
					 | 
				
			||||||
to build something, probably a table.  The problem is clearly in the
 | 
					 | 
				
			||||||
optimization code, because if one eliminates optimization completely (-O0),
 | 
					 | 
				
			||||||
the compilation goes through (and the compiler consumes about 2MB of resident
 | 
					 | 
				
			||||||
memory instead of 240MB or whatever one's limit is currently).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There are three options to solve this problem:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
1. set your current data segment size soft limit higher.  Experience shows
 | 
					 | 
				
			||||||
that about 241000 kbytes seems to be enough on an AlphaServer DS10.  You do
 | 
					 | 
				
			||||||
this with the command 'ulimit -Sd nnnnnn', where 'nnnnnn' is the number of
 | 
					 | 
				
			||||||
kbytes to set the limit to.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
2. If you have a hard limit that is lower than what you need and you can't
 | 
					 | 
				
			||||||
get it changed, you can compile all of OpenSSL with -O0 as optimization
 | 
					 | 
				
			||||||
level.  This is however not a very nice thing to do for those who expect to
 | 
					 | 
				
			||||||
get the best result from OpenSSL.  A bit more complicated solution is the
 | 
					 | 
				
			||||||
following:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
----- snip:start -----
 | 
					 | 
				
			||||||
  make DIRS=crypto SDIRS=sha "`grep '^CFLAG=' Makefile.ssl | \
 | 
					 | 
				
			||||||
       sed -e 's/ -O[0-9] / -O0 /'`"
 | 
					 | 
				
			||||||
  rm `ls crypto/*.o crypto/sha/*.o | grep -v 'sha_dgst\.o'`
 | 
					 | 
				
			||||||
  make
 | 
					 | 
				
			||||||
----- snip:end -----
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This will only compile sha_dgst.c with -O0, the rest with the optimization
 | 
					 | 
				
			||||||
level chosen by the configuration process.  When the above is done, do the
 | 
					 | 
				
			||||||
test and installation and you're set.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail with "ar: command not found"?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Getting this message is quite usual on Solaris 2, because Sun has hidden
 | 
					 | 
				
			||||||
away 'ar' and other development commands in directories that aren't in
 | 
					 | 
				
			||||||
$PATH by default.  One of those directories is '/usr/ccs/bin'.  The
 | 
					 | 
				
			||||||
quickest way to fix this is to do the following (it assumes you use sh
 | 
					 | 
				
			||||||
or any sh-compatible shell):
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
----- snip:start -----
 | 
					 | 
				
			||||||
  PATH=${PATH}:/usr/ccs/bin; export PATH
 | 
					 | 
				
			||||||
----- snip:end -----
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
and then redo the compilation.  What you should really do is make sure
 | 
					 | 
				
			||||||
'/usr/ccs/bin' is permanently in your $PATH, for example through your
 | 
					 | 
				
			||||||
'.profile' (again, assuming you use a sh-compatible shell).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why does the OpenSSL compilation fail on Win32 with VC++?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Sometimes, you may get reports from VC++ command line (cl) that it
 | 
					 | 
				
			||||||
can't find standard include files like stdio.h and other weirdnesses.
 | 
					 | 
				
			||||||
One possible cause is that the environment isn't correctly set up.
 | 
					 | 
				
			||||||
To solve that problem, one should run VCVARS32.BAT which is found in
 | 
					 | 
				
			||||||
the 'bin' subdirectory of the VC++ installation directory (somewhere
 | 
					 | 
				
			||||||
under 'Program Files').  This needs to be done prior to running NMAKE,
 | 
					 | 
				
			||||||
and the changes are only valid for the current DOS session.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[PROG] ========================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Is OpenSSL thread-safe?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Yes (with limitations: an SSL connection may not concurrently be used
 | 
					 | 
				
			||||||
by multiple threads).  On Windows and many Unix systems, OpenSSL
 | 
					 | 
				
			||||||
automatically uses the multi-threaded versions of the standard
 | 
					 | 
				
			||||||
libraries.  If your platform is not one of these, consult the INSTALL
 | 
					 | 
				
			||||||
file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Multi-threaded applications must provide two callback functions to
 | 
					 | 
				
			||||||
OpenSSL.  This is described in the threads(3) manpage.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* I've compiled a program under Windows and it crashes: why?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This is usually because you've missed the comment in INSTALL.W32.
 | 
					 | 
				
			||||||
Your application must link against the same version of the Win32
 | 
					 | 
				
			||||||
C-Runtime against which your openssl libraries were linked.  The
 | 
					 | 
				
			||||||
default version for OpenSSL is /MD - "Multithreaded DLL".
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you are using Microsoft Visual C++'s IDE (Visual Studio), in
 | 
					 | 
				
			||||||
many cases, your new project most likely defaulted to "Debug
 | 
					 | 
				
			||||||
Singlethreaded" - /ML.  This is NOT interchangeable with /MD and your
 | 
					 | 
				
			||||||
program will crash, typically on the first BIO related read or write
 | 
					 | 
				
			||||||
operation.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
For each of the six possible link stage configurations within Win32,
 | 
					 | 
				
			||||||
your application must link  against the same by which OpenSSL was
 | 
					 | 
				
			||||||
built.  If you are using MS Visual C++ (Studio) this can be changed
 | 
					 | 
				
			||||||
by:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
1.  Select Settings... from the Project Menu.
 | 
					 | 
				
			||||||
2.  Select the C/C++ Tab.
 | 
					 | 
				
			||||||
3.  Select "Code Generation from the "Category" drop down list box
 | 
					 | 
				
			||||||
4.  Select the Appropriate library (see table below) from the "Use
 | 
					 | 
				
			||||||
    run-time library" drop down list box.  Perform this step for both
 | 
					 | 
				
			||||||
    your debug and release versions of your application (look at the
 | 
					 | 
				
			||||||
    top left of the settings panel to change between the two)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Single Threaded           /ML        -  MS VC++ often defaults to
 | 
					 | 
				
			||||||
                                            this for the release
 | 
					 | 
				
			||||||
                                            version of a new project.
 | 
					 | 
				
			||||||
    Debug Single Threaded     /MLd       -  MS VC++ often defaults to
 | 
					 | 
				
			||||||
                                            this for the debug version
 | 
					 | 
				
			||||||
                                            of a new project.
 | 
					 | 
				
			||||||
    Multithreaded             /MT
 | 
					 | 
				
			||||||
    Debug Multithreaded       /MTd
 | 
					 | 
				
			||||||
    Multithreaded DLL         /MD        -  OpenSSL defaults to this.
 | 
					 | 
				
			||||||
    Debug Multithreaded DLL   /MDd
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Note that debug and release libraries are NOT interchangeable.  If you
 | 
					 | 
				
			||||||
built OpenSSL with /MD your application must use /MD and cannot use /MDd.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* How do I read or write a DER encoded buffer using the ASN1 functions?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
You have two options. You can either use a memory BIO in conjunction
 | 
					 | 
				
			||||||
with the i2d_XXX_bio() or d2i_XXX_bio() functions or you can use the
 | 
					 | 
				
			||||||
i2d_XXX(), d2i_XXX() functions directly. Since these are often the
 | 
					 | 
				
			||||||
cause of grief here are some code fragments using PKCS7 as an example:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unsigned char *buf, *p;
 | 
					 | 
				
			||||||
int len;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
len = i2d_PKCS7(p7, NULL);
 | 
					 | 
				
			||||||
buf = OPENSSL_malloc(len); /* or Malloc, error checking omitted */
 | 
					 | 
				
			||||||
p = buf;
 | 
					 | 
				
			||||||
i2d_PKCS7(p7, &p);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
At this point buf contains the len bytes of the DER encoding of
 | 
					 | 
				
			||||||
p7.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The opposite assumes we already have len bytes in buf:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unsigned char *p;
 | 
					 | 
				
			||||||
p = buf;
 | 
					 | 
				
			||||||
p7 = d2i_PKCS7(NULL, &p, len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
At this point p7 contains a valid PKCS7 structure of NULL if an error
 | 
					 | 
				
			||||||
occurred. If an error occurred ERR_print_errors(bio) should give more
 | 
					 | 
				
			||||||
information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The reason for the temporary variable 'p' is that the ASN1 functions
 | 
					 | 
				
			||||||
increment the passed pointer so it is ready to read or write the next
 | 
					 | 
				
			||||||
structure. This is often a cause of problems: without the temporary
 | 
					 | 
				
			||||||
variable the buffer pointer is changed to point just after the data
 | 
					 | 
				
			||||||
that has been read or written. This may well be uninitialized data
 | 
					 | 
				
			||||||
and attempts to free the buffer will have unpredictable results
 | 
					 | 
				
			||||||
because it no longer points to the same address.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This usually happens when you try compiling something using the PKCS#12
 | 
					 | 
				
			||||||
macros with a C++ compiler. There is hardly ever any need to use the
 | 
					 | 
				
			||||||
PKCS#12 macros in a program, it is much easier to parse and create
 | 
					 | 
				
			||||||
PKCS#12 files using the PKCS12_parse() and PKCS12_create() functions
 | 
					 | 
				
			||||||
documented in doc/openssl.txt and with examples in demos/pkcs12. The
 | 
					 | 
				
			||||||
'pkcs12' application has to use the macros because it prints out 
 | 
					 | 
				
			||||||
debugging information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* I've called <some function> and it fails, why?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Before submitting a report or asking in one of the mailing lists, you
 | 
					 | 
				
			||||||
should try to determine the cause. In particular, you should call
 | 
					 | 
				
			||||||
ERR_print_errors() or ERR_print_errors_fp() after the failed call
 | 
					 | 
				
			||||||
and see if the message helps. Note that the problem may occur earlier
 | 
					 | 
				
			||||||
than you think -- you should check for errors after every call where
 | 
					 | 
				
			||||||
it is possible, otherwise the actual problem may be hidden because
 | 
					 | 
				
			||||||
some OpenSSL functions clear the error state.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* I just get a load of numbers for the error output, what do they mean?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The actual format is described in the ERR_print_errors() manual page.
 | 
					 | 
				
			||||||
You should call the function ERR_load_crypto_strings() before hand and
 | 
					 | 
				
			||||||
the message will be output in text form. If you can't do this (for example
 | 
					 | 
				
			||||||
it is a pre-compiled binary) you can use the errstr utility on the error
 | 
					 | 
				
			||||||
code itself (the hex digits after the second colon).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why do I get errors about unknown algorithms?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This can happen under several circumstances such as reading in an
 | 
					 | 
				
			||||||
encrypted private key or attempting to decrypt a PKCS#12 file. The cause
 | 
					 | 
				
			||||||
is forgetting to load OpenSSL's table of algorithms with
 | 
					 | 
				
			||||||
OpenSSL_add_all_algorithms(). See the manual page for more information.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why can't the OpenSSH configure script detect OpenSSL?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Several reasons for problems with the automatic detection exist.
 | 
					 | 
				
			||||||
OpenSSH requires at least version 0.9.5a of the OpenSSL libraries.
 | 
					 | 
				
			||||||
Sometimes the distribution has installed an older version in the system
 | 
					 | 
				
			||||||
locations that is detected instead of a new one installed. The OpenSSL
 | 
					 | 
				
			||||||
library might have been compiled for another CPU or another mode (32/64 bits).
 | 
					 | 
				
			||||||
Permissions might be wrong.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The general answer is to check the config.log file generated when running
 | 
					 | 
				
			||||||
the OpenSSH configure script. It should contain the detailed information
 | 
					 | 
				
			||||||
on why the OpenSSL library was not detected or considered incompatible.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Can I use OpenSSL's SSL library with non-blocking I/O?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Yes; make sure to read the SSL_get_error(3) manual page!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
A pitfall to avoid: Don't assume that SSL_read() will just read from
 | 
					 | 
				
			||||||
the underlying transport or that SSL_write() will just write to it --
 | 
					 | 
				
			||||||
it is also possible that SSL_write() cannot do any useful work until
 | 
					 | 
				
			||||||
there is data to read, or that SSL_read() cannot do anything until it
 | 
					 | 
				
			||||||
is possible to send data.  One reason for this is that the peer may
 | 
					 | 
				
			||||||
request a new TLS/SSL handshake at any time during the protocol,
 | 
					 | 
				
			||||||
requiring a bi-directional message exchange; both SSL_read() and
 | 
					 | 
				
			||||||
SSL_write() will try to continue any pending handshake.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
* Why doesn't my server application receive a client certificate?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Due to the TLS protocol definition, a client will only send a certificate,
 | 
					 | 
				
			||||||
if explicitly asked by the server. Use the SSL_VERIFY_PEER flag of the
 | 
					 | 
				
			||||||
SSL_CTX_set_verify() function to enable the use of client certificates.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
===============================================================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										205
									
								
								INSTALL
									
									
									
									
									
								
							
							
						
						
									
										205
									
								
								INSTALL
									
									
									
									
									
								
							@@ -2,16 +2,13 @@
 | 
				
			|||||||
 INSTALLATION ON THE UNIX PLATFORM
 | 
					 INSTALLATION ON THE UNIX PLATFORM
 | 
				
			||||||
 ---------------------------------
 | 
					 ---------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 [Installation on Windows, OpenVMS and MacOS (before MacOS X) is described
 | 
					 [See INSTALL.W32 for instructions for compiling OpenSSL on Windows systems,
 | 
				
			||||||
  in INSTALL.W32, INSTALL.VMS and INSTALL.MacOS.]
 | 
					  and INSTALL.VMS for installing on OpenVMS systems.]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 To install OpenSSL, you will need:
 | 
					 To install OpenSSL, you will need:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  * make
 | 
					 | 
				
			||||||
  * Perl 5
 | 
					  * Perl 5
 | 
				
			||||||
  * an ANSI C compiler
 | 
					  * an ANSI C compiler
 | 
				
			||||||
  * a development environment in form of development libraries and C
 | 
					 | 
				
			||||||
    header files
 | 
					 | 
				
			||||||
  * a supported Unix operating system
 | 
					  * a supported Unix operating system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Quick Start
 | 
					 Quick Start
 | 
				
			||||||
@@ -36,8 +33,7 @@
 | 
				
			|||||||
 Configuration Options
 | 
					 Configuration Options
 | 
				
			||||||
 ---------------------
 | 
					 ---------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 There are several options to ./config (or ./Configure) to customize
 | 
					 There are several options to ./config to customize the build:
 | 
				
			||||||
 the build:
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  --prefix=DIR  Install in DIR/bin, DIR/lib, DIR/include/openssl.
 | 
					  --prefix=DIR  Install in DIR/bin, DIR/lib, DIR/include/openssl.
 | 
				
			||||||
	        Configuration files used by OpenSSL will be in DIR/ssl
 | 
						        Configuration files used by OpenSSL will be in DIR/ssl
 | 
				
			||||||
@@ -46,6 +42,9 @@
 | 
				
			|||||||
  --openssldir=DIR Directory for OpenSSL files. If no prefix is specified,
 | 
					  --openssldir=DIR Directory for OpenSSL files. If no prefix is specified,
 | 
				
			||||||
                the library files and binaries are also installed there.
 | 
					                the library files and binaries are also installed there.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  rsaref        Build with RSADSI's RSAREF toolkit (this assumes that
 | 
				
			||||||
 | 
					                librsaref.a is in the library search path).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  no-threads    Don't try to build with support for multi-threaded
 | 
					  no-threads    Don't try to build with support for multi-threaded
 | 
				
			||||||
                applications.
 | 
					                applications.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -53,15 +52,6 @@
 | 
				
			|||||||
                This will usually require additional system-dependent options!
 | 
					                This will usually require additional system-dependent options!
 | 
				
			||||||
                See "Note on multi-threading" below.
 | 
					                See "Note on multi-threading" below.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  no-shared     Don't try to create shared libraries.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  shared        In addition to the usual static libraries, create shared
 | 
					 | 
				
			||||||
                libraries on platforms where it's supported.  See "Note on
 | 
					 | 
				
			||||||
                shared libraries" below.  THIS IS NOT RECOMMENDED!  Since
 | 
					 | 
				
			||||||
                this is a development branch, the positions of the ENGINE
 | 
					 | 
				
			||||||
                symbols in the transfer vector are constantly moving, so
 | 
					 | 
				
			||||||
                binary backward compatibility can't be guaranteed in any way.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  no-asm        Do not use assembler code.
 | 
					  no-asm        Do not use assembler code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  386           Use the 80386 instruction set only (the default x86 code is
 | 
					  386           Use the 80386 instruction set only (the default x86 code is
 | 
				
			||||||
@@ -87,9 +77,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
     This guesses at your operating system (and compiler, if necessary) and
 | 
					     This guesses at your operating system (and compiler, if necessary) and
 | 
				
			||||||
     configures OpenSSL based on this guess. Run ./config -t to see
 | 
					     configures OpenSSL based on this guess. Run ./config -t to see
 | 
				
			||||||
     if it guessed correctly. If you want to use a different compiler, you
 | 
					     if it guessed correctly. If it did not get it correct or you want to
 | 
				
			||||||
     are cross-compiling for another platform, or the ./config guess was
 | 
					     use a different compiler then go to step 1b. Otherwise go to step 2.
 | 
				
			||||||
     wrong for other reasons, go to step 1b. Otherwise go to step 2.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
     On some systems, you can include debugging information as follows:
 | 
					     On some systems, you can include debugging information as follows:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -112,8 +101,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
     If your system is not available, you will have to edit the Configure
 | 
					     If your system is not available, you will have to edit the Configure
 | 
				
			||||||
     program and add the correct configuration for your system. The
 | 
					     program and add the correct configuration for your system. The
 | 
				
			||||||
     generic configurations "cc" or "gcc" should usually work on 32 bit
 | 
					     generic configurations "cc" or "gcc" should usually work.
 | 
				
			||||||
     systems.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
     Configure creates the file Makefile.ssl from Makefile.org and
 | 
					     Configure creates the file Makefile.ssl from Makefile.org and
 | 
				
			||||||
     defines various macros in crypto/opensslconf.h (generated from
 | 
					     defines various macros in crypto/opensslconf.h (generated from
 | 
				
			||||||
@@ -127,30 +115,18 @@
 | 
				
			|||||||
     OpenSSL binary ("openssl"). The libraries will be built in the top-level
 | 
					     OpenSSL binary ("openssl"). The libraries will be built in the top-level
 | 
				
			||||||
     directory, and the binary will be in the "apps" directory.
 | 
					     directory, and the binary will be in the "apps" directory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     If "make" fails, look at the output.  There may be reasons for
 | 
					     If "make" fails, please report the problem to <openssl-bugs@openssl.org>.
 | 
				
			||||||
     the failure that aren't problems in OpenSSL itself (like missing
 | 
					     Include the output of "./config -t" and the OpenSSL version
 | 
				
			||||||
     standard headers).  If it is a problem with OpenSSL itself, please
 | 
					     number in your message.
 | 
				
			||||||
     report the problem to <openssl-bugs@openssl.org> (note that your
 | 
					 | 
				
			||||||
     message will be forwarded to a public mailing list).  Include the
 | 
					 | 
				
			||||||
     output of "make report" in your message.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
     [If you encounter assembler error messages, try the "no-asm"
 | 
					 | 
				
			||||||
     configuration option as an immediate fix.]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
     Compiling parts of OpenSSL with gcc and others with the system
 | 
					 | 
				
			||||||
     compiler will result in unresolved symbols on some systems.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  3. After a successful build, the libraries should be tested. Run:
 | 
					  3. After a successful build, the libraries should be tested. Run:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       $ make test
 | 
					       $ make test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     If a test fails, look at the output.  There may be reasons for
 | 
					    If a test fails, try removing any compiler optimization flags from
 | 
				
			||||||
     the failure that isn't a problem in OpenSSL itself (like a missing
 | 
					    the CFLAGS line in Makefile.ssl and run "make clean; make". Please
 | 
				
			||||||
     or malfunctioning bc).  If it is a problem with OpenSSL itself,
 | 
					    send a bug report to <openssl-bugs@openssl.org>, including the
 | 
				
			||||||
     try removing any compiler optimization flags from the CFLAGS line
 | 
					    output of "openssl version -a" and of the failed test.
 | 
				
			||||||
     in Makefile.ssl and run "make clean; make". Please send a bug
 | 
					 | 
				
			||||||
     report to <openssl-bugs@openssl.org>, including the output of
 | 
					 | 
				
			||||||
     "make report".
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  4. If everything tests ok, install OpenSSL with
 | 
					  4. If everything tests ok, install OpenSSL with
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -161,13 +137,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
       certs           Initially empty, this is the default location
 | 
					       certs           Initially empty, this is the default location
 | 
				
			||||||
                       for certificate files.
 | 
					                       for certificate files.
 | 
				
			||||||
       man/man1        Manual pages for the 'openssl' command line tool
 | 
					 | 
				
			||||||
       man/man3        Manual pages for the libraries (very incomplete)
 | 
					 | 
				
			||||||
       misc            Various scripts.
 | 
					       misc            Various scripts.
 | 
				
			||||||
       private         Initially empty, this is the default location
 | 
					       private         Initially empty, this is the default location
 | 
				
			||||||
                       for private key files.
 | 
					                       for private key files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     If you didn't choose a different installation prefix, the
 | 
					     If you didn't chose a different installation prefix, the
 | 
				
			||||||
     following additional subdirectories will be created:
 | 
					     following additional subdirectories will be created:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       bin             Contains the openssl binary and a few other 
 | 
					       bin             Contains the openssl binary and a few other 
 | 
				
			||||||
@@ -269,18 +243,137 @@
 | 
				
			|||||||
 from the Configure script.)
 | 
					 from the Configure script.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Note on shared libraries
 | 
					--------------------------------------------------------------------------------
 | 
				
			||||||
 ------------------------
 | 
					The orignal Unix build instructions from SSLeay follow. 
 | 
				
			||||||
 | 
					Note: some of this may be out of date and no longer applicable
 | 
				
			||||||
 | 
					--------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Shared library is currently an experimental feature.  The only reason to
 | 
					# When bringing the SSLeay distribution back from the evil intel world
 | 
				
			||||||
 have them would be to conserve memory on systems where several program
 | 
					# of Windows NT, do the following to make it nice again under unix :-)
 | 
				
			||||||
 are using OpenSSL.  Binary backward compatibility can't be guaranteed
 | 
					# You don't normally need to run this.
 | 
				
			||||||
 before OpenSSL version 1.0.
 | 
					sh util/fixNT.sh	# This only works for NT now - eay - 21-Jun-1996
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 For some systems, the OpenSSL Configure script knows what is needed to
 | 
					# If you have perl, and it is not in /usr/local/bin, you can run
 | 
				
			||||||
 build shared libraries for libcrypto and libssl.  On these systems,
 | 
					perl util/perlpath.pl /new/path
 | 
				
			||||||
 the shared libraries are currently not created by default, but giving
 | 
					# and this will fix the paths in all the scripts.  DO NOT put
 | 
				
			||||||
 the option "shared" will get them created.  This method supports Makefile
 | 
					# /new/path/perl, just /new/path. The build
 | 
				
			||||||
 targets for shared library creation, like linux-shared.  Those targets
 | 
					# environment always run scripts as 'perl perlscript.pl' but some of the
 | 
				
			||||||
 can currently be used on their own just as well, but this is expected
 | 
					# 'applications' are easier to usr with the path fixed.
 | 
				
			||||||
 to change in future versions of OpenSSL.
 | 
					
 | 
				
			||||||
 | 
					# Edit crypto/cryptlib.h, tools/c_rehash, and Makefile.ssl
 | 
				
			||||||
 | 
					# to set the install locations if you don't like
 | 
				
			||||||
 | 
					# the default location of /usr/local/ssl
 | 
				
			||||||
 | 
					# Do this by running
 | 
				
			||||||
 | 
					perl util/ssldir.pl /new/ssl/home
 | 
				
			||||||
 | 
					# if you have perl, or by hand if not.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# If things have been stuffed up with the sym links, run
 | 
				
			||||||
 | 
					make -f Makefile.ssl links
 | 
				
			||||||
 | 
					# This will re-populate lib/include with symlinks and for each
 | 
				
			||||||
 | 
					# directory, link Makefile to Makefile.ssl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Setup the machine dependent stuff for the top level makefile
 | 
				
			||||||
 | 
					# and some select .h files
 | 
				
			||||||
 | 
					# If you don't have perl, this will bomb, in which case just edit the
 | 
				
			||||||
 | 
					# top level Makefile.ssl
 | 
				
			||||||
 | 
					./Configure 'system type'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# The 'Configure' command contains default configuration parameters
 | 
				
			||||||
 | 
					# for lots of machines.  Configure edits 5 lines in the top level Makefile
 | 
				
			||||||
 | 
					# It modifies the following values in the following files
 | 
				
			||||||
 | 
					Makefile.ssl		CC CFLAG EX_LIBS BN_MULW
 | 
				
			||||||
 | 
					crypto/des/des.h	DES_LONG
 | 
				
			||||||
 | 
					crypto/des/des_locl.h	DES_PTR
 | 
				
			||||||
 | 
					crypto/md2/md2.h	MD2_INT
 | 
				
			||||||
 | 
					crypto/rc4/rc4.h	RC4_INT
 | 
				
			||||||
 | 
					crypto/rc4/rc4_enc.c	RC4_INDEX
 | 
				
			||||||
 | 
					crypto/rc2/rc2.h	RC2_INT
 | 
				
			||||||
 | 
					crypto/bf/bf_locl.h	BF_INT
 | 
				
			||||||
 | 
					crypto/idea/idea.h	IDEA_INT
 | 
				
			||||||
 | 
					crypto/bn/bn.h		BN_LLONG (and defines one of SIXTY_FOUR_BIT,
 | 
				
			||||||
 | 
									  SIXTY_FOUR_BIT_LONG, THIRTY_TWO_BIT,
 | 
				
			||||||
 | 
									  SIXTEEN_BIT or EIGHT_BIT)
 | 
				
			||||||
 | 
					Please remember that all these files are actually copies of the file with
 | 
				
			||||||
 | 
					a .org extention.  So if you change crypto/des/des.h, the next time
 | 
				
			||||||
 | 
					you run Configure, it will be runover by a 'configured' version of
 | 
				
			||||||
 | 
					crypto/des/des.org.  So to make the changer the default, change the .org
 | 
				
			||||||
 | 
					files.  The reason these files have to be edited is because most of
 | 
				
			||||||
 | 
					these modifications change the size of fundamental data types.
 | 
				
			||||||
 | 
					While in theory this stuff is optional, it often makes a big
 | 
				
			||||||
 | 
					difference in performance and when using assember, it is importaint
 | 
				
			||||||
 | 
					for the 'Bignum bits' match those required by the assember code.
 | 
				
			||||||
 | 
					A warning for people using gcc with sparc cpu's.  Gcc needs the -mv8
 | 
				
			||||||
 | 
					flag to use the hardware multiply instruction which was not present in
 | 
				
			||||||
 | 
					earlier versions of the sparc CPU.  I define it by default.  If you
 | 
				
			||||||
 | 
					have an old sparc, and it crashes, try rebuilding with this flag
 | 
				
			||||||
 | 
					removed.  I am leaving this flag on by default because it makes
 | 
				
			||||||
 | 
					things run 4 times faster :-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# clean out all the old stuff
 | 
				
			||||||
 | 
					make clean
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Do a make depend only if you have the makedepend command installed
 | 
				
			||||||
 | 
					# This is not needed but it does make things nice when developing.
 | 
				
			||||||
 | 
					make depend
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# make should build everything
 | 
				
			||||||
 | 
					make
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# fix up the demo certificate hash directory if it has been stuffed up.
 | 
				
			||||||
 | 
					make rehash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# test everything
 | 
				
			||||||
 | 
					make test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# install the lot
 | 
				
			||||||
 | 
					make install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# It is worth noting that all the applications are built into the one
 | 
				
			||||||
 | 
					# program, ssleay, which is then has links from the other programs
 | 
				
			||||||
 | 
					# names to it.
 | 
				
			||||||
 | 
					# The applicatons can be built by themselves, just don't define the
 | 
				
			||||||
 | 
					# 'MONOLITH' flag.  So to build the 'enc' program stand alone,
 | 
				
			||||||
 | 
					gcc -O2 -Iinclude apps/enc.c apps/apps.c libcrypto.a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Other useful make options are
 | 
				
			||||||
 | 
					make makefile.one
 | 
				
			||||||
 | 
					# which generate a 'makefile.one' file which will build the complete
 | 
				
			||||||
 | 
					# SSLeay distribution with temp. files in './tmp' and 'installable' files
 | 
				
			||||||
 | 
					# in './out'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Have a look at running
 | 
				
			||||||
 | 
					perl util/mk1mf.pl help
 | 
				
			||||||
 | 
					# this can be used to generate a single makefile and is about the only
 | 
				
			||||||
 | 
					# way to generate makefiles for windows.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# There is actually a final way of building SSLeay.
 | 
				
			||||||
 | 
					gcc -O2 -c -Icrypto -Iinclude crypto/crypto.c
 | 
				
			||||||
 | 
					gcc -O2 -c -Issl -Iinclude ssl/ssl.c
 | 
				
			||||||
 | 
					# and you now have the 2 libraries as single object files :-).
 | 
				
			||||||
 | 
					# If you want to use the assember code for your particular platform
 | 
				
			||||||
 | 
					# (DEC alpha/x86 are the main ones, the other assember is just the
 | 
				
			||||||
 | 
					# output from gcc) you will need to link the assember with the above generated
 | 
				
			||||||
 | 
					# object file and also do the above compile as
 | 
				
			||||||
 | 
					gcc -O2 -DBN_ASM -c -Icrypto -Iinclude crypto/crypto.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This last option is probably the best way to go when porting to another
 | 
				
			||||||
 | 
					platform or building shared libraries.  It is not good for development so
 | 
				
			||||||
 | 
					I don't normally use it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					To build shared libararies under unix, have a look in shlib, basically 
 | 
				
			||||||
 | 
					you are on your own, but it is quite easy and all you have to do
 | 
				
			||||||
 | 
					is compile 2 (or 3) files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					For mult-threading, have a read of doc/threads.doc.  Again it is quite
 | 
				
			||||||
 | 
					easy and normally only requires some extra callbacks to be defined
 | 
				
			||||||
 | 
					by the application.
 | 
				
			||||||
 | 
					The examples for solaris and windows NT/95 are in the mt directory.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					have fun
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					eric 25-Jun-1997
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IRIX 5.x will build as a 32 bit system with mips1 assember.
 | 
				
			||||||
 | 
					IRIX 6.x will build as a 64 bit system with mips3 assember.  It conforms
 | 
				
			||||||
 | 
					to n32 standards. In theory you can compile the 64 bit assember under
 | 
				
			||||||
 | 
					IRIX 5.x but you will have to have the correct system software installed.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,72 +0,0 @@
 | 
				
			|||||||
OpenSSL - Port To The Macintosh OS 9 or Earlier
 | 
					 | 
				
			||||||
===============================================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Thanks to Roy Wood <roy@centricsystems.ca> initial support for Mac OS (pre
 | 
					 | 
				
			||||||
X) is now provided. "Initial" means that unlike other platforms where you
 | 
					 | 
				
			||||||
get an SDK and a "swiss army" openssl application, on Macintosh you only
 | 
					 | 
				
			||||||
get one sample application which fetches a page over HTTPS(*) and dumps it
 | 
					 | 
				
			||||||
in a window. We don't even build the test applications so that we can't
 | 
					 | 
				
			||||||
guarantee that all algorithms are operational.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Required software:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- StuffIt Expander 5.5 or later, alternatively MacGzip and SUNtar;
 | 
					 | 
				
			||||||
- Scriptable Finder;
 | 
					 | 
				
			||||||
- CodeWarrior Pro 5;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Installation procedure:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- fetch the source at ftp://ftp.openssl.org/ (well, you probably already
 | 
					 | 
				
			||||||
  did, huh?)
 | 
					 | 
				
			||||||
- unpack the .tar.gz file:
 | 
					 | 
				
			||||||
	- if you have StuffIt Expander then just drag it over it;
 | 
					 | 
				
			||||||
	- otherwise uncompress it with MacGzip and then unpack with SUNtar;
 | 
					 | 
				
			||||||
- locate MacOS folder in OpenSSL source tree and open it;
 | 
					 | 
				
			||||||
- unbinhex mklinks.as.hqx and OpenSSL.mcp.hqx if present (**), do it
 | 
					 | 
				
			||||||
  "in-place", i.e. unpacked files should end-up in the very same folder;
 | 
					 | 
				
			||||||
- execute mklinks.as;
 | 
					 | 
				
			||||||
- open OpenSSL.mcp(***) and build 'GetHTTPS PPC' target(****);
 | 
					 | 
				
			||||||
- that's it for now;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
(*)	URL is hardcoded into ./MacOS/GetHTTPS.src/GetHTTPS.cpp, lines 40
 | 
					 | 
				
			||||||
        to 42, change appropriately.
 | 
					 | 
				
			||||||
(**)	If you use SUNtar, then it might have already unbinhexed the files
 | 
					 | 
				
			||||||
	in question.
 | 
					 | 
				
			||||||
(***)	The project file was saved with CW Pro 5.3. If you have earlier
 | 
					 | 
				
			||||||
	version and it refuses to open it, then download
 | 
					 | 
				
			||||||
	http://www.openssl.org/~appro/OpenSSL.mcp.xml and import it
 | 
					 | 
				
			||||||
	overwriting the original OpenSSL.mcp.
 | 
					 | 
				
			||||||
(****)	Other targets are work in progress. If you feel like giving 'em a
 | 
					 | 
				
			||||||
	shot, then you should know that OpenSSL* and Lib* targets are
 | 
					 | 
				
			||||||
	supposed to be built with the GUSI, MacOS library which mimics
 | 
					 | 
				
			||||||
	BSD sockets and some other POSIX APIs. The GUSI distribution is
 | 
					 | 
				
			||||||
	expected to be found in the same directory as openssl source tree,
 | 
					 | 
				
			||||||
	i.e. in the parent directory to the one where this very file,
 | 
					 | 
				
			||||||
	namely INSTALL.MacOS. For more information about GUSI, see
 | 
					 | 
				
			||||||
	http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Finally some essential comments from our generous contributor:-)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
"I've gotten OpenSSL working on the Macintosh. It's probably a bit of a
 | 
					 | 
				
			||||||
hack, but it works for what I'm doing. If you don't like the way I've done
 | 
					 | 
				
			||||||
it, then feel free to change what I've done. I freely admit that I've done
 | 
					 | 
				
			||||||
some less-than-ideal things in my port, and if you don't like the way I've
 | 
					 | 
				
			||||||
done something, then feel free to change it-- I won't be offended!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
... I've tweaked "bss_sock.c" a little to call routines in a "MacSocket"
 | 
					 | 
				
			||||||
library I wrote. My MacSocket library is a wrapper around OpenTransport,
 | 
					 | 
				
			||||||
handling stuff like endpoint creation, reading, writing, etc. It is not
 | 
					 | 
				
			||||||
designed as a high-performance package such as you'd use in a webserver,
 | 
					 | 
				
			||||||
but is fine for lots of other applications. MacSocket also uses some other
 | 
					 | 
				
			||||||
code libraries I've written to deal with string manipulations and error
 | 
					 | 
				
			||||||
handling. Feel free to use these things in your own code, but give me
 | 
					 | 
				
			||||||
credit and/or send me free stuff in appreciation! :-)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
...
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
If you have any questions, feel free to email me as the following:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
roy@centricsystems.ca
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-Roy Wood"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										155
									
								
								INSTALL.VMS
									
									
									
									
									
								
							
							
						
						
									
										155
									
								
								INSTALL.VMS
									
									
									
									
									
								
							@@ -8,54 +8,13 @@ Intro:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
This file is divided in the following parts:
 | 
					This file is divided in the following parts:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Requirements			- Mandatory reading.
 | 
					 | 
				
			||||||
  Checking the distribution	- Mandatory reading.
 | 
					 | 
				
			||||||
  Compilation			- Mandatory reading.
 | 
					  Compilation			- Mandatory reading.
 | 
				
			||||||
  Logical names			- Mandatory reading.
 | 
					 | 
				
			||||||
  Test				- Mandatory reading.
 | 
					  Test				- Mandatory reading.
 | 
				
			||||||
  Installation			- Mandatory reading.
 | 
					  Installation			- Mandatory reading.
 | 
				
			||||||
  Backward portability		- Read if it's an issue.
 | 
					  Backward portability		- Read if it's an issue.
 | 
				
			||||||
  Possible bugs or quirks	- A few warnings on things that
 | 
					  Possible bugs or quirks	- A few warnings on things that
 | 
				
			||||||
				  may go wrong or may surprise you.
 | 
									  may go wrong or may surprise you.
 | 
				
			||||||
  TODO				- Things that are to come.
 | 
					  Report			- How to get in touch with me.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Requirements:
 | 
					 | 
				
			||||||
=============
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To build and install OpenSSL, you will need:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 * DEC C or some other ANSI C compiler.  VAX C is *not* supported.
 | 
					 | 
				
			||||||
   [Note: OpenSSL has only been tested with DEC C.  Compiling with 
 | 
					 | 
				
			||||||
    a different ANSI C compiler may require some work]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Checking the distribution:
 | 
					 | 
				
			||||||
==========================
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There have been reports of places where the distribution didn't quite get
 | 
					 | 
				
			||||||
through, for example if you've copied the tree from a NFS-mounted unix
 | 
					 | 
				
			||||||
mount point.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The easiest way to check if everything got through as it should is to check
 | 
					 | 
				
			||||||
for oen of the following files:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	[.CRYPTO]OPENSSLCONF.H_IN
 | 
					 | 
				
			||||||
	[.CRYPTO]OPENSSLCONF_H.IN
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
They should never exist both at once, but one of them should (preferably
 | 
					 | 
				
			||||||
the first variant).  If you can't find any of those two, something went
 | 
					 | 
				
			||||||
wrong.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The best way to get a correct distribution is to download the gzipped tar
 | 
					 | 
				
			||||||
file from ftp://ftp.openssl.org/source/, use GUNZIP to uncompress it and
 | 
					 | 
				
			||||||
use VMSTAR to unpack the resulting tar file.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
GUNZIP is available in many places on the net.  One of the distribution
 | 
					 | 
				
			||||||
points is the WKU software archive, ftp://ftp.wku.edu/vms/fileserv/ .
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
VMSTAR is also available in many places on the net.  The recommended place
 | 
					 | 
				
			||||||
to find information about it is http://www.free.lp.se/vmstar/ .
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Compilation:
 | 
					Compilation:
 | 
				
			||||||
============
 | 
					============
 | 
				
			||||||
@@ -76,33 +35,26 @@ directory.  The syntax is trhe following:
 | 
				
			|||||||
<option> must be one of the following:
 | 
					<option> must be one of the following:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      ALL       Just build "everything".
 | 
					      ALL       Just build "everything".
 | 
				
			||||||
      CONFIG    Just build the "[.CRYPTO]OPENSSLCONF.H" file.
 | 
					      DATE      Just build the "[.INCLUDE]DATE.H" file.
 | 
				
			||||||
      BUILDINF  Just build the "[.INCLUDE]BUILDINF.H" file.
 | 
					 | 
				
			||||||
      SOFTLINKS Just copies some files, to simulate Unix soft links.
 | 
					      SOFTLINKS Just copies some files, to simulate Unix soft links.
 | 
				
			||||||
      BUILDALL  Same as ALL, except CONFIG, BUILDINF and SOFTILNKS aren't done.
 | 
					 | 
				
			||||||
      RSAREF    Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
 | 
					      RSAREF    Just build the "[.xxx.EXE.RSAREF]LIBRSAGLUE.OLB" library.
 | 
				
			||||||
      CRYPTO    Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
 | 
					      CRYPTO    Just build the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" library.
 | 
				
			||||||
      SSL       Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library.
 | 
					      SSL       Just build the "[.xxx.EXE.SSL]LIBSSL.OLB" library.
 | 
				
			||||||
      SSL_TASK  Just build the "[.xxx.EXE.SSL]SSL_TASK.EXE" program.
 | 
					      SSL_TASK  Just build the "[.xxx.EXE.SSL]SSL_TASK.EXE" program.
 | 
				
			||||||
      TEST      Just build the "[.xxx.EXE.TEST]" test programs for OpenSSL.
 | 
					      TEST      Just build the "test" programs for OpenSSL.
 | 
				
			||||||
      APPS      Just build the "[.xxx.EXE.APPS]" application programs for OpenSSL.
 | 
					      APPS      Just build the "application" programs for OpenSSL.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<rsaref-p> must be one of the following:
 | 
					<rsaref-p> must be one of the following:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      RSAREF    compile using the RSAREF Library
 | 
					      RSAREF    compile using the RSAREF Library
 | 
				
			||||||
      NORSAREF  compile without using RSAREF
 | 
					      NORSAREF  compile without using RSAREF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note 0: The RASREF library IS NO LONGER NEEDED.  The RSA patent
 | 
					Note: The RSAREF libraries are NOT INCLUDED and you have to
 | 
				
			||||||
        expires September 20, 2000, and RSA Security chose to make
 | 
					      download it from "ftp://ftp.rsa.com/rsaref".  You have to
 | 
				
			||||||
        the algorithm public domain two weeks before that.
 | 
					      get the ".tar-Z" file as the ".zip" file dosen't have the
 | 
				
			||||||
 | 
					      directory structure stored.  You have to extract the file
 | 
				
			||||||
Note 1: If you still want to use RSAREF, the library is NOT INCLUDED
 | 
					      into the [.RSAREF] directory as that is where the scripts
 | 
				
			||||||
        and you have to download it.  RSA Security doesn't carry it
 | 
					      will look for the files.
 | 
				
			||||||
        any more, but there are a number of places where you can find
 | 
					 | 
				
			||||||
        it.  You have to get the ".tar-Z" file as the ".zip" file
 | 
					 | 
				
			||||||
        doesn't have the directory structure stored.  You have to
 | 
					 | 
				
			||||||
        extract the file into the [.RSAREF] directory as that is where
 | 
					 | 
				
			||||||
        the scripts will look for the files.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note 2: I have never done this, so I've no idea if it works or not.
 | 
					Note 2: I have never done this, so I've no idea if it works or not.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -113,6 +65,7 @@ Note 2: I have never done this, so I've no idea if it works or not.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<compiler> must be one of the following:
 | 
					<compiler> must be one of the following:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      VAXC      For VAX C.
 | 
				
			||||||
      DECC      For DEC C.
 | 
					      DECC      For DEC C.
 | 
				
			||||||
      GNUC      For GNU C.
 | 
					      GNUC      For GNU C.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -124,33 +77,11 @@ named LIBSSL.OLB, and you will find a bunch of useful programs in
 | 
				
			|||||||
just to test them.  For production use, make sure you install first, see
 | 
					just to test them.  For production use, make sure you install first, see
 | 
				
			||||||
Installation below.
 | 
					Installation below.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note 1: Some programs in this package require a TCP/IP library.
 | 
					Note: Some programs in this package require a TCP/IP library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note 2: if you want to compile the crypto library only, please make sure
 | 
					Note 2: if you want to compile the crypto library only, please make sure
 | 
				
			||||||
        you have at least done a @MAKEVMS CONFIG, a @MAKEVMS BUILDINF and
 | 
					        you have at least done a @MAKEVMS DATE and a @MAKEVMS SOFTLINKS.
 | 
				
			||||||
        a @MAKEVMS SOFTLINKS.  A lot of things will break if you don't.
 | 
					        A lot of things will break if you don't.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Logical names:
 | 
					 | 
				
			||||||
==============
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There are a few things that can't currently be given through the command
 | 
					 | 
				
			||||||
line.  Instead, logical names are used.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Currently, the logical names supported are:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      OPENSSL_NO_ASM    with value YES, the assembler parts of OpenSSL will
 | 
					 | 
				
			||||||
                        not be used.  Instead, plain C implementations are
 | 
					 | 
				
			||||||
                        used.  This is good to try if something doesn't work.
 | 
					 | 
				
			||||||
      OPENSSL_NO_'alg'  with value YES, the corresponding crypto algorithm
 | 
					 | 
				
			||||||
                        will not be implemented.  Supported algorithms to
 | 
					 | 
				
			||||||
                        do this with are: RSA, DSA, DH, MD2, MD4, MD5, RIPEMD,
 | 
					 | 
				
			||||||
                        SHA, DES, MDC2, CR2, RC4, RC5, IDEA, BF, CAST, HMAC,
 | 
					 | 
				
			||||||
                        SSL2.  So, for example, having the logical name
 | 
					 | 
				
			||||||
                        OPENSSL_NO_RSA with the value YES means that the
 | 
					 | 
				
			||||||
                        LIBCRYPTO.OLB library will not contain an RSA
 | 
					 | 
				
			||||||
                        implementation.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Test:
 | 
					Test:
 | 
				
			||||||
=====
 | 
					=====
 | 
				
			||||||
@@ -164,7 +95,6 @@ it's an ugly hack!) and rebuild. Please send a bug report to
 | 
				
			|||||||
<openssl-bugs@openssl.org>, including the output of "openssl version -a"
 | 
					<openssl-bugs@openssl.org>, including the output of "openssl version -a"
 | 
				
			||||||
and of the failed test.
 | 
					and of the failed test.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
Installation:
 | 
					Installation:
 | 
				
			||||||
=============
 | 
					=============
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -176,9 +106,6 @@ Installation is easy, just do the following:
 | 
				
			|||||||
subdirectories, libraries, header files, programs and startup command
 | 
					subdirectories, libraries, header files, programs and startup command
 | 
				
			||||||
procedures.
 | 
					procedures.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
N.B.: INSTALL.COM builds a new directory structure, different from
 | 
					 | 
				
			||||||
the directory tree where you have now build OpenSSL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
In the [.VMS] subdirectory of the installation, you will find the
 | 
					In the [.VMS] subdirectory of the installation, you will find the
 | 
				
			||||||
following command procedures:
 | 
					following command procedures:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -200,29 +127,14 @@ The logical names that are set up are the following:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  SSLROOT       a dotted concealed logical name pointing at the
 | 
					  SSLROOT       a dotted concealed logical name pointing at the
 | 
				
			||||||
                root directory.
 | 
					                root directory.
 | 
				
			||||||
 | 
					  SSLLIB        points at the directory where CRYPTORTL.OLB and
 | 
				
			||||||
  SSLCERTS      Initially an empty directory, this is the default
 | 
							SSLRTL.OLB are installed.
 | 
				
			||||||
		location for certificate files.
 | 
					  SSLINCLUDE    points at the directory where the header files are
 | 
				
			||||||
  SSLMISC	Various scripts.
 | 
					                installed.
 | 
				
			||||||
  SSLPRIVATE	Initially an empty directory, this is the default
 | 
					  SSLEXE        points at the directory where the applications are
 | 
				
			||||||
		location for private key files.
 | 
					                installed.
 | 
				
			||||||
 | 
					  SSLCERTS      the place where the certificates are stored.
 | 
				
			||||||
  SSLEXE        Contains the openssl binary and a few other utility
 | 
					  SSLPRIVATE    I'm actually not sure what this is used for.
 | 
				
			||||||
		programs.
 | 
					 | 
				
			||||||
  SSLINCLUDE    Contains the header files needed if you want to
 | 
					 | 
				
			||||||
		compile programs with libcrypto or libssl.
 | 
					 | 
				
			||||||
  SSLLIB        Contains the OpenSSL library files (LIBCRYPTO.OLB
 | 
					 | 
				
			||||||
		and LIBSSL.OLB) themselves.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  OPENSSL	Same as SSLINCLUDE.  This is because the standard
 | 
					 | 
				
			||||||
		way to include OpenSSL header files from version
 | 
					 | 
				
			||||||
		0.9.3 and on is:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			#include <openssl/header.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		For more info on this issue, see the INSTALL. file
 | 
					 | 
				
			||||||
		(the NOTE in section 4 of "Installation in Detail").
 | 
					 | 
				
			||||||
		You don't need to "deleting old header files"!!!
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Backward portability:
 | 
					Backward portability:
 | 
				
			||||||
@@ -242,7 +154,7 @@ dependent on the OpenVMS version or the C library version, *and* you
 | 
				
			|||||||
can use those macros to simulate older OpenVMS or C library versions,
 | 
					can use those macros to simulate older OpenVMS or C library versions,
 | 
				
			||||||
by defining the macros _VMS_V6_SOURCE, __VMS_VER and __CTRL_VER with
 | 
					by defining the macros _VMS_V6_SOURCE, __VMS_VER and __CTRL_VER with
 | 
				
			||||||
correct values.  In the compilation scripts, I've provided the possibility
 | 
					correct values.  In the compilation scripts, I've provided the possibility
 | 
				
			||||||
for the user to influence the creation of such macros, through a bunch of
 | 
					for the user to influense the creation of such macros, through a bunch of
 | 
				
			||||||
symbols, all having names starting with USER_.  Here's the list of them:
 | 
					symbols, all having names starting with USER_.  Here's the list of them:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  USER_CCFLAGS		 - Used to give additional qualifiers to the
 | 
					  USER_CCFLAGS		 - Used to give additional qualifiers to the
 | 
				
			||||||
@@ -279,21 +191,14 @@ directory by default, it may very well be that you have to give them
 | 
				
			|||||||
extra arguments.  Please experiment.
 | 
					extra arguments.  Please experiment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TODO:
 | 
					Report:
 | 
				
			||||||
=====
 | 
					=======
 | 
				
			||||||
 | 
					
 | 
				
			||||||
There are a few things that need to be worked out in the VMS version of
 | 
					I maintain a few mailinglists for bug reports and such on software that
 | 
				
			||||||
OpenSSL, still:
 | 
					I develop/port/enhance/destroy.  Please look at http://www.free.lp.se/
 | 
				
			||||||
 | 
					for further info.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Description files. ("Makefile's" :-))
 | 
					 | 
				
			||||||
- Script code to link an already compiled build tree.
 | 
					 | 
				
			||||||
- A VMSINSTALlable version (way in the future, unless someone else hacks).
 | 
					 | 
				
			||||||
- shareable images (DLL for you Windows folks).
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
There may be other things that I have missed and that may be desirable.
 | 
					-- 
 | 
				
			||||||
Please send mail to <openssl-users@openssl.org> or to me directly if you
 | 
					 | 
				
			||||||
have any ideas.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--
 | 
					 | 
				
			||||||
Richard Levitte <richard@levitte.org>
 | 
					Richard Levitte <richard@levitte.org>
 | 
				
			||||||
2000-02-27
 | 
					1999-03-09
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										333
									
								
								INSTALL.W32
									
									
									
									
									
								
							
							
						
						
									
										333
									
								
								INSTALL.W32
									
									
									
									
									
								
							@@ -2,39 +2,16 @@
 | 
				
			|||||||
 INSTALLATION ON THE WIN32 PLATFORM
 | 
					 INSTALLATION ON THE WIN32 PLATFORM
 | 
				
			||||||
 ----------------------------------
 | 
					 ----------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Heres a few comments about building OpenSSL in Windows environments.  Most
 | 
					 Heres a few comments about building OpenSSL in Windows environments. Most of
 | 
				
			||||||
 of this is tested on Win32 but it may also work in Win 3.1 with some
 | 
					 this is tested on Win32 but it may also work in Win 3.1 with some
 | 
				
			||||||
 modification.
 | 
					 modification.  See the end of this file for Eric's original comments.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 You need Perl for Win32.  Unless you will build on Cygwin, you will need
 | 
					 | 
				
			||||||
 ActiveState Perl, available from http://www.activestate.com/ActivePerl.
 | 
					 | 
				
			||||||
 For Cygwin users, there's more info in the Cygwin section.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 You need Perl for Win32 (available from http://activestate.com/ActivePerl)
 | 
				
			||||||
 and one of the following C compilers:
 | 
					 and one of the following C compilers:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  * Visual C++
 | 
					  * Visual C++
 | 
				
			||||||
  * Borland C
 | 
					  * Borland C
 | 
				
			||||||
  * GNU C (Mingw32 or Cygwin)
 | 
					  * GNU C (Mingw32 or Cygwin32)
 | 
				
			||||||
 | 
					 | 
				
			||||||
 If you want to compile in the assembly language routines with Visual C++ then
 | 
					 | 
				
			||||||
 you will need an assembler. This is worth doing because it will result in
 | 
					 | 
				
			||||||
 faster code: for example it will typically result in a 2 times speedup in the
 | 
					 | 
				
			||||||
 RSA routines. Currently the following assemblers are supported:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  * Microsoft MASM (aka "ml")
 | 
					 | 
				
			||||||
  * Free Netwide Assembler NASM.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 MASM was at one point distributed with VC++. It is now distributed with some
 | 
					 | 
				
			||||||
 Microsoft DDKs, for example the Windows NT 4.0 DDK and the Windows 98 DDK. If
 | 
					 | 
				
			||||||
 you do not have either of these DDKs then you can just download the binaries
 | 
					 | 
				
			||||||
 for the Windows 98 DDK and extract and rename the two files XXXXXml.exe and
 | 
					 | 
				
			||||||
 XXXXXml.err, to ml.exe and ml.err and install somewhere on your PATH. Both
 | 
					 | 
				
			||||||
 DDKs can be downloaded from the Microsoft developers site www.msdn.com.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 NASM is freely available. Version 0.98 was used during testing: other versions
 | 
					 | 
				
			||||||
 may also work. It is available from many places, see for example:
 | 
					 | 
				
			||||||
 http://www.kernel.org/pub/software/devel/nasm/binaries/win32/
 | 
					 | 
				
			||||||
 The NASM binary nasmw.exe needs to be installed anywhere on your PATH.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If you are compiling from a tarball or a CVS snapshot then the Win32 files
 | 
					 If you are compiling from a tarball or a CVS snapshot then the Win32 files
 | 
				
			||||||
 may well be not up to date. This may mean that some "tweaking" is required to
 | 
					 may well be not up to date. This may mean that some "tweaking" is required to
 | 
				
			||||||
@@ -44,27 +21,13 @@
 | 
				
			|||||||
 Visual C++
 | 
					 Visual C++
 | 
				
			||||||
 ----------
 | 
					 ----------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Firstly you should run Configure:
 | 
					 Firstly you should run Configure and build the Win32 Makefiles:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 > perl Configure VC-WIN32
 | 
					 > perl Configure VC-WIN32
 | 
				
			||||||
 | 
					 > ms\do_ms
 | 
				
			||||||
 Next you need to build the Makefiles and optionally the assembly language
 | 
					 | 
				
			||||||
 files:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - If you are using MASM then run:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   > ms\do_masm
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - If you are using NASM then run:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   > ms\do_nasm
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 - If you don't want to use the assembly language files at all then run:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   > ms\do_ms
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If you get errors about things not having numbers assigned then check the
 | 
					 If you get errors about things not having numbers assigned then check the
 | 
				
			||||||
 troubleshooting section: you probably won't be able to compile it as it
 | 
					 troubleshooting section: you probably wont be able to compile it as it
 | 
				
			||||||
 stands.
 | 
					 stands.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Then from the VC++ environment at a prompt do:
 | 
					 Then from the VC++ environment at a prompt do:
 | 
				
			||||||
@@ -79,10 +42,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 Tweaks:
 | 
					 Tweaks:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 There are various changes you can make to the Win32 compile environment. By
 | 
					 There are various changes you can make to the Win32 compile environment. If
 | 
				
			||||||
 default the library is not compiled with debugging symbols. If you add 'debug'
 | 
					 you have the MASM assembler 'ml' then you can try the assembly language code.
 | 
				
			||||||
 to the mk1mf.pl lines in the do_* batch file then debugging symbols will be
 | 
					 To do this remove the 'no-asm' part from do_ms.bat. You can also add 'debug'
 | 
				
			||||||
 compiled in.
 | 
					 here to make a debugging version of the library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 The default Win32 environment is to leave out any Windows NT specific
 | 
					 The default Win32 environment is to leave out any Windows NT specific
 | 
				
			||||||
 features.
 | 
					 features.
 | 
				
			||||||
@@ -111,20 +74,18 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 * Compiler installation:
 | 
					 * Compiler installation:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Mingw32 is available from <ftp://ftp.xraylith.wisc.edu/pub/khan/
 | 
					   Mingw32 is available from <ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/
 | 
				
			||||||
   gnu-win32/mingw32/gcc-2.95.2/gcc-2.95.2-msvcrt.exe>. GNU make is at
 | 
					   mingw32/egcs-1.1.2/egcs-1.1.2-mingw32.zip>. GNU make is at
 | 
				
			||||||
   <ftp://agnes.dida.physik.uni-essen.de/home/janjaap/mingw32/binaries/
 | 
					   <ftp://agnes.dida.physik.uni-essen.de/home/janjaap/mingw32/binaries/
 | 
				
			||||||
   make-3.76.1.zip>. Install both of them in C:\egcs-1.1.2 and run
 | 
					   make-3.76.1.zip>. Install both of them in C:\egcs-1.1.2 and run
 | 
				
			||||||
   C:\egcs-1.1.2\mingw32.bat to set the PATH.
 | 
					   C:\egcs-1.1.2\mingw32.bat to set the PATH.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 * Compile OpenSSL:
 | 
					 * Compile OpenSSL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   > ms\mingw32
 | 
					   > perl Configure Mingw32
 | 
				
			||||||
 | 
					   > ms\mw.bat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This will create the library and binaries in out. In case any problems
 | 
					   This will create the library and binaries in out.
 | 
				
			||||||
   occur, try
 | 
					 | 
				
			||||||
   > ms\mingw32 no-asm
 | 
					 | 
				
			||||||
   instead.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
   libcrypto.a and libssl.a are the static libraries. To use the DLLs,
 | 
					   libcrypto.a and libssl.a are the static libraries. To use the DLLs,
 | 
				
			||||||
   link with libeay32.a and libssl32.a instead.
 | 
					   link with libeay32.a and libssl32.a instead.
 | 
				
			||||||
@@ -137,84 +98,6 @@
 | 
				
			|||||||
   > cd out
 | 
					   > cd out
 | 
				
			||||||
   > ..\ms\test
 | 
					   > ..\ms\test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 GNU C (Cygwin)
 | 
					 | 
				
			||||||
 --------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 Cygwin provides a bash shell and GNU tools environment running on
 | 
					 | 
				
			||||||
 NT 4.0, Windows 9x and Windows 2000. Consequently, a make of OpenSSL
 | 
					 | 
				
			||||||
 with Cygwin is closer to a GNU bash environment such as Linux rather
 | 
					 | 
				
			||||||
 than other W32 makes that are based on a single makefile approach.
 | 
					 | 
				
			||||||
 Cygwin implements Posix/Unix calls through cygwin1.dll, and is
 | 
					 | 
				
			||||||
 contrasted to Mingw32 which links dynamically to msvcrt.dll or
 | 
					 | 
				
			||||||
 crtdll.dll.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 To build OpenSSL using Cygwin:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 * Install Cygwin (see http://sourceware.cygnus.com/cygwin)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 * Install Perl and ensure it is in the path (recent Cygwin perl 
 | 
					 | 
				
			||||||
   (version 5.6.1-2 of the latter has been reported to work) or
 | 
					 | 
				
			||||||
   ActivePerl)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 * Run the Cygwin bash shell
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 * $ tar zxvf openssl-x.x.x.tar.gz
 | 
					 | 
				
			||||||
   $ cd openssl-x.x.x
 | 
					 | 
				
			||||||
   $ ./config
 | 
					 | 
				
			||||||
   [...]
 | 
					 | 
				
			||||||
   $ make
 | 
					 | 
				
			||||||
   [...]
 | 
					 | 
				
			||||||
   $ make test
 | 
					 | 
				
			||||||
   $ make install
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 This will create a default install in /usr/local/ssl.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 Cygwin Notes:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 "make test" and normal file operations may fail in directories
 | 
					 | 
				
			||||||
 mounted as text (i.e. mount -t c:\somewhere /home) due to Cygwin
 | 
					 | 
				
			||||||
 stripping of carriage returns. To avoid this ensure that a binary
 | 
					 | 
				
			||||||
 mount is used, e.g. mount -b c:\somewhere /home.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 As of version 1.1.1 Cygwin is relatively unstable in its handling
 | 
					 | 
				
			||||||
 of cr/lf issues. These make procedures succeeded with versions 1.1 and
 | 
					 | 
				
			||||||
 the snapshot 20000524 (Slow!).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 "bc" is not provided in the Cygwin distribution.  This causes a
 | 
					 | 
				
			||||||
 non-fatal error in "make test" but is otherwise harmless.  If
 | 
					 | 
				
			||||||
 desired, GNU bc can be built with Cygwin without change.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 Installation
 | 
					 | 
				
			||||||
 ------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 If you used the Cygwin procedure above, you have already installed and
 | 
					 | 
				
			||||||
 can skip this section.  For all other procedures, there's currently no real
 | 
					 | 
				
			||||||
 installation procedure for Win32.  There are, however, some suggestions:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - do nothing.  The include files are found in the inc32/ subdirectory,
 | 
					 | 
				
			||||||
      all binaries are found in out32dll/ or out32/ depending if you built
 | 
					 | 
				
			||||||
      dynamic or static libraries.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - do as is written in INSTALL.Win32 that comes with modssl:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	$ md c:\openssl 
 | 
					 | 
				
			||||||
	$ md c:\openssl\bin
 | 
					 | 
				
			||||||
	$ md c:\openssl\lib
 | 
					 | 
				
			||||||
	$ md c:\openssl\include
 | 
					 | 
				
			||||||
	$ md c:\openssl\include\openssl
 | 
					 | 
				
			||||||
	$ copy /b inc32\*               c:\openssl\include\openssl
 | 
					 | 
				
			||||||
	$ copy /b out32dll\ssleay32.lib c:\openssl\lib
 | 
					 | 
				
			||||||
	$ copy /b out32dll\libeay32.lib c:\openssl\lib
 | 
					 | 
				
			||||||
	$ copy /b out32dll\ssleay32.dll c:\openssl\bin
 | 
					 | 
				
			||||||
	$ copy /b out32dll\libeay32.dll c:\openssl\bin
 | 
					 | 
				
			||||||
	$ copy /b out32dll\openssl.exe  c:\openssl\bin
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      Of course, you can choose another device than c:.  C: is used here
 | 
					 | 
				
			||||||
      because that's usually the first (and often only) harddisk device.
 | 
					 | 
				
			||||||
      Note: in the modssl INSTALL.Win32, p: is used rather than c:.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 Troubleshooting
 | 
					 Troubleshooting
 | 
				
			||||||
 ---------------
 | 
					 ---------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -225,21 +108,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 > perl util\mkdef.pl crypto ssl update
 | 
					 > perl util\mkdef.pl crypto ssl update
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 then ms\do_XXX should not give a warning any more. However the numbers that
 | 
					 then ms\do_ms should not give a warning any more. However the numbers that
 | 
				
			||||||
 get assigned by this technique may not match those that eventually get
 | 
					 get assigned by this technique may not match those that eventually get
 | 
				
			||||||
 assigned in the CVS tree: so anything linked against this version of the
 | 
					 assigned in the CVS tree: so anything linked against this version of the
 | 
				
			||||||
 library may need to be recompiled.
 | 
					 library may need to be recompiled.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If you get errors about unresolved symbols there are several possible
 | 
					 If you get errors about unresolved externals then this means that either you
 | 
				
			||||||
 causes.
 | 
					 didn't read the note above about functions not having numbers assigned or
 | 
				
			||||||
 | 
					 someone forgot to add a function to the header file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If this happens when the DLL is being linked and you have disabled some
 | 
					 In this latter case check out the header file to see if the function is
 | 
				
			||||||
 ciphers then it is possible the DEF file generator hasn't removed all
 | 
					 defined in the header file.
 | 
				
			||||||
 the disabled symbols: the easiest solution is to edit the DEF files manually
 | 
					 | 
				
			||||||
 to delete them. The DEF files are ms\libeay32.def ms\ssleay32.def.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 Another cause is if you missed or ignored the errors about missing numbers
 | 
					 | 
				
			||||||
 mentioned above.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If you get warnings in the code then the compilation will halt.
 | 
					 If you get warnings in the code then the compilation will halt.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -254,13 +133,159 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 One final comment about compiling applications linked to the OpenSSL library.
 | 
					 One final comment about compiling applications linked to the OpenSSL library.
 | 
				
			||||||
 If you don't use the multithreaded DLL runtime library (/MD option) your
 | 
					 If you don't use the multithreaded DLL runtime library (/MD option) your
 | 
				
			||||||
 program will almost certainly crash because malloc gets confused -- the
 | 
					 program will almost certainly crash: see the original SSLeay description
 | 
				
			||||||
 OpenSSL DLLs are statically linked to one version, the application must
 | 
					 below for more details.
 | 
				
			||||||
 not use a different one.  You might be able to work around such problems
 | 
					
 | 
				
			||||||
 by adding CRYPTO_malloc_init() to your program before any calls to the
 | 
					--------------------------------------------------------------------------------
 | 
				
			||||||
 OpenSSL libraries: This tells the OpenSSL libraries to use the same
 | 
					The orignal Windows build instructions from SSLeay follow. 
 | 
				
			||||||
 malloc(), free() and realloc() as the application.  However there are many
 | 
					Note: some of this may be out of date and no longer applicable. In particular
 | 
				
			||||||
 standard library functions used by OpenSSL that call malloc() internally
 | 
					the Crypto_malloc_init() comment appears to be wrong: you always need to use
 | 
				
			||||||
 (e.g. fopen()), and OpenSSL cannot change these; so in general you cannot
 | 
					the same runtime library as the DLL itself.
 | 
				
			||||||
 rely on CYRPTO_malloc_init() solving your problem, and you should
 | 
					--------------------------------------------------------------------------------
 | 
				
			||||||
 consistently use the multithreaded library.
 | 
					
 | 
				
			||||||
 | 
					The Microsoft World.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The good news, to build SSLeay for the Microsft World
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Windows 3.1 DLL's
 | 
				
			||||||
 | 
					perl Configure VC-WIN16
 | 
				
			||||||
 | 
					nmake -f ms\w31dll.mak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Windows NT/95 DLL's
 | 
				
			||||||
 | 
					perl Configure VC-WIN32
 | 
				
			||||||
 | 
					nmake -f ms\ntdll.mak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Now the bad news
 | 
				
			||||||
 | 
					All builds were done using Microsofts Visual C++ 1.52c and [45].x.
 | 
				
			||||||
 | 
					If you are a borland person, you are probably going to have to help me
 | 
				
			||||||
 | 
					finish the stuff in util/pl/BC*pl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					All builds were made under Windows NT - this means long filenames, so
 | 
				
			||||||
 | 
					you may have problems under Windows 3.1 but probably not under 95.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Because file pointers don't work in DLL's under Windows 3.1 (well at
 | 
				
			||||||
 | 
					least stdin/stdout don't and I don't like having to differentiate
 | 
				
			||||||
 | 
					between these and other file pointers), I now use the BIO file-pointer
 | 
				
			||||||
 | 
					module, which needs to be linked into your application.  You can either
 | 
				
			||||||
 | 
					use the memory buffer BIO for IO, or compile bss_file.c into your
 | 
				
			||||||
 | 
					application, it is in the apps directory and is just a copy of
 | 
				
			||||||
 | 
					crypto/buffer/bss_file.c with #define APPS_WIN16 added.
 | 
				
			||||||
 | 
					I have not yet automated the makefile to automatically copy it into 'out'
 | 
				
			||||||
 | 
					for a win 3.1 build....
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					All callbacks passed into SSLeay for Windows 3.1 need to be of type
 | 
				
			||||||
 | 
					_far _loadds.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					I don't support building with the pascal calling convention.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The DLL and static builds are large memory model.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					To build static libraries for NT/95 or win 3.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					perl util/mk1mf.pl VC-WIN32 > mf-stat.nt
 | 
				
			||||||
 | 
					perl util/mk1mf.pl VC-WIN16 > mf-stat.w31
 | 
				
			||||||
 | 
					for DLL's
 | 
				
			||||||
 | 
					perl util/mk1mf.pl dll VC-WIN32	> mf-dll.nt
 | 
				
			||||||
 | 
					perl util/mk1mf.pl dll VC-WIN16 > mf-dll.w31
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Again you will notice that if you dont have perl, you cannot do this.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Now the next importaint issue.  Running Configure!
 | 
				
			||||||
 | 
					I have small assember code files for critical big number library operation
 | 
				
			||||||
 | 
					in crypto/bn/asm.  There is, asm code, object files and uuencode
 | 
				
			||||||
 | 
					object files.  They are
 | 
				
			||||||
 | 
					x86nt32.asm	- 32bit flat memory model assember - suitable Win32
 | 
				
			||||||
 | 
					x86w16.asm	- 16bit assember - used in the msdos build.
 | 
				
			||||||
 | 
					x86w32.asm	- 32bit assember, win 3.1 segments, used for win16 build.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you feel compelled to build the 16bit maths routines in the windows 3.1
 | 
				
			||||||
 | 
					build,
 | 
				
			||||||
 | 
					perl Configure VC-W31-16
 | 
				
			||||||
 | 
					perl util/mk1mf.pl dll VC-W31-16 > mf-dll.w31
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you hate assember and don't want anything to do with it,
 | 
				
			||||||
 | 
					perl util/mk1mf.pl no-asm VC-WIN16 > mf-dll.w31
 | 
				
			||||||
 | 
					will work for any of the makefile generations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					There are more options to mk1mf.pl but these all leave the temporary
 | 
				
			||||||
 | 
					files in 'tmp' and the output files in 'out' by default.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The NT build is done for console mode.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The Windows 3.1 version of SSLeay uses quickwin, the interface is ugly
 | 
				
			||||||
 | 
					but it is better than nothing.  If you want ugly, try doing anything
 | 
				
			||||||
 | 
					that involves getting a password.  I decided to be ugly instead of
 | 
				
			||||||
 | 
					echoing characters.  For Windows 3.1 I would just sugest using the
 | 
				
			||||||
 | 
					msdos version of the ssleay application for command line work.
 | 
				
			||||||
 | 
					The QuickWin build is primarily for testing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					For both NT and Windows 3.1, I have not written the code so that
 | 
				
			||||||
 | 
					s_client, s_server can take input from the keyboard.  You can happily
 | 
				
			||||||
 | 
					start applications up in separate windows, watch them handshake, and then sit
 | 
				
			||||||
 | 
					there for-ever.  I have not had the time to get this working, and I've
 | 
				
			||||||
 | 
					been able to test things from a unix box to the NT box :-).
 | 
				
			||||||
 | 
					Try running ssleay s_server on the windows box
 | 
				
			||||||
 | 
					(with either -cert ../apps/server.pem -www)
 | 
				
			||||||
 | 
					and run ssleay s_time from another window.
 | 
				
			||||||
 | 
					This often stuffs up on Windows 3.1, but I'm not worried since this is
 | 
				
			||||||
 | 
					probably a problem with my demo applications, not the libraries.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					After a build of one of the version of microsoft SSLeay,
 | 
				
			||||||
 | 
					'cd ms' and then run 'test'.  This should check everything out and
 | 
				
			||||||
 | 
					even does a trial run of generating certificates.
 | 
				
			||||||
 | 
					'test.bat' requires that perl be install, you be in the ms directory
 | 
				
			||||||
 | 
					(not the test directory, thats for unix so stay out :-) and that the
 | 
				
			||||||
 | 
					build output directory be ../out 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					On a last note, you will probably get division by zero errors and
 | 
				
			||||||
 | 
					stuff after a build.  This is due to your own inability to follow
 | 
				
			||||||
 | 
					instructions :-).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The reasons for the problem is probably one of the following.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1)	You did not run Configure.  This is critical for windows 3.1 when
 | 
				
			||||||
 | 
						using assember.  The values in crypto/bn/bn.h must match the
 | 
				
			||||||
 | 
						ones requred for the assember code.  (remember that if you
 | 
				
			||||||
 | 
						edit crypto/bn/bn.h by hand, it will be clobered the next time
 | 
				
			||||||
 | 
						you run Configure by the contents of crypto/bn/bn.org).
 | 
				
			||||||
 | 
						SSLeay version -o will list the compile options.
 | 
				
			||||||
 | 
						For VC-WIN32 you need bn(64,32) or bn(32,32)
 | 
				
			||||||
 | 
						For VC-W31-32/VC-WIN16 you need bn(32,32)
 | 
				
			||||||
 | 
						For VC-W31-16 you need bn(32,16) or bn(16,16)
 | 
				
			||||||
 | 
						For VC-MSDOS you need bn(32,16) or bn(16,16).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						The first number will be 2 times bigger than the second if
 | 
				
			||||||
 | 
						BN_LLONG is defined in bn.h and the size of the second number
 | 
				
			||||||
 | 
						depends on the 'bits' defined at the start of bn.h.  Have a
 | 
				
			||||||
 | 
						look, it's all reasonably clear.
 | 
				
			||||||
 | 
						If you want to start messing with 8 bit builds and things like
 | 
				
			||||||
 | 
						that, build without the assember by re-generating a makefile
 | 
				
			||||||
 | 
						via 'perl util/mk1mf.pl no-asm'.
 | 
				
			||||||
 | 
					2)	You tried to build under MS-DOS or Windows 3.1 using the /G3
 | 
				
			||||||
 | 
						option.  Don't.  It is buggy (thats why you just got that
 | 
				
			||||||
 | 
						error) and unless you want to work out which optimising flag
 | 
				
			||||||
 | 
						to turn off, I'm not going to help you :-).  I also noticed
 | 
				
			||||||
 | 
						that code often ran slower when compiled with /G3.
 | 
				
			||||||
 | 
					3)	Under NT/95, malloc goes stupid.  You are probably linking with
 | 
				
			||||||
 | 
						the wrong library, there are problems if you mix the threaded
 | 
				
			||||||
 | 
						and non-threaded libraries (due to the DLL being staticly
 | 
				
			||||||
 | 
						linked with one and the applicaion using another.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Well hopefully thats most of the MS issues handled, see you in ssl-users :-).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					eric 30-Aug-1996
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SSLeay 0.6.5
 | 
				
			||||||
 | 
					For Windows 95/NT, add CRYPTO_malloc_init() to your program before any
 | 
				
			||||||
 | 
					calls to the SSLeay libraries.  This function will insert callbacks so that
 | 
				
			||||||
 | 
					the SSLeay libraries will use the same malloc(), free() and realloc() as
 | 
				
			||||||
 | 
					your application so 'problem 3)' mentioned above will go away.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					There is now DES assember for Windows NT/95.  The file is
 | 
				
			||||||
 | 
					crypto/des/asm/win32.asm and replaces crypto/des/des_enc.c in the build.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					There is also Blowfish assember for Windows NT/95.  The file is
 | 
				
			||||||
 | 
					crypto/bf/asm/win32.asm and replaces crypto/bf/bf_enc.c in the build.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					eric 25-Jun-1997
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							@@ -12,7 +12,7 @@
 | 
				
			|||||||
  ---------------
 | 
					  ---------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ====================================================================
 | 
					/* ====================================================================
 | 
				
			||||||
 * Copyright (c) 1998-2002 The OpenSSL Project.  All rights reserved.
 | 
					 * Copyright (c) 1998-1999 The OpenSSL Project.  All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Redistribution and use in source and binary forms, with or without
 | 
					 * Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
 * modification, are permitted provided that the following conditions
 | 
					 * modification, are permitted provided that the following conditions
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,62 +0,0 @@
 | 
				
			|||||||
/**************** BEGIN GUSI CONFIGURATION ****************************
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * GUSI Configuration section generated by GUSI Configurator
 | 
					 | 
				
			||||||
 * last modified: Wed Jan  5 20:33:51 2000
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This section will be overwritten by the next run of Configurator.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GUSI_SOURCE
 | 
					 | 
				
			||||||
#include <GUSIConfig.h>
 | 
					 | 
				
			||||||
#include <sys/cdefs.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Declarations of Socket Factories */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__BEGIN_DECLS
 | 
					 | 
				
			||||||
void GUSIwithInetSockets();
 | 
					 | 
				
			||||||
void GUSIwithLocalSockets();
 | 
					 | 
				
			||||||
void GUSIwithMTInetSockets();
 | 
					 | 
				
			||||||
void GUSIwithMTTcpSockets();
 | 
					 | 
				
			||||||
void GUSIwithMTUdpSockets();
 | 
					 | 
				
			||||||
void GUSIwithOTInetSockets();
 | 
					 | 
				
			||||||
void GUSIwithOTTcpSockets();
 | 
					 | 
				
			||||||
void GUSIwithOTUdpSockets();
 | 
					 | 
				
			||||||
void GUSIwithPPCSockets();
 | 
					 | 
				
			||||||
void GUSISetupFactories();
 | 
					 | 
				
			||||||
__END_DECLS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Configure Socket Factories */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void GUSISetupFactories()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#ifdef GUSISetupFactories_BeginHook
 | 
					 | 
				
			||||||
	GUSISetupFactories_BeginHook
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	GUSIwithInetSockets();
 | 
					 | 
				
			||||||
#ifdef GUSISetupFactories_EndHook
 | 
					 | 
				
			||||||
	GUSISetupFactories_EndHook
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Declarations of File Devices */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__BEGIN_DECLS
 | 
					 | 
				
			||||||
void GUSIwithDConSockets();
 | 
					 | 
				
			||||||
void GUSIwithNullSockets();
 | 
					 | 
				
			||||||
void GUSISetupDevices();
 | 
					 | 
				
			||||||
__END_DECLS
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Configure File Devices */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void GUSISetupDevices()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#ifdef GUSISetupDevices_BeginHook
 | 
					 | 
				
			||||||
	GUSISetupDevices_BeginHook
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	GUSIwithNullSockets();
 | 
					 | 
				
			||||||
#ifdef GUSISetupDevices_EndHook
 | 
					 | 
				
			||||||
	GUSISetupDevices_EndHook
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**************** END GUSI CONFIGURATION *************************/
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,104 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength);
 | 
					 | 
				
			||||||
void CopyPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void CopyCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void CopyCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void ConcatPStrToCStr(const unsigned char *thePStr,char *theCStr,const int maxCStrLength);
 | 
					 | 
				
			||||||
void ConcatPStrToPStr(const unsigned char *theSrcPStr,unsigned char *theDstPStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void ConcatCStrToPStr(const char *theSrcCStr,unsigned char *theDstPStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void ConcatCStrToCStr(const char *theSrcCStr,char *theDstCStr,const int maxCStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ConcatCharToCStr(const char theChar,char *theDstCStr,const int maxCStrLength);
 | 
					 | 
				
			||||||
void ConcatCharToPStr(const char theChar,unsigned char *theDstPStr,const int maxPStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int ComparePStrs(const unsigned char *theFirstPStr,const unsigned char *theSecondPStr,const Boolean ignoreCase = true);
 | 
					 | 
				
			||||||
int CompareCStrs(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase = true);
 | 
					 | 
				
			||||||
int CompareCStrToPStr(const char *theCStr,const unsigned char *thePStr,const Boolean ignoreCase = true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Boolean CStrsAreEqual(const char *theFirstCStr,const char *theSecondCStr,const Boolean ignoreCase = true);
 | 
					 | 
				
			||||||
Boolean PStrsAreEqual(const unsigned char *theFirstCStr,const unsigned char *theSecondCStr,const Boolean ignoreCase = true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits = -1);
 | 
					 | 
				
			||||||
void CopyUnsignedLongIntToCStr(const unsigned long theNum,char *theCStr,const int maxCStrLength);
 | 
					 | 
				
			||||||
void ConcatLongIntToCStr(const long theNum,char *theCStr,const int maxCStrLength,const int numDigits = -1);
 | 
					 | 
				
			||||||
void CopyCStrAndConcatLongIntToCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits = -1);
 | 
					 | 
				
			||||||
void ConcatLongIntToPStr(const long theNum,unsigned char *thePStr,const int maxPStrLength,const int numDigits = -1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
long CStrLength(const char *theCString);
 | 
					 | 
				
			||||||
long PStrLength(const unsigned char *thePString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr CopyCStrToExistingHandle(const char *theCString,Handle theHandle);
 | 
					 | 
				
			||||||
OSErr CopyLongIntToExistingHandle(const long inTheLongInt,Handle theHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr CopyCStrToNewHandle(const char *theCString,Handle *theHandle);
 | 
					 | 
				
			||||||
OSErr CopyPStrToNewHandle(const unsigned char *thePString,Handle *theHandle);
 | 
					 | 
				
			||||||
OSErr CopyLongIntToNewHandle(const long inTheLongInt,Handle *theHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr AppendCStrToHandle(const char *theCString,Handle theHandle,long *currentLength = nil,long *maxLength = nil);
 | 
					 | 
				
			||||||
OSErr AppendCharsToHandle(const char *theChars,const int numChars,Handle theHandle,long *currentLength = nil,long *maxLength = nil);
 | 
					 | 
				
			||||||
OSErr AppendPStrToHandle(const unsigned char *thePString,Handle theHandle,long *currentLength = nil);
 | 
					 | 
				
			||||||
OSErr AppendLongIntToHandle(const long inTheLongInt,Handle theHandle,long *currentLength = nil);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ZeroMem(void *theMemPtr,const unsigned long numBytes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *FindCharInCStr(const char theChar,const char *theCString);
 | 
					 | 
				
			||||||
long FindCharOffsetInCStr(const char theChar,const char *theCString,const Boolean inIgnoreCase = false);
 | 
					 | 
				
			||||||
long FindCStrOffsetInCStr(const char *theCSubstring,const char *theCString,const Boolean inIgnoreCase = false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyCSubstrToCStr(const char *theSrcCStr,const int maxCharsToCopy,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void CopyCSubstrToPStr(const char *theSrcCStr,const int maxCharsToCopy,unsigned char *theDstPStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void InsertCStrIntoCStr(const char *theSrcCStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void InsertPStrIntoCStr(const unsigned char *theSrcPStr,const int theInsertionOffset,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
OSErr InsertCStrIntoHandle(const char *theCString,Handle theHandle,const long inInsertOffset);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyCStrAndInsertCStrIntoCStr(const char *theSrcCStr,const char *theInsertCStr,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyCStrAndInsertCStrsLongIntsIntoCStr(const char *theSrcCStr,const char **theInsertCStrs,const long *theLongInts,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyCStrAndInsert1LongIntIntoCStr(const char *theSrcCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void CopyCStrAndInsert2LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
void CopyCStrAndInsert3LongIntsIntoCStr(const char *theSrcCStr,const long long1,const long long2,const long long3,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CopyCStrAndInsertCStrLongIntIntoCStr(const char *theSrcCStr,const char *theInsertCStr,const long theNum,char *theDstCStr,const int maxDstStrLength);
 | 
					 | 
				
			||||||
OSErr CopyCStrAndInsertCStrLongIntIntoHandle(const char *theSrcCStr,const char *theInsertCStr,const long theNum,Handle *theHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr CopyIndexedWordToCStr(char *theSrcCStr,int whichWord,char *theDstCStr,int maxDstCStrLength);
 | 
					 | 
				
			||||||
OSErr CopyIndexedWordToNewHandle(char *theSrcCStr,int whichWord,Handle *outTheHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr CopyIndexedLineToCStr(const char *theSrcCStr,int inWhichLine,int *lineEndIndex,Boolean *gotLastLine,char *theDstCStr,const int maxDstCStrLength);
 | 
					 | 
				
			||||||
OSErr CopyIndexedLineToNewHandle(const char *theSrcCStr,int inWhichLine,Handle *outNewHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr ExtractIntFromCStr(const char *theSrcCStr,int *outInt,Boolean skipLeadingSpaces = true);
 | 
					 | 
				
			||||||
OSErr ExtractIntFromPStr(const unsigned char *theSrcPStr,int *outInt,Boolean skipLeadingSpaces = true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ConvertCStrToUpperCase(char *theSrcCStr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int CountOccurencesOfCharInCStr(const char inChar,const char *inSrcCStr);
 | 
					 | 
				
			||||||
int CountWordsInCStr(const char *inSrcCStr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr CountDigits(const char *inCStr,int *outNumIntegerDigits,int *outNumFractDigits);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ExtractCStrItemFromCStr(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,char *outDstCharPtr,const int inDstCharPtrMaxLength,const Boolean inTreatMultipleDelimsAsSingleDelim = false);
 | 
					 | 
				
			||||||
OSErr ExtractCStrItemFromCStrIntoNewHandle(const char *inSrcCStr,const char inItemDelimiter,const int inItemNumber,Boolean *foundItem,Handle *outNewHandle,const Boolean inTreatMultipleDelimsAsSingleDelim = false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr ExtractFloatFromCStr(const char *inCString,extended80 *outFloat);
 | 
					 | 
				
			||||||
OSErr CopyFloatToCStr(const extended80 *theFloat,char *theCStr,const int maxCStrLength,const int inMaxNumIntDigits = -1,const int inMaxNumFractDigits = -1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SkipWhiteSpace(char **ioSrcCharPtr,const Boolean inStopAtEOL = false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,170 +0,0 @@
 | 
				
			|||||||
/* ====================================================================
 | 
					 | 
				
			||||||
 * Copyright (c) 1998-1999 The OpenSSL Project.  All rights reserved.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 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 above 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 acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
					 | 
				
			||||||
 *    endorse or promote products derived from this software without
 | 
					 | 
				
			||||||
 *    prior written permission. For written permission, please contact
 | 
					 | 
				
			||||||
 *    openssl-core@openssl.org.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
					 | 
				
			||||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
					 | 
				
			||||||
 *    permission of the OpenSSL Project.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
					 | 
				
			||||||
 *    acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
					 | 
				
			||||||
 * EXPRESSED 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 OpenSSL PROJECT OR
 | 
					 | 
				
			||||||
 * ITS 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.
 | 
					 | 
				
			||||||
 * ====================================================================
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This product includes cryptographic software written by Eric Young
 | 
					 | 
				
			||||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
					 | 
				
			||||||
 * Hudson (tjh@cryptsoft.com).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 #include "ErrorHandling.hpp"
 | 
					 | 
				
			||||||
#include "CPStringUtils.hpp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __EXCEPTIONS_ENABLED__
 | 
					 | 
				
			||||||
	#include "CMyException.hpp"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static char					gErrorMessageBuffer[512];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char 						*gErrorMessage = gErrorMessageBuffer;
 | 
					 | 
				
			||||||
int							gErrorMessageMaxLength = sizeof(gErrorMessageBuffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SetErrorMessage(const char *theErrorMessage)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (theErrorMessage != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CopyCStrToCStr(theErrorMessage,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (theErrorMessage != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CopyCStrAndConcatLongIntToCStr(theErrorMessage,theLongInt,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (theErrorMessage != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CopyCStrAndInsertCStrLongIntIntoCStr(theErrorMessage,theCStr,theLongInt,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (theErrorMessage != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		CopyCStrAndInsertCStrLongIntIntoCStr(theErrorMessage,theCStr,-1,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AppendCStrToErrorMessage(const char *theErrorMessage)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (theErrorMessage != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		ConcatCStrToCStr(theErrorMessage,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AppendLongIntToErrorMessage(const long theLongInt)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ConcatLongIntToCStr(theLongInt,gErrorMessage,gErrorMessageMaxLength);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *GetErrorMessage(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return gErrorMessage;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr GetErrorMessageInNewHandle(Handle *inoutHandle)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
OSErr		errCode;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	errCode = CopyCStrToNewHandle(gErrorMessage,inoutHandle);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return(errCode);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr GetErrorMessageInExistingHandle(Handle inoutHandle)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
OSErr		errCode;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	errCode = CopyCStrToExistingHandle(gErrorMessage,inoutHandle);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return(errCode);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr AppendErrorMessageToHandle(Handle inoutHandle)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
OSErr		errCode;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	errCode = AppendCStrToHandle(gErrorMessage,inoutHandle,nil);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return(errCode);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __EXCEPTIONS_ENABLED__
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ThrowErrorMessageException(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ThrowDescriptiveException(gErrorMessage);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,147 +0,0 @@
 | 
				
			|||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef kGenericError
 | 
					 | 
				
			||||||
	#define kGenericError		-1
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char	*gErrorMessage;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SetErrorMessage(const char *theErrorMessage);
 | 
					 | 
				
			||||||
void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt);
 | 
					 | 
				
			||||||
void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt);
 | 
					 | 
				
			||||||
void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr);
 | 
					 | 
				
			||||||
void AppendCStrToErrorMessage(const char *theErrorMessage);
 | 
					 | 
				
			||||||
void AppendLongIntToErrorMessage(const long theLongInt);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *GetErrorMessage(void);
 | 
					 | 
				
			||||||
OSErr GetErrorMessageInNewHandle(Handle *inoutHandle);
 | 
					 | 
				
			||||||
OSErr GetErrorMessageInExistingHandle(Handle inoutHandle);
 | 
					 | 
				
			||||||
OSErr AppendErrorMessageToHandle(Handle inoutHandle);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __EXCEPTIONS_ENABLED__
 | 
					 | 
				
			||||||
	void ThrowErrorMessageException(void);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	A bunch of evil macros that would be uneccessary if I were always using C++ !
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndBailIfNil(theArg,theMessage)								\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if (theArg == nil)																\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		SetErrorMessage(theMessage);												\
 | 
					 | 
				
			||||||
		errCode = kGenericError;													\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndBail(theMessage)											\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
		SetErrorMessage(theMessage);												\
 | 
					 | 
				
			||||||
		errCode = kGenericError;													\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndLongIntAndBail(theMessage,theLongInt)						\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
		SetErrorMessageAndAppendLongInt(theMessage,theLongInt);						\
 | 
					 | 
				
			||||||
		errCode = kGenericError;													\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndLongIntAndBailIfError(theErrCode,theMessage,theLongInt)	\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if (theErrCode != noErr)														\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		SetErrorMessageAndAppendLongInt(theMessage,theLongInt);						\
 | 
					 | 
				
			||||||
		errCode = theErrCode;														\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageCStrLongIntAndBailIfError(theErrCode,theMessage,theCStr,theLongInt)	\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if (theErrCode != noErr)														\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		SetErrorMessageAndCStrAndLongInt(theMessage,theCStr,theLongInt);			\
 | 
					 | 
				
			||||||
		errCode = theErrCode;														\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndCStrAndBail(theMessage,theCStr)							\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	SetErrorMessageAndCStr(theMessage,theCStr);										\
 | 
					 | 
				
			||||||
	errCode = kGenericError;														\
 | 
					 | 
				
			||||||
	goto EXITPOINT;																	\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndBailIfError(theErrCode,theMessage)						\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if (theErrCode != noErr)														\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		SetErrorMessage(theMessage);												\
 | 
					 | 
				
			||||||
		errCode = theErrCode;														\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorMessageAndLongIntAndBailIfNil(theArg,theMessage,theLongInt)			\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if (theArg == nil)																\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		SetErrorMessageAndAppendLongInt(theMessage,theLongInt);						\
 | 
					 | 
				
			||||||
		errCode = kGenericError;													\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BailIfError(theErrCode)														\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	if ((theErrCode) != noErr)														\
 | 
					 | 
				
			||||||
	{																				\
 | 
					 | 
				
			||||||
		goto EXITPOINT;																\
 | 
					 | 
				
			||||||
	}																				\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrCodeAndBail(theErrCode)												\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	errCode = theErrCode;															\
 | 
					 | 
				
			||||||
																					\
 | 
					 | 
				
			||||||
	goto EXITPOINT;																	\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define SetErrorCodeAndMessageAndBail(theErrCode,theMessage)						\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	SetErrorMessage(theMessage);													\
 | 
					 | 
				
			||||||
	errCode = theErrCode;															\
 | 
					 | 
				
			||||||
	goto EXITPOINT;																	\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BailNow()																	\
 | 
					 | 
				
			||||||
{																					\
 | 
					 | 
				
			||||||
	errCode = kGenericError;														\
 | 
					 | 
				
			||||||
	goto EXITPOINT;																	\
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,209 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
 *	An demo illustrating how to retrieve a URI from a secure HTTP server.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *	Author: 	Roy Wood
 | 
					 | 
				
			||||||
 *	Date:		September 7, 1999
 | 
					 | 
				
			||||||
 *	Comments:	This relies heavily on my MacSockets library.
 | 
					 | 
				
			||||||
 *				This project is also set up so that it expects the OpenSSL source folder (0.9.4 as I write this)
 | 
					 | 
				
			||||||
 *				to live in a folder called "OpenSSL-0.9.4" in this project's parent folder.  For example:
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *					Macintosh HD:
 | 
					 | 
				
			||||||
 *						Development:
 | 
					 | 
				
			||||||
 *							OpenSSL-0.9.4:
 | 
					 | 
				
			||||||
 *								(OpenSSL sources here)
 | 
					 | 
				
			||||||
 *							OpenSSL Example:
 | 
					 | 
				
			||||||
 *								(OpenSSL example junk here)
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 *				Also-- before attempting to compile this, make sure the aliases in "OpenSSL-0.9.4:include:openssl" 
 | 
					 | 
				
			||||||
 *				are installed!  Use the AppleScript applet in the "openssl-0.9.4" folder to do this!
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* modified to seed the PRNG */
 | 
					 | 
				
			||||||
/* modified to use CRandomizer for seeding */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Include some funky libs I've developed over time
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "CPStringUtils.hpp"
 | 
					 | 
				
			||||||
#include "ErrorHandling.hpp"
 | 
					 | 
				
			||||||
#include "MacSocket.h"
 | 
					 | 
				
			||||||
#include "Randomizer.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	We use the OpenSSL implementation of SSL....
 | 
					 | 
				
			||||||
//	This was a lot of work to finally get going, though you wouldn't know it by the results!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <timer.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Let's try grabbing some data from here:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define kHTTPS_DNS		"www.apache-ssl.org"
 | 
					 | 
				
			||||||
#define kHTTPS_Port		443
 | 
					 | 
				
			||||||
#define kHTTPS_URI		"/"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Forward-declare this
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	My idle-wait callback.  Doesn't do much, does it?  Silly cooperative multitasking.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MyMacSocket_IdleWaitCallback(void *inUserRefPtr)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#pragma unused(inUserRefPtr)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EventRecord		theEvent;
 | 
					 | 
				
			||||||
	::EventAvail(everyEvent,&theEvent);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	CRandomizer *randomizer = (CRandomizer*)inUserRefPtr;
 | 
					 | 
				
			||||||
	if (randomizer)
 | 
					 | 
				
			||||||
		randomizer->PeriodicAction();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return(noErr);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Finally!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void main(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	OSErr				errCode;
 | 
					 | 
				
			||||||
	int					theSocket = -1;
 | 
					 | 
				
			||||||
	int					theTimeout = 30;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	SSL_CTX				*ssl_ctx = nil;
 | 
					 | 
				
			||||||
	SSL					*ssl = nil;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	char				tempString[256];
 | 
					 | 
				
			||||||
	UnsignedWide		microTickCount;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	CRandomizer randomizer;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	printf("OpenSSL Demo by Roy Wood, roy@centricsystems.ca\n\n");
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	BailIfError(errCode = MacSocket_Startup());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//	Create a socket-like object
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	BailIfError(errCode = MacSocket_socket(&theSocket,false,theTimeout * 60,MyMacSocket_IdleWaitCallback,&randomizer));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	//	Set up the connect string and try to connect
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	CopyCStrAndInsertCStrLongIntIntoCStr("%s:%ld",kHTTPS_DNS,kHTTPS_Port,tempString,sizeof(tempString));
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	printf("Connecting to %s....\n",tempString);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	BailIfError(errCode = MacSocket_connect(theSocket,tempString));
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	//	Init SSL stuff
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	SSL_load_error_strings();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	SSLeay_add_ssl_algorithms();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	//	Pick the SSL method
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	ssl_ctx = SSL_CTX_new(SSLv2_client_method());
 | 
					 | 
				
			||||||
	ssl_ctx = SSL_CTX_new(SSLv23_client_method());
 | 
					 | 
				
			||||||
//	ssl_ctx = SSL_CTX_new(SSLv3_client_method());
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//	Create an SSL thingey and try to negotiate the connection
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ssl = SSL_new(ssl_ctx);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	SSL_set_fd(ssl,theSocket);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	errCode = SSL_connect(ssl);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (errCode < 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		SetErrorMessageAndLongIntAndBail("OpenSSL: Can't initiate SSL connection, SSL_connect() = ",errCode);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	//	Request the URI from the host
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	CopyCStrToCStr("GET ",tempString,sizeof(tempString));
 | 
					 | 
				
			||||||
	ConcatCStrToCStr(kHTTPS_URI,tempString,sizeof(tempString));
 | 
					 | 
				
			||||||
	ConcatCStrToCStr(" HTTP/1.0\r\n\r\n",tempString,sizeof(tempString));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	errCode = SSL_write(ssl,tempString,CStrLength(tempString));
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (errCode < 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		SetErrorMessageAndLongIntAndBail("OpenSSL: Error writing data via ssl, SSL_write() = ",errCode);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (;;)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	char	tempString[256];
 | 
					 | 
				
			||||||
	int		bytesRead;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//	Read some bytes and dump them to the console
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		bytesRead = SSL_read(ssl,tempString,sizeof(tempString) - 1);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (bytesRead == 0 && MacSocket_RemoteEndIsClosing(theSocket))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		else if (bytesRead < 0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			SetErrorMessageAndLongIntAndBail("OpenSSL: Error reading data via ssl, SSL_read() = ",bytesRead);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		tempString[bytesRead] = '\0';
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		printf(tempString);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	printf("\n\n\n");
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	//	All done!
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	errCode = noErr;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
EXITPOINT:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//	Clean up and go home
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (theSocket >= 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		MacSocket_close(theSocket);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (ssl != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		SSL_free(ssl);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (ssl_ctx != nil)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		SSL_CTX_free(ssl_ctx);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (errCode != noErr)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		printf("An error occurred:\n");
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		printf(GetErrorMessage());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	MacSocket_Shutdown();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,103 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
extern "C" {
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	kMacSocket_TimeoutErr = -2
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Since MacSocket does busy waiting, I do a callback while waiting
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef OSErr (*MacSocket_IdleWaitCallback)(void *);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this before anything else!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_Startup(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to cleanup before quitting
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_Shutdown(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to allocate a "socket" (reference number is returned in outSocketNum)
 | 
					 | 
				
			||||||
//	Note that inDoThreadSwitching is pretty much irrelevant right now, since I ignore it
 | 
					 | 
				
			||||||
//	The inTimeoutTicks parameter is applied during reads/writes of data
 | 
					 | 
				
			||||||
//	The inIdleWaitCallback parameter specifies a callback which is called during busy-waiting periods
 | 
					 | 
				
			||||||
//	The inUserRefPtr parameter is passed back to the idle-wait callback
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_socket(int *outSocketNum,const Boolean inDoThreadSwitching,const long inTimeoutTicks,MacSocket_IdleWaitCallback inIdleWaitCallback,void *inUserRefPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to connect to an IP/DNS address
 | 
					 | 
				
			||||||
//	Note that inTargetAddressAndPort is in "IP:port" format-- e.g. 10.1.1.1:123
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_connect(const int inSocketNum,char *inTargetAddressAndPort);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to listen on a port
 | 
					 | 
				
			||||||
//	Since this a low-performance implementation, I allow a maximum of 1 (one!) incoming request when I listen
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_listen(const int inSocketNum,const int inPortNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to close a socket
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
OSErr MacSocket_close(const int inSocketNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to receive data on a socket
 | 
					 | 
				
			||||||
//	Most parameters' purpose are obvious-- except maybe "inBlock" which controls whether I wait for data or return immediately
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MacSocket_recv(const int inSocketNum,void *outBuff,int outBuffLength,const Boolean inBlock);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to send data on a socket
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MacSocket_send(const int inSocketNum,void *inBuff,int inBuffLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	If zero bytes were read in a call to MacSocket_recv(), it may be that the remote end has done a half-close
 | 
					 | 
				
			||||||
//	This function will let you check whether that's true or not
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Boolean MacSocket_RemoteEndIsClosing(const int inSocketNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to see if the listen has completed after a call to MacSocket_listen()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Boolean MacSocket_ListenCompleted(const int inSocketNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	These really aren't very useful anymore
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Boolean MacSocket_LocalEndIsOpen(const int inSocketNum);
 | 
					 | 
				
			||||||
Boolean MacSocket_RemoteEndIsOpen(const int inSocketNum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	You may wish to change the userRefPtr for a socket callback-- use this to do it
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void MacSocket_SetUserRefPtr(const int inSocketNum,void *inNewRefPtr);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call these to get the socket's IP:port descriptor
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void MacSocket_GetLocalIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);
 | 
					 | 
				
			||||||
void MacSocket_GetRemoteIPAndPort(const int inSocketNum,char *outIPAndPort,const int inIPAndPortLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	Call this to get error info from a socket
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void MacSocket_GetSocketErrorInfo(const int inSocketNum,int *outSocketErrCode,char *outSocketErrString,const int inSocketErrStringMaxLength);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __cplusplus
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,476 +0,0 @@
 | 
				
			|||||||
/* 
 | 
					 | 
				
			||||||
------- Strong random data generation on a Macintosh (pre - OS X) ------
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
--	GENERAL: We aim to generate unpredictable bits without explicit
 | 
					 | 
				
			||||||
	user interaction. A general review of the problem may be found
 | 
					 | 
				
			||||||
	in RFC 1750, "Randomness Recommendations for Security", and some
 | 
					 | 
				
			||||||
	more discussion, of general and Mac-specific issues has appeared
 | 
					 | 
				
			||||||
	in "Using and Creating Cryptographic- Quality Random Numbers" by
 | 
					 | 
				
			||||||
	Jon Callas (www.merrymeet.com/jon/usingrandom.html).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	The data and entropy estimates provided below are based on my
 | 
					 | 
				
			||||||
	limited experimentation and estimates, rather than by any
 | 
					 | 
				
			||||||
	rigorous study, and the entropy estimates tend to be optimistic.
 | 
					 | 
				
			||||||
	They should not be considered absolute.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Some of the information being collected may be correlated in
 | 
					 | 
				
			||||||
	subtle ways. That includes mouse positions, timings, and disk
 | 
					 | 
				
			||||||
	size measurements. Some obvious correlations will be eliminated
 | 
					 | 
				
			||||||
	by the programmer, but other, weaker ones may remain. The
 | 
					 | 
				
			||||||
	reliability of the code depends on such correlations being
 | 
					 | 
				
			||||||
	poorly understood, both by us and by potential interceptors.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	This package has been planned to be used with OpenSSL, v. 0.9.5.
 | 
					 | 
				
			||||||
	It requires the OpenSSL function RAND_add. 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	OTHER WORK: Some source code and other details have been
 | 
					 | 
				
			||||||
	published elsewhere, but I haven't found any to be satisfactory
 | 
					 | 
				
			||||||
	for the Mac per se:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* The Linux random number generator (by Theodore Ts'o, in
 | 
					 | 
				
			||||||
	  drivers/char/random.c), is a carefully designed open-source
 | 
					 | 
				
			||||||
	  crypto random number package. It collects data from a variety
 | 
					 | 
				
			||||||
	  of sources, including mouse, keyboard and other interrupts.
 | 
					 | 
				
			||||||
	  One nice feature is that it explicitly estimates the entropy
 | 
					 | 
				
			||||||
	  of the data it collects. Some of its features (e.g. interrupt
 | 
					 | 
				
			||||||
	  timing) cannot be reliably exported to the Mac without using
 | 
					 | 
				
			||||||
	  undocumented APIs.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* Truerand by Don P. Mitchell and Matt Blaze uses variations
 | 
					 | 
				
			||||||
	  between different timing mechanisms on the same system. This
 | 
					 | 
				
			||||||
	  has not been tested on the Mac, but requires preemptive
 | 
					 | 
				
			||||||
	  multitasking, and is hardware-dependent, and can't be relied
 | 
					 | 
				
			||||||
	  on to work well if only one oscillator is present.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* Cryptlib's RNG for the Mac (RNDMAC.C by Peter Gutmann),
 | 
					 | 
				
			||||||
	  gathers a lot of information about the machine and system
 | 
					 | 
				
			||||||
	  environment. Unfortunately, much of it is constant from one
 | 
					 | 
				
			||||||
	  startup to the next. In other words, the random seed could be
 | 
					 | 
				
			||||||
	  the same from one day to the next. Some of the APIs are
 | 
					 | 
				
			||||||
	  hardware-dependent, and not all are compatible with Carbon (OS
 | 
					 | 
				
			||||||
	  X). Incidentally, the EGD library is based on the UNIX entropy
 | 
					 | 
				
			||||||
	  gathering methods in cryptlib, and isn't suitable for MacOS
 | 
					 | 
				
			||||||
	  either.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* Mozilla (and perhaps earlier versions of Netscape) uses the
 | 
					 | 
				
			||||||
	  time of day (in seconds) and an uninitialized local variable
 | 
					 | 
				
			||||||
	  to seed the random number generator. The time of day is known
 | 
					 | 
				
			||||||
	  to an outside interceptor (to within the accuracy of the
 | 
					 | 
				
			||||||
	  system clock). The uninitialized variable could easily be
 | 
					 | 
				
			||||||
	  identical between subsequent launches of an application, if it
 | 
					 | 
				
			||||||
	  is reached through the same path.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* OpenSSL provides the function RAND_screen(), by G. van
 | 
					 | 
				
			||||||
	  Oosten, which hashes the contents of the screen to generate a
 | 
					 | 
				
			||||||
	  seed. This is not useful for an extension or for an
 | 
					 | 
				
			||||||
	  application which launches at startup time, since the screen
 | 
					 | 
				
			||||||
	  is likely to look identical from one launch to the next. This
 | 
					 | 
				
			||||||
	  method is also rather slow.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	* Using variations in disk drive seek times has been proposed
 | 
					 | 
				
			||||||
	  (Davis, Ihaka and Fenstermacher, world.std.com/~dtd/;
 | 
					 | 
				
			||||||
	  Jakobsson, Shriver, Hillyer and Juels,
 | 
					 | 
				
			||||||
	  www.bell-labs.com/user/shriver/random.html). These variations
 | 
					 | 
				
			||||||
	  appear to be due to air turbulence inside the disk drive
 | 
					 | 
				
			||||||
	  mechanism, and are very strongly unpredictable. Unfortunately
 | 
					 | 
				
			||||||
	  this technique is slow, and some implementations of it may be
 | 
					 | 
				
			||||||
	  patented (see Shriver's page above.) It of course cannot be
 | 
					 | 
				
			||||||
	  used with a RAM disk.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	TIMING: On the 601 PowerPC the time base register is guaranteed
 | 
					 | 
				
			||||||
	to change at least once every 10 addi instructions, i.e. 10
 | 
					 | 
				
			||||||
	cycles. On a 60 MHz machine (slowest PowerPC) this translates to
 | 
					 | 
				
			||||||
	a resolution of 1/6 usec. Newer machines seem to be using a 10
 | 
					 | 
				
			||||||
	cycle resolution as well.
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	For 68K Macs, the Microseconds() call may be used. See Develop
 | 
					 | 
				
			||||||
	issue 29 on the Apple developer site
 | 
					 | 
				
			||||||
	(developer.apple.com/dev/techsupport/develop/issue29/minow.html)
 | 
					 | 
				
			||||||
	for information on its accuracy and resolution. The code below
 | 
					 | 
				
			||||||
	has been tested only on PowerPC based machines.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	The time from machine startup to the launch of an application in
 | 
					 | 
				
			||||||
	the startup folder has a variance of about 1.6 msec on a new G4
 | 
					 | 
				
			||||||
	machine with a defragmented and optimized disk, most extensions
 | 
					 | 
				
			||||||
	off and no icons on the desktop. This can be reasonably taken as
 | 
					 | 
				
			||||||
	a lower bound on the variance. Most of this variation is likely
 | 
					 | 
				
			||||||
	due to disk seek time variability. The distribution of startup
 | 
					 | 
				
			||||||
	times is probably not entirely even or uncorrelated. This needs
 | 
					 | 
				
			||||||
	to be investigated, but I am guessing that it not a majpor
 | 
					 | 
				
			||||||
	problem. Entropy = log2 (1600/0.166) ~= 13 bits on a 60 MHz
 | 
					 | 
				
			||||||
	machine, ~16 bits for a 450 MHz machine.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	User-launched application startup times will have a variance of
 | 
					 | 
				
			||||||
	a second or more relative to machine startup time. Entropy >~22
 | 
					 | 
				
			||||||
	bits.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Machine startup time is available with a 1-second resolution. It
 | 
					 | 
				
			||||||
	is predictable to no better a minute or two, in the case of
 | 
					 | 
				
			||||||
	people who show up punctually to work at the same time and
 | 
					 | 
				
			||||||
	immediately start their computer. Using the scheduled startup
 | 
					 | 
				
			||||||
	feature (when available) will cause the machine to start up at
 | 
					 | 
				
			||||||
	the same time every day, making the value predictable. Entropy
 | 
					 | 
				
			||||||
	>~7 bits, or 0 bits with scheduled startup.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	The time of day is of course known to an outsider and thus has 0
 | 
					 | 
				
			||||||
	entropy if the system clock is regularly calibrated.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	KEY TIMING: A  very fast typist (120 wpm) will have a typical
 | 
					 | 
				
			||||||
	inter-key timing interval of 100 msec. We can assume a variance
 | 
					 | 
				
			||||||
	of no less than 2 msec -- maybe. Do good typists have a constant
 | 
					 | 
				
			||||||
	rhythm, like drummers? Since what we measure is not the
 | 
					 | 
				
			||||||
	key-generated interrupt but the time at which the key event was
 | 
					 | 
				
			||||||
	taken off the event queue, our resolution is roughly the time
 | 
					 | 
				
			||||||
	between process switches, at best 1 tick (17 msec). I  therefore
 | 
					 | 
				
			||||||
	consider this technique questionable and not very useful for
 | 
					 | 
				
			||||||
	obtaining high entropy data on the Mac.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	MOUSE POSITION AND TIMING: The high bits of the mouse position
 | 
					 | 
				
			||||||
	are far from arbitrary, since the mouse tends to stay in a few
 | 
					 | 
				
			||||||
	limited areas of the screen. I am guessing that the position of
 | 
					 | 
				
			||||||
	the mouse is arbitrary within a 6 pixel square. Since the mouse
 | 
					 | 
				
			||||||
	stays still for long periods of time, it should be sampled only
 | 
					 | 
				
			||||||
	after it was moved, to avoid correlated data. This gives an
 | 
					 | 
				
			||||||
	entropy of log2(6*6) ~= 5 bits per measurement.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	The time during which the mouse stays still can vary from zero
 | 
					 | 
				
			||||||
	to, say, 5 seconds (occasionally longer). If the still time is
 | 
					 | 
				
			||||||
	measured by sampling the mouse during null events, and null
 | 
					 | 
				
			||||||
	events are received once per tick, its resolution is 1/60th of a
 | 
					 | 
				
			||||||
	second, giving an entropy of log2 (60*5) ~= 8 bits per
 | 
					 | 
				
			||||||
	measurement. Since the distribution of still times is uneven,
 | 
					 | 
				
			||||||
	this estimate is on the high side.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	For simplicity and compatibility across system versions, the
 | 
					 | 
				
			||||||
	mouse is to be sampled explicitly (e.g. in the event loop),
 | 
					 | 
				
			||||||
	rather than in a time manager task.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	STARTUP DISK TOTAL FILE SIZE: Varies typically by at least 20k
 | 
					 | 
				
			||||||
	from one startup to the next, with 'minimal' computer use. Won't
 | 
					 | 
				
			||||||
	vary at all if machine is started again immediately after
 | 
					 | 
				
			||||||
	startup (unless virtual memory is on), but any application which
 | 
					 | 
				
			||||||
	uses the web and caches information to disk is likely to cause
 | 
					 | 
				
			||||||
	this much variation or more. The variation is probably not
 | 
					 | 
				
			||||||
	random, but I don't know in what way. File sizes tend to be
 | 
					 | 
				
			||||||
	divisible by 4 bytes since file format fields are often
 | 
					 | 
				
			||||||
	long-aligned. Entropy > log2 (20000/4) ~= 12 bits.
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
--	STARTUP DISK FIRST AVAILABLE ALLOCATION BLOCK: As the volume
 | 
					 | 
				
			||||||
	gets fragmented this could be anywhere in principle. In a
 | 
					 | 
				
			||||||
	perfectly unfragmented volume this will be strongly correlated
 | 
					 | 
				
			||||||
	with the total file size on the disk. With more fragmentation
 | 
					 | 
				
			||||||
	comes less certainty. I took the variation in this value to be
 | 
					 | 
				
			||||||
	1/8 of the total file size on the volume.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--	SYSTEM REQUIREMENTS: The code here requires System 7.0 and above
 | 
					 | 
				
			||||||
	(for Gestalt and Microseconds calls). All the calls used are
 | 
					 | 
				
			||||||
	Carbon-compatible.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*------------------------------ Includes ----------------------------*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "Randomizer.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Mac OS API
 | 
					 | 
				
			||||||
#include <Files.h>
 | 
					 | 
				
			||||||
#include <Folders.h>
 | 
					 | 
				
			||||||
#include <Events.h>
 | 
					 | 
				
			||||||
#include <Processes.h>
 | 
					 | 
				
			||||||
#include <Gestalt.h>
 | 
					 | 
				
			||||||
#include <Resources.h>
 | 
					 | 
				
			||||||
#include <LowMem.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Standard C library
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <math.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*---------------------- Function declarations -----------------------*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// declared in OpenSSL/crypto/rand/rand.h
 | 
					 | 
				
			||||||
extern "C" void RAND_add (const void *buf, int num, double entropy);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unsigned long GetPPCTimer (bool is601);	// Make it global if needed
 | 
					 | 
				
			||||||
					// elsewhere
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*---------------------------- Constants -----------------------------*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define kMouseResolution 6		// Mouse position has to differ
 | 
					 | 
				
			||||||
					// from the last one by this
 | 
					 | 
				
			||||||
					// much to be entered
 | 
					 | 
				
			||||||
#define kMousePositionEntropy 5.16	// log2 (kMouseResolution**2)
 | 
					 | 
				
			||||||
#define kTypicalMouseIdleTicks 300.0	// I am guessing that a typical
 | 
					 | 
				
			||||||
					// amount of time between mouse
 | 
					 | 
				
			||||||
					// moves is 5 seconds
 | 
					 | 
				
			||||||
#define kVolumeBytesEntropy 12.0	// about log2 (20000/4),
 | 
					 | 
				
			||||||
					// assuming a variation of 20K
 | 
					 | 
				
			||||||
					// in total file size and
 | 
					 | 
				
			||||||
					// long-aligned file formats.
 | 
					 | 
				
			||||||
#define kApplicationUpTimeEntropy 6.0	// Variance > 1 second, uptime
 | 
					 | 
				
			||||||
					// in ticks  
 | 
					 | 
				
			||||||
#define kSysStartupEntropy 7.0		// Entropy for machine startup
 | 
					 | 
				
			||||||
					// time
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*------------------------ Function definitions ----------------------*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
CRandomizer::CRandomizer (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	long	result;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	mSupportsLargeVolumes =
 | 
					 | 
				
			||||||
		(Gestalt(gestaltFSAttr, &result) == noErr) &&
 | 
					 | 
				
			||||||
		((result & (1L << gestaltFSSupports2TBVols)) != 0);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (Gestalt (gestaltNativeCPUtype, &result) != noErr)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		mIsPowerPC = false;
 | 
					 | 
				
			||||||
		mIs601 = false;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		mIs601 = (result == gestaltCPU601);
 | 
					 | 
				
			||||||
		mIsPowerPC = (result >= gestaltCPU601);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	mLastMouse.h = mLastMouse.v = -10;	// First mouse will
 | 
					 | 
				
			||||||
						// always be recorded
 | 
					 | 
				
			||||||
	mLastPeriodicTicks = TickCount();
 | 
					 | 
				
			||||||
	GetTimeBaseResolution ();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// Add initial entropy
 | 
					 | 
				
			||||||
	AddTimeSinceMachineStartup ();
 | 
					 | 
				
			||||||
	AddAbsoluteSystemStartupTime ();
 | 
					 | 
				
			||||||
	AddStartupVolumeInfo ();
 | 
					 | 
				
			||||||
	AddFiller ();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::PeriodicAction (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	AddCurrentMouse ();
 | 
					 | 
				
			||||||
	AddNow (0.0);	// Should have a better entropy estimate here
 | 
					 | 
				
			||||||
	mLastPeriodicTicks = TickCount();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*------------------------- Private Methods --------------------------*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddCurrentMouse (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	Point mouseLoc;
 | 
					 | 
				
			||||||
	unsigned long lastCheck;	// Ticks since mouse was last
 | 
					 | 
				
			||||||
					// sampled
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if TARGET_API_MAC_CARBON
 | 
					 | 
				
			||||||
	GetGlobalMouse (&mouseLoc);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	mouseLoc = LMGetMouseLocation();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (labs (mLastMouse.h - mouseLoc.h) > kMouseResolution/2 &&
 | 
					 | 
				
			||||||
	    labs (mLastMouse.v - mouseLoc.v) > kMouseResolution/2)
 | 
					 | 
				
			||||||
		AddBytes (&mouseLoc, sizeof (mouseLoc),
 | 
					 | 
				
			||||||
				kMousePositionEntropy);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (mLastMouse.h == mouseLoc.h && mLastMouse.v == mouseLoc.v)
 | 
					 | 
				
			||||||
		mMouseStill ++;
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		double entropy;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Mouse has moved. Add the number of measurements for
 | 
					 | 
				
			||||||
		// which it's been still. If the resolution is too
 | 
					 | 
				
			||||||
		// coarse, assume the entropy is 0.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		lastCheck = TickCount() - mLastPeriodicTicks;
 | 
					 | 
				
			||||||
		if (lastCheck <= 0)
 | 
					 | 
				
			||||||
			lastCheck = 1;
 | 
					 | 
				
			||||||
		entropy = log2l
 | 
					 | 
				
			||||||
			(kTypicalMouseIdleTicks/(double)lastCheck);
 | 
					 | 
				
			||||||
		if (entropy < 0.0)
 | 
					 | 
				
			||||||
			entropy = 0.0;
 | 
					 | 
				
			||||||
		AddBytes (&mMouseStill, sizeof (mMouseStill), entropy);
 | 
					 | 
				
			||||||
		mMouseStill = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	mLastMouse = mouseLoc;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddAbsoluteSystemStartupTime (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	unsigned long	now;		// Time in seconds since
 | 
					 | 
				
			||||||
					// 1/1/1904
 | 
					 | 
				
			||||||
	GetDateTime (&now);
 | 
					 | 
				
			||||||
	now -= TickCount() / 60;	// Time in ticks since machine
 | 
					 | 
				
			||||||
					// startup
 | 
					 | 
				
			||||||
	AddBytes (&now, sizeof (now), kSysStartupEntropy);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddTimeSinceMachineStartup (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	AddNow (1.5);			// Uncertainty in app startup
 | 
					 | 
				
			||||||
					// time is > 1.5 msec (for
 | 
					 | 
				
			||||||
					// automated app startup).
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddAppRunningTime (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ProcessSerialNumber PSN;
 | 
					 | 
				
			||||||
	ProcessInfoRec		ProcessInfo;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	ProcessInfo.processInfoLength = sizeof (ProcessInfoRec);
 | 
					 | 
				
			||||||
	ProcessInfo.processName = nil;
 | 
					 | 
				
			||||||
	ProcessInfo.processAppSpec = nil;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	GetCurrentProcess (&PSN);
 | 
					 | 
				
			||||||
	GetProcessInformation (&PSN, &ProcessInfo);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Now add the amount of time in ticks that the current process
 | 
					 | 
				
			||||||
	// has been active
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	AddBytes (&ProcessInfo, sizeof (ProcessInfoRec),
 | 
					 | 
				
			||||||
			kApplicationUpTimeEntropy);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddStartupVolumeInfo (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	short			vRefNum;
 | 
					 | 
				
			||||||
	long			dirID;
 | 
					 | 
				
			||||||
	XVolumeParam	pb;
 | 
					 | 
				
			||||||
	OSErr			err;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (!mSupportsLargeVolumes)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	FindFolder (kOnSystemDisk, kSystemFolderType, kDontCreateFolder,
 | 
					 | 
				
			||||||
			&vRefNum, &dirID);
 | 
					 | 
				
			||||||
	pb.ioVRefNum = vRefNum;
 | 
					 | 
				
			||||||
	pb.ioCompletion = 0;
 | 
					 | 
				
			||||||
	pb.ioNamePtr = 0;
 | 
					 | 
				
			||||||
	pb.ioVolIndex = 0;
 | 
					 | 
				
			||||||
	err = PBXGetVolInfoSync (&pb);
 | 
					 | 
				
			||||||
	if (err != noErr)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	// Base the entropy on the amount of space used on the disk and
 | 
					 | 
				
			||||||
	// on the next available allocation block. A lot else might be
 | 
					 | 
				
			||||||
	// unpredictable, so might as well toss the whole block in. See
 | 
					 | 
				
			||||||
	// comments for entropy estimate justifications.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	AddBytes (&pb, sizeof (pb),
 | 
					 | 
				
			||||||
		kVolumeBytesEntropy +
 | 
					 | 
				
			||||||
		log2l (((pb.ioVTotalBytes.hi - pb.ioVFreeBytes.hi)
 | 
					 | 
				
			||||||
				* 4294967296.0D +
 | 
					 | 
				
			||||||
			(pb.ioVTotalBytes.lo - pb.ioVFreeBytes.lo))
 | 
					 | 
				
			||||||
				/ pb.ioVAlBlkSiz - 3.0));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	On a typical startup CRandomizer will come up with about 60
 | 
					 | 
				
			||||||
	bits of good, unpredictable data. Assuming no more input will
 | 
					 | 
				
			||||||
	be available, we'll need some more lower-quality data to give
 | 
					 | 
				
			||||||
	OpenSSL the 128 bits of entropy it desires. AddFiller adds some
 | 
					 | 
				
			||||||
	relatively predictable data into the soup.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddFiller (void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		ProcessSerialNumber psn;	// Front process serial
 | 
					 | 
				
			||||||
						// number
 | 
					 | 
				
			||||||
		RGBColor	hiliteRGBValue;	// User-selected
 | 
					 | 
				
			||||||
						// highlight color
 | 
					 | 
				
			||||||
		long		processCount;	// Number of active
 | 
					 | 
				
			||||||
						// processes
 | 
					 | 
				
			||||||
		long		cpuSpeed;	// Processor speed
 | 
					 | 
				
			||||||
		long		totalMemory;	// Total logical memory
 | 
					 | 
				
			||||||
						// (incl. virtual one)
 | 
					 | 
				
			||||||
		long		systemVersion;	// OS version
 | 
					 | 
				
			||||||
		short		resFile;	// Current resource file
 | 
					 | 
				
			||||||
	} data;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	GetNextProcess ((ProcessSerialNumber*) kNoProcess);
 | 
					 | 
				
			||||||
	while (GetNextProcess (&data.psn) == noErr)
 | 
					 | 
				
			||||||
		data.processCount++;
 | 
					 | 
				
			||||||
	GetFrontProcess (&data.psn);
 | 
					 | 
				
			||||||
	LMGetHiliteRGB (&data.hiliteRGBValue);
 | 
					 | 
				
			||||||
	Gestalt (gestaltProcClkSpeed, &data.cpuSpeed);
 | 
					 | 
				
			||||||
	Gestalt (gestaltLogicalRAMSize, &data.totalMemory);
 | 
					 | 
				
			||||||
	Gestalt (gestaltSystemVersion, &data.systemVersion);
 | 
					 | 
				
			||||||
	data.resFile = CurResFile ();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// Here we pretend to feed the PRNG completely random data. This
 | 
					 | 
				
			||||||
	// is of course false, as much of the above data is predictable
 | 
					 | 
				
			||||||
	// by an outsider. At this point we don't have any more
 | 
					 | 
				
			||||||
	// randomness to add, but with OpenSSL we must have a 128 bit
 | 
					 | 
				
			||||||
	// seed before we can start. We just add what we can, without a
 | 
					 | 
				
			||||||
	// real entropy estimate, and hope for the best.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	AddBytes (&data, sizeof(data), 8.0 * sizeof(data));
 | 
					 | 
				
			||||||
	AddCurrentMouse ();
 | 
					 | 
				
			||||||
	AddNow (1.0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//-------------------  LOW LEVEL ---------------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddBytes (void *data, long size, double entropy)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	RAND_add (data, size, entropy * 0.125);	// Convert entropy bits
 | 
					 | 
				
			||||||
						// to bytes
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::AddNow (double millisecondUncertainty)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	long time = SysTimer();
 | 
					 | 
				
			||||||
	AddBytes (&time, sizeof (time), log2l (millisecondUncertainty *
 | 
					 | 
				
			||||||
			mTimebaseTicksPerMillisec));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//----------------- TIMING SUPPORT ------------------
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CRandomizer::GetTimeBaseResolution (void)
 | 
					 | 
				
			||||||
{	
 | 
					 | 
				
			||||||
#ifdef __powerc
 | 
					 | 
				
			||||||
	long speed;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// gestaltProcClkSpeed available on System 7.5.2 and above
 | 
					 | 
				
			||||||
	if (Gestalt (gestaltProcClkSpeed, &speed) != noErr)
 | 
					 | 
				
			||||||
		// Only PowerPCs running pre-7.5.2 are 60-80 MHz
 | 
					 | 
				
			||||||
		// machines.
 | 
					 | 
				
			||||||
		mTimebaseTicksPerMillisec =  6000.0D;
 | 
					 | 
				
			||||||
	// Assume 10 cycles per clock update, as in 601 spec. Seems true
 | 
					 | 
				
			||||||
	// for later chips as well.
 | 
					 | 
				
			||||||
	mTimebaseTicksPerMillisec = speed / 1.0e4D;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	// 68K VIA-based machines (see Develop Magazine no. 29)
 | 
					 | 
				
			||||||
	mTimebaseTicksPerMillisec = 783.360D;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unsigned long CRandomizer::SysTimer (void)	// returns the lower 32
 | 
					 | 
				
			||||||
						// bit of the chip timer
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#ifdef __powerc
 | 
					 | 
				
			||||||
	return GetPPCTimer (mIs601);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	UnsignedWide usec;
 | 
					 | 
				
			||||||
	Microseconds (&usec);
 | 
					 | 
				
			||||||
	return usec.lo;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __powerc
 | 
					 | 
				
			||||||
// The timebase is available through mfspr on 601, mftb on later chips.
 | 
					 | 
				
			||||||
// Motorola recommends that an 601 implementation map mftb to mfspr
 | 
					 | 
				
			||||||
// through an exception, but I haven't tested to see if MacOS actually
 | 
					 | 
				
			||||||
// does this. We only sample the lower 32 bits of the timer (i.e. a
 | 
					 | 
				
			||||||
// few minutes of resolution)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
asm unsigned long GetPPCTimer (register bool is601)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cmplwi	is601, 0	// Check if 601
 | 
					 | 
				
			||||||
	bne	_601		// if non-zero goto _601
 | 
					 | 
				
			||||||
	mftb  	r3		// Available on 603 and later.
 | 
					 | 
				
			||||||
	blr			// return with result in r3
 | 
					 | 
				
			||||||
_601:
 | 
					 | 
				
			||||||
	mfspr r3, spr5  	// Available on 601 only.
 | 
					 | 
				
			||||||
				// blr inserted automatically
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,43 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
//	Gathers unpredictable system data to be used for generating
 | 
					 | 
				
			||||||
//	random bits
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <MacTypes.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CRandomizer
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	CRandomizer (void);
 | 
					 | 
				
			||||||
	void PeriodicAction (void);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Private calls
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void		AddTimeSinceMachineStartup (void);
 | 
					 | 
				
			||||||
	void		AddAbsoluteSystemStartupTime (void);
 | 
					 | 
				
			||||||
	void		AddAppRunningTime (void);
 | 
					 | 
				
			||||||
	void		AddStartupVolumeInfo (void);
 | 
					 | 
				
			||||||
	void		AddFiller (void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void		AddCurrentMouse (void);
 | 
					 | 
				
			||||||
	void		AddNow (double millisecondUncertainty);
 | 
					 | 
				
			||||||
	void		AddBytes (void *data, long size, double entropy);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	void		GetTimeBaseResolution (void);
 | 
					 | 
				
			||||||
	unsigned long	SysTimer (void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// System Info	
 | 
					 | 
				
			||||||
	bool		mSupportsLargeVolumes;
 | 
					 | 
				
			||||||
	bool		mIsPowerPC;
 | 
					 | 
				
			||||||
	bool		mIs601;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// Time info
 | 
					 | 
				
			||||||
	double		mTimebaseTicksPerMillisec;
 | 
					 | 
				
			||||||
	unsigned long	mLastPeriodicTicks;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// Mouse info
 | 
					 | 
				
			||||||
	long		mSamplePeriod;
 | 
					 | 
				
			||||||
	Point		mLastMouse;
 | 
					 | 
				
			||||||
	long		mMouseStill;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
							
								
								
									
										18
									
								
								MacOS/TODO
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								MacOS/TODO
									
									
									
									
									
								
							@@ -1,18 +0,0 @@
 | 
				
			|||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
Verify server certificate
 | 
					 | 
				
			||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
Currently omitted from the project:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	crypto/tmdiff.c
 | 
					 | 
				
			||||||
	crypto/bio/bss_conn.c
 | 
					 | 
				
			||||||
	crypto/bio/b_sock.c
 | 
					 | 
				
			||||||
	crypto/bio/bss_acpt.c
 | 
					 | 
				
			||||||
	crypto/bio/bss_log.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
Build libraries to link with...
 | 
					 | 
				
			||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
Port openssl application.
 | 
					 | 
				
			||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
BN optimizations (currently PPC version is compiled with BN_LLONG)
 | 
					 | 
				
			||||||
-------------------------------------------------------------------
 | 
					 | 
				
			||||||
@@ -1,9 +0,0 @@
 | 
				
			|||||||
#include <MacHeaders.h>
 | 
					 | 
				
			||||||
#define B_ENDIAN
 | 
					 | 
				
			||||||
#ifdef __POWERPC__
 | 
					 | 
				
			||||||
#pragma longlong on
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#if 1
 | 
					 | 
				
			||||||
#define MAC_OS_GUSI_SOURCE
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#define MONOLITH
 | 
					 | 
				
			||||||
@@ -1,9 +0,0 @@
 | 
				
			|||||||
#include <MacHeaders.h>
 | 
					 | 
				
			||||||
#define B_ENDIAN
 | 
					 | 
				
			||||||
#ifdef __POWERPC__
 | 
					 | 
				
			||||||
#pragma longlong on
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
#define MAC_OS_GUSI_SOURCE
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#define MONOLITH
 | 
					 | 
				
			||||||
@@ -1,5 +0,0 @@
 | 
				
			|||||||
#ifndef MK1MF_BUILD
 | 
					 | 
				
			||||||
#  define CFLAGS	"-DB_ENDIAN"
 | 
					 | 
				
			||||||
#  define PLATFORM	"macos"
 | 
					 | 
				
			||||||
#  define DATE		"Sun Feb 27 19:44:16 MET 2000"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1,820 +0,0 @@
 | 
				
			|||||||
(This file must be converted with BinHex 4.0)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
:#QeVE'PZDh-ZBA-!39"36'&`E(3J!!!!!!!!!*LiI6m!!!!!!3!!!*G#!!#@3J!
 | 
					 | 
				
			||||||
!!AChFQPd!!!!K3)"!3m(Fh9`F'pbG!!!!)B#!3%$"(0eFQ8!!!#(!J-%"!3("3C
 | 
					 | 
				
			||||||
cGfPdBfJ!!!#)!J%"#39cH@jMD!!!!)N#"J%$!`-&"3-'FhPcG'9Y!!!!LJ)&"3)
 | 
					 | 
				
			||||||
%!J8("!-#!`4dB@*X!!!!L`))!3-$!`-$!`-$"(4PE'`!!!#-!J)"#38$G'KP!!!
 | 
					 | 
				
			||||||
!M3))(J)@!Ki#!J))!K)#!`)B!Kd%G'KPE3!!!)i#!J%&#`4dD'9j!!!!M`)#!J)
 | 
					 | 
				
			||||||
#$3TdD(*[G@GSEh9d!!!!N!!#!3%&"(4TCQB!!!#4!J%"!`4dD@eP!!!!NJ)"!JS
 | 
					 | 
				
			||||||
#!h4T!!!!'N!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!H!!!!!!!#!!!!!!
 | 
					 | 
				
			||||||
!!!!!!!!!!!!!rrrrr`!!!$3!!!!N!!!!!#"[!!5JAb"[!!5K++!M6R9$9'mJFR9
 | 
					 | 
				
			||||||
Z)(4SDA-JFf0bDA"d)'&`F'aTBf&dD@pZ,#"jEh8JEA9cG#"QDA*cG#"TER0dB@a
 | 
					 | 
				
			||||||
X)%&`F'aP8f0bDA"d,J!!!)C8D'Pc)(0MFQP`G#"MFQ9KG'9c)#iZ,fPZBfaeC'8
 | 
					 | 
				
			||||||
[Eh"PER0cE#"KEQ3JCQPXE(-JDA3JGfPdD#"ZC@0PFh0KFRNJB@aTBA0PFbi0$8P
 | 
					 | 
				
			||||||
d)'eTCfKd)(4KDf8JB5"hD'PXC5"dEb"MEfe`E'9dC5"cEb"`E'9KFf8JBQ8JF'&
 | 
					 | 
				
			||||||
dD@9ZG$SY+3!!!#S!!J!!!!!!$3!+!"!!!!!-!!!!!!!!!!!!63!0!!S!%!%!!!`
 | 
					 | 
				
			||||||
!!!!!!!!!!!!B!!!!+!!!!!!!!!!)!!!!)!#N2c`!!DR`!!!!l!!!!!&19[ri,`0
 | 
					 | 
				
			||||||
f!#m$-$bKVDG'*KmY52ri,`-`2+LITdBQ(b!ZrrLa`'FJ,`-J2'0`ER4"l[rm)NL
 | 
					 | 
				
			||||||
KV5+)*Kp+3'B)5Ulrr'F#GJ%3!bBZrr41ANje6PB!!#m-@Bm[2%j29%Nr2!#!U"m
 | 
					 | 
				
			||||||
SAb!-CJK`!cm!UFKJ+#m-UC)J9#!)d+J!'#&!!"JJ9#!)d+J!(#&!!"a9Mbm8)&q
 | 
					 | 
				
			||||||
JAMk!9%mSE[rm6Pj1G8j@!!![$%kkre4+!'FU@Bm[2'&`E(3[2(0MF(4`)DJU+&m
 | 
					 | 
				
			||||||
J$'F5@Bm[$#mm!!!!!A!!U#UTp&K26VVrG#KZrra1ANje!!!!('&`E(3!!!!"4P*
 | 
					 | 
				
			||||||
&4J!!!!!!J%P$6L-!!!!!!*B!!!!"!!!!!!G"8&"-!!!!!!!"!!!"!!!!!S!!!!4
 | 
					 | 
				
			||||||
!!!"i)!!!K"!!!3))!!)#"!!%"!)!#!J"!"!8!)!J)J"!3%%!)2#!J"#*!%!)KJ!
 | 
					 | 
				
			||||||
J")3!)!*!!"!")!!3!K!!%!3)!"!)"!!J%!)!3#!"!)"!!S%!J!5#!3!)4!)!#%J
 | 
					 | 
				
			||||||
%!!KB#!!%C"!!!m)J!!!"3!!!!)!!!!%!!!!$J!!!"m!!!(rJ!!$rm!!"rrJ!!rr
 | 
					 | 
				
			||||||
m!!IrrJ!2rrm!(rrrJ$rrrm"rrrrJrrrrm2rrrrMrrrrmrrrrrRrrrrmrrrrq(rr
 | 
					 | 
				
			||||||
rr!rrrrJ(rrr`!rrri!(rrm!$rrq!"rrr!!rrrJ!2rr`!$rri!!IRm!!$`q!!!!(
 | 
					 | 
				
			||||||
!!!!!J!!!!!)!!!!!!!!!!!m!!!!!!!!!!!!!!!!!!!$`m!!!!!!!!!!!!!!!!!!
 | 
					 | 
				
			||||||
2!!m!!!!!!!!!!!!!!!rrm!!!m!!!!!!!!!!!!!$`c0m!!!m!!!!!!!!!!!!2!!c
 | 
					 | 
				
			||||||
-m!!!m!!!!!!!!!!!m!$-cI!!!!m!!!!!!!!!$`!-c0m!!!!!m!!!!!!!!2!!c-h
 | 
					 | 
				
			||||||
`!!!!!!m!!!!!!!m!$-cIh`!!!!!!m!!!!!$`!-c0rGh`!!!!!!m!!!!2!!c-hph
 | 
					 | 
				
			||||||
-h`!!!!!!m!!!rrr-cIhF`-h`!!!!!!m!!2lFr0rGc!`-h`!!!!!!m!$pc-rph-$
 | 
					 | 
				
			||||||
!`-h`!!!!!!m!r-`2cF`-$!!-r3!!!!!!m!m!`-c!`-!!$0m!!!!!$-m!m!`-$!`
 | 
					 | 
				
			||||||
!!-cI!!!!!-c`!!m!`-$!!!`-h`!!!!c2!!!!m!`-!!$!c0m!!!$-m!!!!!m!`!!
 | 
					 | 
				
			||||||
-$-hm!!!-c`!!!!!!m!!!`-cIc!!!c2!!!!!!!!m!$!c0r-`!$-m!!!!!!!$pm-$
 | 
					 | 
				
			||||||
-hmc!!-c`!!!!!!!2hI`-cIc-!!c2!!!!!!!!rGc2c0r-`!$-m!!!!!!!!2h-cmh
 | 
					 | 
				
			||||||
mc!!-c`!!!!!!!!$mc!rIr-!!c2!!!!!!!!!!$m$2m!r-$-m!!!!!!!!!!!$rr`!
 | 
					 | 
				
			||||||
!r-c`!!!!!!!!!!!!!!!!!!r2!!!!!!!!!!!!!!!!!!!!m!!!!!!!!!!!!!"!!B!
 | 
					 | 
				
			||||||
13"%J)4"##18%Q)+3!%&!)5!L%%3BL#83*L!G3!#!!B!2`"rJ2r"rq2rmrrlrrhr
 | 
					 | 
				
			||||||
r2riIr"ri2r!ri"h!!)!!!!#!!!!!$r!!!!!!!2r`$`!!!!!2$!m!m!!!!2$!c`!
 | 
					 | 
				
			||||||
2!!!2$!c`!!$`!2r`cpm!!!m!rGrpc2!!!2$p$p`-c`!!$`m!`-$0m!$2!2!-$-h
 | 
					 | 
				
			||||||
`$2!!$`$-hm$2!!!2m-hm$2!!!2h2hm$2!!!!r-rm$2!!!!!2r`r2!!!!!!!!!2!
 | 
					 | 
				
			||||||
!!!!!!!#D8f0bDA"d)%&`F'aTBf&dD@pZ$3e8D'Pc)(0MFQP`G#"MFQ9KG'9c)#i
 | 
					 | 
				
			||||||
Z,fPZBfaeC'8[Eh"PER0cE#"KEQ3JCQPXE(-JDA3JGfPdD#"ZC@0PFh0KFRNJB@a
 | 
					 | 
				
			||||||
TBA0PFbi0$8Pd)'eTCfKd)(4KDf8JB5"hD'PXC5"dEb"MEfe`E'9dC5"cEb"`E'9
 | 
					 | 
				
			||||||
KFf8JBQ8JF'&dD@9ZG$SY+3!!!")!!J!!!!!!!!!!!!%!"J!'%iN!!!!+@1!!!b!
 | 
					 | 
				
			||||||
!!!-J!!!!!"3!+`!(!Cm#@!!V!!F"f!*B!!!!!3!!M`C'BA0N98&6)$%Z-6!a,M%
 | 
					 | 
				
			||||||
`$J!!!!32rrm!!3!#!!-"rrm!!!d!!3!"D`!!!!!!!!!%!J!%!!)!"3!'$3!&!!*
 | 
					 | 
				
			||||||
X!!)!!!U`!!IrrJd!"`!#6`!!!!!+X!!)!!N0!!J!!@X!!!!%#Um!#J)!#J!#!!X
 | 
					 | 
				
			||||||
!$!d!#`!#E!!#!!3!"2rprr`"rrd!!!(rr!!!!J!-!!)!$3!1$3!0!!*X!!%!"!!
 | 
					 | 
				
			||||||
%rrX!$`(rq`!!$!!2!&N!8b"(CA3JF'&dD#"dEb"dD'Pc)%&`F'aP8f0bDA"d)'&
 | 
					 | 
				
			||||||
`F'aPG$XJGA0P)'Pd)(4[)'C[FQdJG'KP)("KG'JJG'mJG'KP)'PZBfaeC'8JCQp
 | 
					 | 
				
			||||||
XC'9b!!)!!!)!$J!#!"!!%3d!%!!#E!!"!!3!"2rk!")"rrS!!!`!%J!Q!#!JB@j
 | 
					 | 
				
			||||||
N)(4SC5"[G'KPFL"bC@aPGQ&ZG#"QEfaNCA*c,J!#!!!#!"%!!J!6!"30!"-!!R-
 | 
					 | 
				
			||||||
!!!!%!"%!&3!@$3!9!!*M!!!!"!!1!"F!'!d!&`!#E!!&!!3!$!!CrrN0!"N!!Qi
 | 
					 | 
				
			||||||
!!!!%!!`!'J!E$3!D!!)d!!!!"3!-rrJ!(!Vrq!!%#Q0[BQS0!"`!!Q`!"3!'!!X
 | 
					 | 
				
			||||||
!(Irh$3!G!!0*!!)!"J!,rrB!([re#[rf!"JZC@&bFfCQC(*KE'Pc!!!!!!!!)!"
 | 
					 | 
				
			||||||
KCQ4b$3!H!!"Q!!!!"J!(![re!!!"rrF!!!d!'`!"E3!!!!3!"3!I$`!I!6J)ER9
 | 
					 | 
				
			||||||
XE!!!!!!!!Gq!rrm!!!!A"NCTEQ4PFJ!!(`*[Me!!ASfm!Qq,i!"HA[!!I&M!!!!
 | 
					 | 
				
			||||||
!!!!!'mi!!JN#!Qq-1!!!Kb%#Ei`J!!!!!%C14&*038e"3e-!!"%!B@aTF`!!!!!
 | 
					 | 
				
			||||||
!fJ!#!!!-6@&MD@jdEh0S)%K%!!!!!!!!!!!!!!!!!!!!XSA5h%*%!!!!!!!A"NC
 | 
					 | 
				
			||||||
TEQ4PFJ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 | 
					 | 
				
			||||||
!!!!!!!!!!!!!!!!!!!!!3rLc#@a!4Nj%8Ne"3e2rrrrr!!!!!!!!!!!!!!!!!!!
 | 
					 | 
				
			||||||
!!!!!!!e6HA0dC@dJ4QpXC'9b!!!"!!3!!!!A!!)!)8eKBfPZG'pcD#")4$T6HA0
 | 
					 | 
				
			||||||
dC@dJ4QpXC'9b1NCTEQ4PFJ$rr`!!!Irj!!!0!"J!!@d!!!!-!!hrp!Vrp!!%#Q0
 | 
					 | 
				
			||||||
dH(30!"B!!@m!!!!!!!$rm`[rm`!5-!!(G'KPF'&dD!!(G'KP8'&dD!)!&!!#!#!
 | 
					 | 
				
			||||||
!)3d!)!!#E!!#!")!%[rbrr%"rr)!!!(rm3!!!J!K!!)!)J!M$3!L!!*b!!!!%J!
 | 
					 | 
				
			||||||
A!#3!*3d!*!!#EJ!$!")!&3!Q!#F0!#B!!6%!!!!6!"Arm!Vrm!!%#R4iC'`0!#F
 | 
					 | 
				
			||||||
!!6%!!!!5!"2rl`Vrl`!%#Q&cBh)0!#8!!@m!!!!!!!$rlJ[rlJ!F-!!-G'KPEfa
 | 
					 | 
				
			||||||
NC'9XD@ec!!adD'92E'4%C@aTEA-#!#-!!J!S!#N0!#J!!R)!!!!B!"d!+J!V$3!
 | 
					 | 
				
			||||||
U!!&Y!!!!'!!C!#`-!#`!"`!"1J!#!!!0!#X!!Qi!!`!!!!!!,3!Z$3!Y!!%a!!!
 | 
					 | 
				
			||||||
!'J!Frqd+rqd!"!TdH'4X$3!Z!!%a!!!!'3!Drq`+rq`!"!TKFf0b!J!T!!)!,`!
 | 
					 | 
				
			||||||
`$3![!!*X!!)!(J!Hrq[rkJ(rk`!!!IrU!!!#!$!!!J!a!$)0!$%!!R)!!!!H!#X
 | 
					 | 
				
			||||||
!-`!d$3!c!!*X!!8!(J!T!$Ark3d!03!#EJ!!!"i!+3!f!$F0!$B!!cF"!!!I!#R
 | 
					 | 
				
			||||||
rk!!i!$N+rqJ!"!TMDA4Y$3!i!!&Y!!!!)`!PrqF$rqF!!3d!13!"E3!!!#B!+2r
 | 
					 | 
				
			||||||
Q!rrQrrd0!$F!!@m!!!!H!"rrj3[rj3!5-!!(G'KPF'&dD!!(G'KP8'&dD!(rk3!
 | 
					 | 
				
			||||||
!$3!d!!&[!!!!!!!!rq3,rq3!)$!!$R4SCA"bEfTPBh4`BA4S!!jdD'93FQpUC@0
 | 
					 | 
				
			||||||
d8'&dD!)!-J!#!$S!1`d!1J!#FJ!!!#`!1`!m!$d0!$`!!Q-!!!!X!$N!2J!r$3!
 | 
					 | 
				
			||||||
q!!*X!!8!,!!h!%$ri`d!3!!#EJ!!!#`!0`""!%)0!%%!!cF"!!!Y!$IriJ"$!%3
 | 
					 | 
				
			||||||
+rq)!"!TMDA4Y$3"$!!&Y!!!!-3!crq%$rq%!!3d!4!!"E3!!!$3!0[rJ!rrJrri
 | 
					 | 
				
			||||||
0!%)!!@m!!!!X!#hrh`[rh`!5-!!(G'KPF'&dD!!(G'KP8'&dD!(ri`!!$3!r!!&
 | 
					 | 
				
			||||||
Y!!!!0`!irpi+rpi!"!T849K8$3!p!!&[!!!!!!!!rpd,rpd!&M!!#A4SC@ePF'&
 | 
					 | 
				
			||||||
dD!!*G'KP6@93BA4S!J!l!!)!43"'$3"&!!*X!!)!2!!mrpcrf`(rh!!!!IrE!!!
 | 
					 | 
				
			||||||
#!%B!!J"(!%J0!%F!!R)!!!!m!%8!53"+$3"*!!*M!!!!2!""!%X!6!d!5`!#BJ!
 | 
					 | 
				
			||||||
!!$`!2`"0!%i0!%d!!@m!!!!m!$hrfJ[rfJ!J-!!1G'KPF(*[DQ9MG("KG'J!$R4
 | 
					 | 
				
			||||||
SC9"bEfTPBh43BA4S$3"1!!&Y!!!!23!q!%m-!%m!$3!(D@jME(9NC3!#!!!0!%`
 | 
					 | 
				
			||||||
!!@d!!!!r!%$rf3Vrf3!%#P4&@&30!%S!!@m!!!!!!!$rf![rf!!Q-!!4D@jME(9
 | 
					 | 
				
			||||||
NC@C[E'4PFR"KG'J!%@PZBfaeC'9'EfaNCA*3BA4S!J")!!)!8!"4$3"3!!*b!!!
 | 
					 | 
				
			||||||
!4J"9!&)!8`d!8J!#B`!!!%B!83"8!&80!&3!!Q)!!!"'!%m!9J"A$3"@!!*L!!!
 | 
					 | 
				
			||||||
!4J",!&J!@3d!@!!"E`!!!%B!4rrA#rrA!#!`!!jdD'9`FQpUC@0dF'&dD!!1G'K
 | 
					 | 
				
			||||||
P8(*[DQ9MG&"KG'J0!&N!!@d!!!"(!%S!@J`!@J!0!!GTEQ0XG@4P!!)!!!d!9`!
 | 
					 | 
				
			||||||
"E3!!!%X!6J"E$!"E!!d!"fp`C@jcFf`!!J!!$3"9!!&Y!!!!6`"3rpB+rpB!"!T
 | 
					 | 
				
			||||||
849K8$3"6!!&[!!!!!!!!rp8,rp8!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&
 | 
					 | 
				
			||||||
dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S!J"4!!)!A!"G$3"F!!*b!!!!9J"
 | 
					 | 
				
			||||||
K!&i!A`d!AJ!#B`!!!&B!A3"J!'%0!'!!!Q)!!!"@!&X!BJ"M$3"L!!&[!!!!9J"
 | 
					 | 
				
			||||||
Arp3,rp3!)$!!$R4SCA"bEfTPBh4`BA4S!!jdD'93FQpUC@0d8'&dD!d!B`!"E3!
 | 
					 | 
				
			||||||
!!&F!@J"N$!"N!!`!"Q0bHA"dE`!#!!!0!'%!!@d!!!"E!&crd`Vrd`!%#P4&@&3
 | 
					 | 
				
			||||||
0!&m!!@m!!!!!!!$rdJ[rdJ!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4Qp
 | 
					 | 
				
			||||||
XC'9b8'&dD!)!A3!#!'8!CJd!C3!#FJ!!!')!E3"R!'J0!'F!!Q-!!!"L!'N!D3"
 | 
					 | 
				
			||||||
U$3"T!!*L!!!!BJ"R!'X!E!d!D`!"E`!!!')!Brr4#rr4!#!`!!jdD'9`FQpUC@0
 | 
					 | 
				
			||||||
dF'&dD!!1G'KP8(*[DQ9MG&"KG'J0!'`!!@d!!!"M!'B!E3`!E3!*!!0cFf`!!J!
 | 
					 | 
				
			||||||
!$3"U!!&Y!!!!C`"Srp!+rp!!"!T849K8$3"S!!&[!!!!!!!!rmm,rmm!(M!!$A0
 | 
					 | 
				
			||||||
cE'C[E'4PFR"KG'J!$A0cE%C[E'4PFP"KG'J#!'B!!J"Z!'m0!'i!!R)!!!"Z!(8
 | 
					 | 
				
			||||||
!F!"a$3"`!!*M!!!!EJ"a!()!F`d!FJ!"E`!!!'i!Err1#rr1!#!`!!jdD'9`FQp
 | 
					 | 
				
			||||||
UC@0dF'&dD!!1G'KP8(*[DQ9MG&"KG'J0!(-!!@d!!!"[!($rc3Vrc3!%#P4&@&3
 | 
					 | 
				
			||||||
0!(%!!@m!!!!!!!$rc![rc!!Q-!!4Eh"PER0cE'C[E'4PFR"KG'J!%@p`C@jcFfa
 | 
					 | 
				
			||||||
'EfaNCA*3BA4S!J"[!!)!G!"e$3"d!!*X!!)!GJ"frm[rbJ(rb`!!!Ir+!!!#!(8
 | 
					 | 
				
			||||||
!!J"f!(F0!(B!!R)!!!"f!(X!H!"j$3"i!!&[!!!!GJ"hrmN,rmN!($!!$(4SC@p
 | 
					 | 
				
			||||||
XC'4PE'PYF`!-G'KP6faN4'9XD@ec$3"j!!*Z!!-!!!!!!(S!H`d!HJ!"-3!!!(J
 | 
					 | 
				
			||||||
!H[r)#[r)!!3+G(KNE!d!H`!"-3!!!(F!H2r(#[r(!!3+BA0MFJ)!G`!#!(`!I3d
 | 
					 | 
				
			||||||
!I!!#E!!#!(`!I2r'rm8"rmB!!!(ra3!!!J"p!!)!IJ"r$3"q!!*X!!%!I!"mrm3
 | 
					 | 
				
			||||||
!J!(ra!!!$!#!!%!!1L"NC@aPG'8JEfaN)'PZBfaeC'8kEh"PER0cE#"QEfaNCA)
 | 
					 | 
				
			||||||
JB@jN)(*PBh*PBA4P)'Pd)'0XC@&ZE(N!!J!!!J"r!!)!J3##$3#"!!*X!!)!I!"
 | 
					 | 
				
			||||||
mrm2r`J(r``!!!Ir#!!!#!))!!J#$!)30!)-!!e%!!!"m!+8!K3#'!)F0!)8!!@X
 | 
					 | 
				
			||||||
!!!"r!*`!L!)!L!!#!)N!LJd!L3!$53!#!(m!N[r"!)[r`!Vr`3!B,QeTFf0cE'0
 | 
					 | 
				
			||||||
d+LSU+J!!!!!!!*!!!#SU+LS0!)X!!Qi!!!"r!)i!M!#0$3#-!!)d!!!!K`#1rlm
 | 
					 | 
				
			||||||
!MJVr[`!%#Q0QEf`0!)i!!@d!!!#+!)d!M``!M`!0!!G[F'9ZFh0X!!)!!!d!M3!
 | 
					 | 
				
			||||||
#0!!!!(m!Krqq!*!!#[qq!!3+BfC[E!d!N!!!!@m!!!#$!)Er[3[r[3!Q-!!4D@j
 | 
					 | 
				
			||||||
ME(9NC@C[E'4PFR"KG'J!%@PZBfaeC'9'EfaNCA*3BA4S![r!!!!#!)S!!J#4rl`
 | 
					 | 
				
			||||||
0!*%!!dN!!J#6!*crZ`#5rlS+rlX!'#jMEh*PC'9XEbSU+LS!!!!!!!#3!!!U+LS
 | 
					 | 
				
			||||||
U$3#5!!%a!!!!N`#BrlN+rlN!"!TcC@aP![qk!!!#rl`!!!d!KJ!$8J!!!!!!!2q
 | 
					 | 
				
			||||||
irlIrYJVrZ!!B,Q&cBh*PFR)J+LSU+J!!!!!!!*!!!#SU+LS"rlF!!!,rYJ!!$3#
 | 
					 | 
				
			||||||
(!!*X!!%!T!#Nrl8!N`(rY3!!$!#6!"-!$5"TCfj[FQ8JCA*bEh)!!J!!!J#%!!)
 | 
					 | 
				
			||||||
!P!#9$3#8!!*X!!)!TJ#Qrl6rX`(rY!!!!Iqc!!!#!*8!!J#@!*F0!*B!!dN!!J#
 | 
					 | 
				
			||||||
Q!,lrX[qa!*J+rl)!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Iqa!!!'!*J
 | 
					 | 
				
			||||||
!!rq`!*N!QJVrX!!%#QY[Bf`0!*N!!@d!!!#U!+hrV`VrV`!%#Q0QEf`'!*S!!rq
 | 
					 | 
				
			||||||
Z!*[rV3VrVJ!%#QPZFfJ0!*X!!M3!!!#`!,MrV!#F#[qX!!3+BfC[E!d!R!!"E`!
 | 
					 | 
				
			||||||
!!,3!YrqV#rqV!#B`!"&TEQ0XG@4PCQpXC'9bF'&dD!!4D@jME(9NC8C[E'4PFP"
 | 
					 | 
				
			||||||
KG'J'rkd!!!)!P`!#!*d!RJd!R3!#FJ!!!,m!aJ#I!+!0!*m!!Q`"!!#r!-)!SIq
 | 
					 | 
				
			||||||
U$3#K!!%a!!!![`$#rkN+rkN!"!TbFfad!IqU!!!0!+!!!@m!!!!!!!$rU![rU!!
 | 
					 | 
				
			||||||
Z-!!9G'KPEQ9hCQpXC'9bFQ9QCA*PEQ0P!"9dD'91CAG'EfaNCA*5C@CPFQ9ZBf8
 | 
					 | 
				
			||||||
#!*i!!J#L!+-0!+)!!dN!!J$(!-lrT`#NrkB+rkF!'#jYDA0MFfaMG#SU+LS!!!!
 | 
					 | 
				
			||||||
!!!#3!!!U+LSU$3#N!!&[!!!!a`$+rk8,rk8!,M!!&A4SC@jPGfC[E'4PFR*PCQ9
 | 
					 | 
				
			||||||
bC@jMC3!9G'KP6Q9h4QpXC'9b8Q9QCA*PEQ0P![qQ!!!#!+-!!J#P!+B0!+8!!R)
 | 
					 | 
				
			||||||
!!!$2!0`!T`#S$3#R!!&Y!!!!c`$5!+N-!+N!$3!(Eh"PER0cE!!#!!!0!+J!!Qi
 | 
					 | 
				
			||||||
!!!!!!!!!UJ#V$3#U!!%a!!!!e`$Erk3+rk3!"!T`EQ&Y$3#V!!%a!!!!dJ$Ark-
 | 
					 | 
				
			||||||
+rk-!"!TcC@aP!J#Q!!)!V!#Y$3#X!!*X!!)!h3$Grk,rS3(rSJ!!!IqK!!!#!+d
 | 
					 | 
				
			||||||
!!J#Z!+m0!+i!!Q`!!3$G!0hrS!#`!IqJ!!!-!,!!(`!C)&0dBA*d)'eKDfPZCb"
 | 
					 | 
				
			||||||
dD'8JB@aTBA0PF`!#!!!#!+m!!J#a!,)0!,%!!dN!!J$G!3ArRrqH!,-+rjm!'#j
 | 
					 | 
				
			||||||
MEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!IqH!!!'!,-!!rqG!,3!Y3VrR3!%#QY
 | 
					 | 
				
			||||||
[Bf`0!,3!!@d!!!$K!16rR!VrR!!%#Q&XD@%'!,8!!rqE!,B!Y`VrQ`!%#QPZFfJ
 | 
					 | 
				
			||||||
0!,B!!M3!!!$R!1rrQJ#i#[qD!!3+BfC[E!d!Z!!"E`!!!1X!l[qC#rqC!$3`!"K
 | 
					 | 
				
			||||||
[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&
 | 
					 | 
				
			||||||
dD!B!Y`!$rjJ!ZIqA#[qB!!3+G'mJ)!d!Z3!#EJ!!!2)!r`#k!,X0!,S!!M3!!!$
 | 
					 | 
				
			||||||
i!2rrPJ#m#[q@!!3+CQPXC3d![!!"E3!!!2X!rJ#p$!#p!"-!$@p`C@jcFfaMEfj
 | 
					 | 
				
			||||||
Q,QJ!!J!!$3#l!!)d!!!!mJ$irj8![JVrP3!%#Q0QEf`0!,i!!@m!!!$f!2IrP![
 | 
					 | 
				
			||||||
rP!!@-!!*G'KPE@9`BA4S!!PdD'90C9"KG'J'rjF!!!)!XJ!#!,m!`!d![`!#E!!
 | 
					 | 
				
			||||||
#!3B""[q6rj)"rj-!!!(rNJ!!!J$!!!)!`3$#$3$"!!*b!!!""J%4!--!a!d!``!
 | 
					 | 
				
			||||||
#BJ!!!3B"$3$&!-B0!-8!!@m!!!%'!3RrN3[rN3!N-!!3Bh*jF(4[CQpXC'9bF'&
 | 
					 | 
				
			||||||
dD!!3Bh*jF(4[4QpXC'9b8'&dD!d!aJ!"E3!!!3N"$!$($!$(!!X!"6TKFfia!!)
 | 
					 | 
				
			||||||
!!!d!a!!"E`!!!!!!!2q3!![rN!!!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)!`J!
 | 
					 | 
				
			||||||
#!-J!b3d!b!!$53!#!4)"22q2rii!bJVrM`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!
 | 
					 | 
				
			||||||
!!'jeE'`"rii!!!B!bJ!$rid!b`$-#[q0!!3+DfpME!d!b`!"E3!!!4B"'Iq-#[q
 | 
					 | 
				
			||||||
-!!3+B@aTB3B!c!!$riX!c3$1#[q,!!3+D@jcD!d!c3!#0!!!!4`"*2q+!-m+riS
 | 
					 | 
				
			||||||
!"!TMCQpX$3$2!!&[!!!")!%MriN,riN!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9
 | 
					 | 
				
			||||||
bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J$1!!2rL!$3riF+riJ!"!T
 | 
					 | 
				
			||||||
dEb!J$3$3!!*Z!!!"*`%f!0%!dJd!d3!#0!!!!5m"0[q'!0-+riB!"!TQD@aP$3$
 | 
					 | 
				
			||||||
6!!&Y!!!"-J%e!03-!03!$!!'BA0Z-5jS!!)!!!d!dJ!#0!!!!5F",rq&!08+ri8
 | 
					 | 
				
			||||||
!"!TMCQpX$3$9!!&[!!!"+`%Zri3,ri3!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!E
 | 
					 | 
				
			||||||
rK`!!!J$*!!)!eJ$A$3$@!!0*!!)"23&Rri2rJJ$B#[q$!"JZBfpbC@0bC@`U+LS
 | 
					 | 
				
			||||||
U!!!!!!!!N!!!ER9XE!(rJJ!!"J$B!!2rJ3$C!0S+ri%!"!TVEf0X$3$C!!&Y!!!
 | 
					 | 
				
			||||||
"33&%ri!+ri!!"!TKE'PK"J$D!!2rI`$E!0`+rhm!"!TTER0S$3$E!!)d!!!"4`&
 | 
					 | 
				
			||||||
2rhi!h3VrIJ!%#Q0QEf`0!0d!!@m!!!&,!8lrI3[rI3!d-!!BEh"PER0cE'PZBfa
 | 
					 | 
				
			||||||
eC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!0`!!rpm!0l
 | 
					 | 
				
			||||||
rH`VrI!!%#R4[)#!0!0i!!Qi!!!&5!@%!h`$J$3$I!!)d!!!"@J&KrhS!i3VrHJ!
 | 
					 | 
				
			||||||
%#QCTE'80!1%!!@d!!!&G!@!!iJ`!iJ!3!!TKFfiaAfeKBbjS!!)!!!d!i!!#0!!
 | 
					 | 
				
			||||||
!!9)"@[pj!1-+rhN!"!TMCQpX$3$M!!&[!!!"9J&CrhJ,rhJ!&$!!#(4PEA"`BA4
 | 
					 | 
				
			||||||
S!!KdC@e`8'&dD!ErH`!!!J$A!!)!j!$P$3$N!!*X!!)"D!&SrhIrGJ(rG`!!!Ip
 | 
					 | 
				
			||||||
f!!!#!18!!J$Q!1F0!1B!!R)!!!&S!A-!k!$T$3$S!!*L!!!"D!&[!1S!k`d!kJ!
 | 
					 | 
				
			||||||
"E`!!!@J"Drpe#rpe!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*
 | 
					 | 
				
			||||||
3BA4S$3$V!!&Y!!!"D`&Z!1`-!1`!#J!%1Q*TE`!#!!!0!1N!!@m!!!!!!!$rG![
 | 
					 | 
				
			||||||
rG!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J$R!!)!l3$Z$3$Y!!0*!!)"G!'Hrh2
 | 
					 | 
				
			||||||
rFJ$[#[pc!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!(rFJ!!"J$[!!2rF3$
 | 
					 | 
				
			||||||
`!2%+rh%!"!TVEf0X$3$`!!&Y!!!"H!&lrh!+rh!!"!TKE'PK"J$a!!2rE`$b!2-
 | 
					 | 
				
			||||||
+rfm!"!TTER0S$3$b!!)d!!!"IJ''rfi!p!VrEJ!%#Q0QEf`0!23!!@m!!!'#!BA
 | 
					 | 
				
			||||||
rE3[rE3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9
 | 
					 | 
				
			||||||
NC8C[E'4PFP"KG'J'!2-!!rpX!2ArD`VrE!!%#R4[)#!0!28!!Qi!!!'*!CJ!pJ$
 | 
					 | 
				
			||||||
h$3$f!!)d!!!"N3'BrfS!q!VrDJ!%#QCTE'80!2J!!@d!!!'8!CF!q3`!q3!,!!9
 | 
					 | 
				
			||||||
LD@mZD!!#!!!0!2F!!M3!!!'*!C(rD3$k#[pT!!3+BfC[E!d!qJ!"E`!!!Bd"N!$
 | 
					 | 
				
			||||||
rD![rD!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[pV!!!#!1i!!J$l!2`0!2X!!Q`
 | 
					 | 
				
			||||||
!!J'I!CrrCrpQ!IpR!!!"rfB!!!)!r!!#!2d!rJd!r3!#FJ!!!Cm"UJ$r!3!0!2m
 | 
					 | 
				
			||||||
!!Q)!!!'I!DB"!3%#$3%"!!&[!!!"R`'Lrf8,rf8!*$!!%'0bHA"dEfC[E'4PFR"
 | 
					 | 
				
			||||||
KG'J!%'0bHA"dEdC[E'4PFP"KG'J0!3)!!@d!!!'L!D8"!``"!`!*!!-kBQB!!J!
 | 
					 | 
				
			||||||
!$3%!!!&[!!!!!!!!rf3,rf3!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)!rJ!#!33
 | 
					 | 
				
			||||||
""3d""!!$53!#!DX"eIpMrf)""JVrB`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'j
 | 
					 | 
				
			||||||
eE'`"rf)!!!B""J!$rf%""`%)#[pK!!3+DfpME!d""`!"E3!!!Dm"X[pJ#[pJ!!3
 | 
					 | 
				
			||||||
+B@aTB3B"#!!$rem"#3%+#[pI!!3+D@jcD!d"#3!#0!!!!E8"[IpH!3X+rei!"!T
 | 
					 | 
				
			||||||
MCQpX$3%,!!&[!!!"Z3'mred,red!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&
 | 
					 | 
				
			||||||
dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J%+!!2rA!%-reX+re`!"!TdEb!
 | 
					 | 
				
			||||||
J$3%-!!*Z!!!"`!(2!3d"$Jd"$3!#0!!!!FJ"crpD!3m+reS!"!TQD@aP$3%2!!&
 | 
					 | 
				
			||||||
Y!!!"b`(1!4!-!4!!%!!+BQa[GfCTFfJZD!!#!!!0!3i!!M3!!!(!!FMr@3%4#[p
 | 
					 | 
				
			||||||
C!!3+BfC[E!d"%3!"E`!!!F3"arpB#rpB!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J
 | 
					 | 
				
			||||||
'reX!!!)""3!#!4)"%`d"%J!#E!!#!GB"e[pAreB"reF!!!(r9J!!!J%6!!)"&!%
 | 
					 | 
				
			||||||
9$3%8!!*b!!!"eJ(K!4B"&`d"&J!#BJ!!!GB"h3%B!4N0!4J!!@m!!!(@!GRr93[
 | 
					 | 
				
			||||||
r93!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d"'3!"E3!
 | 
					 | 
				
			||||||
!!GN"h!%D$!%D!!N!!cTLEJ!#!!!0!4F!!@m!!!!!!!$r9![r9!!8-!!)G'9YF("
 | 
					 | 
				
			||||||
KG'J!#(4PEA"3BA4S!J%9!!)"'`%F$3%E!!0*!!)"iJ)-re2r8J%G#[p6!"JZBfp
 | 
					 | 
				
			||||||
bC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!(r8J!!"J%G!!2r83%H!4m+re%!"!TVEf0
 | 
					 | 
				
			||||||
X$3%H!!&Y!!!"jJ(Tre!+re!!"!TKE'PK"J%I!!2r6`%J!5%+rdm!"!TTER0S$3%
 | 
					 | 
				
			||||||
J!!)d!!!"l!(drdi")JVr6J!%#Q0QEf`0!5)!!@m!!!(`!I2r63[r63!d-!!BEh"
 | 
					 | 
				
			||||||
PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J
 | 
					 | 
				
			||||||
'!5%!!rp-!52r5`Vr6!!%#R4[)#!0!5-!!Qi!!!(h!JB"*!%P$3%N!!)d!!!"r`)
 | 
					 | 
				
			||||||
'rdS"*JVr5J!%#QCTE'80!5B!!@d!!!)#!J8"*``"*`!+!!4LELjS!!)!!!d"*3!
 | 
					 | 
				
			||||||
#0!!!!IF"rrp*!5J+rdN!"!TMCQpX$3%S!!&[!!!"q`(qrdJ,rdJ!&$!!#(4PEA"
 | 
					 | 
				
			||||||
`BA4S!!KdC@e`8'&dD!Er5`!!!J%F!!)"+3%U$3%T!!*X!!)#$3)0rdIr4J(r4`!
 | 
					 | 
				
			||||||
!!Ip'!!!#!5S!!J%V!5`0!5X!!R)!!!)0!KJ",3%Z$3%Y!!*L!!!#$3)8!5m"-!d
 | 
					 | 
				
			||||||
",`!"E`!!!Jd#%2p&#rp&!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'Efa
 | 
					 | 
				
			||||||
NCA*3BA4S$3%`!!&Y!!!#%!)6!6%-!6%!$3!(1Q*eCQCPFJ!#!!!0!5i!!@m!!!!
 | 
					 | 
				
			||||||
!!!$r4![r4!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J%X!!)"-J%c$3%b!!0*!!)
 | 
					 | 
				
			||||||
#'3*$rd2r3J%d#[p$!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!(r3J!!"J%
 | 
					 | 
				
			||||||
d!!2r33%e!6B+rd%!"!TVEf0X$3%e!!&Y!!!#(3)Jrd!+rd!!"!TKE'PK"J%f!!2
 | 
					 | 
				
			||||||
r2`%h!6J+rcm!"!TTER0S$3%h!!)d!!!#)`)Vrci"13Vr2J!%#Q0QEf`0!6N!!@m
 | 
					 | 
				
			||||||
!!!)R!LVr23[r23!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0
 | 
					 | 
				
			||||||
-5@jME(9NC8C[E'4PFP"KG'J'!6J!!rmm!6Vr1`Vr2!!%#R4[)#!0!6S!!Qi!!!)
 | 
					 | 
				
			||||||
Z!Md"1`%m$3%l!!)d!!!#0J)prcS"23Vr1J!%#QCTE'80!6d!!@d!!!)j!M`"2J`
 | 
					 | 
				
			||||||
"2J!1!!KLG@CQCA)ZD!!#!!!0!6`!!M3!!!)Z!MEr13%r#[mj!!3+BfC[E!d"2`!
 | 
					 | 
				
			||||||
"E`!!!M)#0Imi#rmi!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'rcX!!!)"-`!#!8!
 | 
					 | 
				
			||||||
"33d"3!!#E!!#!N3#42mhrcB"rcF!!!(r0J!!!J&"!!)"3J&$$3&#!!*b!!!#4!*
 | 
					 | 
				
			||||||
2!83"43d"4!!#BJ!!!N3#5`&'!8F0!8B!!@m!!!*%!NIr03[r03!N-!!3Bh*jF(4
 | 
					 | 
				
			||||||
[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d"4`!"E3!!!NF#5J&)$!&)!!X
 | 
					 | 
				
			||||||
!"6TMBA0d!!)!!!d"43!"E`!!!!!!!2md#rmd!"3`!!KdC@e`F'&dD!!)G'9YF&"
 | 
					 | 
				
			||||||
KG'J#!8-!!J&*!8S0!8N!!dN!!J*3!RVr-rmb!8X+rc-!'#jMEh*PBh*PE#SU+LS
 | 
					 | 
				
			||||||
!!!!!!!#3!!"ZG@aX!Imb!!!'!8X!!rma!8`"63Vr-3!%#QY[Bf`0!8`!!@d!!!*
 | 
					 | 
				
			||||||
8!PIr-!Vr-!!%#Q&XD@%'!8d!!rm[!8i"6`Vr,`!%#QPZFfJ0!8i!!M3!!!*D!Q,
 | 
					 | 
				
			||||||
r,J&3#[mZ!!3+BfC[E!d"8!!"E`!!!Pi#BImY#rmY!$3`!"K[F'9ZFh0XD@jME(9
 | 
					 | 
				
			||||||
NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B"6`!$rb`"8Im
 | 
					 | 
				
			||||||
V#[mX!!3+G'mJ)!d"83!#EJ!!!Q8#G!&5!9-0!9)!!M3!!!*Y!R6r+J&8#[mU!!3
 | 
					 | 
				
			||||||
+CQPXC3d"9!!"E3!!!R!#F`&9$!&9!!`!"Q0KFh3ZD!!#!!!0!9-!!M3!!!*P!Qh
 | 
					 | 
				
			||||||
r+3&@#[mT!!3+BfC[E!d"9J!"E`!!!QN#E2mS#rmS!"3`!!KdC@e`F'&dD!!)G'9
 | 
					 | 
				
			||||||
YF&"KG'J'rbX!!!)"5J!#!9F"@!d"9`!#E!!#!RX#HrmRrbB"rbF!!!(r*J!!!J&
 | 
					 | 
				
			||||||
B!!)"@3&D$3&C!!*b!!!#H`+'!9X"A!d"@`!#BJ!!!RX#JJ&G!9i0!9d!!@m!!!*
 | 
					 | 
				
			||||||
l!Rlr*3[r*3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d
 | 
					 | 
				
			||||||
"AJ!"E3!!!Ri#J3&I$!&I!!X!"6TMEfe`!!)!!!d"A!!"E`!!!!!!!2mN#rmN!"3
 | 
					 | 
				
			||||||
`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!9S!!J&J!@%0!@!!!dN!!J+(!V(r)rmL!@)
 | 
					 | 
				
			||||||
+rb-!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!ImL!!!'!@)!!rmK!@-"C!V
 | 
					 | 
				
			||||||
r)3!%#QY[Bf`0!@-!!@d!!!+,!Slr)!Vr)!!%#Q&XD@%'!@3!!rmI!@8"CJVr(`!
 | 
					 | 
				
			||||||
%#QPZFfJ0!@8!!M3!!!+4!TRr(J&R#[mH!!3+BfC[E!d"C`!"E`!!!T8#Q2mG#rm
 | 
					 | 
				
			||||||
G!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4Qp
 | 
					 | 
				
			||||||
XC'9b8'&dD!B"CJ!$ra`"D2mE#[mF!!3+G'mJ)!d"D!!#EJ!!!T`#U`&T!@S0!@N
 | 
					 | 
				
			||||||
!!M3!!!+N!U[r'J&V#[mD!!3+CQPXC3d"D`!"E3!!!UF#UJ&X$!&X!!`!"Q0[EA!
 | 
					 | 
				
			||||||
ZD!!#!!!0!@S!!M3!!!+F!U6r'3&Y#[mC!!3+BfC[E!d"E3!"E`!!!U!#SrmB#rm
 | 
					 | 
				
			||||||
B!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'raX!!!)"B3!#!@i"E`d"EJ!#E!!#!V)
 | 
					 | 
				
			||||||
#X[mAraB"raF!!!(r&J!!!J&[!!)"F!&a$3&`!!*b!!!#XJ+p!A)"F`d"FJ!#BJ!
 | 
					 | 
				
			||||||
!!V)#Z3&d!A80!A3!!@m!!!+b!VAr&3[r&3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!
 | 
					 | 
				
			||||||
3Bh*jF(4[4QpXC'9b8'&dD!d"G3!"E3!!!V8#Z!&f$!&f!!X!"6TMEfjQ!!)!!!d
 | 
					 | 
				
			||||||
"F`!"E`!!!!!!!2m8#rm8!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!A%!!J&h!AJ
 | 
					 | 
				
			||||||
0!AF!!dN!!J+q!ZMr%rm5!AN+ra-!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@a
 | 
					 | 
				
			||||||
X!Im5!!!'!AN!!rm4!AS"H`Vr%3!%#QY[Bf`0!AS!!@d!!!,#!XAr%!Vr%!!%#Q&
 | 
					 | 
				
			||||||
XD@%'!AX!!rm2!A`"I3Vr$`!%#QPZFfJ0!A`!!M3!!!,)!Y$r$J&q#[m1!!3+BfC
 | 
					 | 
				
			||||||
[E!d"IJ!"E`!!!X`#crm0#rm0!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J
 | 
					 | 
				
			||||||
!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B"I3!$r``"Irm,#[m-!!3+G'mJ)!d
 | 
					 | 
				
			||||||
"I`!#EJ!!!Y-#iJ'!!B%0!B!!!M3!!!,E!Z,r#J'##[m+!!3+CQPXC3d"JJ!"E3!
 | 
					 | 
				
			||||||
!!Yi#i3'$$!'$!!`!"Q0[EQBZD!!#!!!0!B%!!M3!!!,6!Y[r#3'%#[m*!!3+BfC
 | 
					 | 
				
			||||||
[E!d"K!!"E`!!!YF#f[m)#rm)!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'r`X!!!)
 | 
					 | 
				
			||||||
"H!!#!B8"KJd"K3!#E!!#!ZN#kIm(r`B"r`F!!!(r"J!!!J''!!)"K`')$3'(!!*
 | 
					 | 
				
			||||||
b!!!#k3,d!BN"LJd"L3!#BJ!!!ZN#m!',!B`0!BX!!@m!!!,T!Zcr"3[r"3!N-!!
 | 
					 | 
				
			||||||
3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d"M!!"E3!!!Z`#l`'
 | 
					 | 
				
			||||||
0$!'0!!S!"$TNCA-!!J!!$3'+!!&[!!!!!!!!r`3,r`3!&$!!#(4PEA"`BA4S!!K
 | 
					 | 
				
			||||||
dC@e`8'&dD!)"L!!#!Bi"M`d"MJ!$53!#![8$(rm$r`)"N!!+r`-!'#jMEh*PBh*
 | 
					 | 
				
			||||||
PE#SU+LS!!!!!!!#3!!"ZG@aX!Im#!!!'!C!!!!2r!3'4!C)+r`%!"!TVEf0X$3'
 | 
					 | 
				
			||||||
4!!&Y!!!#q3,mr`!+r`!!"!TKE'PK"J'5!!2qr`'6!C3+r[m!"!TTER0S$3'6!!)
 | 
					 | 
				
			||||||
d!!!#r`-(r[i"P3VqrJ!%#Q0QEf`0!C8!!@m!!!-$!`Eqr3[qr3!d-!!BEh"PER0
 | 
					 | 
				
			||||||
cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!C3
 | 
					 | 
				
			||||||
!!rlm!CEqq`Vqr!!%#R4[)#!0!CB!!Qi!!!-+!aN"P`'B$3'A!!)d!!!$%J-Cr[S
 | 
					 | 
				
			||||||
"Q3VqqJ!%#QCTE'80!CN!!@d!!!-9!aJ"QJ`"QJ!,!!9NCA-ZD!!#!!!0!CJ!!M3
 | 
					 | 
				
			||||||
!!!-+!a,qq3'E#[lj!!3+BfC[E!d"Q`!"E`!!!`i$%Ili#rli!"3`!!KdC@e`F'&
 | 
					 | 
				
			||||||
dD!!)G'9YF&"KG'J'r[X!!!)"M`!#!C`"R3d"R!!#E!!#!b!$)2lhr[B"r[F!!!(
 | 
					 | 
				
			||||||
qpJ!!!J'G!!)"RJ'I$3'H!!*b!!!$)!-V!D!"S3d"S!!#BJ!!!b!$*`'L!D-0!D)
 | 
					 | 
				
			||||||
!!@m!!!-J!b2qp3[qp3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9
 | 
					 | 
				
			||||||
b8'&dD!d"S`!"E3!!!b-$*J'N$!'N!!N!!cTND!!#!!!0!D%!!@m!!!!!!!$qp![
 | 
					 | 
				
			||||||
qp!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J'I!!)"T3'Q$3'P!!0*!!)$,!0@r[2
 | 
					 | 
				
			||||||
qmJ'R#[lc!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!(qmJ!!"J'R!!2qm3'
 | 
					 | 
				
			||||||
S!DN+r[%!"!TVEf0X$3'S!!&Y!!!$-!-cr[!+r[!!"!TKE'PK"J'T!!2ql`'U!DX
 | 
					 | 
				
			||||||
+rZm!"!TTER0S$3'U!!)d!!!$0J-qrZi"V!VqlJ!%#Q0QEf`0!D`!!@m!!!-k!ch
 | 
					 | 
				
			||||||
ql3[ql3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9
 | 
					 | 
				
			||||||
NC8C[E'4PFP"KG'J'!DX!!rlX!Dhqk`Vql!!%#R4[)#!0!Dd!!Qi!!!0"!e!"VJ'
 | 
					 | 
				
			||||||
[$3'Z!!)d!!!$5303rZS"X!VqkJ!%#QCTE'80!E!!!@d!!!0-!dm"X3`"X3!+!!4
 | 
					 | 
				
			||||||
ND#jS!!)!!!d"V`!#0!!!!d%$5IlT!E)+rZN!"!TMCQpX$3'b!!&[!!!$430)rZJ
 | 
					 | 
				
			||||||
,rZJ!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!Eqk`!!!J'Q!!)"X`'d$3'c!!*X!!)
 | 
					 | 
				
			||||||
$9`0ArZIqjJ(qj`!!!IlQ!!!#!E3!!J'e!EB0!E8!!R)!!!0A!f)"Y`'i$3'h!!*
 | 
					 | 
				
			||||||
L!!!$9`0H!EN"ZJd"Z3!"E`!!!eF$@[lP#rlP!#3`!""MFRP`G'pQEfaNCA*`BA4
 | 
					 | 
				
			||||||
S!""MFRP`G'p'EfaNCA*3BA4S$3'k!!&Y!!!$@J0G!EX-!EX!#J!%1Q4cB3!#!!!
 | 
					 | 
				
			||||||
0!EJ!!@m!!!!!!!$qj![qj!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J'f!!)"[!'
 | 
					 | 
				
			||||||
p$3'm!!0*!!)$B`10rZ2qiJ'q#[lM!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9
 | 
					 | 
				
			||||||
XE!(qiJ!!"J'q!!2qi3'r!F!+rZ%!"!TVEf0X$3'r!!&Y!!!$C`0UrZ!+rZ!!"!T
 | 
					 | 
				
			||||||
KE'PK"J(!!!2qh`("!F)+rYm!"!TTER0S$3("!!)d!!!$E30erYi"``VqhJ!%#Q0
 | 
					 | 
				
			||||||
QEf`0!F-!!@m!!!0a!h6qh3[qh3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4
 | 
					 | 
				
			||||||
S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!F)!!rlF!F6qf`Vqh!!%#R4[)#!
 | 
					 | 
				
			||||||
0!F3!!Qi!!!0i!iF"a3('$3(&!!)d!!!$J!1(rYS"a`VqfJ!%#QCTE'80!FF!!@d
 | 
					 | 
				
			||||||
!!!1$!iB"b!`"b!!,!!9NFf%ZD!!#!!!0!FB!!M3!!!0i!i$qf3(*#[lC!!3+BfC
 | 
					 | 
				
			||||||
[E!d"b3!"E`!!!h`$IrlB#rlB!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'rYX!!!)
 | 
					 | 
				
			||||||
"[3!#!FS"b`d"bJ!#E!!#!ii$M[lArYB"rYF!!!(qeJ!!!J(,!!)"c!(0$3(-!!*
 | 
					 | 
				
			||||||
b!!!$MJ1C!Fi"c`d"cJ!#BJ!!!ii$P3(3!G%0!G!!!@m!!!11!j(qe3[qe3!N-!!
 | 
					 | 
				
			||||||
3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d"d3!"E3!!!j%$P!(
 | 
					 | 
				
			||||||
5$!(5!!S!"$TPFR)!!J!!$3(2!!&[!!!!!!!!rY3,rY3!&$!!#(4PEA"`BA4S!!K
 | 
					 | 
				
			||||||
dC@e`8'&dD!)"c3!#!G-"e!d"d`!$53!#!jS$a2l6rY)"e3Vqd`!B,Q0[FQ9MFQ9
 | 
					 | 
				
			||||||
X+LSU+J!!!!!!!*!!!'jeE'`"rY)!!!B"e3!$rY%"eJ(A#[l4!!3+DfpME!d"eJ!
 | 
					 | 
				
			||||||
"E3!!!ji$SIl3#[l3!!3+B@aTB3B"e`!$rXm"f!(C#[l2!!3+D@jcD!d"f!!#0!!
 | 
					 | 
				
			||||||
!!k3$V2l1!GS+rXi!"!TMCQpX$3(D!!&[!!!$U!1VrXd,rXd!0$!!''p`C@jcFfa
 | 
					 | 
				
			||||||
TEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J(C!!2
 | 
					 | 
				
			||||||
qc!(ErXX+rX`!"!TdEb!J$3(E!!*Z!!!$V`1q!G`"h3d"h!!#0!!!!lF$[[l+!Gi
 | 
					 | 
				
			||||||
+rXS!"!TQD@aP$3(H!!&Y!!!$ZJ1p!Gm-!Gm!#`!&CA*b,QJ!!J!!$3(G!!)d!!!
 | 
					 | 
				
			||||||
$V`1hrXN"i!Vqb3!%#Q0QEf`0!H!!!@m!!!1c!lEqb![qb!!8-!!)G'9YF("KG'J
 | 
					 | 
				
			||||||
!#(4PEA"3BA4S"[l,!!!#!G3!!J(K!H)0!H%!!Q`!!J2&!mAqarl'!Il(!!!"rXB
 | 
					 | 
				
			||||||
!!!)"iJ!#!H-"j!d"i`!#FJ!!!m8$d!(P!HB0!H8!!Q)!!!2&!m`"j`(S$3(R!!&
 | 
					 | 
				
			||||||
[!!!$a32)rX8,rX8!*$!!%'0bHA"dEfC[E'4PFR"KG'J!%'0bHA"dEdC[E'4PFP"
 | 
					 | 
				
			||||||
KG'J0!HJ!!@d!!!2)!mX"k3`"k3!+!!3kCAC`!!)!!!d"jJ!"E`!!!!!!!2l%#rl
 | 
					 | 
				
			||||||
%!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!H3!!J(U!HX0!HS!!dN!!J24!r[q`rl
 | 
					 | 
				
			||||||
#!H`+rX-!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Il#!!!'!H`!!rl"!Hd
 | 
					 | 
				
			||||||
"lJVq`3!%#QY[Bf`0!Hd!!@d!!!29!pMq`!Vq`!!%#Q&XD@%'!Hi!!rkr!Hm"m!V
 | 
					 | 
				
			||||||
q[`!%#QPZFfJ0!Hm!!M3!!!2E!q2q[J(a#[kq!!3+BfC[E!d"m3!"E`!!!pm$i[k
 | 
					 | 
				
			||||||
p#rkp!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4
 | 
					 | 
				
			||||||
P4QpXC'9b8'&dD!B"m!!$rV`"m[kl#[km!!3+G'mJ)!d"mJ!#EJ!!!qB$p3(c!I3
 | 
					 | 
				
			||||||
0!I-!!M3!!!2Z!rAqZJ(e#[kk!!3+CQPXC3d"p3!"E3!!!r%$p!(f$!(f!!X!"@9
 | 
					 | 
				
			||||||
fF#jS!!)!!!d"p!!#0!!!!qB$l[kj!IF+rVN!"!TMCQpX$3(h!!&[!!!$kJ2YrVJ
 | 
					 | 
				
			||||||
,rVJ!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!EqZ`!!!J(V!!)"q!(j$3(i!!*X!!)
 | 
					 | 
				
			||||||
$r!2mrVIqYJ(qY`!!!Ikf!!!#!IN!!J(k!IX0!IS!!R)!!!2m"!F"r!(p$3(m!!*
 | 
					 | 
				
			||||||
L!!!$r!3$!Ii"r`d"rJ!"E`!!!r`$rrke#rke!#3`!""MFRP`G'pQEfaNCA*`BA4
 | 
					 | 
				
			||||||
S!""MFRP`G'p'EfaNCA*3BA4S$3(r!!&Y!!!$r`3#!J!-!J!!#`!&1QKYB@-!!J!
 | 
					 | 
				
			||||||
!$3(p!!&[!!!!!!!!rV3,rV3!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)"q`!#!J%
 | 
					 | 
				
			||||||
#!Jd#!3!$53!#"!J%-[kcrV)#!`VqX`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'j
 | 
					 | 
				
			||||||
eE'`"rV)!!!B#!`!$rV%#"!)&#[ka!!3+DfpME!d#"!!"E3!!"!`%$rk`#[k`!!3
 | 
					 | 
				
			||||||
+B@aTB3B#"3!$rUm#"J)(#[k[!!3+D@jcD!d#"J!#0!!!"")%'[kZ!JJ+rUi!"!T
 | 
					 | 
				
			||||||
MCQpX$3))!!&[!!!%&J3CrUd,rUd!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&
 | 
					 | 
				
			||||||
dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J)(!!2qV!)*rUX+rU`!"!TdEb!
 | 
					 | 
				
			||||||
J$3)*!!*Z!!!%(33X!JS##`d##J!#0!!!"#8%,2kU!J`+rUS!"!TQD@aP$3)-!!&
 | 
					 | 
				
			||||||
Y!!!%+!3V!Jd-!Jd!$!!'D'eKBbjS!!)!!!d##`!#0!!!""d%*IkT!Ji+rUN!"!T
 | 
					 | 
				
			||||||
MCQpX$3)1!!&[!!!%)33NrUJ,rUJ!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!EqU`!
 | 
					 | 
				
			||||||
!!J)#!!)#$`)3$3)2!!*X!!)%-`3crUIqTJ(qT`!!!IkQ!!!#!K!!!J)4!K)0!K%
 | 
					 | 
				
			||||||
!!R)!!!3c"$i#%`)8$3)6!!*L!!!%-`3k!K8#&Jd#&3!"E`!!"$-%0[kP#rkP!#3
 | 
					 | 
				
			||||||
`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3)@!!&Y!!!%0J3
 | 
					 | 
				
			||||||
j!KF-!KF!#`!&1QPNC@%!!J!!$3)8!!&[!!!!!!!!rU3,rU3!&$!!#(4PEA"`BA4
 | 
					 | 
				
			||||||
S!!KdC@e`8'&dD!)#%J!#!KJ#'3d#'!!$53!#"$m%DIkMrU)#'JVqS`!B,Q0[FQ9
 | 
					 | 
				
			||||||
MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rU)!!!B#'J!$rU%#'`)F#[kK!!3+DfpME!d
 | 
					 | 
				
			||||||
#'`!"E3!!"%-%4[kJ#[kJ!!3+B@aTB3B#(!!$rTm#(3)H#[kI!!3+D@jcD!d#(3!
 | 
					 | 
				
			||||||
#0!!!"%N%8IkH!Km+rTi!"!TMCQpX$3)I!!&[!!!%6343rTd,rTd!0$!!''p`C@j
 | 
					 | 
				
			||||||
cFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J)
 | 
					 | 
				
			||||||
H!!2qR!)JrTX+rT`!"!TdEb!J$3)J!!*Z!!!%9!4M!L%#)Jd#)3!#0!!!"&`%Brk
 | 
					 | 
				
			||||||
D!L-+rTS!"!TQD@aP$3)M!!&Y!!!%A`4L!L3-!L3!$!!'D@4PB5jS!!)!!!d#)J!
 | 
					 | 
				
			||||||
#0!!!"&3%A2kC!L8+rTN!"!TMCQpX$3)P!!&[!!!%@!4ErTJ,rTJ!&$!!#(4PEA"
 | 
					 | 
				
			||||||
`BA4S!!KdC@e`8'&dD!EqQ`!!!J)C!!)#*J)R$3)Q!!*X!!)%DJ4UrTIqPJ(qP`!
 | 
					 | 
				
			||||||
!!Ik@!!!#!LF!!J)S!LN0!LJ!!R)!!!4U"(8#+J)V$3)U!!*L!!!%DJ4a!L`#,3d
 | 
					 | 
				
			||||||
#,!!"E`!!"'S%EIk9#rk9!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'Efa
 | 
					 | 
				
			||||||
NCA*3BA4S$3)Y!!&Y!!!%E34`!Li-!Li!$!!'1QaSBA0S!!)!!!d#+`!"E`!!!!!
 | 
					 | 
				
			||||||
!!2k8#rk8!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!LN!!J)[!M!0!Lm!!dN!!J4
 | 
					 | 
				
			||||||
f"+$qNrk5!M%+rT-!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Ik5!!!'!M%
 | 
					 | 
				
			||||||
!!rk4!M)#-`VqN3!%#QY[Bf`0!M)!!@d!!!4k"(hqN!!+rT!!!!3+B@aTB3B#-`!
 | 
					 | 
				
			||||||
$rSm#0!)e#[k2!!3+D@jcD!d#0!!#0!!!")!%L2k1!MB+rSi!"!TMCQpX$3)f!!&
 | 
					 | 
				
			||||||
[!!!%K!5(rSd,rSd!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP0
 | 
					 | 
				
			||||||
66%PZBfaeC'9'EfaNCA*3BA4S"J)e!!2qM!)hrSX+rS`!"!TdEb!J$3)h!!*Z!!!
 | 
					 | 
				
			||||||
%L`5D!MJ#13d#1!!#0!!!"*-%Q[k+!MS+rSS!"!TQD@aP$3)k!!&Y!!!%PJ5C!MX
 | 
					 | 
				
			||||||
-!MX!$3!(E'KKFfJZD!!#!!!0!MN!!M3!!!5,"*2qL3)m#[k*!!3+BfC[E!d#2!!
 | 
					 | 
				
			||||||
"E`!!")m%N[k)#rk)!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'rSX!!!)#-!!#!Md
 | 
					 | 
				
			||||||
#2Jd#23!#E!!#"+%%SIk(rSB"rSF!!!(qKJ!!!J)q!!)#2`*!$3)r!!*b!!!%S35
 | 
					 | 
				
			||||||
X!N%#3Jd#33!#BJ!!"+%%U!*$!N30!N-!!@m!!!5K"+6qK3[qK3!N-!!3Bh*jF(4
 | 
					 | 
				
			||||||
[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d#4!!"E3!!"+3%T`*&$!*&!!S
 | 
					 | 
				
			||||||
!"$TYC$)!!J!!$3*#!!&[!!!!!!!!rS3,rS3!&$!!#(4PEA"`BA4S!!KdC@e`8'&
 | 
					 | 
				
			||||||
dD!)#3!!#!NB#4`d#4J!$53!#"+d%erk$rS)#5!VqJ`!B,Q0[FQ9MFQ9X+LSU+J!
 | 
					 | 
				
			||||||
!!!!!!*!!!'jeE'`"rS)!!!B#5!!$rS%#53*+#[k"!!3+DfpME!d#53!"E3!!",%
 | 
					 | 
				
			||||||
%Y2k!#[k!!!3+B@aTB3B#5J!$rRm#5`*-#[jr!!3+D@jcD!d#5`!#0!!!",F%[rj
 | 
					 | 
				
			||||||
q!Nd+rRi!"!TMCQpX$3*0!!&[!!!%Z`5qrRd,rRd!0$!!''p`C@jcFfaTEQ0XG@4
 | 
					 | 
				
			||||||
PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J*-!!2qI!*1rRX
 | 
					 | 
				
			||||||
+rR`!"!TdEb!J$3*1!!*Z!!!%`J64!Nm#8!d#6`!#0!!!"-S%dIjk!P%+rRS!"!T
 | 
					 | 
				
			||||||
QD@aP$3*4!!&Y!!!%c363!P)-!P)!#`!&E@3b,QJ!!J!!$3*3!!)d!!!%`J6+rRN
 | 
					 | 
				
			||||||
#8`VqH3!%#Q0QEf`0!P-!!@m!!!6'"-RqH![qH!!8-!!)G'9YF("KG'J!#(4PEA"
 | 
					 | 
				
			||||||
3BA4S"[jl!!!#!NF!!J*8!P80!P3!!Q`!!J6B"0MqGrjf!Ijh!!!"rRB!!!)#93!
 | 
					 | 
				
			||||||
#!PB#9`d#9J!#FJ!!"0J%i`*B!PN0!PJ!!Q)!!!6B"0m#@J*E$3*D!!&[!!!%f!6
 | 
					 | 
				
			||||||
ErR8,rR8!*$!!%'0bHA"dEfC[E'4PFR"KG'J!%'0bHA"dEdC[E'4PFP"KG'J0!PX
 | 
					 | 
				
			||||||
!!@d!!!6E"0i#A!`#A!!+!!3kE@3e!!)!!!d#@3!"E`!!!!!!!2jd#rjd!"3`!!K
 | 
					 | 
				
			||||||
dC@e`F'&dD!!)G'9YF&"KG'J#!PF!!J*G!Pi0!Pd!!dN!!J6N"3lqFrjb!Pm+rR-
 | 
					 | 
				
			||||||
!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Ijb!!!'!Pm!!rja!Q!#B3VqF3!
 | 
					 | 
				
			||||||
%#QY[Bf`0!Q!!!@d!!!6S"1[qF!VqF!!%#Q&XD@%'!Q%!!rj[!Q)#B`VqE`!%#QP
 | 
					 | 
				
			||||||
ZFfJ0!Q)!!M3!!!6Z"2EqEJ*N#[jZ!!3+BfC[E!d#C!!"E`!!"2)%pIjY#rjY!$3
 | 
					 | 
				
			||||||
`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9
 | 
					 | 
				
			||||||
b8'&dD!B#B`!$rQ`#CIjV#[jX!!3+G'mJ)!d#C3!#EJ!!"2N&#!*Q!QF0!QB!!M3
 | 
					 | 
				
			||||||
!!!8""3MqDJ*S#[jU!!3+CQPXC3d#D!!"E3!!"33&"`*T$!*T!!X!"@eN05jS!!)
 | 
					 | 
				
			||||||
!!!d#C`!#0!!!"2N&!IjT!QS+rQN!"!TMCQpX$3*U!!&[!!!%r38!rQJ,rQJ!&$!
 | 
					 | 
				
			||||||
!#(4PEA"`BA4S!!KdC@e`8'&dD!EqD`!!!J*H!!)#D`*X$3*V!!*X!!)&$`82rQI
 | 
					 | 
				
			||||||
qCJ(qC`!!!IjQ!!!#!Q`!!J*Y!Qi0!Qd!!R)!!!82"4S#E`*`$3*[!!*L!!!&$`8
 | 
					 | 
				
			||||||
@!R%#FJd#F3!"E`!!"3m&%[jP#rjP!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP
 | 
					 | 
				
			||||||
`G'p'EfaNCA*3BA4S$3*b!!&Y!!!&%J89!R--!R-!#`!&1QeNBc)!!J!!$3*`!!&
 | 
					 | 
				
			||||||
[!!!!!!!!rQ3,rQ3!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)#EJ!#!R3#G3d#G!!
 | 
					 | 
				
			||||||
$53!#"4X&4IjMrQ)#GJVqB`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rQ)
 | 
					 | 
				
			||||||
!!!B#GJ!$rQ%#G`*i#[jK!!3+DfpME!d#G`!"E3!!"4m&)[jJ#[jJ!!3+B@aTB3B
 | 
					 | 
				
			||||||
#H!!$rPm#H3*k#[jI!!3+D@jcD!d#H3!#0!!!"58&,IjH!RX+rPi!"!TMCQpX$3*
 | 
					 | 
				
			||||||
l!!&[!!!&+38XrPd,rPd!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"
 | 
					 | 
				
			||||||
PEP066%PZBfaeC'9'EfaNCA*3BA4S"J*k!!2qA!*mrPX+rP`!"!TdEb!J$3*m!!*
 | 
					 | 
				
			||||||
Z!!!&-!8r!Rd#IJd#I3!#0!!!"6J&2rjD!Rm+rPS!"!TQD@aP$3*r!!&Y!!!&1`8
 | 
					 | 
				
			||||||
q!S!-!S!!$!!'E@4M-LjS!!)!!!d#IJ!#0!!!"6!&12jC!S%+rPN!"!TMCQpX$3+
 | 
					 | 
				
			||||||
"!!&[!!!&0!8hrPJ,rPJ!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!Eq@`!!!J*e!!)
 | 
					 | 
				
			||||||
#JJ+$$3+#!!*X!!)&4J9'rPIq9J(q9`!!!Ij@!!!#!S-!!J+%!S80!S3!!R)!!!9
 | 
					 | 
				
			||||||
'"9%#KJ+($3+'!!*L!!!&4J90!SJ#L3d#L!!"E`!!"8B&5Ij9#rj9!#3`!""MFRP
 | 
					 | 
				
			||||||
`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3+*!!&Y!!!&539-!SS-!SS
 | 
					 | 
				
			||||||
!$J!)1QpLDQ9MG(-!!J!!$3+(!!&[!!!!!!!!rP3,rP3!&$!!#(4PEA"`BA4S!!K
 | 
					 | 
				
			||||||
dC@e`8'&dD!)#K3!#!SX#M!d#L`!$53!#"9)&I2j6rP)#M3Vq8`!B,Q0[FQ9MFQ9
 | 
					 | 
				
			||||||
X+LSU+J!!!!!!!*!!!'jeE'`"rP)!!!B#M3!$rP%#MJ+2#[j4!!3+DfpME!d#MJ!
 | 
					 | 
				
			||||||
"E3!!"9B&@Ij3#[j3!!3+B@aTB3B#M`!$rNm#N!!#N3Vq6`!%#QPZFfJ0!T!!!!)
 | 
					 | 
				
			||||||
d!!!&A!9NrNi#NJVq6J!%#Q0QEf`0!T)!!@m!!!9J"@2q63[q63!d-!!BEh"PER0
 | 
					 | 
				
			||||||
cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!T%
 | 
					 | 
				
			||||||
!!rj-!T2q5`Vq6!!%#R4[)#!0!T-!!Qi!!!9R"AB#P!+9$3+8!!)d!!!&E`9frNS
 | 
					 | 
				
			||||||
#PJVq5J!%#QCTE'80!TB!!@d!!!9b"A8#P``#P`!2!!P[BQTPBh4c,QJ!!J!!$3+
 | 
					 | 
				
			||||||
9!!)d!!!&C`9[rNN#Q!Vq53!%#Q0QEf`0!TJ!!@m!!!9V"@lq5![q5!!8-!!)G'9
 | 
					 | 
				
			||||||
YF("KG'J!#(4PEA"3BA4S"[j,!!!#!S`!!J+C!TS0!TN!!Q`!!J9p"Ahq4rj'!Ij
 | 
					 | 
				
			||||||
(!!!"rNB!!!)#QJ!#!TX#R!d#Q`!#FJ!!"Ad&L!+G!Ti0!Td!!Q)!!!9p"B3#R`+
 | 
					 | 
				
			||||||
J$3+I!!&[!!!&I3@!rN8,rN8!*$!!%'0bHA"dEfC[E'4PFR"KG'J!%'0bHA"dEdC
 | 
					 | 
				
			||||||
[E'4PFP"KG'J0!U!!!@d!!!@!"B-#S3`#S3!+!!3kF'9Y!!)!!!d#RJ!"E`!!!!!
 | 
					 | 
				
			||||||
!!2j%#rj%!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!T`!!J+L!U-0!U)!!dN!!J@
 | 
					 | 
				
			||||||
*"E2q3rj#!U3+rN-!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Ij#!!!'!U3
 | 
					 | 
				
			||||||
!!rj"!U8#TJVq33!%#QY[Bf`0!U8!!@d!!!@0"C!!rN!+rN!!"!TKE'PK"J+Q!!2
 | 
					 | 
				
			||||||
q2`+R!UJ+rMm!"!TTER0S$3+R!!)d!!!&N`@ErMi#U3Vq2J!%#Q0QEf`0!UN!!@m
 | 
					 | 
				
			||||||
!!!@A"CVq23[q23!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0
 | 
					 | 
				
			||||||
-5@jME(9NC8C[E'4PFP"KG'J'!UJ!!rim!UVq1`Vq2!!%#R4[)#!0!US!!Qi!!!@
 | 
					 | 
				
			||||||
H"Dd#U`+X$3+V!!)d!!!&TJ@YrMS#V3Vq1J!%#QCTE'80!Ud!!@d!!!@T"D`#VJ`
 | 
					 | 
				
			||||||
#VJ!,!!9`C@dZD!!#!!!0!U`!!M3!!!@H"DEq13+[#[ij!!3+BfC[E!d#V`!"E`!
 | 
					 | 
				
			||||||
!"D)&TIii#rii!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'rMX!!!)#S`!#!V!#X3d
 | 
					 | 
				
			||||||
#X!!$53!#"E3&h[ihrMB#XJVq0`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`
 | 
					 | 
				
			||||||
"rMB!!!B#XJ!$rM8#X`+d#[ie!!3+DfpME!d#X`!"E3!!"EJ&Zrid#[id!!3+B@a
 | 
					 | 
				
			||||||
TB3B#Y!!$rM-#Y3+f#[ic!!3+D@jcD!d#Y3!#0!!!"Ei&a[ib!VF+rM)!"!TMCQp
 | 
					 | 
				
			||||||
X$3+h!!&[!!!&`JA&rM%,rM%!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!
 | 
					 | 
				
			||||||
BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J+f!!2q-!+irLm+rM!!"!TdEb!J$3+
 | 
					 | 
				
			||||||
i!!*Z!!!&b3AB!VN#ZJd#Z3!#0!!!"G%&f2iZ!VX+rLi!"!TQD@aP$3+l!!&Y!!!
 | 
					 | 
				
			||||||
&e!AA!V`-!V`!$!!'F'9Y-LjS!!)!!!d#ZJ!#0!!!"FN&dIiY!Vd+rLd!"!TMCQp
 | 
					 | 
				
			||||||
X$3+p!!&[!!!&c3A3rL`,rL`!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!Eq,`!!!J+
 | 
					 | 
				
			||||||
a!!)#[J+r$3+q!!*X!!)&h`AIrL[q+J(q+`!!!IiU!!!#!Vm!!J,!!X%0!X!!!R)
 | 
					 | 
				
			||||||
!!!AI"HS#`J,$$3,#!!*L!!!&h`AQ!X3#a3d#a!!"E`!!"Gm&i[iT#riT!#3`!""
 | 
					 | 
				
			||||||
MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3,&!!&Y!!!&iJAP!XB
 | 
					 | 
				
			||||||
-!XB!$3!(1R"VBh-a-J!#!!!0!X-!!@m!!!!!!!$q+![q+!!8-!!)G'9YF("KG'J
 | 
					 | 
				
			||||||
!#(4PEA"3BA4S!J,"!!)#a`,)$3,(!!0*!!)&k`B9rLIq*J,*#[iR!"JZBfpbC@0
 | 
					 | 
				
			||||||
bC@`U+LSU!!!!!!!!N!!!ER9XE!(q*J!!"J,*!!2q*3,+!XX+rL8!"!TVEf0X$3,
 | 
					 | 
				
			||||||
+!!&Y!!!&l`AbrL3+rL3!"!TKE'PK"J,,!!2q)`,-!Xd+rL-!"!TTER0S$3,-!!)
 | 
					 | 
				
			||||||
d!!!&p3AprL)#cJVq)J!%#Q0QEf`0!Xi!!@m!!!Aj"Icq)3[q)3!d-!!BEh"PER0
 | 
					 | 
				
			||||||
cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!Xd
 | 
					 | 
				
			||||||
!!riJ!Xrq(`Vq)!!%#R4[)#!0!Xm!!Qi!!!B!"Jm#d!,4$3,3!!)d!!!'#!B2rKi
 | 
					 | 
				
			||||||
#dJVq(J!%#QCTE'80!Y)!!@d!!!B,"Ji#d``#d`!1!!K`Df0c-6)ZD!!#!!!0!Y%
 | 
					 | 
				
			||||||
!!M3!!!B!"JMq(3,8#[iG!!3+BfC[E!d#e!!"E`!!"J3'"riF#riF!"3`!!KdC@e
 | 
					 | 
				
			||||||
`F'&dD!!)G'9YF&"KG'J'rKm!!!)#b!!#!Y8#eJd#e3!#E!!#"KB'&[iErKS"rKX
 | 
					 | 
				
			||||||
!!!(q'J!!!J,@!!)#e`,B$3,A!!*b!!!'&JBK!YN#fJd#f3!#BJ!!"KB'(3,E!Y`
 | 
					 | 
				
			||||||
0!YX!!@m!!!B@"KRq'3[q'3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4Qp
 | 
					 | 
				
			||||||
XC'9b8'&dD!d#h!!"E3!!"KN'(!,G$!,G!!`!"MT`Df0c0`!#!!!0!YS!!@m!!!!
 | 
					 | 
				
			||||||
!!!$q'![q'!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J,B!!)#hJ,I$3,H!!0*!!)
 | 
					 | 
				
			||||||
')JC-rKIq&J,J#[iA!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!(q&J!!"J,
 | 
					 | 
				
			||||||
J!!2q&3,K!Z)+rK8!"!TVEf0X$3,K!!&Y!!!'*JBTrK3+rK3!"!TKE'PK"J,L!!2
 | 
					 | 
				
			||||||
q%`,M!Z3+rK-!"!TTER0S$3,M!!)d!!!',!BdrK)#j3Vq%J!%#Q0QEf`0!Z8!!@m
 | 
					 | 
				
			||||||
!!!B`"M2q%3[q%3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0
 | 
					 | 
				
			||||||
-5@jME(9NC8C[E'4PFP"KG'J'!Z3!!ri3!ZEq$`Vq%!!%#R4[)#!0!ZB!!Qi!!!B
 | 
					 | 
				
			||||||
h"NB#j`,S$3,R!!)d!!!'2`C'rJi#k3Vq$J!%#QCTE'80!ZN!!@d!!!C#"N8#kJ`
 | 
					 | 
				
			||||||
#kJ!0!!G`Df0c0bjS!!)!!!d#k!!#0!!!"MF'2ri0!ZX+rJd!"!TMCQpX$3,V!!&
 | 
					 | 
				
			||||||
[!!!'1`BqrJ`,rJ`!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!Eq$`!!!J,I!!)#l!,
 | 
					 | 
				
			||||||
Y$3,X!!*X!!)'63C0rJ[q#J(q#`!!!Ii+!!!#!Zd!!J,Z!Zm0!Zi!!R)!!!C0"PJ
 | 
					 | 
				
			||||||
#m!,a$3,`!!*L!!!'63C8![)#m`d#mJ!"E`!!"Nd'82i*#ri*!#3`!""MFRP`G'p
 | 
					 | 
				
			||||||
QEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3,c!!&Y!!!'8!C6![3-![3!#`!
 | 
					 | 
				
			||||||
&1R*KEQ3!!J!!$3,a!!&[!!!!!!!!rJJ,rJJ!&$!!#(4PEA"`BA4S!!KdC@e`8'&
 | 
					 | 
				
			||||||
dD!)#l`!#![8#pJd#p3!$53!#"PN'Jri(rJB#p`Vq"`!B,Q0[FQ9MFQ9X+LSU+J!
 | 
					 | 
				
			||||||
!!!!!!*!!!'jeE'`"rJB!!!B#p`!$rJ8#q!,j#[i&!!3+DfpME!d#q!!"E3!!"Pd
 | 
					 | 
				
			||||||
'B2i%#[i%!!3+B@aTB3B#q3!$rJ-#qJ,l#[i$!!3+D@jcD!d#qJ!#0!!!"Q-'Dri
 | 
					 | 
				
			||||||
#![`+rJ)!"!TMCQpX$3,m!!&[!!!'C`CUrJ%,rJ%!0$!!''p`C@jcFfaTEQ0XG@4
 | 
					 | 
				
			||||||
PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J,l!!2q!!,prIm
 | 
					 | 
				
			||||||
+rJ!!"!TdEb!J$3,p!!*Z!!!'EJCp![i#r`d#rJ!#0!!!"RB'IIhq!`!+rIi!"!T
 | 
					 | 
				
			||||||
QD@aP$3-!!!&Y!!!'H3Cm!`%-!`%!$!!'FQ&ZC#jS!!)!!!d#r`!#0!!!"Qi'G[h
 | 
					 | 
				
			||||||
p!`)+rId!"!TMCQpX$3-#!!&[!!!'FJCerI`,rI`!&$!!#(4PEA"`BA4S!!KdC@e
 | 
					 | 
				
			||||||
`8'&dD!Epr`!!!J,f!!)$!`-%$3-$!!*X!!)'K!D%rI[pqJ(pq`!!!Ihk!!!#!`3
 | 
					 | 
				
			||||||
!!J-&!`B0!`8!!R)!!!D%"Sm$"`-)$3-(!!*L!!!'K!D,!`N$#Jd$#3!"E`!!"S3
 | 
					 | 
				
			||||||
'Krhj#rhj!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3-
 | 
					 | 
				
			||||||
+!!&Y!!!'K`D+!`X-!`X!#J!%1R*M-J!#!!!0!`J!!@m!!!!!!!$pq![pq!!8-!!
 | 
					 | 
				
			||||||
)G'9YF("KG'J!#(4PEA"3BA4S!J-'!!)$$!-0$3--!!0*!!)'N!!'Z[hhrIB$$JV
 | 
					 | 
				
			||||||
pp`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rIB!!!B$$J!$rI8$$`-3#[h
 | 
					 | 
				
			||||||
e!!3+DfpME!d$$`!"E3!!"T3'Prhd#[hd!!3+B@aTB3B$%!!$rI-$%3-5#[hc!!3
 | 
					 | 
				
			||||||
+D@jcD!d$%3!#0!!!"TS'S[hb!a-+rI)!"!TMCQpX$3-6!!&[!!!'RJDKrI%,rI%
 | 
					 | 
				
			||||||
!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'Efa
 | 
					 | 
				
			||||||
NCA*3BA4S"J-5!!2pm!-8rHm+rI!!"!TdEb!J$3-8!!*Z!!!'T3Dd!a8$&Jd$&3!
 | 
					 | 
				
			||||||
#0!!!"Ud'Y2hZ!aF+rHi!"!TQD@aP$3-A!!&Y!!!'X!Dc!aJ-!aJ!#`!&FQ-b,QJ
 | 
					 | 
				
			||||||
!!J!!$3-@!!)d!!!'T3DYrHd$'3Vpl3!%#Q0QEf`0!aN!!@m!!!DT"Ucpl![pl!!
 | 
					 | 
				
			||||||
8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[h[!!!#!`d!!J-D!aX0!aS!!Q`!!JDl"V[
 | 
					 | 
				
			||||||
pkrhU!IhV!!!"rHS!!!)$'`!#!a`$(3d$(!!#FJ!!"VX'aJ-H!am0!ai!!Q)!!!D
 | 
					 | 
				
			||||||
l"X)$)!-K$3-J!!&[!!!'Z`DqrHN,rHN!*$!!%'0bHA"dEfC[E'4PFR"KG'J!%'0
 | 
					 | 
				
			||||||
bHA"dEdC[E'4PFP"KG'J0!b%!!@d!!!Dq"X%$)J`$)J!+!!3kFQ-d!!)!!!d$(`!
 | 
					 | 
				
			||||||
"E`!!!!!!!2hS#rhS!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!ad!!J-M!b30!b-
 | 
					 | 
				
			||||||
!!dN!!JE("[(pjrhQ!b8+rHF!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"ZG@aX!Ih
 | 
					 | 
				
			||||||
Q!!!'!b8!!rhP!bB$*`Vpj3!%#QY[Bf`0!bB!!@d!!!E,"Xlpj!Vpj!!%#Q&XD@%
 | 
					 | 
				
			||||||
'!bF!!rhM!bJ$+3Vpi`!%#QPZFfJ0!bJ!!M3!!!E4"YRpiJ-U#[hL!!3+BfC[E!d
 | 
					 | 
				
			||||||
$+J!"E`!!"Y8'f2hK#rhK!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p
 | 
					 | 
				
			||||||
`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B$+3!$rH!$+rhI#[hJ!!3+G'mJ)!d$+`!
 | 
					 | 
				
			||||||
#EJ!!"Y`'k`-X!bd0!b`!!M3!!!EN"Z[phJ-Z#[hH!!3+CQPXC3d$,J!"E3!!"ZF
 | 
					 | 
				
			||||||
'kJ-[$!-[!!X!"A*M0#jS!!)!!!d$,3!#0!!!"Y`'j2hG!c!+rGd!"!TMCQpX$3-
 | 
					 | 
				
			||||||
`!!&[!!!'i!EMrG`,rG`!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!Eph`!!!J-N!!)
 | 
					 | 
				
			||||||
$-3-b$3-a!!*X!!)'mJEbrG[pfJ(pf`!!!IhD!!!#!c)!!J-c!c30!c-!!R)!!!E
 | 
					 | 
				
			||||||
b"[d$03-f$3-e!!*L!!!'mJEj!cF$1!d$0`!"E`!!"[)'pIhC#rhC!#3`!""MFRP
 | 
					 | 
				
			||||||
`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$3-i!!&Y!!!'p3Ei!cN-!cN
 | 
					 | 
				
			||||||
!#J!%1R*M03!#!!!0!cB!!@m!!!!!!!$pf![pf!!8-!!)G'9YF("KG'J!#(4PEA"
 | 
					 | 
				
			||||||
3BA4S!J-d!!)$1J-l$3-k!!0*!!)'rJFSrGIpeJ-m#[hA!"JZBfpbC@0bC@`U+LS
 | 
					 | 
				
			||||||
U!!!!!!!!N!!!ER9XE!(peJ!!"J-m!!2pe3-p!ci+rG8!"!TVEf0X$3-p!!&Y!!!
 | 
					 | 
				
			||||||
(!JF&rG3+rG3!"!TKE'PK"J-q!!2pd`-r!d!+rG-!"!TTER0S$3-r!!)d!!!(#!F
 | 
					 | 
				
			||||||
3rG)$33VpdJ!%#Q0QEf`0!d%!!@m!!!F-"`rpd3[pd3!d-!!BEh"PER0cE'PZBfa
 | 
					 | 
				
			||||||
eC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!d!!!rh3!d,
 | 
					 | 
				
			||||||
pc`Vpd!!%#R4[)#!0!d)!!Qi!!!F6"b)$3`0%$30$!!)d!!!('`FLrFi$43VpcJ!
 | 
					 | 
				
			||||||
%#QCTE'80!d8!!@d!!!FH"b%$4J`$4J!,!!9bBc8ZD!!#!!!0!d3!!M3!!!F6"a[
 | 
					 | 
				
			||||||
pc30(#[h0!!3+BfC[E!d$4`!"E`!!"aF('[h-#rh-!"3`!!KdC@e`F'&dD!!)G'9
 | 
					 | 
				
			||||||
YF&"KG'J'rFm!!!)$1`!#!dJ$53d$5!!#E!!#"bN(+Ih,rFS"rFX!!!(pbJ!!!J0
 | 
					 | 
				
			||||||
*!!)$5J0,$30+!!*b!!!(+3Fd!d`$63d$6!!#BJ!!"bN(-!01!dm0!di!!@m!!!F
 | 
					 | 
				
			||||||
T"bcpb3[pb3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d
 | 
					 | 
				
			||||||
$6`!"E3!!"b`(,`03$!03!!d!"cTbDA"PE@3!!J!!$300!!&[!!!!!!!!rFJ,rFJ
 | 
					 | 
				
			||||||
!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)$5`!#!e%$8Jd$83!$53!#"c8(Arh(rFB
 | 
					 | 
				
			||||||
$8`Vpa`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rFB!!!B$8`!$rF8$9!0
 | 
					 | 
				
			||||||
9#[h&!!3+DfpME!d$9!!"E3!!"cN(22h%#[h%!!3+B@aTB3B$93!$rF-$9J0A#[h
 | 
					 | 
				
			||||||
$!!3+D@jcD!d$9J!#0!!!"cm(4rh#!eJ+rF)!"!TMCQpX$30B!!&[!!!(3`G'rF%
 | 
					 | 
				
			||||||
,rF%!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9
 | 
					 | 
				
			||||||
'EfaNCA*3BA4S"J0A!!2p`!0CrEm+rF!!"!TdEb!J$30C!!*Z!!!(5JGC!eS$@`d
 | 
					 | 
				
			||||||
$@J!#0!!!"e)(@Ifq!e`+rEi!"!TQD@aP$30F!!&Y!!!(93GB!ed-!ed!$J!)FQP
 | 
					 | 
				
			||||||
`C@eN,QJ!!J!!$30E!!)d!!!(5JG5rEd$AJVp[3!%#Q0QEf`0!ei!!@m!!!G1"e(
 | 
					 | 
				
			||||||
p[![p[!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[fr!!!#!e)!!J0I!f!0!em!!Q`
 | 
					 | 
				
			||||||
!!JGJ"f$pZrfk!Ifl!!!"rES!!!)$B!!#!f%$BJd$B3!#FJ!!"f!(D`0M!f30!f-
 | 
					 | 
				
			||||||
!!Q)!!!GJ"fF$C30Q$30P!!&[!!!(B!GMrEN,rEN!*$!!%'0bHA"dEfC[E'4PFR"
 | 
					 | 
				
			||||||
KG'J!%'0bHA"dEdC[E'4PFP"KG'J0!fB!!@d!!!GM"fB$C``$C`!+!!3kFR0K!!)
 | 
					 | 
				
			||||||
!!!d$C!!"E`!!!!!!!2fi#rfi!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J#!f)!!J0
 | 
					 | 
				
			||||||
S!fN0!fJ!!dN!!JGX"jEpYrff!fS+rEF!'#jMEh*PBh*PE#SU+LS!!!!!!!#3!!"
 | 
					 | 
				
			||||||
ZG@aX!Iff!!!'!fS!!rfe!fX$E!VpY3!%#QY[Bf`0!fX!!@d!!!G`"h2pY!VpY!!
 | 
					 | 
				
			||||||
%#Q&XD@%'!f`!!rfc!fd$EJVpX`!%#QPZFfJ0!fd!!M3!!!Gf"hlpXJ0[#[fb!!3
 | 
					 | 
				
			||||||
+BfC[E!d$E`!"E`!!"hS(IIfa#rfa!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4PFR"
 | 
					 | 
				
			||||||
KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B$EJ!$rE!$F2f[#[f`!!3+G'm
 | 
					 | 
				
			||||||
J)!d$F!!#EJ!!"i%(N!!$F30b$30a!!)d!!!(L3H3!2fZ!h-+rDi!"!TQD@aP$30
 | 
					 | 
				
			||||||
c!!&Y!!!(M!H2!h3-!h3!#`!&FR0K,QJ!!J!!$30b!!)d!!!(J3H*rDd$G3VpV3!
 | 
					 | 
				
			||||||
%#Q0QEf`0!h8!!@m!!!H&"iMpV![pV!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[f
 | 
					 | 
				
			||||||
[!!!#!fN!!J0f!hF0!hB!!Q`!!JHA"jIpUrfU!IfV!!!"rDS!!!)$G`!#!hJ$H3d
 | 
					 | 
				
			||||||
$H!!#FJ!!"jF(SJ0k!hX0!hS!!Q)!!!HA"ji$I!0p$30m!!&[!!!(P`HDrDN,rDN
 | 
					 | 
				
			||||||
!*$!!%'0bHA"dEfC[E'4PFR"KG'J!%'0bHA"dEdC[E'4PFP"KG'J0!hd!!@d!!!H
 | 
					 | 
				
			||||||
D"jd$IJ`$IJ!-!!BkFh4KBfX!!J!!$30l!!&[!!!!!!!!rDJ,rDJ!&$!!#(4PEA"
 | 
					 | 
				
			||||||
`BA4S!!KdC@e`8'&dD!)$H3!#!hm$J!d$I`!$53!#"k-(cIfRrDB$J3VpT`!B,Q0
 | 
					 | 
				
			||||||
[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rDB!!!B$J3!$rD8$JJ1$#[fP!!3+Dfp
 | 
					 | 
				
			||||||
ME!d$JJ!"E3!!"kF(U[fN#[fN!!3+B@aTB3B$J`!$rD-$K!1&#[fM!!3+D@jcD!d
 | 
					 | 
				
			||||||
$K!!#0!!!"kd(YIfL!iB+rD)!"!TMCQpX$31'!!&[!!!(X3HdrD%,rD%!0$!!''p
 | 
					 | 
				
			||||||
`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4
 | 
					 | 
				
			||||||
S"J1&!!2pS!1(rCm+rD!!"!TdEb!J$31(!!*Z!!!(Z!I(!iJ$L3d$L!!#0!!!"m!
 | 
					 | 
				
			||||||
(arfH!iS+rCi!"!TQD@aP$31+!!&Y!!!(``I'!iX-!iX!$3!(Fh4KBfXZD!!#!!!
 | 
					 | 
				
			||||||
0!iN!!M3!!!Hi"m$pR31-#[fG!!3+BfC[E!d$M!!"E`!!"l`([rfF#rfF!"3`!!K
 | 
					 | 
				
			||||||
dC@e`F'&dD!!)G'9YF&"KG'J'rCm!!!)$J!!#!id$MJd$M3!$53!#"mi(q2fErCS
 | 
					 | 
				
			||||||
$M`VpQ`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rCS!!!B$M`!$rCN$N!!
 | 
					 | 
				
			||||||
$N3VpQ3!%#QY[Bf`0!j!!!!&Y!!!(dJI9rCJ+rCJ!"!TKE'PK"J14!!2pP`15!j-
 | 
					 | 
				
			||||||
+rCF!"!TTER0S$315!!)d!!!(f!IJrCB$P!VpPJ!%#Q0QEf`0!j3!!@m!!!IF"pr
 | 
					 | 
				
			||||||
pP3[pP3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9
 | 
					 | 
				
			||||||
NC8C[E'4PFP"KG'J'!j-!!rf8!jApN`VpP!!%#R4[)#!0!j8!!Qi!!!IM"r)$PJ1
 | 
					 | 
				
			||||||
A$31@!!)d!!!(k`IbrC)$Q!VpNJ!%#QCTE'80!jJ!!@d!!!IZ"r%$Q3`$Q3!4!!Y
 | 
					 | 
				
			||||||
cB@CPFh4KBfXZD!!#!!!0!jF!!M3!!!IM"q[pN31D#[f4!!3+BfC[E!d$QJ!"E`!
 | 
					 | 
				
			||||||
!"qF(k[f3!![pN!!!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!EpN`!!!J11!!)$Q`1
 | 
					 | 
				
			||||||
F$31E!!*X!!)(q3IjrBrpMJ(pM`!!!If1!!!#!j`!!J1G!ji0!jd!!R)!!!Ij#!3
 | 
					 | 
				
			||||||
$R`1J$31I!!*L!!!(q3J!!k%$SJd$S3!"E`!!"rN(r2f0#rf0!#3`!""MFRP`G'p
 | 
					 | 
				
			||||||
QEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S$31L!!&Y!!!(r!Ir!k--!k-!#J!
 | 
					 | 
				
			||||||
%1R0SB3!#!!!0!k!!!@m!!!!!!!$pM![pM!!8-!!)G'9YF("KG'J!#(4PEA"3BA4
 | 
					 | 
				
			||||||
S!J1H!!)$T!1P$31N!!0*!!))"3J[rB[pLJ1Q#[f,!"JZBfpbC@0bC@`U+LSU!!!
 | 
					 | 
				
			||||||
!!!!!N!!!ER9XE!(pLJ!!"J1Q!!2pL31R!kJ+rBN!"!TVEf0X$31R!!&Y!!!)#3J
 | 
					 | 
				
			||||||
-rBJ+rBJ!"!TKE'PK"J1S!!2pK`1T!kS+rBF!"!TTER0S$31T!!)d!!!)$`JArBB
 | 
					 | 
				
			||||||
$U`VpKJ!%#Q0QEf`0!kX!!@m!!!J6#"EpK3[pK3!d-!!BEh"PER0cE'PZBfaeC'9
 | 
					 | 
				
			||||||
QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!kS!!rf%!kcpJ`V
 | 
					 | 
				
			||||||
pK!!%#R4[)#!0!k`!!Qi!!!JD##N$V31Z$31Y!!)d!!!))JJTrB)$V`VpJJ!%#QC
 | 
					 | 
				
			||||||
TE'80!km!!@d!!!JP##J$X!`$X!!,!!9cD'%ZD!!#!!!0!ki!!M3!!!JD##,pJ31
 | 
					 | 
				
			||||||
a#[f"!!3+BfC[E!d$X3!"E`!!#"i))If!#rf!!"3`!!KdC@e`F'&dD!!)G'9YF&"
 | 
					 | 
				
			||||||
KG'J'rB-!!!)$T3!#!l)$X`d$XJ!#E!!##$!)-2errAi"rAm!!!(pIJ!!!J1c!!)
 | 
					 | 
				
			||||||
$Y!1e$31d!!*b!!!)-!Jl!lB$Y`d$YJ!#BJ!!#$!)0`1i!lN0!lJ!!@m!!!J`#$2
 | 
					 | 
				
			||||||
pI3[pI3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD!d$Z3!
 | 
					 | 
				
			||||||
"E3!!#$-)0J1k$!1k!!d!"cTdH(4IC')!!J!!$31h!!&[!!!!!!!!rA`,rA`!&$!
 | 
					 | 
				
			||||||
!#(4PEA"`BA4S!!KdC@e`8'&dD!)$Y3!#!lX$[!d$Z`!$53!##$`)C[elrAS$[3V
 | 
					 | 
				
			||||||
pH`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"rAS!!!B$[3!$rAN$[J1r#[e
 | 
					 | 
				
			||||||
j!!3+DfpME!d$[J!"E3!!#%!)3rei#[ei!!3+B@aTB3B$[`!$rAF$`!2"#[eh!!3
 | 
					 | 
				
			||||||
+D@jcD!d$`!!#0!!!#%B)6[ef!m)+rAB!"!TMCQpX$32#!!&[!!!)5JK0rA8,rA8
 | 
					 | 
				
			||||||
!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'Efa
 | 
					 | 
				
			||||||
NCA*3BA4S"J2"!!2pG!2$rA-+rA3!"!TdEb!J$32$!!*Z!!!)83KJ!m3$a3d$a!!
 | 
					 | 
				
			||||||
#0!!!#&N)B2eb!mB+rA)!"!TQD@aP$32'!!&Y!!!)A!KI!mF-!mF!$J!)G(KdAf4
 | 
					 | 
				
			||||||
L,QJ!!J!!$32&!!)d!!!)83KCrA%$b!VpF3!%#Q0QEf`0!mJ!!@m!!!K9#&MpF![
 | 
					 | 
				
			||||||
pF!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[ec!!!#!l`!!J2*!mS0!mN!!Q`!!JK
 | 
					 | 
				
			||||||
R#'IpEreZ!Ie[!!!"r@i!!!)$bJ!#!mX$c!d$b`!#FJ!!#'F)FJ20!mi0!md!!Q)
 | 
					 | 
				
			||||||
!!!KR#'i$c`23$322!!&[!!!)C`KUr@d,r@d!*$!!%'0bHA"dEfC[E'4PFR"KG'J
 | 
					 | 
				
			||||||
!%'0bHA"dEdC[E'4PFP"KG'J0!p!!!@d!!!KU#'d$d3`$d3!,!!8kH$8`13!#!!!
 | 
					 | 
				
			||||||
0!mi!!@m!!!!!!!$pE![pE!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!J2-!!)$dJ2
 | 
					 | 
				
			||||||
6$325!!0*!!))F`LGr@[pDJ28#[eV!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9
 | 
					 | 
				
			||||||
XE!(pDJ!!"J28!!2pD329!pB+r@N!"!TVEf0X$329!!&Y!!!)G`Kkr@J+r@J!"!T
 | 
					 | 
				
			||||||
KE'PK"J2@!!2pC`2A!pJ+r@F!"!TTER0S$32A!!)d!!!)I3L&r@B$f3VpCJ!%#Q0
 | 
					 | 
				
			||||||
QEf`0!pN!!@m!!!L"#)6pC3[pC3!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4
 | 
					 | 
				
			||||||
S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'!pJ!!reN!pVpB`VpC!!%#R4[)#!
 | 
					 | 
				
			||||||
0!pS!!Qi!!!L)#*F$f`2F$32E!!)d!!!)N!!)PreL!pd+r@)!"!TQD@aP$32G!!&
 | 
					 | 
				
			||||||
Y!!!)N`L@!pi-!pi!$!!'H$8`15jS!!)!!!d$h!!#0!!!#)J)N!$pB32I#[eK!!3
 | 
					 | 
				
			||||||
+BfC[E!d$h`!"E`!!#)`)MreJ#reJ!"3`!!KdC@e`F'&dD!!)G'9YF&"KG'J'r@-
 | 
					 | 
				
			||||||
!!!)$d`!#!q!$i3d$i!!$53!##*i)b2eIr9i$iJVpA`!B,Q0[FQ9MFQ9X+LSU+J!
 | 
					 | 
				
			||||||
!!!!!!*!!!'jeE'`"r9i!!!B$iJ!$r9d$i`2N#[eG!!3+DfpME!d$i`!"E3!!#+)
 | 
					 | 
				
			||||||
)TIeF#[eF!!3+B@aTB3B$j!!$r9X$j32Q#[eE!!3+D@jcD!d$j3!#0!!!#+J)X2e
 | 
					 | 
				
			||||||
D!qF+r9S!"!TMCQpX$32R!!&[!!!)V!L[r9N,r9N!0$!!''p`C@jcFfaTEQ0XG@4
 | 
					 | 
				
			||||||
PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J2Q!!2p@!2Sr9F
 | 
					 | 
				
			||||||
+r9J!"!TdEb!J$32S!!*Z!!!)X`M#!qN$kJd$k3!#0!!!#,X)`[e@!qX+r9B!"!T
 | 
					 | 
				
			||||||
QD@aP$32V!!&Y!!!)[JM"!q`-!q`!%!!+H$8`19pfCRNZD!!#!!!0!qS!!M3!!!L
 | 
					 | 
				
			||||||
c#,[p932Y#[e9!!3+BfC[E!d$l3!"E`!!#,F)Z[e8#re8!"3`!!KdC@e`F'&dD!!
 | 
					 | 
				
			||||||
)G'9YF&"KG'J'r9F!!!)$i3!#!qi$l`d$lJ!#E!!##-N)bIe6r9)"r9-!!!(p8J!
 | 
					 | 
				
			||||||
!!J2[!!)$m!2a$32`!!*b!!!)b3M8!r)$m`d$mJ!#BJ!!#-N)d!2d!r80!r3!!@m
 | 
					 | 
				
			||||||
!!!M*#-cp83[p83!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&
 | 
					 | 
				
			||||||
dD!d$p3!"E3!!#-`)c`2f$!2f!!d!"cTi06!jGM-!!J!!$32c!!&[!!!!!!!!r9!
 | 
					 | 
				
			||||||
,r9!!&$!!#(4PEA"`BA4S!!KdC@e`8'&dD!)$m3!#!rF$q!d$p`!$53!##08)rre
 | 
					 | 
				
			||||||
2r8i$q3Vp6`!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"r8i!!!B$q3!$r8d
 | 
					 | 
				
			||||||
$qJ2l#[e0!!3+DfpME!d$qJ!"E3!!#0N)h2e-#[e-!!3+B@aTB3B$q`!$r8X$r!2
 | 
					 | 
				
			||||||
p#[e,!!3+D@jcD!d$r!!#0!!!#0m)jre+!ri+r8S!"!TMCQpX$32q!!&[!!!)i`M
 | 
					 | 
				
			||||||
Qr8N,r8N!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfa
 | 
					 | 
				
			||||||
eC'9'EfaNCA*3BA4S"J2p!!2p5!2rr8F+r8J!"!TdEb!J$32r!!*Z!!!)kJMj"!!
 | 
					 | 
				
			||||||
%!3d%!!!#0!!!#2))qIe'"!)+r8B!"!TQD@aP$33#!!&Y!!!)p3Mi"!--"!-!$J!
 | 
					 | 
				
			||||||
)H$8`1ABc,QJ!!J!!$33"!!)d!!!)kJMbr88%"!Vp43!%#Q0QEf`0"!3!!@m!!!M
 | 
					 | 
				
			||||||
Z#2(p4![p4!!8-!!)G'9YF("KG'J!#(4PEA"3BA4S"[e(!!!#!rJ!!J3&"!B0"!8
 | 
					 | 
				
			||||||
!!Q`!!JN!#3$p3re#!Ie$!!!"r8)!!!)%"J!#"!F%#!d%"`!$53!##3!*+[e"r8!
 | 
					 | 
				
			||||||
%#3Vp33!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"r8!!!!B%#3!$r6m%#J3
 | 
					 | 
				
			||||||
,#[dr!!3+DfpME!d%#J!"E3!!#33*"rdq#[dq!!3+B@aTB3B%#`!$r6d%$!30#[d
 | 
					 | 
				
			||||||
p!!3+D@jcD!d%$!!#0!!!#3S*%[dm"!i+r6`!"!TMCQpX$331!!&[!!!*$JN4r6X
 | 
					 | 
				
			||||||
,r6X!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9
 | 
					 | 
				
			||||||
'EfaNCA*3BA4S"J30!!2p1J32r6N+r6S!"!TdEb!J$332!!*Z!!!*&3NN""!%%3d
 | 
					 | 
				
			||||||
%%!!#0!!!#4d**2di"")+r6J!"!TQD@aP$335!!&Y!!!*)!NM""--""-!#`!&Fh0
 | 
					 | 
				
			||||||
X,QJ!!J!!$334!!)d!!!*&3NGr6F%&!Vp0`!%#Q0QEf`0""3!!@m!!!NC#4cp0J[
 | 
					 | 
				
			||||||
p0J!H-!!0Fh0XCQpXC'9bF'&dD!!0Fh0X4QpXC'9b8'&dD!Ep13!!!J3)!!)%&33
 | 
					 | 
				
			||||||
@$339!!0*!!)*+`P9r6Ap0!3A#[de!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9
 | 
					 | 
				
			||||||
XE!(p0!!!"J3A!!2p-`3B""N+r6-!"!TVEf0X$33B!!&Y!!!*,`Nbr6)+r6)!"!T
 | 
					 | 
				
			||||||
KE'PK"J3C!!2p-33D""X+r6%!"!TTER0S$33D!!)d!!!*03Npr6!%(!Vp-!!%#Q0
 | 
					 | 
				
			||||||
QEf`0""`!!@m!!!Nj#6cp,`[p,`!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4
 | 
					 | 
				
			||||||
S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'""X!!rdZ""hp,3Vp,J!%#R4[)#!
 | 
					 | 
				
			||||||
0""d!!Qi!!!P!#8m%(J3I$33H!!)d!!!*5!P2r5`%)!Vp,!!%#QCTE'80"#!!!@d
 | 
					 | 
				
			||||||
!!!P,#8i%)3`%)3!-!!CcFf`b,QJ!!J!!$33I!!)d!!!*3!P)r5X%)JVp+`!%#Q0
 | 
					 | 
				
			||||||
QEf`0"#)!!@m!!!P%#8Ip+J[p+J!H-!!0Fh0XCQpXC'9bF'&dD!!0Fh0X4QpXC'9
 | 
					 | 
				
			||||||
b8'&dD!Ep,3!!!J3@!!)%)`3N$33M!!0*!!)*9JQ!r5Rp+!3P#[dT!"JZBfpbC@0
 | 
					 | 
				
			||||||
bC@`U+LSU!!!!!!!!N!!!ER9XE!(p+!!!"J3P!!2p*`3Q"#F+r5F!"!TVEf0X$33
 | 
					 | 
				
			||||||
Q!!&Y!!!*@JPGr5B+r5B!"!TKE'PK"J3R!!2p*33S"#N+r58!"!TTER0S$33S!!)
 | 
					 | 
				
			||||||
d!!!*B!PSr53%+JVp*!!%#Q0QEf`0"#S!!@m!!!PN#@Ip)`[p)`!d-!!BEh"PER0
 | 
					 | 
				
			||||||
cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'"#N
 | 
					 | 
				
			||||||
!!rdL"#[p)3Vp)J!%#R4[)#!0"#X!!Qi!!!PV#AS%,!3Y$33X!!)d!!!*F`Pkr5!
 | 
					 | 
				
			||||||
%,JVp)!!%#QCTE'80"#i!!@d!!!Pf#AN%,``%,`!0!!GcFf`b-bjS!!)!!!d%,3!
 | 
					 | 
				
			||||||
#0!!!#@X*FrdI"$!+r4m!"!TMCQpX$33`!!&[!!!*E`Pbr4i,r4i!(M!!$A0cE'C
 | 
					 | 
				
			||||||
[E'4PFR"KG'J!$A0cE%C[E'4PFP"KG'J'r5%!!!)%*!!#"$%%-Jd%-3!$53!##B%
 | 
					 | 
				
			||||||
*UrdGr4`%-`Vp(3!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"r4`!!!B%-`!
 | 
					 | 
				
			||||||
$r4X%0!3e#[dE!!3+DfpME!d%0!!"E3!!#B8*L2dD#[dD!!3+B@aTB3B%03!$r4N
 | 
					 | 
				
			||||||
%0J3h#[dC!!3+D@jcD!d%0J!#0!!!#BX*NrdB"$J+r4J!"!TMCQpX$33i!!&[!!!
 | 
					 | 
				
			||||||
*M`Q5r4F,r4F!0$!!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%P
 | 
					 | 
				
			||||||
ZBfaeC'9'EfaNCA*3BA4S"J3h!!2p&J3jr48+r4B!"!TdEb!J$33j!!*Z!!!*PJQ
 | 
					 | 
				
			||||||
P"$S%1`d%1J!#0!!!#Ci*TId8"$`+r43!"!TQD@aP$33m!!&Y!!!*S3QN"$d-"$d
 | 
					 | 
				
			||||||
!$!!'Fh0X-bjS!!)!!!d%1`!#0!!!#CB*R[d6"$i+r4-!"!TMCQpX$33q!!&[!!!
 | 
					 | 
				
			||||||
*QJQGr4),r4)!(M!!$A0cE'C[E'4PFR"KG'J!$A0cE%C[E'4PFP"KG'J'r48!!!)
 | 
					 | 
				
			||||||
%-J!#"$m%3!d%2`!$53!##D`*e[d4r4!%33Vp%3!B,Q0[FQ9MFQ9X+LSU+J!!!!!
 | 
					 | 
				
			||||||
!!*!!!'jeE'`"r4!!!!B%33!$r3m%3J4$#[d2!!3+DfpME!d%3J!"E3!!#E!*Xrd
 | 
					 | 
				
			||||||
1#[d1!!3+B@aTB3B%3`!$r3d%4!4&#[d0!!3+D@jcD!d%4!!#0!!!#EB*[[d-"%B
 | 
					 | 
				
			||||||
+r3`!"!TMCQpX$34'!!&[!!!*ZJQpr3X,r3X!0$!!''p`C@jcFfaTEQ0XG@4PCQp
 | 
					 | 
				
			||||||
XC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*3BA4S"J4&!!2p#J4(r3N+r3S
 | 
					 | 
				
			||||||
!"!TdEb!J$34(!!*Z!!!*`3R3"%J%53d%5!!#0!!!#FN*d2d)"%S+r3J!"!TQD@a
 | 
					 | 
				
			||||||
P$34+!!&Y!!!*c!R2"%X-"%X!$!!'G'ac-5jS!!)!!!d%53!#0!!!#F%*bId("%`
 | 
					 | 
				
			||||||
+r3F!"!TMCQpX$34-!!&[!!!*a3R)r3B,r3B!(M!!$A0cE'C[E'4PFR"KG'J!$A0
 | 
					 | 
				
			||||||
cE%C[E'4PFP"KG'J'r3N!!!)%3!!#"%d%6Jd%63!#E!!##GF*erd&r33"r38!!!(
 | 
					 | 
				
			||||||
p"!!!!J41!!)%6`43$342!!0*!!)*e`S"r32p!J44#[d$!"JZBfpbC@0bC@`U+LS
 | 
					 | 
				
			||||||
U!!!!!!!!N!!!ER9XE!(p!J!!"J44!!2p!345"&-+r3%!"!TVEf0X$345!!&Y!!!
 | 
					 | 
				
			||||||
*f`RHr3!+r3!!"!TKE'PK"J46!!2mr`48"&8+r2m!"!TTER0S$348!!)d!!!*i3R
 | 
					 | 
				
			||||||
Tr2i%9JVmrJ!%#Q0QEf`0"&B!!@m!!!RP#HMmr3[mr3!d-!!BEh"PER0cE'PZBfa
 | 
					 | 
				
			||||||
eC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9NC8C[E'4PFP"KG'J'"&8!!rcm"&I
 | 
					 | 
				
			||||||
mq`Vmr!!%#R4[)#!0"&F!!Qi!!!RX#IX%@!4C$34B!!)d!!!*p!Rlr2S%@JVmqJ!
 | 
					 | 
				
			||||||
%#QCTE'80"&S!!@d!!!Rh#IS%@``%@`!1!!KMFRP`G'mZD!!#!!!0"&N!!M3!!!R
 | 
					 | 
				
			||||||
X#I6mq34F#[cj!!3+BfC[E!d%A!!"E`!!#I!*mrci#rci!#3`!""MFRP`G'pQEfa
 | 
					 | 
				
			||||||
NCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S"[cl!!!#"&!!!J4G"&i0"&d!!Q`!!JS
 | 
					 | 
				
			||||||
##J,mprcf!Ich!!!"r2B!!!)%AJ!#"&m%B!d%A`!$53!##J)+,2cer23%B3Vmp3!
 | 
					 | 
				
			||||||
B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"r23!!!B%B3!$r2-%BJ4M#[cc!!3
 | 
					 | 
				
			||||||
+DfpME!d%BJ!"E3!!#JB+#Icb#[cb!!3+B@aTB3B%B`!$r2%%C!4P#[ca!!3+D@j
 | 
					 | 
				
			||||||
cD!d%C!!#0!!!#J`+&2c`"'B+r2!!"!TMCQpX$34Q!!&[!!!+%!S6r1m,r1m!0$!
 | 
					 | 
				
			||||||
!''p`C@jcFfaTEQ0XG@4PCQpXC'9bF'&dD!!BEh"PEP066%PZBfaeC'9'EfaNCA*
 | 
					 | 
				
			||||||
3BA4S"J4P!!2mlJ4Rr1d+r1i!"!TdEb!J$34R!!*Z!!!+&`SQ"'J%D3d%D!!#0!!
 | 
					 | 
				
			||||||
!#Km+*[cX"'S+r1`!"!TQD@aP$34U!!&Y!!!+)JSP"'X-"'X!%!!+Eh"PER0cE(B
 | 
					 | 
				
			||||||
ZD!!#!!!0"'N!!M3!!!SA#Krmk`4X#[cV!!3+BfC[E!d%E!!"E`!!#KX+([cU#rc
 | 
					 | 
				
			||||||
U!#3`!""MFRP`G'pQEfaNCA*`BA4S!""MFRP`G'p'EfaNCA*3BA4S"[cY!!!#"'!
 | 
					 | 
				
			||||||
!!J4Y"'i0"'d!!dN!!JSY#PImkIcS"'m+r1N!'#jMEh*PBh*PE#SU+LS!!!!!!!#
 | 
					 | 
				
			||||||
3!!"ZG@aX!IcS!!!'"'m!!rcR"(!%F3Vmj`!%#QY[Bf`0"(!!!@d!!!Sa#M6mjJV
 | 
					 | 
				
			||||||
mjJ!%#Q&XD@%'"(%!!rcP"()%F`Vmj3!%#QPZFfJ0"()!!M3!!!Sh#Mrmj!4d#[c
 | 
					 | 
				
			||||||
N!!3+BfC[E!d%G!!"E`!!#MX+2[cM#rcM!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4
 | 
					 | 
				
			||||||
PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B%F`!$r1)%GIcK#[cL!!3
 | 
					 | 
				
			||||||
+G'mJ)!d%G3!#EJ!!#N)+834f"(F0"(B!!M3!!!T+#P(mi!4i#[cJ!!3+CQPXC3d
 | 
					 | 
				
			||||||
%H!!"E3!!#Nd+8!4j$!4j!!i!#(4YC'PQCLjS!!)!!!d%G`!#0!!!#N)+5[cI"(S
 | 
					 | 
				
			||||||
+r0m!"!TMCQpX$34k!!&[!!!+4JT*r0i,r0i!*$!!%'0bHA"dEfC[E'4PFR"KG'J
 | 
					 | 
				
			||||||
!%'0bHA"dEdC[E'4PFP"KG'J'r1%!!!)%EJ!#"(X%I!d%H`!#E!!##PJ+@2cGr0`
 | 
					 | 
				
			||||||
"r0d!!!(mh!!!!J4m!!)%I34q$34p!!*X!!)+@!TBr0[mfJ(mf`!!!IcD!!!#"(i
 | 
					 | 
				
			||||||
!!J4r")!0"(m!!dN!!JTB#S,mfIcB")%+r0N!'#jMEh*PBh*PE#SU+LS!!!!!!!#
 | 
					 | 
				
			||||||
3!!"ZG@aX!IcB!!!'")%!!rcA"))%J`Vme`!%#QY[Bf`0"))!!@d!!!TF#PrmeJV
 | 
					 | 
				
			||||||
meJ!%#Q&XD@%'")-!!rc9")3%K3Vme3!%#QPZFfJ0")3!!M3!!!TL#QVme!5'#[c
 | 
					 | 
				
			||||||
8!!3+BfC[E!d%KJ!"E`!!#QB+DIc6#rc6!$3`!"K[F'9ZFh0XD@jME(9NC@C[E'4
 | 
					 | 
				
			||||||
PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD!B%K3!$r0)%Krc4#[c5!!3
 | 
					 | 
				
			||||||
+G'mJ)!d%K`!#EJ!!#Qd+I!5)")N0")J!!M3!!!Te#Rcmd!5+#[c3!!3+CQPXC3d
 | 
					 | 
				
			||||||
%LJ!"E3!!#RJ+H`5,$!5,!!`!"Q9IEh-ZD!!#!!!0")N!!M3!!!TY#RAmc`5-#[c
 | 
					 | 
				
			||||||
2!!3+BfC[E!d%M!!"E`!!#R%+G2c1#rc1!#B`!"&[F'9ZFh0XCQpXC'9bF'&dD!!
 | 
					 | 
				
			||||||
4Eh"PER0cE%C[E'4PFP"KG'J'r0%!!!)%J!!#")d%MJd%M3!$53!##S-+VIc0r-`
 | 
					 | 
				
			||||||
%M`Vmc3!B,Q0[FQ9MFQ9X+LSU+J!!!!!!!*!!!'jeE'`"r-`!!!B%M`!$r-X%N!!
 | 
					 | 
				
			||||||
%N3Vmb`!%#QY[Bf`0"*!!!!&Y!!!+K`U+r-S+r-S!"!TKE'PK"J54!!2mb355"*-
 | 
					 | 
				
			||||||
+r-N!"!TTER0S$355!!)d!!!+M3U9r-J%P!Vmb!!%#Q0QEf`0"*3!!@m!!!U4#T6
 | 
					 | 
				
			||||||
ma`[ma`!d-!!BEh"PER0cE'PZBfaeC'9QEfaNCA*`BA4S!"K[F'9Z8e0-5@jME(9
 | 
					 | 
				
			||||||
NC8C[E'4PFP"KG'J'"*-!!rc'"*Ama3VmaJ!%#R4[)#!0"*8!!Qi!!!UB#UF%PJ5
 | 
					 | 
				
			||||||
A$35@!!)d!!!+S!URr-3%Q!Vma!!%#QCTE'80"*J!!@d!!!UM#UB%Q3`%Q3!0!!G
 | 
					 | 
				
			||||||
PAfpc-LjS!!)!!!d%P`!#0!!!#TJ+S2c$"*S+r--!"!TMCQpX$35D!!&[!!!+R!U
 | 
					 | 
				
			||||||
Ir-),r-)!*M!!%@p`C@jcFfaQEfaNCA*`BA4S!"&[F'9ZFh0X4QpXC'9b8'&dD!E
 | 
					 | 
				
			||||||
ma3!!!J51!!)%Qrc"$35E!!*X!!)+VJUZr-$m[`(m`!!!!Ibr!!!#r-%!!!d!#3!
 | 
					 | 
				
			||||||
"E3!!!!!!!3!I!Irq!!!#!!B!!J5F"*d0"*`!!Q`!!J!!!!$m[[bp!Ibq!!!"r,d
 | 
					 | 
				
			||||||
!!!)%R3!#"*i%R`d%RJ!#E!!##V%+b!5Jr,`0"+!!!dN!!JUa#XMmZ`5K"+)+r,X
 | 
					 | 
				
			||||||
!'#jcHA0[C'a[Cf&cDh)!!!!!!!!!!&4&@&30"+%!!@d!!!Ua#V3%S``%S`!'!!!
 | 
					 | 
				
			||||||
!!J!!"J5L!!2mZJ5N"+8+r,S!"!TLG'jc$35N!!&+!!!+Y`Um"+B#"+B!!J5Rr,N
 | 
					 | 
				
			||||||
0"+F!!@d!!!Uh#VS%U!`%U!!+!!4%EfjP!!)!!!,mZ3!!"J5P!!2mZ!5Tr,F+r,J
 | 
					 | 
				
			||||||
!"!TRDACe$35T!!&Y!!!+[`V#r,B$r,B!"3EmY`!!!Ibm!!!#"*m!!J5Ur,80"+S
 | 
					 | 
				
			||||||
!!Q`!!J!!!!$mY2bc!Ibd!!!"r,-!!!,mY3!!$J!#!!!2%!!$!",mXJ5V"+`%V35
 | 
					 | 
				
			||||||
Z"+m%X!5a",)%X`5d",8%YJ5hr,(mX2b[r+i"r,)!!"!%U`!3r+hmV2bVr+VmUIb
 | 
					 | 
				
			||||||
Sr+ImT[bPr+6mSrbLr+(mS2bIr*i+r+d!'#jKCACdEf&`F'jeE'`!!)!!!!#3!!!
 | 
					 | 
				
			||||||
U+LSU#rbX!")`!!GdD'9`BA4S!!GdD'93BA4S#rbV!"``!!adD'9[E'4NC@aTEA-
 | 
					 | 
				
			||||||
!$(4SC8pXC%4PE'PYF`[mUJ!J-!!1G'KPF(*[DQ9MG("KG'J!$R4SC9"bEfTPBh4
 | 
					 | 
				
			||||||
3BA4S#rbT!"B`!!PdD'9YCA"KG'J!#A4SC8eP8'&dD![mU!!Q-!!4D@jME(9NC@C
 | 
					 | 
				
			||||||
[E'4PFR"KG'J!%@PZBfaeC'9'EfaNCA*3BA4S#rbR!$3`!"K[F'9ZFh0XD@jME(9
 | 
					 | 
				
			||||||
NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&dD![mTJ!N-!!3Bh*
 | 
					 | 
				
			||||||
jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD![mT3!H-!!0Fh0XCQpXC'9
 | 
					 | 
				
			||||||
bF'&dD!!0Fh0X4QpXC'9b8'&dD![mT!!Q-!!4Eh"PER0cE'C[E'4PFR"KG'J!%@p
 | 
					 | 
				
			||||||
`C@jcFfa'EfaNCA*3BA4S#rbM!#i`!"9dD'9ZCAGQEfaNCA*bC@CPFQ9ZBf8!&A4
 | 
					 | 
				
			||||||
SC8jPGdC[E'4PFP*PCQ9bC@jMC3[mSJ!8-!!)G'9YF("KG'J!#(4PEA"3BA4S!Ib
 | 
					 | 
				
			||||||
K!!!"r+!!!!(mR`!!!IbH!!!1"+`!"a$mR35ir*cmQ`5j",VmQJVmR3!B,Q&PGR4
 | 
					 | 
				
			||||||
[BA"`ER9XE!!!J!!!!*!!!#SU+LS0",J!!@X!!!!!#XJ%Z`)%Z`!#!!8%[!)%[!!
 | 
					 | 
				
			||||||
#"*lmQ3,mQ3!!!IbF!!!#r*X!!"!%Z3!!%!5k!)B!(rbBr*ImP[b9r*6mNrb5!#c
 | 
					 | 
				
			||||||
mNIb3!2b2r)lmMIb-!%rmL`"D!&[mLJ"Nr)N!EIb)r)ImKJ#2r)AmK2b$r),mJIb
 | 
					 | 
				
			||||||
!r(rmI[apr(cmH`#Tr(VmHIair(F![Iaf!-ImG3$8!1)!l!$j!3-"%!%D!5F"-3%
 | 
					 | 
				
			||||||
q!8J"93&I!@`"GJ'$!Bd"QJ'N!E%"Z`()!G)"h`(T!IB#!!)0!KF#*!)Z!MX#43*
 | 
					 | 
				
			||||||
5!P`#D3*c!S!#LJ+A!U%#VJ+m!XB#d`,G!ZS#p!-"!`X$'!-L!bm$130'!e!$A30
 | 
					 | 
				
			||||||
R!h3$IJ1,!jN$S`1`!lS$a`24!pi$l!2f"!-%%`3K"#m%234,"&X%D`4j")X%Q35
 | 
					 | 
				
			||||||
Mr(3%U2acr(,mF3VmQ!!%#Q0[BQS+r*F!'#jPBA*cCQCNFQ&XDA-!!!!!!!!J!'&
 | 
					 | 
				
			||||||
QC()+r*B!"!TMG(Kd#rb9!")`!!GdD'9`BA4S!!GdD'93BA4S#[b8!!3+BA0MFJV
 | 
					 | 
				
			||||||
mN`!%#R4iC'`,r*)!($!!$(4SC@pXC'4PE'PYF`!-G'KP6faN4'9XD@ec#[b4!!3
 | 
					 | 
				
			||||||
+BfPdE32mN!$rr3[mM`!J-!!1G'KPF(*[DQ9MG("KG'J!$R4SC9"bEfTPBh43BA4
 | 
					 | 
				
			||||||
S!rb1rri+r)d!"!T849K8#rb-!"B`!!PdD'9YCA"KG'J!#A4SC8eP8'&dD![mL`!
 | 
					 | 
				
			||||||
Q-!!4D@jME(9NC@C[E'4PFR"KG'J!%@PZBfaeC'9'EfaNCA*3BA4S#rb+!$3`!"K
 | 
					 | 
				
			||||||
[F'9ZFh0XD@jME(9NC@C[E'4PFR"KG'J!''p`C@j68da*EQ0XG@4P4QpXC'9b8'&
 | 
					 | 
				
			||||||
dD![mL3!N-!!3Bh*jF(4[CQpXC'9bF'&dD!!3Bh*jF(4[4QpXC'9b8'&dD![mL!!
 | 
					 | 
				
			||||||
H-!!0Fh0XCQpXC'9bF'&dD!!0Fh0X4QpXC'9b8'&dD![mK`!Q-!!4Eh"PER0cE'C
 | 
					 | 
				
			||||||
[E'4PFR"KG'J!%@p`C@jcFfa'EfaNCA*3BA4S#[b'!!3+BfC[E!VmK3!B,QeTFf0
 | 
					 | 
				
			||||||
cE'0d+LSU+J!!!!!!!*!!!#SU+LS+r)3!"!TcC@aP#[b$!"JZBfpbC@4PE'mU+LS
 | 
					 | 
				
			||||||
U!!!!!!!!N!!!+LSU+J(mJJ!!![b"!!!+r)!!"!TVEf0X#[ar!!3+D@jcD!2mIJ!
 | 
					 | 
				
			||||||
%#[ap!"JZBfpbC@0bC@`U+LSU!!!!!!!!N!!!ER9XE!VmI!!%#R*cE(3,r(X!,M!
 | 
					 | 
				
			||||||
!&A4SC@jPGfC[E'4PFR*PCQ9bC@jMC3!9G'KP6Q9h4QpXC'9b8Q9QCA*PEQ0P#[a
 | 
					 | 
				
			||||||
k!!3+F'jKE3VmH3!%#Q&XD@%+r(J!"!TdEb!J#[ah!!3+CQPXC32mGJ!'#rae!"3
 | 
					 | 
				
			||||||
`!!KdC@e`F'&dD!!)G'9YF&"KG'J+r(3!"!TLG'jc#[ac!!3+CfPfG32mFJ!&#[a
 | 
					 | 
				
			||||||
a!"JZFhPcEf4XEfGKFfYb!!!!!!!!!!"849K8%IbD#XRJ%JUYi1%TDJ`!!LrM*N9
 | 
					 | 
				
			||||||
4e%r&jLa&edrSaHBX4Nr%@qPF@eTVA&VU-NAE6m4Ek9aE@QYF@Z`bl5C&hNr,lbA
 | 
					 | 
				
			||||||
Y*N9J!""2bf%!%59K!")Pl5C&B!!66mYK!"3Pl5C&B!!96mYK!"BPl5C&B!!A6m[
 | 
					 | 
				
			||||||
Y*N9J!"K2amAQ,%C2&!!L+Q%!'9m!%#pK!"PK!"S[DJ`!'dmUB3!F,'S-!"eA!!K
 | 
					 | 
				
			||||||
B!"i!(fK2+Q%!)'%!'@%!)5TK!"PI!"![B3!L$!!M6em!*%9J!#92A`!PDJ`!'dp
 | 
					 | 
				
			||||||
K!#BUB3!F,'%!*ba'6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"R1,f%!+Q%!+bp
 | 
					 | 
				
			||||||
K!#`-!#02A`!9B3!Y*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,Lp
 | 
					 | 
				
			||||||
K!#TK!#m[B3!X$!!M6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3!
 | 
					 | 
				
			||||||
`,f%!,!`!)dpI!"9K!$%P4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!
 | 
					 | 
				
			||||||
Z,f%!+Q%!-LpK!#`-!#02A`!9B3!c*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!
 | 
					 | 
				
			||||||
T+Q%!'9m!,LpK!#TK!$3[B3!X$!!M6em!&@%!059&B!!Z6bTK!#"K!#KK!#%UB3!
 | 
					 | 
				
			||||||
CA`!6,f%!+5TK!"PI!#i[B3!UB3!f,f%!,!`!)dpI!"9K!$FP4@!!,NmUB3!JB3!
 | 
					 | 
				
			||||||
SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!1#pK!#`-!#02A`!9B3!j*89J!#j
 | 
					 | 
				
			||||||
2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!$S[B3!X$!!M6em!&@%
 | 
					 | 
				
			||||||
!1b9&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3!m,f%!,!`
 | 
					 | 
				
			||||||
!)dpI!"9K!$dP4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%
 | 
					 | 
				
			||||||
!2LpK!#`-!#02A`!9B3!r*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m
 | 
					 | 
				
			||||||
!,LpK!#TK!%![B3!X$!!M6em!&@%!359&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%
 | 
					 | 
				
			||||||
!+5TK!"PI!#i[B3!UB3"#,f%!,!`!)dpI!"9K!%-P4@!!,NmUB3!JB3!SB3!K+Q%
 | 
					 | 
				
			||||||
!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!4#pK!#`-!#02A`!9B3"&*89J!#j2+Q%!)'%
 | 
					 | 
				
			||||||
!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!%B[B3!X$!!M6em!&@%!4b9&B!!
 | 
					 | 
				
			||||||
Z6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3"),f%!,!`!)dpI!"9
 | 
					 | 
				
			||||||
K!%NP4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!5LpK!#`
 | 
					 | 
				
			||||||
-!#02A`!9B3",*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#T
 | 
					 | 
				
			||||||
K!%`[B3!X$!!M6em!&@%!659&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"P
 | 
					 | 
				
			||||||
I!#i[B3!UB3"1,f%!,!`!)dpI!"9K!%mP4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bp
 | 
					 | 
				
			||||||
K!#NUB3!CA`!Z,f%!+Q%!8#pK!#`-!#02A`!9B3"4*89J!#j2+Q%!)'%!+'%!)5T
 | 
					 | 
				
			||||||
K!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!&)[B3!X$!!M6em!&@%!8b9&B!!Z6bTK!#"
 | 
					 | 
				
			||||||
K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3"8,f%!,!`!)dpI!"9K!&8P4@!
 | 
					 | 
				
			||||||
!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!9LpK!#`-!#02A`!
 | 
					 | 
				
			||||||
9B3"A*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!&J[B3!
 | 
					 | 
				
			||||||
X$!!M6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3"C,f%!,!`!)dp
 | 
					 | 
				
			||||||
I!"9K!&SP4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!@bp
 | 
					 | 
				
			||||||
K!#`-!#02A`!9B3"F*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,Lp
 | 
					 | 
				
			||||||
K!#TK!&d[B3!X$!!M6em!&@%!AL9&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5T
 | 
					 | 
				
			||||||
K!"PI!#i[B3!UB3"I,f%!,!`!)dpI!"9K!'!P4@!!,NmUB3!JB3!SB3!K+Q%!'9m
 | 
					 | 
				
			||||||
!%bpK!#NUB3!CA`!Z,f%!+Q%!B5pK!#`-!#02A`!9B3"L*89J!#j2+Q%!)'%!+'%
 | 
					 | 
				
			||||||
!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!'-[B3!X$!!M6em!&@%!C#9&B!!Z6bT
 | 
					 | 
				
			||||||
K!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3"P,f%!,!`!)dpI!"9K!'B
 | 
					 | 
				
			||||||
P4@!!,NmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!CbpK!#`-!#0
 | 
					 | 
				
			||||||
2A`!9B3"S*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!,LpK!#TK!'N
 | 
					 | 
				
			||||||
[B3!X$!!M6em!&@%!DL9&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!#i
 | 
					 | 
				
			||||||
[B3!UB3"V,f%!,!`!)dmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%
 | 
					 | 
				
			||||||
!E#pK!#`-!#02A`!9B3"Y*89J!#j2+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m
 | 
					 | 
				
			||||||
!,LpK!#TK!'i[B3!X$!!M6em!&@%!Eb9&B!!Z6bTK!#"K!#KK!#%UB3!CA`!6,f%
 | 
					 | 
				
			||||||
!+5TK!"PI!#i[B3!UB3"`,f%!,!`!)dpI!"9K!(%P4@!!,NmUB3!JB3!SB3!K+Q%
 | 
					 | 
				
			||||||
!'9m!%bpK!#NUB3!CA`!Z,f%!+Q%!FLpK!#`-!#02+Q%!)'%!+'%!)5TK!"PI!"-
 | 
					 | 
				
			||||||
[B3!T+Q%!'9m!,LpK!#TK!(-[B3!X$!!M6em!&@%!G#9&B!!Z6bTK!#"K!#KK!#%
 | 
					 | 
				
			||||||
UB3!CA`!6,f%!+5TK!"PI!#i[B3!UB3"e,f%!,!`!)dmUB3!JB3!SB3!K+Q%!'9m
 | 
					 | 
				
			||||||
!%bpK!#NUB3!CA`!A,f%!+Q%!GLpK!#`-!#02+Q%!)'%!+'%!)5TK!"PI!"-[B3!
 | 
					 | 
				
			||||||
T+Q%!'9m!&bpK!#TK!(F[B3!X$!!M6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"P
 | 
					 | 
				
			||||||
I!"F[B3!UB3"i,f%!,!`!)dmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!A,f%
 | 
					 | 
				
			||||||
!+Q%!H5pK!#`-!#02+Q%!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!&bpK!#TK!(S
 | 
					 | 
				
			||||||
[B3!X$!!M6bTK!#"K!#KK!#%UB3!CA`!6,f%!+5TK!"PI!"8[B3!UB3"l,f%!,!`
 | 
					 | 
				
			||||||
!)dmUB3!JB3!SB3!K+Q%!'9m!%bpK!#NUB3!CA`!9,f%!+Q%!I#pK!#`-!#02+Q%
 | 
					 | 
				
			||||||
!)'%!+'%!)5TK!"PI!"-[B3!T+Q%!'9m!&5pK!#TK!(d[B3!X$!!M6bTK!#"K!#K
 | 
					 | 
				
			||||||
K!#%UB3!CA`!6,f%!+5TK!"PI!"J[B3!UB3"q,f%!,!`!)dmUB3!JB3!SB3!K+Q%
 | 
					 | 
				
			||||||
!'9m!%bpK!#NUB3!CA`!B,f%!+Q%!IbpK!#`-!#028&92B3#!B3#"B3##DhCK!)0
 | 
					 | 
				
			||||||
K!)4K!#)-!)82$!5Y!&%!5deKBfPZG'pcD#")4$T%CA0VG'p`)%C[E'4PFMT*EQ0
 | 
					 | 
				
			||||||
[E@PZCcT[F'9ZFh0X,90139!Y-6Nj16%b-6%k6@&M6e-kE@YXD@jVFbjKF`!#!!!
 | 
					 | 
				
			||||||
1"+i!!J6mF!5p!ra`!!%1",d!!3!%[J`%[J!'!!!!!J!!$J5[!!)%r'm%[`2mE`!
 | 
					 | 
				
			||||||
%$J5r!!3!"-!%`36#"---"-!!%J!-6@&MD@jdEh0S)%K%!!)!!!`%`3!8!!j%CA0
 | 
					 | 
				
			||||||
VG'p`)%C[E'4PFJ!#!!!-"-)!$J!)5@jMEfeTEQF!!J!!$!6$!"X!&@p`C@jcFf`
 | 
					 | 
				
			||||||
Y8dj"8#da16Nj-6)a-3!#!!!-",!!4J"!6@&MD@jdEh0S)%K%1N4PFfYdEh!J4Qp
 | 
					 | 
				
			||||||
XC'9b1NPZBfpYD@jR1Qp`C@jcFf`Y8dj"8#da16Nj-6)a-6T0B@028`!#!!!-",%
 | 
					 | 
				
			||||||
!5!"#6@&MD@jdEh0S)%K%1N4PFfYdEh!J4QpXC'9b1NPZBfpYD@jR1Qp`C@jcFf`
 | 
					 | 
				
			||||||
Y8dj"8#da16Nj-6)a-6TTEQ0XG@4P!!)!!!`%XJ"3!%T0B@0TER4[FfJJ5%3k4'9
 | 
					 | 
				
			||||||
cDh4[F#"'EfaNCA)k5@jMEfeTEQFkEh"PER0cE#e66N&3,6%j16Na-M%a1QPZBfa
 | 
					 | 
				
			||||||
eC'8kEh"PER0cE!!#!!!-",-!4`""6@&MD@jdEh0S)%K%1N4PFfYdEh!J4QpXC'9
 | 
					 | 
				
			||||||
b1NPZBfpYD@jR1Qp`C@jcFf`Y8dj"8#da16Nj-6)a-6TMFRP`G'm!!J!!$!5d!%3
 | 
					 | 
				
			||||||
!2NeKBfPZG'pcD#")4$T%CA0VG'p`)%C[E'4PFMT*EQ0[E@PZCcT[F'9ZFh0X,90
 | 
					 | 
				
			||||||
139!Y-6Nj16%b-6%kFh0X!!)!!!`%Y3"!!$T0B@0TER4[FfJJ5%3k4'9cDh4[F#"
 | 
					 | 
				
			||||||
'EfaNCA)k5@jMEfeTEQFkEh"PER0cE#e66N&3,6%j16Na-M%a!!)!!!i%YJ!"&!6
 | 
					 | 
				
			||||||
%$J6%!!-B"-AmEJ6'$J6&!!-B"-ImE36)$J6(!!-B"-RmE!6+$J6*!!-B!"rmD`6
 | 
					 | 
				
			||||||
,#[aV!!3+BfC[E!`%b`!1!!K*EQ0[E@PZC`!#!!!+r'`!"!TMCQpX$!6+!"X!&@p
 | 
					 | 
				
			||||||
`C@jcFf`Y8dj"8#da16Nj-6)a-3!#!!!+r'd!"!TMCQpX$!6)!!d!"fPZBfaeC'8
 | 
					 | 
				
			||||||
!!J!!#[aZ!!3+BfC[E!`%aJ!9!!peER4TG'aPC#"QEfaNCA)!!J!!$!5h!%i!5%e
 | 
					 | 
				
			||||||
KBfPZG'pcD#")4$T%CA0VG'p`)%C[E'4PFMT*EQ0[E@PZCcT[F'9ZFh0X,90139!
 | 
					 | 
				
			||||||
Y-6Nj16%b-6%kBh*jF(4[1RJe-$Pf-`!#!!!"r,%!!!(mX!!!!Ib[!!!"r+i!!'&
 | 
					 | 
				
			||||||
cBh)!!3!-qYlHV3!!!3!!!*G#!!#@3J!!!AB!!$-8-0J!!!!F!AB!$h0MFhS!!!#
 | 
					 | 
				
			||||||
#6Np853!!!)jcBh"d!!!!QP4&@&3!!3#QFh4jE!!!!,j$6d4&!!%!bN*14%`!!!$
 | 
					 | 
				
			||||||
LBA"XG!!!!1j'8N9'!!!!qNP$6L-!!!%'D@0X0!!!!4*TBh-M!!!"(QPMFc3!!!%
 | 
					 | 
				
			||||||
UD'CNFJ!!!6C659T&!!!"3PG3Eh-!!!&1!!$rr`!!!!!!!!!!!)$rre!!!"i!!!!
 | 
					 | 
				
			||||||
!!)$rr`!!"cJ#DH#m"'Mrr`!!!*S!!!!!%iRrr`!!"Pi!!!!!"'Mrr`!!!53!!!!
 | 
					 | 
				
			||||||
!!!$rrb!!!9)!!!!!!!(rra3!!@i#DG`%!)$rr`!!!Pi#DH"X!!$rr`!!!Ri!!!!
 | 
					 | 
				
			||||||
!!)$rr`!!!S-#DH"d!*Err`!!!Si!!!!!!*Err`!!!j)!!!!!!*Err`!!"CB#DH%
 | 
					 | 
				
			||||||
i!*Err`!!"GS#DH%dkF$rr`!!"[`!!!!!rrrrr`!!"a)!!!!!!)$rr`!!"b!!!!!
 | 
					 | 
				
			||||||
!*4S:
 | 
					 | 
				
			||||||
@@ -1,116 +0,0 @@
 | 
				
			|||||||
/* MacOS/opensslconf.h */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
 | 
					 | 
				
			||||||
#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
 | 
					 | 
				
			||||||
#define OPENSSLDIR "/usr/local/ssl"
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
 | 
					 | 
				
			||||||
#define IDEA_INT unsigned int
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_MD2_H) && !defined(MD2_INT)
 | 
					 | 
				
			||||||
#define MD2_INT unsigned int
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_RC2_H) && !defined(RC2_INT)
 | 
					 | 
				
			||||||
/* I need to put in a mod for the alpha - eay */
 | 
					 | 
				
			||||||
#define RC2_INT unsigned int
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_RC4_H)
 | 
					 | 
				
			||||||
#if !defined(RC4_INT)
 | 
					 | 
				
			||||||
/* using int types make the structure larger but make the code faster
 | 
					 | 
				
			||||||
 * on most boxes I have tested - up to %20 faster. */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * I don't know what does "most" mean, but declaring "int" is a must on:
 | 
					 | 
				
			||||||
 * - Intel P6 because partial register stalls are very expensive;
 | 
					 | 
				
			||||||
 * - elder Alpha because it lacks byte load/store instructions;
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define RC4_INT unsigned char
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#if !defined(RC4_CHUNK)
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * This enables code handling data aligned at natural CPU word
 | 
					 | 
				
			||||||
 * boundary. See crypto/rc4/rc4_enc.c for further details.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define RC4_CHUNK unsigned long
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_DES_H) && !defined(DES_LONG)
 | 
					 | 
				
			||||||
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
 | 
					 | 
				
			||||||
 * %20 speed up (longs are 8 bytes, int's are 4). */
 | 
					 | 
				
			||||||
#ifndef DES_LONG
 | 
					 | 
				
			||||||
#define DES_LONG unsigned long
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
 | 
					 | 
				
			||||||
#define CONFIG_HEADER_BN_H
 | 
					 | 
				
			||||||
#if __option(longlong)
 | 
					 | 
				
			||||||
#  define BN_LLONG
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#  undef BN_LLONG
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Should we define BN_DIV2W here? */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Only one for the following should be defined */
 | 
					 | 
				
			||||||
/* The prime number generation stuff may not work when
 | 
					 | 
				
			||||||
 * EIGHT_BIT but I don't care since I've only used this mode
 | 
					 | 
				
			||||||
 * for debuging the bignum libraries */
 | 
					 | 
				
			||||||
#undef SIXTY_FOUR_BIT_LONG
 | 
					 | 
				
			||||||
#undef SIXTY_FOUR_BIT
 | 
					 | 
				
			||||||
#define THIRTY_TWO_BIT
 | 
					 | 
				
			||||||
#undef SIXTEEN_BIT
 | 
					 | 
				
			||||||
#undef EIGHT_BIT
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
 | 
					 | 
				
			||||||
#define CONFIG_HEADER_RC4_LOCL_H
 | 
					 | 
				
			||||||
/* if this is defined data[i] is used instead of *data, this is a %20
 | 
					 | 
				
			||||||
 * speedup on x86 */
 | 
					 | 
				
			||||||
#undef RC4_INDEX
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
 | 
					 | 
				
			||||||
#define CONFIG_HEADER_BF_LOCL_H
 | 
					 | 
				
			||||||
#define BF_PTR
 | 
					 | 
				
			||||||
#endif /* HEADER_BF_LOCL_H */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
 | 
					 | 
				
			||||||
#define CONFIG_HEADER_DES_LOCL_H
 | 
					 | 
				
			||||||
/* the following is tweaked from a config script, that is why it is a
 | 
					 | 
				
			||||||
 * protected undef/define */
 | 
					 | 
				
			||||||
#ifndef DES_PTR
 | 
					 | 
				
			||||||
#define DES_PTR
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* This helps C compiler generate the correct code for multiple functional
 | 
					 | 
				
			||||||
 * units.  It reduces register dependancies at the expense of 2 more
 | 
					 | 
				
			||||||
 * registers */
 | 
					 | 
				
			||||||
#ifndef DES_RISC1
 | 
					 | 
				
			||||||
#define DES_RISC1
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef DES_RISC2
 | 
					 | 
				
			||||||
#undef DES_RISC2
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(DES_RISC1) && defined(DES_RISC2)
 | 
					 | 
				
			||||||
YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Unroll the inner loop, this sometimes helps, sometimes hinders.
 | 
					 | 
				
			||||||
 * Very mucy CPU dependant */
 | 
					 | 
				
			||||||
#ifndef DES_UNROLL
 | 
					 | 
				
			||||||
#define DES_UNROLL
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* HEADER_DES_LOCL_H */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef __POWERPC__
 | 
					 | 
				
			||||||
#define MD32_XARRAY
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
							
								
								
									
										502
									
								
								Makefile.org
									
									
									
									
									
								
							
							
						
						
									
										502
									
								
								Makefile.org
									
									
									
									
									
								
							@@ -5,16 +5,8 @@
 | 
				
			|||||||
VERSION=
 | 
					VERSION=
 | 
				
			||||||
MAJOR=
 | 
					MAJOR=
 | 
				
			||||||
MINOR=
 | 
					MINOR=
 | 
				
			||||||
SHLIB_VERSION_NUMBER=
 | 
					 | 
				
			||||||
SHLIB_VERSION_HISTORY=
 | 
					 | 
				
			||||||
SHLIB_MAJOR=
 | 
					 | 
				
			||||||
SHLIB_MINOR=
 | 
					 | 
				
			||||||
SHLIB_EXT=
 | 
					 | 
				
			||||||
PLATFORM=dist
 | 
					PLATFORM=dist
 | 
				
			||||||
OPTIONS=
 | 
					OPTIONS=
 | 
				
			||||||
CONFIGURE_ARGS=
 | 
					 | 
				
			||||||
SHLIB_TARGET=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# INSTALL_PREFIX is for package builders so that they can configure
 | 
					# INSTALL_PREFIX is for package builders so that they can configure
 | 
				
			||||||
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
 | 
					# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
 | 
				
			||||||
# Normally it is left empty.
 | 
					# Normally it is left empty.
 | 
				
			||||||
@@ -36,6 +28,8 @@ OPENSSLDIR=/usr/local/ssl
 | 
				
			|||||||
# DEVRANDOM - Give this the value of the 'random device' if your OS supports
 | 
					# DEVRANDOM - Give this the value of the 'random device' if your OS supports
 | 
				
			||||||
#           one.  32 bytes will be read from this when the random
 | 
					#           one.  32 bytes will be read from this when the random
 | 
				
			||||||
#           number generator is initalised.
 | 
					#           number generator is initalised.
 | 
				
			||||||
 | 
					# SSL_ALLOW_ADH - define if you want the server to be able to use the
 | 
				
			||||||
 | 
					#           SSLv3 anon-DH ciphers.
 | 
				
			||||||
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
 | 
					# SSL_FORBID_ENULL - define if you want the server to be not able to use the
 | 
				
			||||||
#           NULL encryption ciphers.
 | 
					#           NULL encryption ciphers.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
@@ -57,14 +51,11 @@ CC= gcc
 | 
				
			|||||||
#CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 | 
					#CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 | 
				
			||||||
CFLAG= -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 | 
					CFLAG= -DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
 | 
				
			||||||
DEPFLAG= 
 | 
					DEPFLAG= 
 | 
				
			||||||
PEX_LIBS= 
 | 
					PEX_LIBS= -L. -L.. -L../.. -L../../..
 | 
				
			||||||
EX_LIBS= 
 | 
					EX_LIBS= 
 | 
				
			||||||
EXE_EXT= 
 | 
					 | 
				
			||||||
AR=ar r
 | 
					AR=ar r
 | 
				
			||||||
RANLIB= ranlib
 | 
					RANLIB= ranlib
 | 
				
			||||||
PERL= perl
 | 
					PERL= perl
 | 
				
			||||||
TAR= tar
 | 
					 | 
				
			||||||
TARFLAGS= --no-recursion
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set BN_ASM to bn_asm.o if you want to use the C version
 | 
					# Set BN_ASM to bn_asm.o if you want to use the C version
 | 
				
			||||||
BN_ASM= bn_asm.o
 | 
					BN_ASM= bn_asm.o
 | 
				
			||||||
@@ -151,25 +142,20 @@ RMD160_ASM_OBJ= asm/rm86-out.o
 | 
				
			|||||||
#RMD160_ASM_OBJ= asm/rm86-out.o       # a.out, FreeBSD
 | 
					#RMD160_ASM_OBJ= asm/rm86-out.o       # a.out, FreeBSD
 | 
				
			||||||
#RMD160_ASM_OBJ= asm/rm86bsdi.o       # bsdi
 | 
					#RMD160_ASM_OBJ= asm/rm86bsdi.o       # bsdi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# When we're prepared to use shared libraries in the programs we link here
 | 
					DIRS=   crypto ssl rsaref apps test tools
 | 
				
			||||||
# we might set SHLIB_MARK to '$(SHARED_LIBS)'.
 | 
					 | 
				
			||||||
SHLIB_MARK=
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DIRS=   crypto ssl rsaref $(SHLIB_MARK) apps test tools
 | 
					 | 
				
			||||||
SHLIBDIRS= crypto ssl
 | 
					SHLIBDIRS= crypto ssl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# dirs in crypto to build
 | 
					# dirs in crypto to build
 | 
				
			||||||
SDIRS=  \
 | 
					SDIRS=  \
 | 
				
			||||||
	md2 md4 md5 sha mdc2 hmac ripemd \
 | 
						md2 md5 sha mdc2 hmac ripemd \
 | 
				
			||||||
	des rc2 rc4 rc5 idea bf cast \
 | 
						des rc2 rc4 rc5 idea bf cast \
 | 
				
			||||||
	bn rsa dsa dh dso engine \
 | 
						bn rsa dsa dh \
 | 
				
			||||||
	buffer bio stack lhash rand err objects \
 | 
						buffer bio stack lhash rand err objects \
 | 
				
			||||||
	evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp
 | 
						evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MAKEFILE= Makefile.ssl
 | 
					MAKEFILE= Makefile.ssl
 | 
				
			||||||
MAKE=     make -f Makefile.ssl
 | 
					MAKE=     make -f Makefile.ssl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MANDIR=$(OPENSSLDIR)/man
 | 
					 | 
				
			||||||
MAN1=1
 | 
					MAN1=1
 | 
				
			||||||
MAN3=3
 | 
					MAN3=3
 | 
				
			||||||
SHELL=/bin/sh
 | 
					SHELL=/bin/sh
 | 
				
			||||||
@@ -178,12 +164,7 @@ TOP=    .
 | 
				
			|||||||
ONEDIRS=out tmp
 | 
					ONEDIRS=out tmp
 | 
				
			||||||
EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
 | 
					EDIRS=  times doc bugs util include certs ms shlib mt demos perl sf dep VMS
 | 
				
			||||||
WDIRS=  windows
 | 
					WDIRS=  windows
 | 
				
			||||||
LIBS=   libcrypto.a libssl.a
 | 
					LIBS=   libcrypto.a libssl.a 
 | 
				
			||||||
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
 | 
					 | 
				
			||||||
SHARED_SSL=libssl$(SHLIB_EXT)
 | 
					 | 
				
			||||||
SHARED_LIBS=
 | 
					 | 
				
			||||||
SHARED_LIBS_LINK_EXTS=
 | 
					 | 
				
			||||||
SHARED_LDFLAGS=
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
GENERAL=        Makefile
 | 
					GENERAL=        Makefile
 | 
				
			||||||
BASENAME=       openssl
 | 
					BASENAME=       openssl
 | 
				
			||||||
@@ -193,306 +174,53 @@ WTARFILE=       $(NAME)-win.tar
 | 
				
			|||||||
EXHEADER=       e_os.h e_os2.h
 | 
					EXHEADER=       e_os.h e_os2.h
 | 
				
			||||||
HEADER=         e_os.h
 | 
					HEADER=         e_os.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# When we're prepared to use shared libraries in the programs we link here
 | 
					all: Makefile.ssl
 | 
				
			||||||
# we might remove 'clean-shared' from the targets to perform at this stage
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
 | 
						do \
 | 
				
			||||||
all: clean-shared Makefile.ssl sub_all
 | 
						(cd $$i && echo "making all in $$i..." && \
 | 
				
			||||||
 | 
						$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \
 | 
				
			||||||
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
sub_all:
 | 
					sub_all:
 | 
				
			||||||
	@for i in $(DIRS); \
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making all in $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making all in $$i..." && \
 | 
						$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' all ) || exit 1; \
 | 
				
			||||||
		$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PROCESSOR='${PROCESSOR}' PERL='${PERL}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' all ) || exit 1; \
 | 
						done;
 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		$(MAKE) $$i; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done; \
 | 
					 | 
				
			||||||
	if echo "$(DIRS)" | \
 | 
					 | 
				
			||||||
	    egrep '(^| )(crypto|ssl)( |$$)' > /dev/null 2>&1 && \
 | 
					 | 
				
			||||||
	   [ -n "$(SHARED_LIBS)" ]; then \
 | 
					 | 
				
			||||||
		$(MAKE) $(SHARED_LIBS); \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
libcrypto$(SHLIB_EXT): libcrypto.a
 | 
					linux-shared:
 | 
				
			||||||
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
 | 
						for i in ${SHLIBDIRS}; do \
 | 
				
			||||||
		$(MAKE) SHLIBDIRS=crypto build-shared; \
 | 
						rm -f lib$$i.a lib$$i.so \
 | 
				
			||||||
	else \
 | 
							lib$$i.so.${MAJOR} lib$$i.so.${MAJOR}.${MINOR}; \
 | 
				
			||||||
		echo "There's no support for shared libraries on this platform" >&2; \
 | 
						${MAKE} CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='-fPIC ${CFLAG}' SDIRS='${SDIRS}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' DIRS=$$i clean all || exit 1; \
 | 
				
			||||||
	fi
 | 
						( set -x; ${CC}  -shared -o lib$$i.so.${MAJOR}.${MINOR} \
 | 
				
			||||||
libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
 | 
							-Wl,-S,-soname=lib$$i.so.${MAJOR} \
 | 
				
			||||||
	@if [ "$(SHLIB_TARGET)" != "" ]; then \
 | 
					 | 
				
			||||||
		$(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		echo "There's no support for shared libraries on this platform" >&2; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
clean-shared:
 | 
					 | 
				
			||||||
	@for i in $(SHLIBDIRS); do \
 | 
					 | 
				
			||||||
		if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
 | 
					 | 
				
			||||||
			tmp="$(SHARED_LIBS_LINK_EXTS)"; \
 | 
					 | 
				
			||||||
			for j in $${tmp:-x}; do \
 | 
					 | 
				
			||||||
				( set -x; rm -f lib$$i$$j ); \
 | 
					 | 
				
			||||||
			done; \
 | 
					 | 
				
			||||||
		fi; \
 | 
					 | 
				
			||||||
		( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
 | 
					 | 
				
			||||||
		if [ "$(PLATFORM)" = "Cygwin" ]; then \
 | 
					 | 
				
			||||||
			( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
 | 
					 | 
				
			||||||
		fi; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
link-shared:
 | 
					 | 
				
			||||||
	@if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
 | 
					 | 
				
			||||||
		tmp="$(SHARED_LIBS_LINK_EXTS)"; \
 | 
					 | 
				
			||||||
		for i in $(SHLIBDIRS); do \
 | 
					 | 
				
			||||||
			prev=lib$$i$(SHLIB_EXT); \
 | 
					 | 
				
			||||||
			for j in $${tmp:-x}; do \
 | 
					 | 
				
			||||||
				( set -x; ln -f -s $$prev lib$$i$$j ); \
 | 
					 | 
				
			||||||
				prev=lib$$i$$j; \
 | 
					 | 
				
			||||||
			done; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
build-shared: clean-shared do_$(SHLIB_TARGET) link-shared
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
do_bsd-gcc-shared: do_gnu-shared
 | 
					 | 
				
			||||||
do_linux-shared: do_gnu-shared
 | 
					 | 
				
			||||||
do_gnu-shared:
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
		-shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		-Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		-Wl,-Bsymbolic \
 | 
					 | 
				
			||||||
		-Wl,--whole-archive lib$$i.a \
 | 
							-Wl,--whole-archive lib$$i.a \
 | 
				
			||||||
		-Wl,--no-whole-archive $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
							-Wl,--no-whole-archive -lc ) || exit 1; \
 | 
				
			||||||
	libs="$$libs -l$$i"; \
 | 
						rm -f lib$$i.a; make -C $$i clean || exit 1 ;\
 | 
				
			||||||
	done
 | 
						done;
 | 
				
			||||||
 | 
						@set -x; \
 | 
				
			||||||
DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
 | 
						for i in ${SHLIBDIRS}; do \
 | 
				
			||||||
	collect2=`gcc -print-prog-name=collect2 2>&1` && \
 | 
						ln -s lib$$i.so.${MAJOR}.${MINOR} lib$$i.so.${MAJOR}; \
 | 
				
			||||||
	[ -n "$$collect2" ] && \
 | 
						ln -s lib$$i.so.${MAJOR} lib$$i.so; \
 | 
				
			||||||
	my_ld=`$$collect2 --help 2>&1 | grep Usage: | sed 's/^Usage: *\([^ ][^ ]*\).*/\1/'` && \
 | 
						done;
 | 
				
			||||||
	[ -n "$$my_ld" ] && \
 | 
					 | 
				
			||||||
	$$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# For Darwin AKA Mac OS/X (dyld)
 | 
					 | 
				
			||||||
do_darwin-shared: 
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x ; ${CC} --verbose -dynamiclib -o lib$$i${SHLIB_EXT} \
 | 
					 | 
				
			||||||
		lib$$i.a $$libs -all_load -current_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		-compatibility_version ${SHLIB_MAJOR}.`echo ${SHLIB_MINOR} | cut -d. -f1` \
 | 
					 | 
				
			||||||
		-install_name ${INSTALLTOP}/lib/lib$$i${SHLIB_EXT} ) || exit 1; \
 | 
					 | 
				
			||||||
	libs="$$libs -l`basename $$i${SHLIB_EXT} .dylib`"; \
 | 
					 | 
				
			||||||
	echo "" ; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
do_cygwin-shared:
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x; ${CC}  -shared -o cyg$$i.dll \
 | 
					 | 
				
			||||||
		-Wl,-Bsymbolic \
 | 
					 | 
				
			||||||
		-Wl,--whole-archive lib$$i.a \
 | 
					 | 
				
			||||||
		-Wl,--out-implib,lib$$i.dll.a \
 | 
					 | 
				
			||||||
		-Wl,--no-whole-archive $$libs ) || exit 1; \
 | 
					 | 
				
			||||||
	libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
do_alpha-osf1-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-shared -o lib$$i.so \
 | 
					 | 
				
			||||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
					 | 
				
			||||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
 | 
					 | 
				
			||||||
# option passed to the linker.
 | 
					 | 
				
			||||||
do_tru64-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-shared -msym -o lib$$i.so \
 | 
					 | 
				
			||||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
					 | 
				
			||||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
# The difference between tru64-shared and tru64-shared-rpath is the
 | 
					 | 
				
			||||||
# -rpath ${INSTALLTOP}/lib passed to the linker.
 | 
					 | 
				
			||||||
do_tru64-shared-rpath:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-shared -msym -o lib$$i.so \
 | 
					 | 
				
			||||||
			-rpath  ${INSTALLTOP}/lib \
 | 
					 | 
				
			||||||
			-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}" \
 | 
					 | 
				
			||||||
			-all lib$$i.a -none $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
do_solaris-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
					 | 
				
			||||||
		  set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-z allextract lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# OpenServer 5 native compilers used
 | 
					 | 
				
			||||||
do_svr3-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
					 | 
				
			||||||
		  find . -name "*.o" -print > allobjs ; \
 | 
					 | 
				
			||||||
		  OBJS= ; export OBJS ; \
 | 
					 | 
				
			||||||
		  for obj in `ar t lib$$i.a` ; do \
 | 
					 | 
				
			||||||
		    OBJS="$${OBJS} `grep $$obj allobjs`" ; \
 | 
					 | 
				
			||||||
		  done ; \
 | 
					 | 
				
			||||||
		  set -x; ${CC}  -G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			$${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# UnixWare 7 and OpenUNIX 8 native compilers used
 | 
					 | 
				
			||||||
do_svr5-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( PATH=/usr/ccs/bin:$$PATH ; export PATH; \
 | 
					 | 
				
			||||||
		  find . -name "*.o" -print > allobjs ; \
 | 
					 | 
				
			||||||
		  OBJS= ; export OBJS ; \
 | 
					 | 
				
			||||||
		  for obj in `ar t lib$$i.a` ; do \
 | 
					 | 
				
			||||||
		    OBJS="$${OBJS} `grep $$obj allobjs`" ; \
 | 
					 | 
				
			||||||
		  done ; \
 | 
					 | 
				
			||||||
		  set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-G -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			$${OBJS} $$libs ${EX_LIBS} ) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
do_irix-shared:
 | 
					 | 
				
			||||||
	if ${DETECT_GNU_LD}; then \
 | 
					 | 
				
			||||||
		$(MAKE) do_gnu-shared; \
 | 
					 | 
				
			||||||
	else \
 | 
					 | 
				
			||||||
		libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
		( set -x; ${CC} ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
			-shared -o lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
			-all lib$$i.a $$libs ${EX_LIBS} -lc) || exit 1; \
 | 
					 | 
				
			||||||
		libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
do_hpux-shared:
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
		+vnocompatwarnings \
 | 
					 | 
				
			||||||
		-b -z -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		-Fl lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
	libs="$$libs -L. -l$$i"; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This assumes that GNU utilities are *not* used
 | 
					 | 
				
			||||||
do_hpux64-shared:
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x; /usr/ccs/bin/ld ${SHARED_LDFLAGS} \
 | 
					 | 
				
			||||||
		-b -z -o lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR} \
 | 
					 | 
				
			||||||
		+forceload lib$$i.a $$libs ${EX_LIBS} -lc ) || exit 1; \
 | 
					 | 
				
			||||||
	libs="$$libs -L. -l$$i"; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# The following method is said to work on all platforms.  Tests will
 | 
					 | 
				
			||||||
# determine if that's how it's gong to be used.
 | 
					 | 
				
			||||||
# This assumes that for all but GNU systems, GNU utilities are *not* used.
 | 
					 | 
				
			||||||
# ALLSYMSFLAGS would be:
 | 
					 | 
				
			||||||
#  GNU systems: --whole-archive
 | 
					 | 
				
			||||||
#  Tru64 Unix:  -all
 | 
					 | 
				
			||||||
#  Solaris:     -z allextract
 | 
					 | 
				
			||||||
#  Irix:        -all
 | 
					 | 
				
			||||||
#  HP/UX-32bit: -Fl
 | 
					 | 
				
			||||||
#  HP/UX-64bit: +forceload
 | 
					 | 
				
			||||||
#  AIX:		-bnogc
 | 
					 | 
				
			||||||
# SHAREDFLAGS would be:
 | 
					 | 
				
			||||||
#  GNU systems: -shared -Wl,-soname=lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
					 | 
				
			||||||
#  Tru64 Unix:  -shared \
 | 
					 | 
				
			||||||
#		-set_version "${SHLIB_VERSION_HISTORY}${SHLIB_VERSION_NUMBER}"
 | 
					 | 
				
			||||||
#  Solaris:     -G -h lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
					 | 
				
			||||||
#  Irix:        -shared -Wl,-soname,lib$$i.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
					 | 
				
			||||||
#  HP/UX-32bit: +vnocompatwarnings -b -z +s \
 | 
					 | 
				
			||||||
#		+h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
					 | 
				
			||||||
#  HP/UX-64bit: -b -z +h lib$$i.sl.${SHLIB_MAJOR}.${SHLIB_MINOR}
 | 
					 | 
				
			||||||
#  AIX:		-G -bE:lib$$i.exp -bM:SRE
 | 
					 | 
				
			||||||
# SHAREDCMD would be:
 | 
					 | 
				
			||||||
#  GNU systems: $(CC)
 | 
					 | 
				
			||||||
#  Tru64 Unix:  $(CC)
 | 
					 | 
				
			||||||
#  Solaris:     $(CC)
 | 
					 | 
				
			||||||
#  Irix:        $(CC)
 | 
					 | 
				
			||||||
#  HP/UX-32bit: /usr/ccs/bin/ld
 | 
					 | 
				
			||||||
#  HP/UX-64bit: /usr/ccs/bin/ld
 | 
					 | 
				
			||||||
#  AIX:		$(CC)
 | 
					 | 
				
			||||||
ALLSYMSFLAG=-bnogc
 | 
					 | 
				
			||||||
SHAREDFLAGS=${SHARED_LDFLAGS} -G -bE:lib$$i.exp -bM:SRE
 | 
					 | 
				
			||||||
SHAREDCMD=$(CC)
 | 
					 | 
				
			||||||
do_aix-shared:
 | 
					 | 
				
			||||||
	libs='-L. ${SHLIBDEPS}'; for i in ${SHLIBDIRS}; do \
 | 
					 | 
				
			||||||
	( set -x; \
 | 
					 | 
				
			||||||
	  ld -r -o $$i.o $(ALLSYMSFLAG) lib$$i.a && \
 | 
					 | 
				
			||||||
	  ( nm -Pg lib$$i.o | grep ' [BD] ' | cut -f1 -d' ' > lib$$i.exp; \
 | 
					 | 
				
			||||||
	    $(SHAREDCMD) $(SHAREDFLAG) -o lib$$i.so lib$$i.o \
 | 
					 | 
				
			||||||
		$$libs ${EX_LIBS} ) ) \
 | 
					 | 
				
			||||||
	|| exit 1; \
 | 
					 | 
				
			||||||
	libs="$$libs -l$$i"; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Makefile.ssl: Makefile.org
 | 
					Makefile.ssl: Makefile.org
 | 
				
			||||||
	@echo "Makefile.ssl is older than Makefile.org."
 | 
						@echo "Makefile.ssl is older than Makefile.org."
 | 
				
			||||||
	@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
 | 
						@echo "Reconfigure the source tree (via 'perl Configure' or 'sh config')"
 | 
				
			||||||
 | 
						@echo "and update the error lists (via 'make errors'), please."
 | 
				
			||||||
	@false
 | 
						@false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libclean:
 | 
					libclean:
 | 
				
			||||||
	rm -f *.a */lib */*/lib
 | 
						rm -f *.a */lib */*/lib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean:
 | 
					clean:
 | 
				
			||||||
	rm -f shlib/*.o *.o core a.out fluff *.map rehash.time testlog make.log cctest cctest.c
 | 
						rm -f shlib/*.o *.o core a.out fluff *.map
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making clean in $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making clean in $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' clean ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' clean ) || exit 1; \
 | 
						rm -f $(LIBS); \
 | 
				
			||||||
		rm -f $(LIBS); \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
	rm -f *.a *.o speed.* *.map *.so .pure core
 | 
						rm -f *.a *.o speed.* *.map *.so .pure core
 | 
				
			||||||
	rm -f $(TARFILE)
 | 
						rm -f $(TARFILE)
 | 
				
			||||||
@@ -509,101 +237,64 @@ files:
 | 
				
			|||||||
	$(PERL) $(TOP)/util/files.pl Makefile.ssl > $(TOP)/MINFO
 | 
						$(PERL) $(TOP)/util/files.pl Makefile.ssl > $(TOP)/MINFO
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making 'files' in $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making 'files' in $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' files ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' files ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
links:
 | 
					links:
 | 
				
			||||||
	@$(TOP)/util/point.sh Makefile.ssl Makefile
 | 
						@$(TOP)/util/point.sh Makefile.ssl Makefile
 | 
				
			||||||
	@$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
 | 
						@-mkdir -p include/openssl 2>/dev/null
 | 
				
			||||||
	@$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
 | 
						@$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
 | 
				
			||||||
	@for i in $(DIRS); do \
 | 
						@for i in $(DIRS); do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making links in $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making links in $$i..." && \
 | 
						$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' links ) || exit 1; \
 | 
				
			||||||
		$(MAKE) CC='${CC}' PLATFORM='${PLATFORM}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' links ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dclean:
 | 
					dclean:
 | 
				
			||||||
	rm -f *.bak
 | 
						rm -f *.bak
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making dclean in $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making dclean in $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' dclean ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' PERL='${PERL}' dclean ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rehash: rehash.time
 | 
					rehash:
 | 
				
			||||||
rehash.time: certs
 | 
						@(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; sh tools/c_rehash certs)
 | 
				
			||||||
	@(OPENSSL="`pwd`/apps/openssl"; export OPENSSL; $(PERL) tools/c_rehash certs)
 | 
					 | 
				
			||||||
	touch rehash.time
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
test:   tests
 | 
					test:   tests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tests: rehash
 | 
					tests: rehash
 | 
				
			||||||
	@(cd test && echo "testing..." && \
 | 
						@(cd test && echo "testing..." && \
 | 
				
			||||||
	$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' PERL='${PERL}' EXE_EXT='${EXE_EXT}' tests );
 | 
						$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_ASM='${BN_ASM}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' tests );
 | 
				
			||||||
	@apps/openssl version -a
 | 
						@apps/openssl version -a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
report:
 | 
					 | 
				
			||||||
	@$(PERL) util/selftest.pl
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
depend:
 | 
					depend:
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making dependancies $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making dependencies $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' depend ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' DEPFLAG='${DEPFLAG}' depend ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
lint:
 | 
					lint:
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making lint $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making lint $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' lint ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' lint ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tags:
 | 
					tags:
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i && echo "making tags $$i..." && \
 | 
				
			||||||
		(cd $$i && echo "making tags $$i..." && \
 | 
						$(MAKE) SDIRS='${SDIRS}' tags ) || exit 1; \
 | 
				
			||||||
		$(MAKE) SDIRS='${SDIRS}' tags ) || exit 1; \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done;
 | 
						done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
errors:
 | 
					errors:
 | 
				
			||||||
	$(PERL) util/mkerr.pl -recurse -write
 | 
						perl util/mkerr.pl -recurse -write
 | 
				
			||||||
 | 
					 | 
				
			||||||
stacks:
 | 
					 | 
				
			||||||
	$(PERL) util/mkstack.pl -write
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
util/libeay.num::
 | 
					 | 
				
			||||||
	$(PERL) util/mkdef.pl crypto update
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
util/ssleay.num::
 | 
					 | 
				
			||||||
	$(PERL) util/mkdef.pl ssl update
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
crypto/objects/obj_dat.h: crypto/objects/obj_mac.h crypto/objects/obj_dat.pl
 | 
					 | 
				
			||||||
	$(PERL) crypto/objects/obj_dat.pl crypto/objects/obj_mac.h crypto/objects/obj_dat.h
 | 
					 | 
				
			||||||
crypto/objects/obj_mac.h: crypto/objects/objects.pl crypto/objects/objects.txt 
 | 
					 | 
				
			||||||
	$(PERL) crypto/objects/objects.pl crypto/objects/objects.txt crypto/objects/obj_mac.num crypto/objects/obj_mac.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TABLE: Configure
 | 
					 | 
				
			||||||
	(echo 'Output of `Configure TABLE'"':"; \
 | 
					 | 
				
			||||||
	$(PERL) Configure TABLE) > TABLE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
update: depend errors stacks util/libeay.num util/ssleay.num crypto/objects/obj_dat.h TABLE
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
tar:
 | 
					tar:
 | 
				
			||||||
	@$(TAR) $(TARFLAGS) -cvf - \
 | 
						@tar --norecurse -cvf - \
 | 
				
			||||||
		`find * \! -path CVS/\* \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS \! -name TABLE | sort` |\
 | 
							`find * -depth \! -path \*/CVS/\* \! -name CVS \! -name .cvsignore \! -name STATUS | sort` |\
 | 
				
			||||||
	tardy --user_number=0  --user_name=openssl \
 | 
						tardy --user_number=0  --user_name=openssl \
 | 
				
			||||||
	      --group_number=0 --group_name=openssl \
 | 
						      --group_number=0 --group_name=openssl \
 | 
				
			||||||
	      --prefix=openssl-$(VERSION) - |\
 | 
						      --prefix=openssl-$(VERSION) - |\
 | 
				
			||||||
@@ -619,14 +310,14 @@ dist:
 | 
				
			|||||||
dist_pem_h:
 | 
					dist_pem_h:
 | 
				
			||||||
	(cd crypto/pem; $(MAKE) CC='${CC}' SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean)
 | 
						(cd crypto/pem; $(MAKE) CC='${CC}' SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install: all install_docs
 | 
					install: all
 | 
				
			||||||
	@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(INSTALLTOP)/bin 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(INSTALLTOP)/lib \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(INSTALLTOP)/lib 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(OPENSSLDIR)/misc 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(OPENSSLDIR)/certs 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/private \
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(OPENSSLDIR)/private 2>/dev/null
 | 
				
			||||||
		$(INSTALL_PREFIX)$(OPENSSLDIR)/lib
 | 
						@-mkdir -p $(INSTALL_PREFIX)$(OPENSSLDIR)/lib 2>/dev/null
 | 
				
			||||||
	@for i in $(EXHEADER) ;\
 | 
						@for i in $(EXHEADER) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
 | 
						(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
 | 
				
			||||||
@@ -634,66 +325,15 @@ install: all install_docs
 | 
				
			|||||||
	done;
 | 
						done;
 | 
				
			||||||
	@for i in $(DIRS) ;\
 | 
						@for i in $(DIRS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
	if [ -d "$$i" ]; then \
 | 
						(cd $$i; echo "installing $$i..."; \
 | 
				
			||||||
		(cd $$i; echo "installing $$i..."; \
 | 
						$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' install ); \
 | 
				
			||||||
		$(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALL_PREFIX='${INSTALL_PREFIX}' INSTALLTOP='${INSTALLTOP}' OPENSSLDIR='${OPENSSLDIR}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' RANLIB='${RANLIB}' EXE_EXT='${EXE_EXT}' install ); \
 | 
					 | 
				
			||||||
	fi; \
 | 
					 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
	@for i in $(LIBS) ;\
 | 
						@for i in $(LIBS) ;\
 | 
				
			||||||
	do \
 | 
						do \
 | 
				
			||||||
		if [ -f "$$i" ]; then \
 | 
						(       echo installing $$i; \
 | 
				
			||||||
		(       echo installing $$i; \
 | 
							cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
 | 
				
			||||||
			cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
 | 
							$(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
 | 
				
			||||||
			$(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
 | 
							chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
 | 
				
			||||||
			chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i ); \
 | 
					 | 
				
			||||||
		fi \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
	@if [ -n "$(SHARED_LIBS)" ]; then \
 | 
					 | 
				
			||||||
		tmp="$(SHARED_LIBS)"; \
 | 
					 | 
				
			||||||
		for i in $${tmp:-x}; \
 | 
					 | 
				
			||||||
		do \
 | 
					 | 
				
			||||||
			if [ -f "$$i" -o -f "$$i.a" ]; then \
 | 
					 | 
				
			||||||
			(       echo installing $$i; \
 | 
					 | 
				
			||||||
				if [ "$(PLATFORM)" != "Cygwin" ]; then \
 | 
					 | 
				
			||||||
					cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
 | 
					 | 
				
			||||||
					chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i; \
 | 
					 | 
				
			||||||
				else \
 | 
					 | 
				
			||||||
					c=`echo $$i | sed 's/^lib/cyg/'`; \
 | 
					 | 
				
			||||||
					cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
 | 
					 | 
				
			||||||
					chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
 | 
					 | 
				
			||||||
					cp $$i.a $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
 | 
					 | 
				
			||||||
					chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/lib/$$i.a; \
 | 
					 | 
				
			||||||
				fi ); \
 | 
					 | 
				
			||||||
			fi \
 | 
					 | 
				
			||||||
		done; \
 | 
					 | 
				
			||||||
		(	here="`pwd`"; \
 | 
					 | 
				
			||||||
			cd $(INSTALL_PREFIX)$(INSTALLTOP)/lib; \
 | 
					 | 
				
			||||||
			make -f $$here/Makefile link-shared ); \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
install_docs:
 | 
					 | 
				
			||||||
	@$(PERL) $(TOP)/util/mkdir-p.pl \
 | 
					 | 
				
			||||||
		$(INSTALL_PREFIX)$(MANDIR)/man1 \
 | 
					 | 
				
			||||||
		$(INSTALL_PREFIX)$(MANDIR)/man3 \
 | 
					 | 
				
			||||||
		$(INSTALL_PREFIX)$(MANDIR)/man5 \
 | 
					 | 
				
			||||||
		$(INSTALL_PREFIX)$(MANDIR)/man7
 | 
					 | 
				
			||||||
	@for i in doc/apps/*.pod; do \
 | 
					 | 
				
			||||||
		fn=`basename $$i .pod`; \
 | 
					 | 
				
			||||||
		if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \
 | 
					 | 
				
			||||||
		echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
 | 
					 | 
				
			||||||
		(cd `dirname $$i`; \
 | 
					 | 
				
			||||||
		$(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
 | 
					 | 
				
			||||||
			 --release=$(VERSION) `basename $$i`) \
 | 
					 | 
				
			||||||
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
	@for i in doc/crypto/*.pod doc/ssl/*.pod; do \
 | 
					 | 
				
			||||||
		fn=`basename $$i .pod`; \
 | 
					 | 
				
			||||||
		if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \
 | 
					 | 
				
			||||||
		echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
 | 
					 | 
				
			||||||
		(cd `dirname $$i`; \
 | 
					 | 
				
			||||||
		$(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
 | 
					 | 
				
			||||||
			--release=$(VERSION) `basename $$i`) \
 | 
					 | 
				
			||||||
			>  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
 | 
					 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
 | 
					# DO NOT DELETE THIS LINE -- make depend depends on it.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										131
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								NEWS
									
									
									
									
									
								
							@@ -5,137 +5,6 @@
 | 
				
			|||||||
  This file gives a brief overview of the major changes between each OpenSSL
 | 
					  This file gives a brief overview of the major changes between each OpenSSL
 | 
				
			||||||
  release. For more details please read the CHANGES file.
 | 
					  release. For more details please read the CHANGES file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Changes between OpenSSL 0.9.6c and OpenSSL 0.9.6d:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Various SSL/TLS library bugfixes.
 | 
					 | 
				
			||||||
      o Fix DH parameter generation for 'non-standard' generators.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Changes between OpenSSL 0.9.6b and OpenSSL 0.9.6c:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Various SSL/TLS library bugfixes.
 | 
					 | 
				
			||||||
      o BIGNUM library fixes.
 | 
					 | 
				
			||||||
      o RSA OAEP and random number generation fixes.
 | 
					 | 
				
			||||||
      o Object identifiers corrected and added.
 | 
					 | 
				
			||||||
      o Add assembler BN routines for IA64.
 | 
					 | 
				
			||||||
      o Add support for OS/390 Unix, UnixWare with gcc, OpenUNIX 8,
 | 
					 | 
				
			||||||
        MIPS Linux; shared library support for Irix, HP-UX.
 | 
					 | 
				
			||||||
      o Add crypto accelerator support for AEP, Baltimore SureWare,
 | 
					 | 
				
			||||||
        Broadcom and Cryptographic Appliance's keyserver
 | 
					 | 
				
			||||||
        [in 0.9.6c-engine release].
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Changes between OpenSSL 0.9.6a and OpenSSL 0.9.6b:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Security fix: PRNG improvements.
 | 
					 | 
				
			||||||
      o Security fix: RSA OAEP check.
 | 
					 | 
				
			||||||
      o Security fix: Reinsert and fix countermeasure to Bleichbacher's
 | 
					 | 
				
			||||||
        attack.
 | 
					 | 
				
			||||||
      o MIPS bug fix in BIGNUM.
 | 
					 | 
				
			||||||
      o Bug fix in "openssl enc".
 | 
					 | 
				
			||||||
      o Bug fix in X.509 printing routine.
 | 
					 | 
				
			||||||
      o Bug fix in DSA verification routine and DSA S/MIME verification.
 | 
					 | 
				
			||||||
      o Bug fix to make PRNG thread-safe.
 | 
					 | 
				
			||||||
      o Bug fix in RAND_file_name().
 | 
					 | 
				
			||||||
      o Bug fix in compatibility mode trust settings.
 | 
					 | 
				
			||||||
      o Bug fix in blowfish EVP.
 | 
					 | 
				
			||||||
      o Increase default size for BIO buffering filter.
 | 
					 | 
				
			||||||
      o Compatibility fixes in some scripts.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.6 and OpenSSL 0.9.6a:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Security fix: change behavior of OpenSSL to avoid using
 | 
					 | 
				
			||||||
        environment variables when running as root.
 | 
					 | 
				
			||||||
      o Security fix: check the result of RSA-CRT to reduce the
 | 
					 | 
				
			||||||
        possibility of deducing the private key from an incorrectly
 | 
					 | 
				
			||||||
        calculated signature.
 | 
					 | 
				
			||||||
      o Security fix: prevent Bleichenbacher's DSA attack.
 | 
					 | 
				
			||||||
      o Security fix: Zero the premaster secret after deriving the
 | 
					 | 
				
			||||||
        master secret in DH ciphersuites.
 | 
					 | 
				
			||||||
      o Reimplement SSL_peek(), which had various problems.
 | 
					 | 
				
			||||||
      o Compatibility fix: the function des_encrypt() renamed to
 | 
					 | 
				
			||||||
        des_encrypt1() to avoid clashes with some Unixen libc.
 | 
					 | 
				
			||||||
      o Bug fixes for Win32, HP/UX and Irix.
 | 
					 | 
				
			||||||
      o Bug fixes in BIGNUM, SSL, PKCS#7, PKCS#12, X.509, CONF and
 | 
					 | 
				
			||||||
        memory checking routines.
 | 
					 | 
				
			||||||
      o Bug fixes for RSA operations in threaded enviroments.
 | 
					 | 
				
			||||||
      o Bug fixes in misc. openssl applications.
 | 
					 | 
				
			||||||
      o Remove a few potential memory leaks.
 | 
					 | 
				
			||||||
      o Add tighter checks of BIGNUM routines.
 | 
					 | 
				
			||||||
      o Shared library support has been reworked for generality.
 | 
					 | 
				
			||||||
      o More documentation.
 | 
					 | 
				
			||||||
      o New function BN_rand_range().
 | 
					 | 
				
			||||||
      o Add "-rand" option to openssl s_client and s_server.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.5a and OpenSSL 0.9.6:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Some documentation for BIO and SSL libraries.
 | 
					 | 
				
			||||||
      o Enhanced chain verification using key identifiers.
 | 
					 | 
				
			||||||
      o New sign and verify options to 'dgst' application.
 | 
					 | 
				
			||||||
      o Support for DER and PEM encoded messages in 'smime' application.
 | 
					 | 
				
			||||||
      o New 'rsautl' application, low level RSA utility.
 | 
					 | 
				
			||||||
      o MD4 now included.
 | 
					 | 
				
			||||||
      o Bugfix for SSL rollback padding check.
 | 
					 | 
				
			||||||
      o Support for external crypto devices [1].
 | 
					 | 
				
			||||||
      o Enhanced EVP interface.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    [1] The support for external crypto devices is currently a separate
 | 
					 | 
				
			||||||
        distribution.  See the file README.ENGINE.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8 
 | 
					 | 
				
			||||||
      o Shared library support for HPUX and Solaris-gcc
 | 
					 | 
				
			||||||
      o Support of Linux/IA64
 | 
					 | 
				
			||||||
      o Assembler support for Mingw32
 | 
					 | 
				
			||||||
      o New 'rand' application
 | 
					 | 
				
			||||||
      o New way to check for existence of algorithms from scripts
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.4 and OpenSSL 0.9.5:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o S/MIME support in new 'smime' command
 | 
					 | 
				
			||||||
      o Documentation for the OpenSSL command line application
 | 
					 | 
				
			||||||
      o Automation of 'req' application
 | 
					 | 
				
			||||||
      o Fixes to make s_client, s_server work under Windows
 | 
					 | 
				
			||||||
      o Support for multiple fieldnames in SPKACs
 | 
					 | 
				
			||||||
      o New SPKAC command line utilty and associated library functions
 | 
					 | 
				
			||||||
      o Options to allow passwords to be obtained from various sources
 | 
					 | 
				
			||||||
      o New public key PEM format and options to handle it
 | 
					 | 
				
			||||||
      o Many other fixes and enhancements to command line utilities
 | 
					 | 
				
			||||||
      o Usable certificate chain verification
 | 
					 | 
				
			||||||
      o Certificate purpose checking
 | 
					 | 
				
			||||||
      o Certificate trust settings
 | 
					 | 
				
			||||||
      o Support of authority information access extension
 | 
					 | 
				
			||||||
      o Extensions in certificate requests
 | 
					 | 
				
			||||||
      o Simplified X509 name and attribute routines
 | 
					 | 
				
			||||||
      o Initial (incomplete) support for international character sets
 | 
					 | 
				
			||||||
      o New DH_METHOD, DSA_METHOD and enhanced RSA_METHOD
 | 
					 | 
				
			||||||
      o Read only memory BIOs and simplified creation function
 | 
					 | 
				
			||||||
      o TLS/SSL protocol bugfixes: Accept TLS 'client hello' in SSL 3.0
 | 
					 | 
				
			||||||
        record; allow fragmentation and interleaving of handshake and other
 | 
					 | 
				
			||||||
        data
 | 
					 | 
				
			||||||
      o TLS/SSL code now "tolerates" MS SGC
 | 
					 | 
				
			||||||
      o Work around for Netscape client certificate hang bug
 | 
					 | 
				
			||||||
      o RSA_NULL option that removes RSA patent code but keeps other
 | 
					 | 
				
			||||||
        RSA functionality
 | 
					 | 
				
			||||||
      o Memory leak detection now allows applications to add extra information
 | 
					 | 
				
			||||||
        via a per-thread stack
 | 
					 | 
				
			||||||
      o PRNG robustness improved
 | 
					 | 
				
			||||||
      o EGD support
 | 
					 | 
				
			||||||
      o BIGNUM library bug fixes
 | 
					 | 
				
			||||||
      o Faster DSA parameter generation
 | 
					 | 
				
			||||||
      o Enhanced support for Alpha Linux
 | 
					 | 
				
			||||||
      o Experimental MacOS support
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.3 and OpenSSL 0.9.4:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o Transparent support for PKCS#8 format private keys: these are used
 | 
					 | 
				
			||||||
        by several software packages and are more secure than the standard
 | 
					 | 
				
			||||||
        form
 | 
					 | 
				
			||||||
      o PKCS#5 v2.0 implementation
 | 
					 | 
				
			||||||
      o Password callbacks have a new void * argument for application data
 | 
					 | 
				
			||||||
      o Avoid various memory leaks
 | 
					 | 
				
			||||||
      o New pipe-like BIO that allows using the SSL library when actual I/O
 | 
					 | 
				
			||||||
        must be handled by the application (BIO pair)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3:
 | 
					  Major changes between OpenSSL 0.9.2b and OpenSSL 0.9.3:
 | 
				
			||||||
      o Lots of enhancements and cleanups to the Configuration mechanism
 | 
					      o Lots of enhancements and cleanups to the Configuration mechanism
 | 
				
			||||||
      o RSA OEAP related fixes
 | 
					      o RSA OEAP related fixes
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										121
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										121
									
								
								README
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 OpenSSL 0.9.6d-beta1 [engine] 17 Apr 2002
 | 
					 OpenSSL 0.9.2b 22-Mar-1999
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Copyright (c) 1998-2002 The OpenSSL Project
 | 
					 Copyright (c) 1998-1999 The OpenSSL Project
 | 
				
			||||||
 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
 | 
					 Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
 | 
				
			||||||
 All rights reserved.
 | 
					 All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -11,10 +11,9 @@
 | 
				
			|||||||
 The OpenSSL Project is a collaborative effort to develop a robust,
 | 
					 The OpenSSL Project is a collaborative effort to develop a robust,
 | 
				
			||||||
 commercial-grade, fully featured, and Open Source toolkit implementing the
 | 
					 commercial-grade, fully featured, and Open Source toolkit implementing the
 | 
				
			||||||
 Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1)
 | 
					 Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1)
 | 
				
			||||||
 protocols as well as a full-strength general purpose cryptography library.
 | 
					 protocols with full-strength cryptography world-wide. The project is managed
 | 
				
			||||||
 The project is managed by a worldwide community of volunteers that use the
 | 
					 by a worldwide community of volunteers that use the Internet to communicate,
 | 
				
			||||||
 Internet to communicate, plan, and develop the OpenSSL toolkit and its
 | 
					 plan, and develop the OpenSSL toolkit and its related documentation. 
 | 
				
			||||||
 related documentation. 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 OpenSSL is based on the excellent SSLeay library developed from Eric A. Young
 | 
					 OpenSSL is based on the excellent SSLeay library developed from Eric A. Young
 | 
				
			||||||
 and Tim J. Hudson.  The OpenSSL toolkit is licensed under a dual-license (the
 | 
					 and Tim J. Hudson.  The OpenSSL toolkit is licensed under a dual-license (the
 | 
				
			||||||
@@ -62,7 +61,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
     X.509v3 certificates
 | 
					     X.509v3 certificates
 | 
				
			||||||
        X509 encoding/decoding into/from binary ASN1 and a PEM
 | 
					        X509 encoding/decoding into/from binary ASN1 and a PEM
 | 
				
			||||||
             based ASCII-binary encoding which supports encryption with a
 | 
					             based ascii-binary encoding which supports encryption with a
 | 
				
			||||||
             private key.  Program to generate RSA and DSA certificate
 | 
					             private key.  Program to generate RSA and DSA certificate
 | 
				
			||||||
             requests and to generate RSA and DSA certificates.
 | 
					             requests and to generate RSA and DSA certificates.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -81,14 +80,40 @@
 | 
				
			|||||||
        A Configuration loader that uses a format similar to MS .ini files.
 | 
					        A Configuration loader that uses a format similar to MS .ini files.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 openssl: 
 | 
					 openssl: 
 | 
				
			||||||
     A command line tool that can be used for:
 | 
					     A command line tool which provides the following functions:
 | 
				
			||||||
        Creation of RSA, DH and DSA key parameters
 | 
					 | 
				
			||||||
        Creation of X.509 certificates, CSRs and CRLs 
 | 
					 | 
				
			||||||
        Calculation of Message Digests
 | 
					 | 
				
			||||||
        Encryption and Decryption with Ciphers
 | 
					 | 
				
			||||||
        SSL/TLS Client and Server Tests
 | 
					 | 
				
			||||||
        Handling of S/MIME signed or encrypted mail
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     enc     - a general encryption program that can encrypt/decrypt using
 | 
				
			||||||
 | 
					               one of 17 different cipher/mode combinations.  The
 | 
				
			||||||
 | 
					               input/output can also be converted to/from base64
 | 
				
			||||||
 | 
					               ascii encoding.
 | 
				
			||||||
 | 
					     dgst    - a generate message digesting program that will generate
 | 
				
			||||||
 | 
					               message digests for any of md2, md5, sha (sha-0 or sha-1)
 | 
				
			||||||
 | 
					               or mdc2.
 | 
				
			||||||
 | 
					     asn1parse - parse and display the structure of an asn1 encoded
 | 
				
			||||||
 | 
					               binary file.
 | 
				
			||||||
 | 
					     rsa     - Manipulate RSA private keys.
 | 
				
			||||||
 | 
					     dsa     - Manipulate DSA private keys.
 | 
				
			||||||
 | 
					     dh      - Manipulate Diffie-Hellman parameter files.
 | 
				
			||||||
 | 
					     dsaparam- Manipulate and generate DSA parameter files.
 | 
				
			||||||
 | 
					     crl     - Manipulate certificate revocation lists.
 | 
				
			||||||
 | 
					     crt2pkcs7- Generate a pkcs7 object containing a crl and a certificate.
 | 
				
			||||||
 | 
					     x509    - Manipulate x509 certificates, self-sign certificates.
 | 
				
			||||||
 | 
					     req     - Manipulate PKCS#10 certificate requests and also
 | 
				
			||||||
 | 
					               generate certificate requests.
 | 
				
			||||||
 | 
					     genrsa  - Generates an arbitrary sized RSA private key.
 | 
				
			||||||
 | 
					     gendsa  - Generates DSA parameters.
 | 
				
			||||||
 | 
					     gendh   - Generates a set of Diffie-Hellman parameters, the prime
 | 
				
			||||||
 | 
					               will be a strong prime.
 | 
				
			||||||
 | 
					     ca      - Create certificates from PKCS#10 certificate requests.
 | 
				
			||||||
 | 
					               This program also maintains a database of certificates
 | 
				
			||||||
 | 
					               issued.
 | 
				
			||||||
 | 
					     verify  - Check x509 certificate signatures.
 | 
				
			||||||
 | 
					     speed   - Benchmark OpenSSL's ciphers.
 | 
				
			||||||
 | 
					     s_server- A test SSL server.
 | 
				
			||||||
 | 
					     s_client- A test SSL client.
 | 
				
			||||||
 | 
					     s_time  - Benchmark SSL performance of SSL server programs.
 | 
				
			||||||
 | 
					     errstr  - Convert from OpenSSL hex error codes to a readable form.
 | 
				
			||||||
 | 
					     nseq    - Netscape certificate sequence utility
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 PATENTS
 | 
					 PATENTS
 | 
				
			||||||
 -------
 | 
					 -------
 | 
				
			||||||
@@ -97,18 +122,19 @@
 | 
				
			|||||||
 locations around the world. _YOU_ are responsible for ensuring that your use
 | 
					 locations around the world. _YOU_ are responsible for ensuring that your use
 | 
				
			||||||
 of any algorithms is legal by checking if there are any patents in your
 | 
					 of any algorithms is legal by checking if there are any patents in your
 | 
				
			||||||
 country.  The file contains some of the patents that we know about or are
 | 
					 country.  The file contains some of the patents that we know about or are
 | 
				
			||||||
 rumored to exist. This is not a definitive list.
 | 
					 rumoured to exist. This is not a definitive list.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 RSA Security holds software patents on the RC5 algorithm.  If you
 | 
					 RSA Data Security holds software patents on the RSA and RC5 algorithms.  If
 | 
				
			||||||
 intend to use this cipher, you must contact RSA Security for
 | 
					 their ciphers are used used inside the USA (and Japan?), you must contact RSA
 | 
				
			||||||
 licensing conditions. Their web page is http://www.rsasecurity.com/.
 | 
					 Data Security for licensing conditions. Their web page is
 | 
				
			||||||
 | 
					 http://www.rsa.com/.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 RC4 is a trademark of RSA Security, so use of this label should perhaps
 | 
					 RC4 is a trademark of RSA Data Security, so use of this label should perhaps
 | 
				
			||||||
 only be used with RSA Security's permission. 
 | 
					 only be used with RSA Data Security's permission. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy,
 | 
					 The IDEA algorithm is patented by Ascom in Austria, France, Germany, Italy,
 | 
				
			||||||
 Japan, the Netherlands, Spain, Sweden, Switzerland, UK and the USA.  They
 | 
					 Japan, Netherlands, Spain, Sweden, Switzerland, UK and the USA.  They should
 | 
				
			||||||
 should be contacted if that algorithm is to be used; their web page is
 | 
					 be contacted if that algorithm is to be used, their web page is
 | 
				
			||||||
 http://www.ascom.ch/.
 | 
					 http://www.ascom.ch/.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 INSTALLATION
 | 
					 INSTALLATION
 | 
				
			||||||
@@ -118,9 +144,12 @@
 | 
				
			|||||||
 a Win32 platform, read the INSTALL.W32 file.  For OpenVMS systems, read
 | 
					 a Win32 platform, read the INSTALL.W32 file.  For OpenVMS systems, read
 | 
				
			||||||
 INSTALL.VMS.
 | 
					 INSTALL.VMS.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 For people in the USA, it is possible to compile OpenSSL to use RSA Inc.'s
 | 
				
			||||||
 | 
					 public key library, RSAREF, by configuring OpenSSL with the option "rsaref".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Read the documentation in the doc/ directory.  It is quite rough, but it
 | 
					 Read the documentation in the doc/ directory.  It is quite rough, but it
 | 
				
			||||||
 lists the functions; you will probably have to look at the code to work out
 | 
					 lists the functions, you will probably have to look at the code to work out
 | 
				
			||||||
 how to use them. Look at the example programs.
 | 
					 how to used them. Look at the example programs.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 SUPPORT 
 | 
					 SUPPORT 
 | 
				
			||||||
 -------
 | 
					 -------
 | 
				
			||||||
@@ -128,43 +157,43 @@
 | 
				
			|||||||
 If you have any problems with OpenSSL then please take the following steps
 | 
					 If you have any problems with OpenSSL then please take the following steps
 | 
				
			||||||
 first:
 | 
					 first:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - Download the current snapshot from ftp://ftp.openssl.org/snapshot/
 | 
					 | 
				
			||||||
      to see if the problem has already been addressed
 | 
					 | 
				
			||||||
    - Remove ASM versions of libraries
 | 
					    - Remove ASM versions of libraries
 | 
				
			||||||
    - Remove compiler optimisation flags 
 | 
					    - Remove compiler optimisation flags 
 | 
				
			||||||
 | 
					    - Add compiler debug flags (if using gcc then remove -fomit-frame-pointer
 | 
				
			||||||
 | 
					      before you try to debug things)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 If you wish to report a bug then please include the following information in
 | 
					 If you wish to report a bug then please include the following information in
 | 
				
			||||||
 any bug report:
 | 
					 any bug report:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - On Unix systems:
 | 
					    OpenSSL Details
 | 
				
			||||||
        Self-test report generated by 'make report'
 | 
					    - Version, most of these details can be got from the
 | 
				
			||||||
    - On other systems:
 | 
					      'openssl version -a' command.
 | 
				
			||||||
        OpenSSL version: output of 'openssl version -a'
 | 
					    Operating System Details
 | 
				
			||||||
        OS Name, Version, Hardware platform
 | 
					    - On Unix systems: Output of './config -t'
 | 
				
			||||||
        Compiler Details (name, version)
 | 
					    - OS Name, Version
 | 
				
			||||||
    - Application Details (name, version)
 | 
					    - Hardware platform
 | 
				
			||||||
    - Problem Description (steps that will reproduce the problem, if known)
 | 
					    Compiler Details
 | 
				
			||||||
    - Stack Traceback (if the application dumps core)
 | 
					    - Name
 | 
				
			||||||
 | 
					    - Version
 | 
				
			||||||
 | 
					    Application Details 
 | 
				
			||||||
 | 
					    - Name 
 | 
				
			||||||
 | 
					    - Version 
 | 
				
			||||||
 | 
					    Problem Description
 | 
				
			||||||
 | 
					    - include steps that will reproduce the problem (if known)
 | 
				
			||||||
 | 
					    Stack Traceback (if the application dumps core)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Report the bug to the OpenSSL project at:
 | 
					 Report the bug to the OpenSSL project at:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    openssl-bugs@openssl.org
 | 
					    openssl-bugs@openssl.org
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Note that mail to openssl-bugs@openssl.org is forwarded to a public
 | 
					 | 
				
			||||||
 mailing list. Confidential mail may be sent to openssl-security@openssl.org
 | 
					 | 
				
			||||||
 (PGP key available from the key servers).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 HOW TO CONTRIBUTE TO OpenSSL
 | 
					 HOW TO CONTRIBUTE TO OpenSSL
 | 
				
			||||||
 ----------------------------
 | 
					 ----------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Development is coordinated on the openssl-dev mailing list (see
 | 
					 Development is coordinated on the openssl-dev mailing list (see
 | 
				
			||||||
 http://www.openssl.org for information on subscribing). If you
 | 
					 http://www.openssl.org for information on subscribing). If you
 | 
				
			||||||
 would like to submit a patch, send it to openssl-dev@openssl.org with
 | 
					 would like to submit a patch, send it to openssl-dev@openssl.org.
 | 
				
			||||||
 the string "[PATCH]" in the subject. Please be sure to include a
 | 
					 Please be sure to include a textual explanation of what your patch
 | 
				
			||||||
 textual explanation of what your patch does.
 | 
					 does.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 Note: For legal reasons, contributions from the US can be accepted only
 | 
					 | 
				
			||||||
 if a copy of the patch is sent to crypt@bxa.doc.gov
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 The preferred format for changes is "diff -u" output. You might
 | 
					 The preferred format for changes is "diff -u" output. You might
 | 
				
			||||||
 generate it like this:
 | 
					 generate it like this:
 | 
				
			||||||
@@ -173,4 +202,4 @@
 | 
				
			|||||||
 # [your changes]
 | 
					 # [your changes]
 | 
				
			||||||
 # ./Configure dist; make clean
 | 
					 # ./Configure dist; make clean
 | 
				
			||||||
 # cd ..
 | 
					 # cd ..
 | 
				
			||||||
 # diff -ur openssl-orig openssl-work > mydiffs.patch
 | 
					 # diff -urN openssl-orig openssl-work > mydiffs.patch
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,63 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
  ENGINE
 | 
					 | 
				
			||||||
  ======
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  With OpenSSL 0.9.6, a new component has been added to support external 
 | 
					 | 
				
			||||||
  crypto devices, for example accelerator cards.  The component is called
 | 
					 | 
				
			||||||
  ENGINE, and has still a pretty experimental status and almost no
 | 
					 | 
				
			||||||
  documentation.  It's designed to be fairly easily extensible by the
 | 
					 | 
				
			||||||
  calling programs.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  There's currently built-in support for the following crypto devices:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o CryptoSwift
 | 
					 | 
				
			||||||
      o Compaq Atalla
 | 
					 | 
				
			||||||
      o nCipher CHIL
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  A number of things are still needed and are being worked on:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      o An openssl utility command to handle or at least check available
 | 
					 | 
				
			||||||
        engines.
 | 
					 | 
				
			||||||
      o A better way of handling the methods that are handled by the
 | 
					 | 
				
			||||||
        engines.
 | 
					 | 
				
			||||||
      o Documentation!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  What already exists is fairly stable as far as it has been tested, but
 | 
					 | 
				
			||||||
  the test base has been a bit small most of the time.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Because of this experimental status and what's lacking, the ENGINE
 | 
					 | 
				
			||||||
  component is not yet part of the default OpenSSL distribution.  However,
 | 
					 | 
				
			||||||
  we have made a separate kit for those who want to try this out, to be
 | 
					 | 
				
			||||||
  found in the same places as the default OpenSSL distribution, but with
 | 
					 | 
				
			||||||
  "-engine-" being part of the kit file name.  For example, version 0.9.6
 | 
					 | 
				
			||||||
  is distributed in the following two files:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      openssl-0.9.6.tar.gz
 | 
					 | 
				
			||||||
      openssl-engine-0.9.6.tar.gz
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  NOTES
 | 
					 | 
				
			||||||
  =====
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  openssl-engine-0.9.6.tar.gz does not depend on openssl-0.9.6.tar, you do
 | 
					 | 
				
			||||||
  not need to download both.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  openssl-engine-0.9.6.tar.gz is usable even if you don't have an external
 | 
					 | 
				
			||||||
  crypto device.  The internal OpenSSL functions are contained in the
 | 
					 | 
				
			||||||
  engine "openssl", and will be used by default.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  No external crypto device is chosen unless you say so.  You have actively
 | 
					 | 
				
			||||||
  tell the openssl utility commands to use it through a new command line
 | 
					 | 
				
			||||||
  switch called "-engine".  And if you want to use the ENGINE library to
 | 
					 | 
				
			||||||
  do something similar, you must also explicitly choose an external crypto
 | 
					 | 
				
			||||||
  device, or the built-in crypto routines will be used, just as in the
 | 
					 | 
				
			||||||
  default OpenSSL distribution.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  PROBLEMS
 | 
					 | 
				
			||||||
  ========
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  It seems like the ENGINE part doesn't work too well with CryptoSwift on
 | 
					 | 
				
			||||||
  Win32.  A quick test done right before the release showed that trying
 | 
					 | 
				
			||||||
  "openssl speed -engine cswift" generated errors.  If the DSO gets enabled,
 | 
					 | 
				
			||||||
  an attempt is made to write at memory address 0x00000002.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										130
									
								
								STATUS
									
									
									
									
									
								
							
							
						
						
									
										130
									
								
								STATUS
									
									
									
									
									
								
							@@ -1,58 +1,78 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  OpenSSL STATUS                           Last modified at
 | 
					  OpenSSL STATUS                           Last modified at
 | 
				
			||||||
  ______________                           $Date: 2002/04/17 12:52:31 $
 | 
					  ______________                           $Date: 1999/05/20 01:42:57 $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEVELOPMENT STATE
 | 
					  DEVELOPMENT STATE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    o  OpenSSL 0.9.7:  Under development...
 | 
					    o  OpenSSL 0.9.3:  Freezed... only bugfixes and cleanups allowed!
 | 
				
			||||||
    o  OpenSSL 0.9.6d: Feature freeze, beta1 April 17th, 2002
 | 
					                       Proposed release date: Mon May 24th, 1999
 | 
				
			||||||
    o  OpenSSL 0.9.6c: Released on December  21st, 2001
 | 
					                       Release manager: Ben Laurie <ben@openssl.org>
 | 
				
			||||||
    o  OpenSSL 0.9.6b: Released on July       9th, 2001
 | 
					                       !! Important: Any non-bugfix, non-cleanup
 | 
				
			||||||
    o  OpenSSL 0.9.6a: Released on April      5th, 2001
 | 
					                       !! and non-documentation commits should
 | 
				
			||||||
    o  OpenSSL 0.9.6:  Released on September 24th, 2000
 | 
					                       !! be approved by Ben, first.
 | 
				
			||||||
    o  OpenSSL 0.9.5a: Released on April      1st, 2000
 | 
					
 | 
				
			||||||
    o  OpenSSL 0.9.5:  Released on February  28th, 2000
 | 
					    o  OpenSSL 0.9.2b: Released on March    22th, 1999
 | 
				
			||||||
    o  OpenSSL 0.9.4:  Released on August    09th, 1999
 | 
					    o  OpenSSL 0.9.1c: Released on December 23th, 1998
 | 
				
			||||||
    o  OpenSSL 0.9.3a: Released on May       29th, 1999
 | 
					 | 
				
			||||||
    o  OpenSSL 0.9.3:  Released on May       25th, 1999
 | 
					 | 
				
			||||||
    o  OpenSSL 0.9.2b: Released on March     22th, 1999
 | 
					 | 
				
			||||||
    o  OpenSSL 0.9.1c: Released on December  23th, 1998
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  RELEASE SHOWSTOPPERS
 | 
					  RELEASE SHOWSTOPPERS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    o BSD/OS: assembler functions must not have leading underscores
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AVAILABLE PATCHES
 | 
					  AVAILABLE PATCHES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    o 
 | 
					    o OCSP (titchenert@certco.com) 
 | 
				
			||||||
 | 
					    o getenv in ca.c and x509_def.c (jaltman@watsun.cc.columbia.edu)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  IN PROGRESS
 | 
					  IN PROGRESS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    o Steve is currently working on (in no particular order):
 | 
					    o Steve is currently working on (in no particular order):
 | 
				
			||||||
        ASN1 code redesign, butchery, replacement.
 | 
					        Proper (or at least usable) certificate chain verification.
 | 
				
			||||||
        OCSP
 | 
					        Documentation on X509 V3 extension code.
 | 
				
			||||||
        EVP cipher enhancement.
 | 
						PKCS #8 and PKCS#5 v2.0 support.
 | 
				
			||||||
        Enhanced certificate chain verification.
 | 
					 | 
				
			||||||
	Private key, certificate and CRL API and implementation.
 | 
						Private key, certificate and CRL API and implementation.
 | 
				
			||||||
	Developing and bugfixing PKCS#7 (S/MIME code).
 | 
						Checking and bugfixing PKCS#7 (S/MIME code).
 | 
				
			||||||
        Various X509 issues: character sets, certificate request extensions.
 | 
					
 | 
				
			||||||
    o Geoff and Richard are currently working on:
 | 
					    o Mark is currently working on:
 | 
				
			||||||
	ENGINE (the new code that gives hardware support among others).
 | 
					        Folding in any changes that are in the C2Net code base that were
 | 
				
			||||||
    o Richard is currently working on:
 | 
					        not in the original SSLeay-0.9.1.b release.  Plus other minor
 | 
				
			||||||
	UI (User Interface)
 | 
					        tidying.
 | 
				
			||||||
	UTIL (a new set of library functions to support some higher level
 | 
					
 | 
				
			||||||
	      functionality that is currently missing).
 | 
					    o Ralf is currently working on:
 | 
				
			||||||
	Shared library support for VMS.
 | 
					        1. Support for SSL_set_default_verify_paths(),
 | 
				
			||||||
	Kerberos 5 authentication
 | 
					           SSL_load_verify_locations(), SSL_get_cert_store() and
 | 
				
			||||||
	Constification
 | 
					           SSL_set_cert_store() functions which work like their existing
 | 
				
			||||||
	OCSP
 | 
					           SSL_CTX_xxx() variants but on a per connection basis. That's needed
 | 
				
			||||||
 | 
					           to let us provide full-featured per-URL client verification in
 | 
				
			||||||
 | 
					           mod_ssl or Apache-SSL.
 | 
				
			||||||
 | 
					           => It still dumps core, so I suspend this and investigate
 | 
				
			||||||
 | 
					              again for OpenSSL 0.9.3.
 | 
				
			||||||
 | 
					        2. The perl/ stuff to make it really work the first time ;-)
 | 
				
			||||||
 | 
					           => I'll investigate a few more hours for OpenSSL 0.9.2
 | 
				
			||||||
 | 
					        3. The new documentation set in POD format under doc/
 | 
				
			||||||
 | 
					           => I'll investigate a few more hours for OpenSSL 0.9.2
 | 
				
			||||||
 | 
					        4. More cleanups to get rid of obsolete/old/ugly files in the
 | 
				
			||||||
 | 
					           source tree which are not really needed.
 | 
				
			||||||
 | 
					           => Done all which were possible with my personal knowledge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    o Ben is currently working on:
 | 
				
			||||||
 | 
						1. Function Prototype Thought Police issues.
 | 
				
			||||||
 | 
						2. Integrated documentation.
 | 
				
			||||||
 | 
						3. New TLS Ciphersuites.
 | 
				
			||||||
 | 
						4. Anything else that takes his fancy.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  NEEDS PATCH
 | 
					  NEEDS PATCH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    o  apps/ca.c: "Sign the certificate?" - "n" creates empty certificate file
 | 
					    o  broken demos
 | 
				
			||||||
 | 
					    o  salzr@certco.com (Rich Salz): Bug in X509_name_print
 | 
				
			||||||
    o  Whenever strncpy is used, make sure the resulting string is NULL-terminated
 | 
					       <29E0A6D39ABED111A36000A0C99609CA2C2BA4@macertco-srv1.ma.certco.com>
 | 
				
			||||||
       or an error is reported
 | 
					    o  [ Compilation warnings: ctype-related int vs. char ]
 | 
				
			||||||
 | 
					       => now casts (unsigned char), maybe those arrays should have
 | 
				
			||||||
    o  "OpenSSL STATUS" is never up-to-date.
 | 
					          members of that type rather than plain char (i.e.
 | 
				
			||||||
 | 
					          unsigned char *p; ....; if (isspace(*p)) ...; where it's now
 | 
				
			||||||
 | 
					          char *p; ....; if (isspace((unsigned char)*p)) ...;)
 | 
				
			||||||
 | 
					    o  $(PERL) in */Makefile.ssl
 | 
				
			||||||
 | 
					    o  "Sign the certificate?" - "n" creates empty certificate file
 | 
				
			||||||
 | 
					    o  dubious declaration of crypt() in des.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  OPEN ISSUES
 | 
					  OPEN ISSUES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,11 +96,6 @@
 | 
				
			|||||||
               compiler PIC and linker DSO flags from Apache
 | 
					               compiler PIC and linker DSO flags from Apache
 | 
				
			||||||
               into the OpenSSL Configure script.
 | 
					               into the OpenSSL Configure script.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               Ulf: +1 for using GNU autoconf and libtool (but not automake,
 | 
					 | 
				
			||||||
                    which apparently is not flexible enough to generate
 | 
					 | 
				
			||||||
                    libcrypto)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    o  The perl/ stuff needs a major overhaul. Currently it's
 | 
					    o  The perl/ stuff needs a major overhaul. Currently it's
 | 
				
			||||||
       totally obsolete. Either we clean it up and enhance it to be up-to-date
 | 
					       totally obsolete. Either we clean it up and enhance it to be up-to-date
 | 
				
			||||||
       with the C code or we also could replace it with the really nice
 | 
					       with the C code or we also could replace it with the really nice
 | 
				
			||||||
@@ -96,16 +111,27 @@
 | 
				
			|||||||
               to date.
 | 
					               to date.
 | 
				
			||||||
               Paul +1
 | 
					               Paul +1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    o The EVP and ASN1 stuff is a mess. Currently you have one EVP_CIPHER
 | 
				
			||||||
 | 
					      structure for each cipher. This may make sense for things like DES but
 | 
				
			||||||
 | 
					      for variable length ciphers like RC2 and RC4 it is NBG. Need a way to
 | 
				
			||||||
 | 
					      use the EVP interface and set up the cipher parameters. The ASN1 stuff
 | 
				
			||||||
 | 
					      is also foo wrt ciphers whose AlgorithmIdentifier has more than just
 | 
				
			||||||
 | 
					      an IV in it (e.g. RC2, RC5). This also means that EVP_Seal and EVP_Open
 | 
				
			||||||
 | 
					      don't work unless the key length matches the fixed value (some vendors
 | 
				
			||||||
 | 
					      use a key length decided by the size of the RSA encrypted key and expect
 | 
				
			||||||
 | 
					      RC2 to adapt).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    o Properly initialize the PRNG in the absence of /dev/random.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    o ERR_error_string(..., buf) does not know how large buf is,
 | 
				
			||||||
 | 
					      there should be ERR_error_string_n(..., buf, bufsize)
 | 
				
			||||||
 | 
					      or similar.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  WISHES
 | 
					  WISHES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    o  SRP in TLS.
 | 
					    o  Mats Nilsson <mats.nilsson@xware.se>:
 | 
				
			||||||
       [wished by:
 | 
					       "Add reference counting to all substructures of X509 etc. For instance,
 | 
				
			||||||
        Dj <derek@yo.net>, Tom Wu <tom@arcot.com>,
 | 
					       X509_NAME lacks a reference counter, while EVP_PKEY has one.  I'm
 | 
				
			||||||
        Tom Holroyd <tomh@po.crl.go.jp>]
 | 
					       making COM-wrappers for selected parts of SSLeay for a project of ours,
 | 
				
			||||||
 | 
					       and has found this inconsistency in copy semantics annoying."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
       See http://search.ietf.org/internet-drafts/draft-ietf-tls-srp-00.txt
 | 
					 | 
				
			||||||
       as well as http://www-cs-students.stanford.edu/~tjw/srp/.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
       Tom Holroyd tells us there is a SRP patch for OpenSSH at
 | 
					 | 
				
			||||||
       http://members.tripod.com/professor_tom/archives/, that could
 | 
					 | 
				
			||||||
       be useful.
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								VMS/TODO
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								VMS/TODO
									
									
									
									
									
								
							@@ -1,18 +0,0 @@
 | 
				
			|||||||
TODO:
 | 
					 | 
				
			||||||
=====
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There are a few things that need to be worked out in the VMS version of
 | 
					 | 
				
			||||||
OpenSSL, still:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Description files. ("Makefile's" :-))
 | 
					 | 
				
			||||||
- Script code to link an already compiled build tree.
 | 
					 | 
				
			||||||
- A VMSINSTALlable version (way in the future, unless someone else hacks).
 | 
					 | 
				
			||||||
- shareable images (DLL for you Windows folks).
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
There may be other things that I have missed and that may be desirable.
 | 
					 | 
				
			||||||
Please send mail to <openssl-users@openssl.org> or to me directly if you
 | 
					 | 
				
			||||||
have any ideas.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
--
 | 
					 | 
				
			||||||
Richard Levitte <richard@levitte.org>
 | 
					 | 
				
			||||||
1999-05-24
 | 
					 | 
				
			||||||
@@ -1,4 +0,0 @@
 | 
				
			|||||||
* Have the building procedure contain a LINK-only possibility.
 | 
					 | 
				
			||||||
  Wished by Mark Daniel <mark.daniel@dsto.defence.gov.au>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  One way to enable that is also to go over to DESCRIP.MMS files.
 | 
					 | 
				
			||||||
@@ -1,72 +0,0 @@
 | 
				
			|||||||
$! INSTALL.COM -- Installs the files in a given directory tree
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$! Author: Richard Levitte <richard@levitte.org>
 | 
					 | 
				
			||||||
$! Time of creation: 23-MAY-1998 19:22
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$! P1	root of the directory tree
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$	IF P1 .EQS. ""
 | 
					 | 
				
			||||||
$	THEN
 | 
					 | 
				
			||||||
$	    WRITE SYS$OUTPUT "First argument missing."
 | 
					 | 
				
			||||||
$	    WRITE SYS$OUTPUT "Should be the directory where you want things installed."
 | 
					 | 
				
			||||||
$	    EXIT
 | 
					 | 
				
			||||||
$	ENDIF
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	ROOT = F$PARSE(P1,"[]A.;0",,,"SYNTAX_ONLY,NO_CONCEAL") - "A.;0"
 | 
					 | 
				
			||||||
$	ROOT_DEV = F$PARSE(ROOT,,,"DEVICE","SYNTAX_ONLY")
 | 
					 | 
				
			||||||
$	ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") -
 | 
					 | 
				
			||||||
		   - "[000000." - "][" - "[" - "]"
 | 
					 | 
				
			||||||
$	ROOT = ROOT_DEV + "[" + ROOT_DIR
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLROOT 'ROOT'.] /TRANS=CONC
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLVLIB WRK_SSLROOT:[VAX_LIB]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLALIB WRK_SSLROOT:[ALPHA_LIB]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLINCLUDE WRK_SSLROOT:[INCLUDE]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLVEXE WRK_SSLROOT:[VAX_EXE]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLAEXE WRK_SSLROOT:[ALPHA_EXE]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLCERTS WRK_SSLROOT:[CERTS]
 | 
					 | 
				
			||||||
$	DEFINE/NOLOG WRK_SSLPRIVATE WRK_SSLROOT:[PRIVATE]
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	IF F$PARSE("WRK_SSLROOT:[000000]") .EQS. "" THEN -
 | 
					 | 
				
			||||||
	   CREATE/DIR/LOG WRK_SSLROOT:[000000]
 | 
					 | 
				
			||||||
$	IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN -
 | 
					 | 
				
			||||||
	   CREATE/DIR/LOG WRK_SSLINCLUDE:
 | 
					 | 
				
			||||||
$	IF F$PARSE("WRK_SSLROOT:[VMS]") .EQS. "" THEN -
 | 
					 | 
				
			||||||
	   CREATE/DIR/LOG WRK_SSLROOT:[VMS]
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	IF F$SEARCH("WRK_SSLINCLUDE:vms_idhacks.h") .NES. "" THEN -
 | 
					 | 
				
			||||||
	   DELETE WRK_SSLINCLUDE:vms_idhacks.h;*
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	OPEN/WRITE SF WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM
 | 
					 | 
				
			||||||
$	WRITE SYS$OUTPUT "%OPEN-I-CREATED,  ",F$SEARCH("WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM")," created."
 | 
					 | 
				
			||||||
$	WRITE SF "$! Startup file for Openssl 0.9.2-RL 15-Mar-1999"
 | 
					 | 
				
			||||||
$	WRITE SF "$!"
 | 
					 | 
				
			||||||
$	WRITE SF "$! Do not edit this file, as it will be regenerated during next installation."
 | 
					 | 
				
			||||||
$	WRITE SF "$! Instead, add or change SSLROOT:[VMS]OPENSSL_SYSTARTUP.COM"
 | 
					 | 
				
			||||||
$	WRITE SF "$!"
 | 
					 | 
				
			||||||
$	WRITE SF "$! P1	a qualifier to DEFINE.  For example ""/SYSTEM"" to get the logical names"
 | 
					 | 
				
			||||||
$	WRITE SF "$!	defined in the system logical name table."
 | 
					 | 
				
			||||||
$	WRITE SF "$!"
 | 
					 | 
				
			||||||
$	WRITE SF "$	ARCH = ""VAX"""
 | 
					 | 
				
			||||||
$	WRITE SF "$	IF F$GETSYI(""CPU"") .GE. 128 THEN ARCH = ""ALPHA"""
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLROOT		",ROOT,".] /TRANS=CONC"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLLIB		SSLROOT:['ARCH'_LIB]"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLINCLUDE	SSLROOT:[INCLUDE]"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLEXE		SSLROOT:['ARCH'_EXE]"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLCERTS	SSLROOT:[CERTS]"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	SSLPRIVATE	SSLROOT:[PRIVATE]"
 | 
					 | 
				
			||||||
$	WRITE SF "$"
 | 
					 | 
				
			||||||
$	WRITE SF "$!	This is program can include <openssl/{foo}.h>"
 | 
					 | 
				
			||||||
$	WRITE SF "$	DEFINE/NOLOG'P1	OPENSSL		SSLINCLUDE:"
 | 
					 | 
				
			||||||
$	WRITE SF "$"
 | 
					 | 
				
			||||||
$	WRITE SF "$	IF F$SEARCH(""SSLROOT:[VMS]OPENSSL_SYSTARTUP.COM"") .NES."""" THEN -"
 | 
					 | 
				
			||||||
$	WRITE SF "	   @SSLROOT:[VMS]OPENSSL_SYSTARTUP.COM"
 | 
					 | 
				
			||||||
$	WRITE SF "$"
 | 
					 | 
				
			||||||
$	WRITE SF "$	EXIT"
 | 
					 | 
				
			||||||
$	CLOSE SF
 | 
					 | 
				
			||||||
$	SET FILE/PROT=WORLD:RE WRK_SSLROOT:[VMS]OPENSSL_STARTUP.COM
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	COPY OPENSSL_UTILS.COM WRK_SSLROOT:[VMS]/LOG
 | 
					 | 
				
			||||||
$	SET FILE/PROT=WORLD:RE WRK_SSLROOT:[VMS]OPENSSL_UTILS.COM
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	EXIT
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
multinet:multinet_socket_library.exe/share
 | 
					 | 
				
			||||||
@@ -1,38 +0,0 @@
 | 
				
			|||||||
$!
 | 
					 | 
				
			||||||
$!  APPS.COM
 | 
					 | 
				
			||||||
$!  Written By:  Robert Byer
 | 
					 | 
				
			||||||
$!               Vice-President
 | 
					 | 
				
			||||||
$!               A-Com Computing, Inc.
 | 
					 | 
				
			||||||
$!               byer@mail.all-net.net
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$! Slightly modified by Richard Levitte <richard@levitte.org>
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$ OPENSSL  :== $SSLEXE:OPENSSL
 | 
					 | 
				
			||||||
$ VERIFY   :== $SSLEXE:OPENSSL VERIFY
 | 
					 | 
				
			||||||
$ ASN1PARSE:== $SSLEXE:OPENSSL ASN1PARS
 | 
					 | 
				
			||||||
$ REQ      :== $SSLEXE:OPENSSL REQ
 | 
					 | 
				
			||||||
$ DGST     :== $SSLEXE:OPENSSL DGST
 | 
					 | 
				
			||||||
$ DH       :== $SSLEXE:OPENSSL DH
 | 
					 | 
				
			||||||
$ ENC      :== $SSLEXE:OPENSSL ENC
 | 
					 | 
				
			||||||
$ GENDH    :== $SSLEXE:OPENSSL GENDH
 | 
					 | 
				
			||||||
$ ERRSTR   :== $SSLEXE:OPENSSL ERRSTR
 | 
					 | 
				
			||||||
$ CA       :== $SSLEXE:OPENSSL CA
 | 
					 | 
				
			||||||
$ CRL      :== $SSLEXE:OPENSSL CRL
 | 
					 | 
				
			||||||
$ RSA      :== $SSLEXE:OPENSSL RSA
 | 
					 | 
				
			||||||
$ DSA      :== $SSLEXE:OPENSSL DSA
 | 
					 | 
				
			||||||
$ DSAPARAM :== $SSLEXE:OPENSSL DSAPARAM
 | 
					 | 
				
			||||||
$ X509     :== $SSLEXE:OPENSSL X509
 | 
					 | 
				
			||||||
$ GENRSA   :== $SSLEXE:OPENSSL GENRSA
 | 
					 | 
				
			||||||
$ GENDSA   :== $SSLEXE:OPENSSL GENDSA
 | 
					 | 
				
			||||||
$ S_SERVER :== $SSLEXE:OPENSSL S_SERVER
 | 
					 | 
				
			||||||
$ S_CLIENT :== $SSLEXE:OPENSSL S_CLIENT
 | 
					 | 
				
			||||||
$ SPEED    :== $SSLEXE:OPENSSL SPEED
 | 
					 | 
				
			||||||
$ S_TIME   :== $SSLEXE:OPENSSL S_TIME
 | 
					 | 
				
			||||||
$ VERSION  :== $SSLEXE:OPENSSL VERSION
 | 
					 | 
				
			||||||
$ PKCS7    :== $SSLEXE:OPENSSL PKCS7
 | 
					 | 
				
			||||||
$ CRL2PKCS7:== $SSLEXE:OPENSSL CRL2P7
 | 
					 | 
				
			||||||
$ SESS_ID  :== $SSLEXE:OPENSSL SESS_ID
 | 
					 | 
				
			||||||
$ CIPHERS  :== $SSLEXE:OPENSSL CIPHERS
 | 
					 | 
				
			||||||
$ NSEQ     :== $SSLEXE:OPENSSL NSEQ
 | 
					 | 
				
			||||||
$ PKCS12   :== $SSLEXE:OPENSSL PKCS12
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
socketshr/share
 | 
					 | 
				
			||||||
@@ -1,28 +0,0 @@
 | 
				
			|||||||
$! Quick script to check how well including individual header files works
 | 
					 | 
				
			||||||
$! on VMS, even when the VMS macro isn't defined.
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$	sav_def = f$env("DEFAULT")
 | 
					 | 
				
			||||||
$	here = f$parse("A.;0",f$ENV("PROCEDURE")) - "A.;0"
 | 
					 | 
				
			||||||
$	set default 'here'
 | 
					 | 
				
			||||||
$	set default [-.include.openssl]
 | 
					 | 
				
			||||||
$	define openssl 'f$env("DEFAULT")'
 | 
					 | 
				
			||||||
$	set default [--]
 | 
					 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$ loop:
 | 
					 | 
				
			||||||
$	f = f$search("openssl:*.h")
 | 
					 | 
				
			||||||
$	if f .eqs. "" then goto loop_end
 | 
					 | 
				
			||||||
$	write sys$output "Checking ",f
 | 
					 | 
				
			||||||
$	open/write foo foo.c
 | 
					 | 
				
			||||||
$	write foo "#undef VMS"
 | 
					 | 
				
			||||||
$	write foo "#include <stdio.h>"
 | 
					 | 
				
			||||||
$	write foo "#include <openssl/",f$parse(f,,,"NAME"),".h>"
 | 
					 | 
				
			||||||
$	write foo "main()"
 | 
					 | 
				
			||||||
$	write foo "{printf(""foo\n"");}"
 | 
					 | 
				
			||||||
$	close foo
 | 
					 | 
				
			||||||
$	cc/STANDARD=ANSI89/NOLIST/PREFIX=ALL foo.c
 | 
					 | 
				
			||||||
$	delete foo.c;
 | 
					 | 
				
			||||||
$	goto loop
 | 
					 | 
				
			||||||
$ loop_end:
 | 
					 | 
				
			||||||
$	set default 'save_def'
 | 
					 | 
				
			||||||
$	exit
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
sys$share:ucx$ipc_shr.exe/share
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
ucx$ipc_shr/share
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
sys$library:ucx$ipc.olb/library
 | 
					 | 
				
			||||||
@@ -1,5 +1,2 @@
 | 
				
			|||||||
openssl
 | 
					openssl
 | 
				
			||||||
Makefile.save
 | 
					Makefile.save
 | 
				
			||||||
der_chop
 | 
					 | 
				
			||||||
der_chop.bak
 | 
					 | 
				
			||||||
CA.pl
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								apps/CA.com
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								apps/CA.com
									
									
									
									
									
								
							@@ -35,7 +35,6 @@ $ REQ    = openssl + " req " + SSLEAY_CONFIG
 | 
				
			|||||||
$ CA     = openssl + " ca " + SSLEAY_CONFIG
 | 
					$ CA     = openssl + " ca " + SSLEAY_CONFIG
 | 
				
			||||||
$ VERIFY = openssl + " verify"
 | 
					$ VERIFY = openssl + " verify"
 | 
				
			||||||
$ X509   = openssl + " x509"
 | 
					$ X509   = openssl + " x509"
 | 
				
			||||||
$ PKCS12 = openssl + " pkcs12"
 | 
					 | 
				
			||||||
$ echo   = "write sys$Output"
 | 
					$ echo   = "write sys$Output"
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ s = F$PARSE(F$ENVIRONMENT("DEFAULT"),"[]") - "].;"
 | 
					$ s = F$PARSE(F$ENVIRONMENT("DEFAULT"),"[]") - "].;"
 | 
				
			||||||
@@ -97,18 +96,10 @@ $     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.certs]
 | 
				
			|||||||
$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.crl]
 | 
					$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.crl]
 | 
				
			||||||
$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.newcerts]
 | 
					$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.newcerts]
 | 
				
			||||||
$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.private]
 | 
					$     CREATE /DIR /PROTECTION=OWNER:RWED 'CATOP'.private]
 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$     OPEN   /WRITE ser_file 'CATOP']serial. 
 | 
					$     OPEN   /WRITE ser_file 'CATOP']serial. 
 | 
				
			||||||
$     WRITE ser_file "01"
 | 
					$     WRITE ser_file "01"
 | 
				
			||||||
$     CLOSE ser_file
 | 
					$     CLOSE ser_file
 | 
				
			||||||
$     APPEND/NEW NL: 'CATOP']index.txt
 | 
					$     APPEND/NEW NL: 'CATOP']index.txt
 | 
				
			||||||
$
 | 
					 | 
				
			||||||
$     ! The following is to make sure access() doesn't get confused.  It
 | 
					 | 
				
			||||||
$     ! really needs one file in the directory to give correct answers...
 | 
					 | 
				
			||||||
$     COPY NLA0: 'CATOP'.certs].;
 | 
					 | 
				
			||||||
$     COPY NLA0: 'CATOP'.crl].;
 | 
					 | 
				
			||||||
$     COPY NLA0: 'CATOP'.newcerts].;
 | 
					 | 
				
			||||||
$     COPY NLA0: 'CATOP'.private].;
 | 
					 | 
				
			||||||
$   ENDIF
 | 
					$   ENDIF
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$   IF F$SEARCH(CATOP+".private"+CAKEY) .EQS. ""
 | 
					$   IF F$SEARCH(CATOP+".private"+CAKEY) .EQS. ""
 | 
				
			||||||
@@ -130,17 +121,6 @@ $   ENDIF
 | 
				
			|||||||
$   GOTO opt_loop_continue
 | 
					$   GOTO opt_loop_continue
 | 
				
			||||||
$ ENDIF
 | 
					$ ENDIF
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ IF (prog_opt .EQS. "-pkcs12")
 | 
					 | 
				
			||||||
$ THEN
 | 
					 | 
				
			||||||
$   i = i + 1
 | 
					 | 
				
			||||||
$   cname = P'i'
 | 
					 | 
				
			||||||
$   IF cname .EQS. "" THEN cname = "My certificate"
 | 
					 | 
				
			||||||
$   PKCS12 -in newcert.pem -inkey newreq.pem -certfile 'CATOP''CACERT -
 | 
					 | 
				
			||||||
	   -out newcert.p12 -export -name "''cname'"
 | 
					 | 
				
			||||||
$   RET=$STATUS
 | 
					 | 
				
			||||||
$   exit RET
 | 
					 | 
				
			||||||
$ ENDIF
 | 
					 | 
				
			||||||
$!
 | 
					 | 
				
			||||||
$ IF (prog_opt .EQS. "-xsign")
 | 
					$ IF (prog_opt .EQS. "-xsign")
 | 
				
			||||||
$ THEN
 | 
					$ THEN
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								apps/CA.pl.in → apps/CA.pl
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										17
									
								
								apps/CA.pl.in → apps/CA.pl
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@@ -36,13 +36,11 @@
 | 
				
			|||||||
# default openssl.cnf file has setup as per the following
 | 
					# default openssl.cnf file has setup as per the following
 | 
				
			||||||
# demoCA ... where everything is stored
 | 
					# demoCA ... where everything is stored
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"};
 | 
					 | 
				
			||||||
$DAYS="-days 365";
 | 
					$DAYS="-days 365";
 | 
				
			||||||
$REQ="openssl req $SSLEAY_CONFIG";
 | 
					$REQ="openssl req $SSLEAY_CONFIG";
 | 
				
			||||||
$CA="openssl ca $SSLEAY_CONFIG";
 | 
					$CA="openssl ca $SSLEAY_CONFIG";
 | 
				
			||||||
$VERIFY="openssl verify";
 | 
					$VERIFY="openssl verify";
 | 
				
			||||||
$X509="openssl x509";
 | 
					$X509="openssl x509";
 | 
				
			||||||
$PKCS12="openssl pkcs12";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$CATOP="./demoCA";
 | 
					$CATOP="./demoCA";
 | 
				
			||||||
$CAKEY="cakey.pem";
 | 
					$CAKEY="cakey.pem";
 | 
				
			||||||
@@ -67,7 +65,7 @@ foreach (@ARGV) {
 | 
				
			|||||||
	    $RET=$?;
 | 
						    $RET=$?;
 | 
				
			||||||
	    print "Request (and private key) is in newreq.pem\n";
 | 
						    print "Request (and private key) is in newreq.pem\n";
 | 
				
			||||||
	} elsif (/^-newca$/) {
 | 
						} elsif (/^-newca$/) {
 | 
				
			||||||
		# if explicitly asked for or it doesn't exist then setup the
 | 
							# if explictly asked for or it doesn't exist then setup the
 | 
				
			||||||
		# directory structure that Eric likes to manage things 
 | 
							# directory structure that Eric likes to manage things 
 | 
				
			||||||
	    $NEW="1";
 | 
						    $NEW="1";
 | 
				
			||||||
	    if ( "$NEW" || ! -f "${CATOP}/serial" ) {
 | 
						    if ( "$NEW" || ! -f "${CATOP}/serial" ) {
 | 
				
			||||||
@@ -101,14 +99,6 @@ foreach (@ARGV) {
 | 
				
			|||||||
		    $RET=$?;
 | 
							    $RET=$?;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	} elsif (/^-pkcs12$/) {
 | 
					 | 
				
			||||||
	    my $cname = $ARGV[1];
 | 
					 | 
				
			||||||
	    $cname = "My Certificate" unless defined $cname;
 | 
					 | 
				
			||||||
	    system ("$PKCS12 -in newcert.pem -inkey newreq.pem " .
 | 
					 | 
				
			||||||
			"-certfile ${CATOP}/$CACERT -out newcert.p12 " .
 | 
					 | 
				
			||||||
			"-export -name \"$cname\"");
 | 
					 | 
				
			||||||
	    $RET=$?;
 | 
					 | 
				
			||||||
	    exit $RET;
 | 
					 | 
				
			||||||
	} elsif (/^-xsign$/) {
 | 
						} elsif (/^-xsign$/) {
 | 
				
			||||||
	    system ("$CA -policy policy_anything -infiles newreq.pem");
 | 
						    system ("$CA -policy policy_anything -infiles newreq.pem");
 | 
				
			||||||
	    $RET=$?;
 | 
						    $RET=$?;
 | 
				
			||||||
@@ -117,11 +107,6 @@ foreach (@ARGV) {
 | 
				
			|||||||
							"-infiles newreq.pem");
 | 
												"-infiles newreq.pem");
 | 
				
			||||||
	    $RET=$?;
 | 
						    $RET=$?;
 | 
				
			||||||
	    print "Signed certificate is in newcert.pem\n";
 | 
						    print "Signed certificate is in newcert.pem\n";
 | 
				
			||||||
	} elsif (/^(-signCA)$/) {
 | 
					 | 
				
			||||||
	    system ("$CA -policy policy_anything -out newcert.pem " .
 | 
					 | 
				
			||||||
					"-extensions v3_ca -infiles newreq.pem");
 | 
					 | 
				
			||||||
	    $RET=$?;
 | 
					 | 
				
			||||||
	    print "Signed CA certificate is in newcert.pem\n";
 | 
					 | 
				
			||||||
	} elsif (/^-signcert$/) {
 | 
						} elsif (/^-signcert$/) {
 | 
				
			||||||
	    system ("$X509 -x509toreq -in newreq.pem -signkey newreq.pem " .
 | 
						    system ("$X509 -x509toreq -in newreq.pem -signkey newreq.pem " .
 | 
				
			||||||
								"-out tmp.pem");
 | 
													"-out tmp.pem");
 | 
				
			||||||
@@ -60,7 +60,7 @@ case $i in
 | 
				
			|||||||
    echo "Request (and private key) is in newreq.pem"
 | 
					    echo "Request (and private key) is in newreq.pem"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
-newca)     
 | 
					-newca)     
 | 
				
			||||||
    # if explicitly asked for or it doesn't exist then setup the directory
 | 
					    # if explictly asked for or it doesn't exist then setup the directory
 | 
				
			||||||
    # structure that Eric likes to manage things 
 | 
					    # structure that Eric likes to manage things 
 | 
				
			||||||
    NEW="1"
 | 
					    NEW="1"
 | 
				
			||||||
    if [ "$NEW" -o ! -f ${CATOP}/serial ]; then
 | 
					    if [ "$NEW" -o ! -f ${CATOP}/serial ]; then
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										215
									
								
								apps/app_rand.c
									
									
									
									
									
								
							
							
						
						
									
										215
									
								
								apps/app_rand.c
									
									
									
									
									
								
							@@ -1,215 +0,0 @@
 | 
				
			|||||||
/* apps/app_rand.c */
 | 
					 | 
				
			||||||
/* 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 (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 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 above 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 acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
					 | 
				
			||||||
 *    endorse or promote products derived from this software without
 | 
					 | 
				
			||||||
 *    prior written permission. For written permission, please contact
 | 
					 | 
				
			||||||
 *    openssl-core@openssl.org.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
					 | 
				
			||||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
					 | 
				
			||||||
 *    permission of the OpenSSL Project.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
					 | 
				
			||||||
 *    acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
					 | 
				
			||||||
 * EXPRESSED 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 OpenSSL PROJECT OR
 | 
					 | 
				
			||||||
 * ITS 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.
 | 
					 | 
				
			||||||
 * ====================================================================
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This product includes cryptographic software written by Eric Young
 | 
					 | 
				
			||||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
					 | 
				
			||||||
 * Hudson (tjh@cryptsoft.com).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define NON_MAIN
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
#undef NON_MAIN
 | 
					 | 
				
			||||||
#include <openssl/bio.h>
 | 
					 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int seeded = 0;
 | 
					 | 
				
			||||||
static int egdsocket = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	int consider_randfile = (file == NULL);
 | 
					 | 
				
			||||||
	char buffer[200];
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
	BIO_printf(bio_e,"Loading 'screen' into random state -");
 | 
					 | 
				
			||||||
	BIO_flush(bio_e);
 | 
					 | 
				
			||||||
	RAND_screen();
 | 
					 | 
				
			||||||
	BIO_printf(bio_e," done\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		file = RAND_file_name(buffer, sizeof buffer);
 | 
					 | 
				
			||||||
	else if (RAND_egd(file) > 0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		/* we try if the given filename is an EGD socket.
 | 
					 | 
				
			||||||
		   if it is, we don't write anything back to the file. */
 | 
					 | 
				
			||||||
		egdsocket = 1;
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (file == NULL || !RAND_load_file(file, -1))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (RAND_status() == 0 && !dont_warn)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_e,"unable to load 'random state'\n");
 | 
					 | 
				
			||||||
			BIO_printf(bio_e,"This means that the random number generator has not been seeded\n");
 | 
					 | 
				
			||||||
			BIO_printf(bio_e,"with much random data.\n");
 | 
					 | 
				
			||||||
			if (consider_randfile) /* explanation does not apply when a file is explicitly named */
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				BIO_printf(bio_e,"Consider setting the RANDFILE environment variable to point at a file that\n");
 | 
					 | 
				
			||||||
				BIO_printf(bio_e,"'random' data can be kept in (the file will be overwritten).\n");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	seeded = 1;
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
long app_RAND_load_files(char *name)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	char *p,*n;
 | 
					 | 
				
			||||||
	int last;
 | 
					 | 
				
			||||||
	long tot=0;
 | 
					 | 
				
			||||||
	int egd;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	for (;;)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		last=0;
 | 
					 | 
				
			||||||
		for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
 | 
					 | 
				
			||||||
		if (*p == '\0') last=1;
 | 
					 | 
				
			||||||
		*p='\0';
 | 
					 | 
				
			||||||
		n=name;
 | 
					 | 
				
			||||||
		name=p+1;
 | 
					 | 
				
			||||||
		if (*n == '\0') break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		egd=RAND_egd(n);
 | 
					 | 
				
			||||||
		if (egd > 0)
 | 
					 | 
				
			||||||
			tot+=egd;
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			tot+=RAND_load_file(n,-1);
 | 
					 | 
				
			||||||
		if (last) break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (tot > 512)
 | 
					 | 
				
			||||||
		app_RAND_allow_write_file();
 | 
					 | 
				
			||||||
	return(tot);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int app_RAND_write_file(const char *file, BIO *bio_e)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	char buffer[200];
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (egdsocket || !seeded)
 | 
					 | 
				
			||||||
		/* If we did not manage to read the seed file,
 | 
					 | 
				
			||||||
		 * we should not write a low-entropy seed file back --
 | 
					 | 
				
			||||||
		 * it would suppress a crucial warning the next time
 | 
					 | 
				
			||||||
		 * we want to use it. */
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		file = RAND_file_name(buffer, sizeof buffer);
 | 
					 | 
				
			||||||
	if (file == NULL || !RAND_write_file(file))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(bio_e,"unable to write 'random state'\n");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void app_RAND_allow_write_file(void)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	seeded = 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
							
								
								
									
										468
									
								
								apps/apps.c
									
									
									
									
									
								
							
							
						
						
									
										468
									
								
								apps/apps.c
									
									
									
									
									
								
							@@ -64,11 +64,6 @@
 | 
				
			|||||||
#define NON_MAIN
 | 
					#define NON_MAIN
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
#undef NON_MAIN
 | 
					#undef NON_MAIN
 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/x509.h>
 | 
					 | 
				
			||||||
#include <openssl/pem.h>
 | 
					 | 
				
			||||||
#include <openssl/pkcs12.h>
 | 
					 | 
				
			||||||
#include <openssl/safestack.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WINDOWS
 | 
					#ifdef WINDOWS
 | 
				
			||||||
#  include "bss_file.c"
 | 
					#  include "bss_file.c"
 | 
				
			||||||
@@ -96,8 +91,8 @@ int args_from_file(char *file, int *argc, char **argv[])
 | 
				
			|||||||
	*argv=NULL;
 | 
						*argv=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	len=(unsigned int)stbuf.st_size;
 | 
						len=(unsigned int)stbuf.st_size;
 | 
				
			||||||
	if (buf != NULL) OPENSSL_free(buf);
 | 
						if (buf != NULL) Free(buf);
 | 
				
			||||||
	buf=(char *)OPENSSL_malloc(len+1);
 | 
						buf=(char *)Malloc(len+1);
 | 
				
			||||||
	if (buf == NULL) return(0);
 | 
						if (buf == NULL) return(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	len=fread(buf,1,len,fp);
 | 
						len=fread(buf,1,len,fp);
 | 
				
			||||||
@@ -107,8 +102,8 @@ int args_from_file(char *file, int *argc, char **argv[])
 | 
				
			|||||||
	i=0;
 | 
						i=0;
 | 
				
			||||||
	for (p=buf; *p; p++)
 | 
						for (p=buf; *p; p++)
 | 
				
			||||||
		if (*p == '\n') i++;
 | 
							if (*p == '\n') i++;
 | 
				
			||||||
	if (arg != NULL) OPENSSL_free(arg);
 | 
						if (arg != NULL) Free(arg);
 | 
				
			||||||
	arg=(char **)OPENSSL_malloc(sizeof(char *)*(i*2));
 | 
						arg=(char **)Malloc(sizeof(char *)*(i*2));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*argv=arg;
 | 
						*argv=arg;
 | 
				
			||||||
	num=0;
 | 
						num=0;
 | 
				
			||||||
@@ -164,14 +159,6 @@ int str2fmt(char *s)
 | 
				
			|||||||
		return(FORMAT_PEM);
 | 
							return(FORMAT_PEM);
 | 
				
			||||||
	else if ((*s == 'N') || (*s == 'n'))
 | 
						else if ((*s == 'N') || (*s == 'n'))
 | 
				
			||||||
		return(FORMAT_NETSCAPE);
 | 
							return(FORMAT_NETSCAPE);
 | 
				
			||||||
	else if ((*s == 'S') || (*s == 's'))
 | 
					 | 
				
			||||||
		return(FORMAT_SMIME);
 | 
					 | 
				
			||||||
	else if ((*s == '1')
 | 
					 | 
				
			||||||
		|| (strcmp(s,"PKCS12") == 0) || (strcmp(s,"pkcs12") == 0)
 | 
					 | 
				
			||||||
		|| (strcmp(s,"P12") == 0) || (strcmp(s,"p12") == 0))
 | 
					 | 
				
			||||||
		return(FORMAT_PKCS12);
 | 
					 | 
				
			||||||
	else if ((*s == 'E') || (*s == 'e'))
 | 
					 | 
				
			||||||
		return(FORMAT_ENGINE);
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return(FORMAT_UNDEF);
 | 
							return(FORMAT_UNDEF);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -260,8 +247,8 @@ int WIN32_rename(char *from, char *to)
 | 
				
			|||||||
	ret=MoveFileEx(from,to,MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED);
 | 
						ret=MoveFileEx(from,to,MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED);
 | 
				
			||||||
	return(ret?0:-1);
 | 
						return(ret?0:-1);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	unlink(to);
 | 
					        unlink(to);
 | 
				
			||||||
	return MoveFile(from, to);
 | 
					        return MoveFile(from, to);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -279,7 +266,7 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
 | 
				
			|||||||
	if (arg->count == 0)
 | 
						if (arg->count == 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		arg->count=20;
 | 
							arg->count=20;
 | 
				
			||||||
		arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count);
 | 
							arg->data=(char **)Malloc(sizeof(char *)*arg->count);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	for (i=0; i<arg->count; i++)
 | 
						for (i=0; i<arg->count; i++)
 | 
				
			||||||
		arg->data[i]=NULL;
 | 
							arg->data[i]=NULL;
 | 
				
			||||||
@@ -298,7 +285,7 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
 | 
				
			|||||||
		if (num >= arg->count)
 | 
							if (num >= arg->count)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			arg->count+=20;
 | 
								arg->count+=20;
 | 
				
			||||||
			arg->data=(char **)OPENSSL_realloc(arg->data,
 | 
								arg->data=(char **)Realloc(arg->data,
 | 
				
			||||||
				sizeof(char *)*arg->count);
 | 
									sizeof(char *)*arg->count);
 | 
				
			||||||
			if (argc == 0) return(0);
 | 
								if (argc == 0) return(0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -337,442 +324,3 @@ int app_init(long mesgwin)
 | 
				
			|||||||
	return(1);
 | 
						return(1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int dump_cert_text (BIO *out, X509 *x)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char buf[256];
 | 
					 | 
				
			||||||
	X509_NAME_oneline(X509_get_subject_name(x),buf,256);
 | 
					 | 
				
			||||||
	BIO_puts(out,"subject=");
 | 
					 | 
				
			||||||
	BIO_puts(out,buf);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
 | 
					 | 
				
			||||||
	BIO_puts(out,"\nissuer= ");
 | 
					 | 
				
			||||||
	BIO_puts(out,buf);
 | 
					 | 
				
			||||||
	BIO_puts(out,"\n");
 | 
					 | 
				
			||||||
        return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static char *app_get_pass(BIO *err, char *arg, int keepbio);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int same;
 | 
					 | 
				
			||||||
	if(!arg2 || !arg1 || strcmp(arg1, arg2)) same = 0;
 | 
					 | 
				
			||||||
	else same = 1;
 | 
					 | 
				
			||||||
	if(arg1) {
 | 
					 | 
				
			||||||
		*pass1 = app_get_pass(err, arg1, same);
 | 
					 | 
				
			||||||
		if(!*pass1) return 0;
 | 
					 | 
				
			||||||
	} else if(pass1) *pass1 = NULL;
 | 
					 | 
				
			||||||
	if(arg2) {
 | 
					 | 
				
			||||||
		*pass2 = app_get_pass(err, arg2, same ? 2 : 0);
 | 
					 | 
				
			||||||
		if(!*pass2) return 0;
 | 
					 | 
				
			||||||
	} else if(pass2) *pass2 = NULL;
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static char *app_get_pass(BIO *err, char *arg, int keepbio)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *tmp, tpass[APP_PASS_LEN];
 | 
					 | 
				
			||||||
	static BIO *pwdbio = NULL;
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	if(!strncmp(arg, "pass:", 5)) return BUF_strdup(arg + 5);
 | 
					 | 
				
			||||||
	if(!strncmp(arg, "env:", 4)) {
 | 
					 | 
				
			||||||
		tmp = getenv(arg + 4);
 | 
					 | 
				
			||||||
		if(!tmp) {
 | 
					 | 
				
			||||||
			BIO_printf(err, "Can't read environment variable %s\n", arg + 4);
 | 
					 | 
				
			||||||
			return NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return BUF_strdup(tmp);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!keepbio || !pwdbio) {
 | 
					 | 
				
			||||||
		if(!strncmp(arg, "file:", 5)) {
 | 
					 | 
				
			||||||
			pwdbio = BIO_new_file(arg + 5, "r");
 | 
					 | 
				
			||||||
			if(!pwdbio) {
 | 
					 | 
				
			||||||
				BIO_printf(err, "Can't open file %s\n", arg + 5);
 | 
					 | 
				
			||||||
				return NULL;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else if(!strncmp(arg, "fd:", 3)) {
 | 
					 | 
				
			||||||
			BIO *btmp;
 | 
					 | 
				
			||||||
			i = atoi(arg + 3);
 | 
					 | 
				
			||||||
			if(i >= 0) pwdbio = BIO_new_fd(i, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
			if((i < 0) || !pwdbio) {
 | 
					 | 
				
			||||||
				BIO_printf(err, "Can't access file descriptor %s\n", arg + 3);
 | 
					 | 
				
			||||||
				return NULL;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			/* Can't do BIO_gets on an fd BIO so add a buffering BIO */
 | 
					 | 
				
			||||||
			btmp = BIO_new(BIO_f_buffer());
 | 
					 | 
				
			||||||
			pwdbio = BIO_push(btmp, pwdbio);
 | 
					 | 
				
			||||||
		} else if(!strcmp(arg, "stdin")) {
 | 
					 | 
				
			||||||
			pwdbio = BIO_new_fp(stdin, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
			if(!pwdbio) {
 | 
					 | 
				
			||||||
				BIO_printf(err, "Can't open BIO for stdin\n");
 | 
					 | 
				
			||||||
				return NULL;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			BIO_printf(err, "Invalid password argument \"%s\"\n", arg);
 | 
					 | 
				
			||||||
			return NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	i = BIO_gets(pwdbio, tpass, APP_PASS_LEN);
 | 
					 | 
				
			||||||
	if(keepbio != 1) {
 | 
					 | 
				
			||||||
		BIO_free_all(pwdbio);
 | 
					 | 
				
			||||||
		pwdbio = NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(i <= 0) {
 | 
					 | 
				
			||||||
		BIO_printf(err, "Error reading password from BIO\n");
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	tmp = strchr(tpass, '\n');
 | 
					 | 
				
			||||||
	if(tmp) *tmp = 0;
 | 
					 | 
				
			||||||
	return BUF_strdup(tpass);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int add_oid_section(BIO *err, LHASH *conf)
 | 
					 | 
				
			||||||
{	
 | 
					 | 
				
			||||||
	char *p;
 | 
					 | 
				
			||||||
	STACK_OF(CONF_VALUE) *sktmp;
 | 
					 | 
				
			||||||
	CONF_VALUE *cnf;
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	if(!(p=CONF_get_string(conf,NULL,"oid_section"))) return 1;
 | 
					 | 
				
			||||||
	if(!(sktmp = CONF_get_section(conf, p))) {
 | 
					 | 
				
			||||||
		BIO_printf(err, "problem loading oid section %s\n", p);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) {
 | 
					 | 
				
			||||||
		cnf = sk_CONF_VALUE_value(sktmp, i);
 | 
					 | 
				
			||||||
		if(OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) {
 | 
					 | 
				
			||||||
			BIO_printf(err, "problem creating object %s=%s\n",
 | 
					 | 
				
			||||||
							 cnf->name, cnf->value);
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
X509 *load_cert(BIO *err, char *file, int format)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	ASN1_HEADER *ah=NULL;
 | 
					 | 
				
			||||||
	BUF_MEM *buf=NULL;
 | 
					 | 
				
			||||||
	X509 *x=NULL;
 | 
					 | 
				
			||||||
	BIO *cert;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((cert=BIO_new(BIO_s_file())) == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		BIO_set_fp(cert,stdin,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (BIO_read_filename(cert,file) <= 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			perror(file);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if 	(format == FORMAT_ASN1)
 | 
					 | 
				
			||||||
		x=d2i_X509_bio(cert,NULL);
 | 
					 | 
				
			||||||
	else if (format == FORMAT_NETSCAPE)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		unsigned char *p,*op;
 | 
					 | 
				
			||||||
		int size=0,i;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* We sort of have to do it this way because it is sort of nice
 | 
					 | 
				
			||||||
		 * to read the header first and check it, then
 | 
					 | 
				
			||||||
		 * try to read the certificate */
 | 
					 | 
				
			||||||
		buf=BUF_MEM_new();
 | 
					 | 
				
			||||||
		for (;;)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((buf == NULL) || (!BUF_MEM_grow(buf,size+1024*10)))
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
			i=BIO_read(cert,&(buf->data[size]),1024*10);
 | 
					 | 
				
			||||||
			size+=i;
 | 
					 | 
				
			||||||
			if (i == 0) break;
 | 
					 | 
				
			||||||
			if (i < 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				perror("reading certificate");
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		p=(unsigned char *)buf->data;
 | 
					 | 
				
			||||||
		op=p;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* First load the header */
 | 
					 | 
				
			||||||
		if ((ah=d2i_ASN1_HEADER(NULL,&p,(long)size)) == NULL)
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		if ((ah->header == NULL) || (ah->header->data == NULL) ||
 | 
					 | 
				
			||||||
			(strncmp(NETSCAPE_CERT_HDR,(char *)ah->header->data,
 | 
					 | 
				
			||||||
			ah->header->length) != 0))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(err,"Error reading header on certificate\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		/* header is ok, so now read the object */
 | 
					 | 
				
			||||||
		p=op;
 | 
					 | 
				
			||||||
		ah->meth=X509_asn1_meth();
 | 
					 | 
				
			||||||
		if ((ah=d2i_ASN1_HEADER(&ah,&p,(long)size)) == NULL)
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		x=(X509 *)ah->data;
 | 
					 | 
				
			||||||
		ah->data=NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else if (format == FORMAT_PEM)
 | 
					 | 
				
			||||||
		x=PEM_read_bio_X509_AUX(cert,NULL,NULL,NULL);
 | 
					 | 
				
			||||||
	else if (format == FORMAT_PKCS12)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		PKCS12 *p12 = d2i_PKCS12_bio(cert, NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		PKCS12_parse(p12, NULL, NULL, &x, NULL);
 | 
					 | 
				
			||||||
		PKCS12_free(p12);
 | 
					 | 
				
			||||||
		p12 = NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else	{
 | 
					 | 
				
			||||||
		BIO_printf(err,"bad input format specified for input cert\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
end:
 | 
					 | 
				
			||||||
	if (x == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"unable to load certificate\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (ah != NULL) ASN1_HEADER_free(ah);
 | 
					 | 
				
			||||||
	if (cert != NULL) BIO_free(cert);
 | 
					 | 
				
			||||||
	if (buf != NULL) BUF_MEM_free(buf);
 | 
					 | 
				
			||||||
	return(x);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *key=NULL;
 | 
					 | 
				
			||||||
	EVP_PKEY *pkey=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"no keyfile specified\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	key=BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
	if (key == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (BIO_read_filename(key,file) <= 0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		perror(file);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (format == FORMAT_ASN1)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		pkey=d2i_PrivateKey_bio(key, NULL);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else if (format == FORMAT_PEM)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		pkey=PEM_read_bio_PrivateKey(key,NULL,NULL,pass);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else if (format == FORMAT_PKCS12)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		PKCS12 *p12 = d2i_PKCS12_bio(key, NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		PKCS12_parse(p12, pass, &pkey, NULL, NULL);
 | 
					 | 
				
			||||||
		PKCS12_free(p12);
 | 
					 | 
				
			||||||
		p12 = NULL;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"bad input format specified for key\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 end:
 | 
					 | 
				
			||||||
	if (key != NULL) BIO_free(key);
 | 
					 | 
				
			||||||
	if (pkey == NULL)
 | 
					 | 
				
			||||||
		BIO_printf(err,"unable to load Private Key\n");
 | 
					 | 
				
			||||||
	return(pkey);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EVP_PKEY *load_pubkey(BIO *err, char *file, int format)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *key=NULL;
 | 
					 | 
				
			||||||
	EVP_PKEY *pkey=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"no keyfile specified\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	key=BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
	if (key == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (BIO_read_filename(key,file) <= 0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		perror(file);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (format == FORMAT_ASN1)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		pkey=d2i_PUBKEY_bio(key, NULL);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else if (format == FORMAT_PEM)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		pkey=PEM_read_bio_PUBKEY(key,NULL,NULL,NULL);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"bad input format specified for key\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 end:
 | 
					 | 
				
			||||||
	if (key != NULL) BIO_free(key);
 | 
					 | 
				
			||||||
	if (pkey == NULL)
 | 
					 | 
				
			||||||
		BIO_printf(err,"unable to load Public Key\n");
 | 
					 | 
				
			||||||
	return(pkey);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
STACK_OF(X509) *load_certs(BIO *err, char *file, int format)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *certs;
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	STACK_OF(X509) *othercerts = NULL;
 | 
					 | 
				
			||||||
	STACK_OF(X509_INFO) *allcerts = NULL;
 | 
					 | 
				
			||||||
	X509_INFO *xi;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if((certs = BIO_new(BIO_s_file())) == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (file == NULL)
 | 
					 | 
				
			||||||
		BIO_set_fp(certs,stdin,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (BIO_read_filename(certs,file) <= 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			perror(file);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if      (format == FORMAT_PEM)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		othercerts = sk_X509_new_null();
 | 
					 | 
				
			||||||
		if(!othercerts)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			sk_X509_free(othercerts);
 | 
					 | 
				
			||||||
			othercerts = NULL;
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL);
 | 
					 | 
				
			||||||
		for(i = 0; i < sk_X509_INFO_num(allcerts); i++)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			xi = sk_X509_INFO_value (allcerts, i);
 | 
					 | 
				
			||||||
			if (xi->x509)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				sk_X509_push(othercerts, xi->x509);
 | 
					 | 
				
			||||||
				xi->x509 = NULL;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else	{
 | 
					 | 
				
			||||||
		BIO_printf(err,"bad input format specified for input cert\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
end:
 | 
					 | 
				
			||||||
	if (othercerts == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(err,"unable to load certificates\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(err);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (allcerts) sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
 | 
					 | 
				
			||||||
	if (certs != NULL) BIO_free(certs);
 | 
					 | 
				
			||||||
	return(othercerts);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct {
 | 
					 | 
				
			||||||
	char *name;
 | 
					 | 
				
			||||||
	unsigned long flag;
 | 
					 | 
				
			||||||
	unsigned long mask;
 | 
					 | 
				
			||||||
} NAME_EX_TBL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int set_name_ex(unsigned long *flags, const char *arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char c;
 | 
					 | 
				
			||||||
	const NAME_EX_TBL *ptbl, ex_tbl[] = {
 | 
					 | 
				
			||||||
		{ "esc_2253", ASN1_STRFLGS_ESC_2253, 0},
 | 
					 | 
				
			||||||
		{ "esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0},
 | 
					 | 
				
			||||||
		{ "esc_msb", ASN1_STRFLGS_ESC_MSB, 0},
 | 
					 | 
				
			||||||
		{ "use_quote", ASN1_STRFLGS_ESC_QUOTE, 0},
 | 
					 | 
				
			||||||
		{ "utf8", ASN1_STRFLGS_UTF8_CONVERT, 0},
 | 
					 | 
				
			||||||
		{ "ignore_type", ASN1_STRFLGS_IGNORE_TYPE, 0},
 | 
					 | 
				
			||||||
		{ "show_type", ASN1_STRFLGS_SHOW_TYPE, 0},
 | 
					 | 
				
			||||||
		{ "dump_all", ASN1_STRFLGS_DUMP_ALL, 0},
 | 
					 | 
				
			||||||
		{ "dump_nostr", ASN1_STRFLGS_DUMP_UNKNOWN, 0},
 | 
					 | 
				
			||||||
		{ "dump_der", ASN1_STRFLGS_DUMP_DER, 0},
 | 
					 | 
				
			||||||
		{ "compat", XN_FLAG_COMPAT, 0xffffffffL},
 | 
					 | 
				
			||||||
		{ "sep_comma_plus", XN_FLAG_SEP_COMMA_PLUS, XN_FLAG_SEP_MASK},
 | 
					 | 
				
			||||||
		{ "sep_comma_plus_space", XN_FLAG_SEP_CPLUS_SPC, XN_FLAG_SEP_MASK},
 | 
					 | 
				
			||||||
		{ "sep_semi_plus_space", XN_FLAG_SEP_SPLUS_SPC, XN_FLAG_SEP_MASK},
 | 
					 | 
				
			||||||
		{ "sep_multiline", XN_FLAG_SEP_MULTILINE, XN_FLAG_SEP_MASK},
 | 
					 | 
				
			||||||
		{ "dn_rev", XN_FLAG_DN_REV, 0},
 | 
					 | 
				
			||||||
		{ "nofname", XN_FLAG_FN_NONE, XN_FLAG_FN_MASK},
 | 
					 | 
				
			||||||
		{ "sname", XN_FLAG_FN_SN, XN_FLAG_FN_MASK},
 | 
					 | 
				
			||||||
		{ "lname", XN_FLAG_FN_LN, XN_FLAG_FN_MASK},
 | 
					 | 
				
			||||||
		{ "oid", XN_FLAG_FN_OID, XN_FLAG_FN_MASK},
 | 
					 | 
				
			||||||
		{ "space_eq", XN_FLAG_SPC_EQ, 0},
 | 
					 | 
				
			||||||
		{ "dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0},
 | 
					 | 
				
			||||||
		{ "RFC2253", XN_FLAG_RFC2253, 0xffffffffL},
 | 
					 | 
				
			||||||
		{ "oneline", XN_FLAG_ONELINE, 0xffffffffL},
 | 
					 | 
				
			||||||
		{ "multiline", XN_FLAG_MULTILINE, 0xffffffffL},
 | 
					 | 
				
			||||||
		{ NULL, 0, 0}
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	c = arg[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(c == '-') {
 | 
					 | 
				
			||||||
		c = 0;
 | 
					 | 
				
			||||||
		arg++;
 | 
					 | 
				
			||||||
	} else if (c == '+') {
 | 
					 | 
				
			||||||
		c = 1;
 | 
					 | 
				
			||||||
		arg++;
 | 
					 | 
				
			||||||
	} else c = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for(ptbl = ex_tbl; ptbl->name; ptbl++) {
 | 
					 | 
				
			||||||
		if(!strcmp(arg, ptbl->name)) {
 | 
					 | 
				
			||||||
			*flags &= ~ptbl->mask;
 | 
					 | 
				
			||||||
			if(c) *flags |= ptbl->flag;
 | 
					 | 
				
			||||||
			else *flags &= ~ptbl->flag;
 | 
					 | 
				
			||||||
			return 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char buf[256];
 | 
					 | 
				
			||||||
	char mline = 0;
 | 
					 | 
				
			||||||
	int indent = 0;
 | 
					 | 
				
			||||||
	if(title) BIO_puts(out, title);
 | 
					 | 
				
			||||||
	if((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
 | 
					 | 
				
			||||||
		mline = 1;
 | 
					 | 
				
			||||||
		indent = 4;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(lflags == XN_FLAG_COMPAT) {
 | 
					 | 
				
			||||||
		X509_NAME_oneline(nm,buf,256);
 | 
					 | 
				
			||||||
		BIO_puts(out,buf);
 | 
					 | 
				
			||||||
		BIO_puts(out, "\n");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if(mline) BIO_puts(out, "\n");
 | 
					 | 
				
			||||||
		X509_NAME_print_ex(out, nm, indent, lflags);
 | 
					 | 
				
			||||||
		BIO_puts(out, "\n");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										45
									
								
								apps/apps.h
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								apps/apps.h
									
									
									
									
									
								
							@@ -59,24 +59,12 @@
 | 
				
			|||||||
#ifndef HEADER_APPS_H
 | 
					#ifndef HEADER_APPS_H
 | 
				
			||||||
#define HEADER_APPS_H
 | 
					#define HEADER_APPS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "openssl/e_os.h"
 | 
					#include <openssl/e_os.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <openssl/buffer.h>
 | 
					#include <openssl/buffer.h>
 | 
				
			||||||
#include <openssl/bio.h>
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
#include <openssl/crypto.h>
 | 
					#include <openssl/crypto.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include "progs.h"
 | 
				
			||||||
#include <openssl/lhash.h>
 | 
					 | 
				
			||||||
#include <openssl/conf.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
 | 
					 | 
				
			||||||
int app_RAND_write_file(const char *file, BIO *bio_e);
 | 
					 | 
				
			||||||
/* When `file' is NULL, use defaults.
 | 
					 | 
				
			||||||
 * `bio_e' is for error messages. */
 | 
					 | 
				
			||||||
void app_RAND_allow_write_file(void);
 | 
					 | 
				
			||||||
long app_RAND_load_files(char *file); /* `file' is a list of files to read,
 | 
					 | 
				
			||||||
                                       * separated by LIST_SEPARATOR_CHAR
 | 
					 | 
				
			||||||
                                       * (see e_os.h).  The string is
 | 
					 | 
				
			||||||
                                       * destroyed! */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef NO_STDIO
 | 
					#ifdef NO_STDIO
 | 
				
			||||||
BIO_METHOD *BIO_s_file();
 | 
					BIO_METHOD *BIO_s_file();
 | 
				
			||||||
@@ -100,6 +88,7 @@ extern BIO *bio_err;
 | 
				
			|||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAIN(a,v)	PROG(a,v)
 | 
					#define MAIN(a,v)	PROG(a,v)
 | 
				
			||||||
 | 
					#include <openssl/conf.h>
 | 
				
			||||||
extern LHASH *config;
 | 
					extern LHASH *config;
 | 
				
			||||||
extern char *default_config_file;
 | 
					extern char *default_config_file;
 | 
				
			||||||
extern BIO *bio_err;
 | 
					extern BIO *bio_err;
 | 
				
			||||||
@@ -114,7 +103,7 @@ extern BIO *bio_err;
 | 
				
			|||||||
#define do_pipe_sig()
 | 
					#define do_pipe_sig()
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(MONOLITH) && !defined(OPENSSL_C)
 | 
					#if defined(MONOLITH) && !defined(SSLEAY)
 | 
				
			||||||
#  define apps_startup()	do_pipe_sig()
 | 
					#  define apps_startup()	do_pipe_sig()
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#  if defined(MSDOS) || defined(WIN16) || defined(WIN32)
 | 
					#  if defined(MSDOS) || defined(WIN16) || defined(WIN32)
 | 
				
			||||||
@@ -133,40 +122,20 @@ extern BIO *bio_err;
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct args_st
 | 
					typedef struct args_st
 | 
				
			||||||
	{
 | 
					        {
 | 
				
			||||||
	char **data;
 | 
					        char **data;
 | 
				
			||||||
	int count;
 | 
						int count;
 | 
				
			||||||
	} ARGS;
 | 
					        } ARGS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int should_retry(int i);
 | 
					int should_retry(int i);
 | 
				
			||||||
int args_from_file(char *file, int *argc, char **argv[]);
 | 
					int args_from_file(char *file, int *argc, char **argv[]);
 | 
				
			||||||
int str2fmt(char *s);
 | 
					int str2fmt(char *s);
 | 
				
			||||||
void program_name(char *in,char *out,int size);
 | 
					void program_name(char *in,char *out,int size);
 | 
				
			||||||
int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
 | 
					int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
 | 
				
			||||||
#ifdef HEADER_X509_H
 | 
					 | 
				
			||||||
int dump_cert_text(BIO *out, X509 *x);
 | 
					 | 
				
			||||||
void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
int set_name_ex(unsigned long *flags, const char *arg);
 | 
					 | 
				
			||||||
int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
 | 
					 | 
				
			||||||
int add_oid_section(BIO *err, LHASH *conf);
 | 
					 | 
				
			||||||
X509 *load_cert(BIO *err, char *file, int format);
 | 
					 | 
				
			||||||
EVP_PKEY *load_key(BIO *err, char *file, int format, char *pass);
 | 
					 | 
				
			||||||
EVP_PKEY *load_pubkey(BIO *err, char *file, int format);
 | 
					 | 
				
			||||||
STACK_OF(X509) *load_certs(BIO *err, char *file, int format);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define FORMAT_UNDEF    0
 | 
					#define FORMAT_UNDEF    0
 | 
				
			||||||
#define FORMAT_ASN1     1
 | 
					#define FORMAT_ASN1     1
 | 
				
			||||||
#define FORMAT_TEXT     2
 | 
					#define FORMAT_TEXT     2
 | 
				
			||||||
#define FORMAT_PEM      3
 | 
					#define FORMAT_PEM      3
 | 
				
			||||||
#define FORMAT_NETSCAPE 4
 | 
					#define FORMAT_NETSCAPE 4
 | 
				
			||||||
#define FORMAT_PKCS12   5
 | 
					 | 
				
			||||||
#define FORMAT_SMIME    6
 | 
					 | 
				
			||||||
/* Since this is currently inofficial, let's give it a high number */
 | 
					 | 
				
			||||||
#define FORMAT_ENGINE   127
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define NETSCAPE_CERT_HDR	"certificate"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define APP_PASS_LEN	1024
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,21 +74,19 @@
 | 
				
			|||||||
 * -i		- indent the details by depth
 | 
					 * -i		- indent the details by depth
 | 
				
			||||||
 * -offset	- where in the file to start
 | 
					 * -offset	- where in the file to start
 | 
				
			||||||
 * -length	- how many bytes to use
 | 
					 * -length	- how many bytes to use
 | 
				
			||||||
 * -oid file	- extra oid description file
 | 
					 * -oid file	- extra oid decription file
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	asn1parse_main
 | 
					#define PROG	asn1parse_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int i,badops=0,offset=0,ret=1,j;
 | 
						int i,badops=0,offset=0,ret=1,j;
 | 
				
			||||||
	unsigned int length=0;
 | 
						unsigned int length=0;
 | 
				
			||||||
	long num,tmplen;
 | 
						long num,tmplen;
 | 
				
			||||||
	BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;
 | 
						BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;
 | 
				
			||||||
	int informat,indent=0, noout = 0, dump = 0;
 | 
						int informat,indent=0;
 | 
				
			||||||
	char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
 | 
						char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;
 | 
				
			||||||
	unsigned char *tmpbuf;
 | 
						unsigned char *tmpbuf;
 | 
				
			||||||
	BUF_MEM *buf=NULL;
 | 
						BUF_MEM *buf=NULL;
 | 
				
			||||||
@@ -108,7 +106,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	argv++;
 | 
						argv++;
 | 
				
			||||||
	if ((osk=sk_new_null()) == NULL)
 | 
						if ((osk=sk_new_null()) == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"Memory allocation failure\n");
 | 
							BIO_printf(bio_err,"Malloc failure\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	while (argc >= 1)
 | 
						while (argc >= 1)
 | 
				
			||||||
@@ -132,7 +130,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
			indent=1;
 | 
								indent=1;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0) noout = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-oid") == 0)
 | 
							else if (strcmp(*argv,"-oid") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -149,16 +146,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			length= atoi(*(++argv));
 | 
								length= atoi(*(++argv));
 | 
				
			||||||
			if (length == 0) goto bad;
 | 
								if (length == 0) goto bad;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-dump") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			dump= -1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-dlimit") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			dump= atoi(*(++argv));
 | 
					 | 
				
			||||||
			if (dump <= 0) goto bad;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-strparse") == 0)
 | 
							else if (strcmp(*argv,"-strparse") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -181,13 +168,9 @@ bad:
 | 
				
			|||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg       input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg      output file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -noout arg    don't produce any output\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -offset arg   offset into file\n");
 | 
							BIO_printf(bio_err," -offset arg   offset into file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -length arg   length of section in file\n");
 | 
							BIO_printf(bio_err," -length arg   lenth of section in file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -i            indent entries\n");
 | 
							BIO_printf(bio_err," -i            indent entries\n");
 | 
				
			||||||
		BIO_printf(bio_err," -dump         dump unknown data in hex form\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -dlimit arg   dump the first arg bytes of unknown data in hex form\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -oid file     file of extra oid definitions\n");
 | 
							BIO_printf(bio_err," -oid file     file of extra oid definitions\n");
 | 
				
			||||||
		BIO_printf(bio_err," -strparse offset\n");
 | 
							BIO_printf(bio_err," -strparse offset\n");
 | 
				
			||||||
		BIO_printf(bio_err,"               a series of these can be used to 'dig' into multiple\n");
 | 
							BIO_printf(bio_err,"               a series of these can be used to 'dig' into multiple\n");
 | 
				
			||||||
@@ -206,12 +189,6 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
						BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
	out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (oidfile != NULL)
 | 
						if (oidfile != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -310,9 +287,7 @@ bad:
 | 
				
			|||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!noout &&
 | 
						if (!ASN1_parse(out,(unsigned char *)&(str[offset]),length,indent))
 | 
				
			||||||
	    !ASN1_parse_dump(out,(unsigned char *)&(str[offset]),length,
 | 
					 | 
				
			||||||
		    indent,dump))
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
@@ -321,7 +296,7 @@ bad:
 | 
				
			|||||||
end:
 | 
					end:
 | 
				
			||||||
	BIO_free(derout);
 | 
						BIO_free(derout);
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (b64 != NULL) BIO_free(b64);
 | 
						if (b64 != NULL) BIO_free(b64);
 | 
				
			||||||
	if (ret != 0)
 | 
						if (ret != 0)
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
07
 | 
					05
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,6 +66,10 @@
 | 
				
			|||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					#include <openssl/ssl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(NO_RSA) && !defined(NO_SSL2)
 | 
				
			||||||
 | 
					#define NO_SSL2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	ciphers_main
 | 
					#define PROG	ciphers_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -74,12 +78,9 @@ static char *ciphers_usage[]={
 | 
				
			|||||||
" -v          - verbose mode, a textual listing of the ciphers in SSLeay\n",
 | 
					" -v          - verbose mode, a textual listing of the ciphers in SSLeay\n",
 | 
				
			||||||
" -ssl2       - SSL2 mode\n",
 | 
					" -ssl2       - SSL2 mode\n",
 | 
				
			||||||
" -ssl3       - SSL3 mode\n",
 | 
					" -ssl3       - SSL3 mode\n",
 | 
				
			||||||
" -tls1       - TLS1 mode\n",
 | 
					 | 
				
			||||||
NULL
 | 
					NULL
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int ret=1,i;
 | 
						int ret=1,i;
 | 
				
			||||||
@@ -108,12 +109,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	if (bio_err == NULL)
 | 
						if (bio_err == NULL)
 | 
				
			||||||
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
							bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
				
			||||||
	STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
 | 
						STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
	STDout = BIO_push(tmpbio, STDout);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	argc--;
 | 
						argc--;
 | 
				
			||||||
	argv++;
 | 
						argv++;
 | 
				
			||||||
@@ -128,10 +123,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
#ifndef NO_SSL3
 | 
					#ifndef NO_SSL3
 | 
				
			||||||
		else if (strcmp(*argv,"-ssl3") == 0)
 | 
							else if (strcmp(*argv,"-ssl3") == 0)
 | 
				
			||||||
			meth=SSLv3_client_method();
 | 
								meth=SSLv3_client_method();
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_TLS1
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-tls1") == 0)
 | 
					 | 
				
			||||||
			meth=TLSv1_client_method();
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		else if ((strncmp(*argv,"-h",2) == 0) ||
 | 
							else if ((strncmp(*argv,"-h",2) == 0) ||
 | 
				
			||||||
			 (strcmp(*argv,"-?") == 0))
 | 
								 (strcmp(*argv,"-?") == 0))
 | 
				
			||||||
@@ -154,16 +145,12 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	OpenSSL_add_ssl_algorithms();
 | 
						SSLeay_add_ssl_algorithms();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx=SSL_CTX_new(meth);
 | 
						ctx=SSL_CTX_new(meth);
 | 
				
			||||||
	if (ctx == NULL) goto err;
 | 
						if (ctx == NULL) goto err;
 | 
				
			||||||
	if (ciphers != NULL) {
 | 
						if (ciphers != NULL)
 | 
				
			||||||
		if(!SSL_CTX_set_cipher_list(ctx,ciphers)) {
 | 
							SSL_CTX_set_cipher_list(ctx,ciphers);
 | 
				
			||||||
			BIO_printf(bio_err, "Error in cipher list\n");
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	ssl=SSL_new(ctx);
 | 
						ssl=SSL_new(ctx);
 | 
				
			||||||
	if (ssl == NULL) goto err;
 | 
						if (ssl == NULL) goto err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -201,7 +188,7 @@ err:
 | 
				
			|||||||
end:
 | 
					end:
 | 
				
			||||||
	if (ctx != NULL) SSL_CTX_free(ctx);
 | 
						if (ctx != NULL) SSL_CTX_free(ctx);
 | 
				
			||||||
	if (ssl != NULL) SSL_free(ssl);
 | 
						if (ssl != NULL) SSL_free(ssl);
 | 
				
			||||||
	if (STDout != NULL) BIO_free_all(STDout);
 | 
						if (STDout != NULL) BIO_free(STDout);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										134
									
								
								apps/crl.c
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								apps/crl.c
									
									
									
									
									
								
							@@ -75,7 +75,7 @@
 | 
				
			|||||||
static char *crl_usage[]={
 | 
					static char *crl_usage[]={
 | 
				
			||||||
"usage: crl args\n",
 | 
					"usage: crl args\n",
 | 
				
			||||||
"\n",
 | 
					"\n",
 | 
				
			||||||
" -inform arg     - input format - default PEM (DER or PEM)\n",
 | 
					" -inform arg     - input format - default PEM (one of DER, TXT or PEM)\n",
 | 
				
			||||||
" -outform arg    - output format - default PEM\n",
 | 
					" -outform arg    - output format - default PEM\n",
 | 
				
			||||||
" -text           - print out a text format version\n",
 | 
					" -text           - print out a text format version\n",
 | 
				
			||||||
" -in arg         - input file - default stdin\n",
 | 
					" -in arg         - input file - default stdin\n",
 | 
				
			||||||
@@ -85,34 +85,21 @@ static char *crl_usage[]={
 | 
				
			|||||||
" -lastupdate     - lastUpdate field\n",
 | 
					" -lastupdate     - lastUpdate field\n",
 | 
				
			||||||
" -nextupdate     - nextUpdate field\n",
 | 
					" -nextupdate     - nextUpdate field\n",
 | 
				
			||||||
" -noout          - no CRL output\n",
 | 
					" -noout          - no CRL output\n",
 | 
				
			||||||
" -CAfile  name   - verify CRL using certificates in file \"name\"\n",
 | 
					 | 
				
			||||||
" -CApath  dir    - verify CRL using certificates in \"dir\"\n",
 | 
					 | 
				
			||||||
NULL
 | 
					NULL
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static X509_CRL *load_crl(char *file, int format);
 | 
					static X509_CRL *load_crl(char *file, int format);
 | 
				
			||||||
static BIO *bio_out=NULL;
 | 
					static BIO *bio_out=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	X509_CRL *x=NULL;
 | 
						X509_CRL *x=NULL;
 | 
				
			||||||
	char *CAfile = NULL, *CApath = NULL;
 | 
					 | 
				
			||||||
	int ret=1,i,num,badops=0;
 | 
						int ret=1,i,num,badops=0;
 | 
				
			||||||
	BIO *out=NULL;
 | 
						BIO *out=NULL;
 | 
				
			||||||
	int informat,outformat;
 | 
						int informat,outformat;
 | 
				
			||||||
	char *infile=NULL,*outfile=NULL;
 | 
						char *infile=NULL,*outfile=NULL;
 | 
				
			||||||
	int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
 | 
						int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0;
 | 
				
			||||||
	int fingerprint = 0;
 | 
					 | 
				
			||||||
	char **pp,buf[256];
 | 
						char **pp,buf[256];
 | 
				
			||||||
	X509_STORE *store = NULL;
 | 
					 | 
				
			||||||
	X509_STORE_CTX ctx;
 | 
					 | 
				
			||||||
	X509_LOOKUP *lookup = NULL;
 | 
					 | 
				
			||||||
	X509_OBJECT xobj;
 | 
					 | 
				
			||||||
	EVP_PKEY *pkey;
 | 
					 | 
				
			||||||
	int do_ver = 0;
 | 
					 | 
				
			||||||
	const EVP_MD *md_alg,*digest=EVP_md5();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -122,15 +109,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (bio_out == NULL)
 | 
						if (bio_out == NULL)
 | 
				
			||||||
		if ((bio_out=BIO_new(BIO_s_file())) != NULL)
 | 
							if ((bio_out=BIO_new(BIO_s_file())) != NULL)
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
 | 
								BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
			bio_out = BIO_push(tmpbio, bio_out);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	informat=FORMAT_PEM;
 | 
						informat=FORMAT_PEM;
 | 
				
			||||||
	outformat=FORMAT_PEM;
 | 
						outformat=FORMAT_PEM;
 | 
				
			||||||
@@ -167,20 +146,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-CApath") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			CApath = *(++argv);
 | 
					 | 
				
			||||||
			do_ver = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-CAfile") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			CAfile = *(++argv);
 | 
					 | 
				
			||||||
			do_ver = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-verify") == 0)
 | 
					 | 
				
			||||||
			do_ver = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
							else if (strcmp(*argv,"-text") == 0)
 | 
				
			||||||
			text = 1;
 | 
								text = 1;
 | 
				
			||||||
		else if (strcmp(*argv,"-hash") == 0)
 | 
							else if (strcmp(*argv,"-hash") == 0)
 | 
				
			||||||
@@ -193,13 +158,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			nextupdate= ++num;
 | 
								nextupdate= ++num;
 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
							else if (strcmp(*argv,"-noout") == 0)
 | 
				
			||||||
			noout= ++num;
 | 
								noout= ++num;
 | 
				
			||||||
		else if (strcmp(*argv,"-fingerprint") == 0)
 | 
					 | 
				
			||||||
			fingerprint= ++num;
 | 
					 | 
				
			||||||
		else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			/* ok */
 | 
					 | 
				
			||||||
			digest=md_alg;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -219,98 +177,40 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
						X509V3_add_standard_extensions();
 | 
				
			||||||
	x=load_crl(infile,informat);
 | 
						x=load_crl(infile,informat);
 | 
				
			||||||
	if (x == NULL) { goto end; }
 | 
						if (x == NULL) { goto end; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(do_ver) {
 | 
					 | 
				
			||||||
		store = X509_STORE_new();
 | 
					 | 
				
			||||||
		lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
 | 
					 | 
				
			||||||
		if (lookup == NULL) goto end;
 | 
					 | 
				
			||||||
		if (!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM))
 | 
					 | 
				
			||||||
			X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
 | 
					 | 
				
			||||||
		if (lookup == NULL) goto end;
 | 
					 | 
				
			||||||
		if (!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM))
 | 
					 | 
				
			||||||
			X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
 | 
					 | 
				
			||||||
		ERR_clear_error();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		X509_STORE_CTX_init(&ctx, store, NULL, NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		i = X509_STORE_get_by_subject(&ctx, X509_LU_X509, 
 | 
					 | 
				
			||||||
					X509_CRL_get_issuer(x), &xobj);
 | 
					 | 
				
			||||||
		if(i <= 0) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,
 | 
					 | 
				
			||||||
				"Error getting CRL issuer certificate\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		pkey = X509_get_pubkey(xobj.data.x509);
 | 
					 | 
				
			||||||
		X509_OBJECT_free_contents(&xobj);
 | 
					 | 
				
			||||||
		if(!pkey) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,
 | 
					 | 
				
			||||||
				"Error getting CRL issuer public key\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		i = X509_CRL_verify(x, pkey);
 | 
					 | 
				
			||||||
		EVP_PKEY_free(pkey);
 | 
					 | 
				
			||||||
		if(i < 0) goto end;
 | 
					 | 
				
			||||||
		if(i == 0) BIO_printf(bio_err, "verify failure\n");
 | 
					 | 
				
			||||||
		else BIO_printf(bio_err, "verify OK\n");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (num)
 | 
						if (num)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		for (i=1; i<=num; i++)
 | 
							for (i=1; i<=num; i++)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (issuer == i)
 | 
								if (issuer == i)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				X509_NAME_oneline(X509_CRL_get_issuer(x),
 | 
									X509_NAME_oneline(x->crl->issuer,buf,256);
 | 
				
			||||||
								buf,256);
 | 
					 | 
				
			||||||
				BIO_printf(bio_out,"issuer= %s\n",buf);
 | 
									BIO_printf(bio_out,"issuer= %s\n",buf);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (hash == i)
 | 
								if (hash == i)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_out,"%08lx\n",
 | 
									BIO_printf(bio_out,"%08lx\n",
 | 
				
			||||||
					X509_NAME_hash(X509_CRL_get_issuer(x)));
 | 
										X509_NAME_hash(x->crl->issuer));
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			if (lastupdate == i)
 | 
								if (lastupdate == i)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_out,"lastUpdate=");
 | 
									BIO_printf(bio_out,"lastUpdate=");
 | 
				
			||||||
				ASN1_TIME_print(bio_out,
 | 
									ASN1_TIME_print(bio_out,x->crl->lastUpdate);
 | 
				
			||||||
						X509_CRL_get_lastUpdate(x));
 | 
					 | 
				
			||||||
				BIO_printf(bio_out,"\n");
 | 
									BIO_printf(bio_out,"\n");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			if (nextupdate == i)
 | 
								if (nextupdate == i)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_out,"nextUpdate=");
 | 
									BIO_printf(bio_out,"nextUpdate=");
 | 
				
			||||||
				if (X509_CRL_get_nextUpdate(x)) 
 | 
									if (x->crl->nextUpdate != NULL)
 | 
				
			||||||
					ASN1_TIME_print(bio_out,
 | 
										ASN1_TIME_print(bio_out,x->crl->nextUpdate);
 | 
				
			||||||
						X509_CRL_get_nextUpdate(x));
 | 
					 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
					BIO_printf(bio_out,"NONE");
 | 
										BIO_printf(bio_out,"NONE");
 | 
				
			||||||
				BIO_printf(bio_out,"\n");
 | 
									BIO_printf(bio_out,"\n");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			if (fingerprint == i)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				int j;
 | 
					 | 
				
			||||||
				unsigned int n;
 | 
					 | 
				
			||||||
				unsigned char md[EVP_MAX_MD_SIZE];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (!X509_CRL_digest(x,digest,md,&n))
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,"out of memory\n");
 | 
					 | 
				
			||||||
					goto end;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				BIO_printf(bio_out,"%s Fingerprint=",
 | 
					 | 
				
			||||||
						OBJ_nid2sn(EVP_MD_type(digest)));
 | 
					 | 
				
			||||||
				for (j=0; j<(int)n; j++)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
					BIO_printf(bio_out,"%02X%c",md[j],
 | 
					 | 
				
			||||||
						(j+1 == (int)n)
 | 
					 | 
				
			||||||
						?'\n':':');
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -322,15 +222,7 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -356,14 +248,10 @@ bad:
 | 
				
			|||||||
	if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
 | 
						if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	BIO_free_all(out);
 | 
						BIO_free(out);
 | 
				
			||||||
	BIO_free_all(bio_out);
 | 
						BIO_free(bio_out);
 | 
				
			||||||
	bio_out=NULL;
 | 
					 | 
				
			||||||
	X509_CRL_free(x);
 | 
						X509_CRL_free(x);
 | 
				
			||||||
	if(store) {
 | 
						X509V3_EXT_cleanup();
 | 
				
			||||||
		X509_STORE_CTX_cleanup(&ctx);
 | 
					 | 
				
			||||||
		X509_STORE_free(store);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -392,7 +280,7 @@ static X509_CRL *load_crl(char *infile, int format)
 | 
				
			|||||||
	if 	(format == FORMAT_ASN1)
 | 
						if 	(format == FORMAT_ASN1)
 | 
				
			||||||
		x=d2i_X509_CRL_bio(in,NULL);
 | 
							x=d2i_X509_CRL_bio(in,NULL);
 | 
				
			||||||
	else if (format == FORMAT_PEM)
 | 
						else if (format == FORMAT_PEM)
 | 
				
			||||||
		x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
 | 
							x=PEM_read_bio_X509_CRL(in,NULL,NULL);
 | 
				
			||||||
	else	{
 | 
						else	{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified for input crl\n");
 | 
							BIO_printf(bio_err,"bad input format specified for input crl\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,14 +76,12 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
 | 
				
			|||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	crl2pkcs7_main
 | 
					#define PROG	crl2pkcs7_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -inform arg	- input format - default PEM (DER or PEM)
 | 
					/* -inform arg	- input format - default PEM (one of DER, TXT or PEM)
 | 
				
			||||||
 * -outform arg - output format - default PEM
 | 
					 * -outform arg - output format - default PEM
 | 
				
			||||||
 * -in arg	- input file - default stdin
 | 
					 * -in arg	- input file - default stdin
 | 
				
			||||||
 * -out arg	- output file - default stdout
 | 
					 * -out arg	- output file - default stdout
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int i,badops=0;
 | 
						int i,badops=0;
 | 
				
			||||||
@@ -94,7 +92,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	PKCS7_SIGNED *p7s = NULL;
 | 
						PKCS7_SIGNED *p7s = NULL;
 | 
				
			||||||
	X509_CRL *crl=NULL;
 | 
						X509_CRL *crl=NULL;
 | 
				
			||||||
	STACK *certflst=NULL;
 | 
						STACK *certflst=NULL;
 | 
				
			||||||
	STACK_OF(X509_CRL) *crl_stack=NULL;
 | 
						STACK *crl_stack=NULL;
 | 
				
			||||||
	STACK_OF(X509) *cert_stack=NULL;
 | 
						STACK_OF(X509) *cert_stack=NULL;
 | 
				
			||||||
	int ret=1,nocrl=0;
 | 
						int ret=1,nocrl=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -141,7 +139,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (strcmp(*argv,"-certfile") == 0)
 | 
							else if (strcmp(*argv,"-certfile") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			if(!certflst) certflst = sk_new_null();
 | 
								if(!certflst) certflst = sk_new(NULL);
 | 
				
			||||||
			sk_push(certflst,*(++argv));
 | 
								sk_push(certflst,*(++argv));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
@@ -159,8 +157,8 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg    input format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -inform arg    input format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg   output format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -outform arg   output format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg        input file\n");
 | 
							BIO_printf(bio_err," -in arg        input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg       output file\n");
 | 
							BIO_printf(bio_err," -out arg       output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -certfile arg  certificates file of chain to a trusted CA\n");
 | 
							BIO_printf(bio_err," -certfile arg  certificates file of chain to a trusted CA\n");
 | 
				
			||||||
@@ -195,7 +193,7 @@ bad:
 | 
				
			|||||||
		if 	(informat == FORMAT_ASN1)
 | 
							if 	(informat == FORMAT_ASN1)
 | 
				
			||||||
			crl=d2i_X509_CRL_bio(in,NULL);
 | 
								crl=d2i_X509_CRL_bio(in,NULL);
 | 
				
			||||||
		else if (informat == FORMAT_PEM)
 | 
							else if (informat == FORMAT_PEM)
 | 
				
			||||||
			crl=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);
 | 
								crl=PEM_read_bio_X509_CRL(in,NULL,NULL);
 | 
				
			||||||
		else	{
 | 
							else	{
 | 
				
			||||||
			BIO_printf(bio_err,"bad input format specified for input crl\n");
 | 
								BIO_printf(bio_err,"bad input format specified for input crl\n");
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
@@ -215,15 +213,15 @@ bad:
 | 
				
			|||||||
	p7s->contents->type=OBJ_nid2obj(NID_pkcs7_data);
 | 
						p7s->contents->type=OBJ_nid2obj(NID_pkcs7_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ASN1_INTEGER_set(p7s->version,1)) goto end;
 | 
						if (!ASN1_INTEGER_set(p7s->version,1)) goto end;
 | 
				
			||||||
	if ((crl_stack=sk_X509_CRL_new_null()) == NULL) goto end;
 | 
						if ((crl_stack=sk_new(NULL)) == NULL) goto end;
 | 
				
			||||||
	p7s->crl=crl_stack;
 | 
						p7s->crl=crl_stack;
 | 
				
			||||||
	if (crl != NULL)
 | 
						if (crl != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		sk_X509_CRL_push(crl_stack,crl);
 | 
							sk_push(crl_stack,(char *)crl);
 | 
				
			||||||
		crl=NULL; /* now part of p7 for OPENSSL_freeing */
 | 
							crl=NULL; /* now part of p7 for Freeing */
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((cert_stack=sk_X509_new_null()) == NULL) goto end;
 | 
						if ((cert_stack=sk_X509_new(NULL)) == NULL) goto end;
 | 
				
			||||||
	p7s->cert=cert_stack;
 | 
						p7s->cert=cert_stack;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(certflst) for(i = 0; i < sk_num(certflst); i++) {
 | 
						if(certflst) for(i = 0; i < sk_num(certflst); i++) {
 | 
				
			||||||
@@ -239,15 +237,7 @@ bad:
 | 
				
			|||||||
	sk_free(certflst);
 | 
						sk_free(certflst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -274,7 +264,7 @@ bad:
 | 
				
			|||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (p7 != NULL) PKCS7_free(p7);
 | 
						if (p7 != NULL) PKCS7_free(p7);
 | 
				
			||||||
	if (crl != NULL) X509_CRL_free(crl);
 | 
						if (crl != NULL) X509_CRL_free(crl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -314,7 +304,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* This loads from a file, a stack of x509/crl/pkey sets */
 | 
						/* This loads from a file, a stack of x509/crl/pkey sets */
 | 
				
			||||||
	sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL);
 | 
						sk=PEM_X509_INFO_read_bio(in,NULL,NULL);
 | 
				
			||||||
	if (sk == NULL) {
 | 
						if (sk == NULL) {
 | 
				
			||||||
		BIO_printf(bio_err,"error reading the file, %s\n",certfile);
 | 
							BIO_printf(bio_err,"error reading the file, %s\n",certfile);
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
@@ -335,7 +325,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ret=count;
 | 
						ret=count;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
 	/* never need to OPENSSL_free x */
 | 
					 	/* never need to Free x */
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (sk != NULL) sk_X509_INFO_free(sk);
 | 
						if (sk != NULL) sk_X509_INFO_free(sk);
 | 
				
			||||||
	return(ret);
 | 
						return(ret);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										240
									
								
								apps/dgst.c
									
									
									
									
									
								
							
							
						
						
									
										240
									
								
								apps/dgst.c
									
									
									
									
									
								
							@@ -66,7 +66,6 @@
 | 
				
			|||||||
#include <openssl/objects.h>
 | 
					#include <openssl/objects.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef BUFSIZE
 | 
					#undef BUFSIZE
 | 
				
			||||||
#define BUFSIZE	1024*8
 | 
					#define BUFSIZE	1024*8
 | 
				
			||||||
@@ -74,36 +73,23 @@
 | 
				
			|||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	dgst_main
 | 
					#define PROG	dgst_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
 | 
					void do_fp(unsigned char *buf,BIO *f,int sep);
 | 
				
			||||||
		EVP_PKEY *key, unsigned char *sigin, int siglen);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	unsigned char *buf=NULL;
 | 
						unsigned char *buf=NULL;
 | 
				
			||||||
	int i,err=0;
 | 
						int i,err=0;
 | 
				
			||||||
	const EVP_MD *md=NULL,*m;
 | 
						const EVP_MD *md=NULL,*m;
 | 
				
			||||||
	BIO *in=NULL,*inp;
 | 
						BIO *in=NULL,*inp;
 | 
				
			||||||
	BIO *bmd=NULL;
 | 
						BIO *bmd=NULL;
 | 
				
			||||||
	BIO *out = NULL;
 | 
					 | 
				
			||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
#define PROG_NAME_SIZE  39
 | 
					#define PROG_NAME_SIZE  16
 | 
				
			||||||
	char pname[PROG_NAME_SIZE+1];
 | 
					        char pname[PROG_NAME_SIZE];
 | 
				
			||||||
	int separator=0;
 | 
						int separator=0;
 | 
				
			||||||
	int debug=0;
 | 
						int debug=0;
 | 
				
			||||||
	const char *outfile = NULL, *keyfile = NULL;
 | 
					 | 
				
			||||||
	const char *sigfile = NULL, *randfile = NULL;
 | 
					 | 
				
			||||||
	int out_bin = -1, want_pub = 0, do_verify = 0;
 | 
					 | 
				
			||||||
	EVP_PKEY *sigkey = NULL;
 | 
					 | 
				
			||||||
	unsigned char *sigbuf = NULL;
 | 
					 | 
				
			||||||
	int siglen = 0;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((buf=(unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL)
 | 
						if ((buf=(unsigned char *)Malloc(BUFSIZE)) == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"out of memory\n");
 | 
							BIO_printf(bio_err,"out of memory\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
@@ -113,7 +99,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* first check the program name */
 | 
						/* first check the program name */
 | 
				
			||||||
	program_name(argv[0],pname,PROG_NAME_SIZE);
 | 
					        program_name(argv[0],pname,PROG_NAME_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	md=EVP_get_digestbyname(pname);
 | 
						md=EVP_get_digestbyname(pname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -124,48 +110,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		if ((*argv)[0] != '-') break;
 | 
							if ((*argv)[0] != '-') break;
 | 
				
			||||||
		if (strcmp(*argv,"-c") == 0)
 | 
							if (strcmp(*argv,"-c") == 0)
 | 
				
			||||||
			separator=1;
 | 
								separator=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			randfile=*(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-out") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			outfile=*(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-sign") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			keyfile=*(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-verify") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			keyfile=*(++argv);
 | 
					 | 
				
			||||||
			want_pub = 1;
 | 
					 | 
				
			||||||
			do_verify = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-prverify") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			keyfile=*(++argv);
 | 
					 | 
				
			||||||
			do_verify = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-signature") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			sigfile=*(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) break;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-hex") == 0)
 | 
					 | 
				
			||||||
			out_bin = 0;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-binary") == 0)
 | 
					 | 
				
			||||||
			out_bin = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-d") == 0)
 | 
							else if (strcmp(*argv,"-d") == 0)
 | 
				
			||||||
			debug=1;
 | 
								debug=1;
 | 
				
			||||||
		else if ((m=EVP_get_digestbyname(&((*argv)[1]))) != NULL)
 | 
							else if ((m=EVP_get_digestbyname(&((*argv)[1]))) != NULL)
 | 
				
			||||||
@@ -179,31 +123,14 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	if (md == NULL)
 | 
						if (md == NULL)
 | 
				
			||||||
		md=EVP_md5();
 | 
							md=EVP_md5();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(do_verify && !sigfile) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "No signature to verify: use the -signature option\n");
 | 
					 | 
				
			||||||
		err = 1; 
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((argc > 0) && (argv[0][0] == '-')) /* bad option */
 | 
						if ((argc > 0) && (argv[0][0] == '-')) /* bad option */
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unknown option '%s'\n",*argv);
 | 
							BIO_printf(bio_err,"unknown option '%s'\n",*argv);
 | 
				
			||||||
		BIO_printf(bio_err,"options are\n");
 | 
							BIO_printf(bio_err,"options are\n");
 | 
				
			||||||
		BIO_printf(bio_err,"-c              to output the digest with separating colons\n");
 | 
							BIO_printf(bio_err,"-c   to output the digest with separating colons\n");
 | 
				
			||||||
		BIO_printf(bio_err,"-d              to output debug info\n");
 | 
							BIO_printf(bio_err,"-d   to output debug info\n");
 | 
				
			||||||
		BIO_printf(bio_err,"-hex            output as hex dump\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-binary         output in binary form\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-sign   file    sign digest using private key in file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-verify file    verify a signature using public key in file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-prverify file  verify a signature using private key in file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-signature file signature to verify\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-binary         output in binary form\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-engine e       use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-%3s to use the %s message digest algorithm (default)\n",
 | 
							BIO_printf(bio_err,"-%3s to use the %s message digest algorithm (default)\n",
 | 
				
			||||||
			LN_md5,LN_md5);
 | 
								LN_md5,LN_md5);
 | 
				
			||||||
		BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
 | 
					 | 
				
			||||||
			LN_md4,LN_md4);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
 | 
							BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
 | 
				
			||||||
			LN_md2,LN_md2);
 | 
								LN_md2,LN_md2);
 | 
				
			||||||
		BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
 | 
							BIO_printf(bio_err,"-%3s to use the %s message digest algorithm\n",
 | 
				
			||||||
@@ -217,25 +144,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		err=1;
 | 
							err=1;
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	bmd=BIO_new(BIO_f_md());
 | 
						bmd=BIO_new(BIO_f_md());
 | 
				
			||||||
	if (debug)
 | 
						if (debug)
 | 
				
			||||||
@@ -251,80 +160,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(out_bin == -1) {
 | 
					 | 
				
			||||||
		if(keyfile) out_bin = 1;
 | 
					 | 
				
			||||||
		else out_bin = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(randfile)
 | 
					 | 
				
			||||||
		app_RAND_load_file(randfile, bio_err, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(outfile) {
 | 
					 | 
				
			||||||
		if(out_bin)
 | 
					 | 
				
			||||||
			out = BIO_new_file(outfile, "wb");
 | 
					 | 
				
			||||||
		else    out = BIO_new_file(outfile, "w");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!out) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error opening output file %s\n", 
 | 
					 | 
				
			||||||
					outfile ? outfile : "(stdout)");
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(keyfile) {
 | 
					 | 
				
			||||||
		BIO *keybio;
 | 
					 | 
				
			||||||
		keybio = BIO_new_file(keyfile, "r");
 | 
					 | 
				
			||||||
		if(!keybio) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error opening key file %s\n",
 | 
					 | 
				
			||||||
								keyfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if(want_pub) 
 | 
					 | 
				
			||||||
			sigkey = PEM_read_bio_PUBKEY(keybio, NULL, NULL, NULL);
 | 
					 | 
				
			||||||
		else sigkey = PEM_read_bio_PrivateKey(keybio, NULL, NULL, NULL);
 | 
					 | 
				
			||||||
		BIO_free(keybio);
 | 
					 | 
				
			||||||
		if(!sigkey) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error reading key file %s\n",
 | 
					 | 
				
			||||||
								keyfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(sigfile && sigkey) {
 | 
					 | 
				
			||||||
		BIO *sigbio;
 | 
					 | 
				
			||||||
		sigbio = BIO_new_file(sigfile, "rb");
 | 
					 | 
				
			||||||
		siglen = EVP_PKEY_size(sigkey);
 | 
					 | 
				
			||||||
		sigbuf = OPENSSL_malloc(siglen);
 | 
					 | 
				
			||||||
		if(!sigbio) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error opening signature file %s\n",
 | 
					 | 
				
			||||||
								sigfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		siglen = BIO_read(sigbio, sigbuf, siglen);
 | 
					 | 
				
			||||||
		BIO_free(sigbio);
 | 
					 | 
				
			||||||
		if(siglen <= 0) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error reading signature file %s\n",
 | 
					 | 
				
			||||||
								sigfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* we use md as a filter, reading from 'in' */
 | 
						/* we use md as a filter, reading from 'in' */
 | 
				
			||||||
	BIO_set_md(bmd,md);
 | 
						BIO_set_md(bmd,md);
 | 
				
			||||||
	inp=BIO_push(bmd,in);
 | 
						inp=BIO_push(bmd,in);
 | 
				
			||||||
@@ -332,7 +167,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	if (argc == 0)
 | 
						if (argc == 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_set_fp(in,stdin,BIO_NOCLOSE);
 | 
							BIO_set_fp(in,stdin,BIO_NOCLOSE);
 | 
				
			||||||
		do_fp(out, buf,inp,separator, out_bin, sigkey, sigbuf, siglen);
 | 
							do_fp(buf,inp,separator);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -345,28 +180,23 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
				err++;
 | 
									err++;
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			if(!out_bin) BIO_printf(out, "%s(%s)= ",name,argv[i]);
 | 
								printf("%s(%s)= ",name,argv[i]);
 | 
				
			||||||
			do_fp(out, buf,inp,separator, out_bin, sigkey, 
 | 
								do_fp(buf,inp,separator);
 | 
				
			||||||
								sigbuf, siglen);
 | 
								BIO_reset(bmd);
 | 
				
			||||||
			(void)BIO_reset(bmd);
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (buf != NULL)
 | 
						if (buf != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		memset(buf,0,BUFSIZE);
 | 
							memset(buf,0,BUFSIZE);
 | 
				
			||||||
		OPENSSL_free(buf);
 | 
							Free(buf);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	BIO_free_all(out);
 | 
					 | 
				
			||||||
	EVP_PKEY_free(sigkey);
 | 
					 | 
				
			||||||
	if(sigbuf) OPENSSL_free(sigbuf);
 | 
					 | 
				
			||||||
	if (bmd != NULL) BIO_free(bmd);
 | 
						if (bmd != NULL) BIO_free(bmd);
 | 
				
			||||||
	EXIT(err);
 | 
						EXIT(err);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
 | 
					void do_fp(unsigned char *buf, BIO *bp, int sep)
 | 
				
			||||||
			EVP_PKEY *key, unsigned char *sigin, int siglen)
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int len;
 | 
						int len;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
@@ -376,44 +206,14 @@ void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
 | 
				
			|||||||
		i=BIO_read(bp,(char *)buf,BUFSIZE);
 | 
							i=BIO_read(bp,(char *)buf,BUFSIZE);
 | 
				
			||||||
		if (i <= 0) break;
 | 
							if (i <= 0) break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if(sigin)
 | 
						len=BIO_gets(bp,(char *)buf,BUFSIZE);
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		EVP_MD_CTX *ctx;
 | 
					 | 
				
			||||||
		BIO_get_md_ctx(bp, &ctx);
 | 
					 | 
				
			||||||
		i = EVP_VerifyFinal(ctx, sigin, (unsigned int)siglen, key); 
 | 
					 | 
				
			||||||
		if(i > 0) BIO_printf(out, "Verified OK\n");
 | 
					 | 
				
			||||||
		else if(i == 0) BIO_printf(out, "Verification Failure\n");
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error Verifying Data\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if(key)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		EVP_MD_CTX *ctx;
 | 
					 | 
				
			||||||
		BIO_get_md_ctx(bp, &ctx);
 | 
					 | 
				
			||||||
		if(!EVP_SignFinal(ctx, buf, (unsigned int *)&len, key)) 
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error Signing Data\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		len=BIO_gets(bp,(char *)buf,BUFSIZE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(binout) BIO_write(out, buf, len);
 | 
						for (i=0; i<len; i++)
 | 
				
			||||||
	else 
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		for (i=0; i<len; i++)
 | 
							if (sep && (i != 0))
 | 
				
			||||||
			{
 | 
								putc(':',stdout);
 | 
				
			||||||
			if (sep && (i != 0))
 | 
							printf("%02x",buf[i]);
 | 
				
			||||||
				BIO_printf(out, ":");
 | 
					 | 
				
			||||||
			BIO_printf(out, "%02x",buf[i]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(out, "\n");
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						printf("\n");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										63
									
								
								apps/dh.c
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								apps/dh.c
									
									
									
									
									
								
							@@ -1,5 +1,4 @@
 | 
				
			|||||||
/* apps/dh.c */
 | 
					/* apps/dh.c */
 | 
				
			||||||
/* obsoleted by dhparam.c */
 | 
					 | 
				
			||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
					/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
				
			||||||
 * All rights reserved.
 | 
					 * All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -69,12 +68,11 @@
 | 
				
			|||||||
#include <openssl/dh.h>
 | 
					#include <openssl/dh.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	dh_main
 | 
					#define PROG	dh_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -inform arg	- input format - default PEM (DER or PEM)
 | 
					/* -inform arg	- input format - default PEM (one of DER, TXT or PEM)
 | 
				
			||||||
 * -outform arg - output format - default PEM
 | 
					 * -outform arg - output format - default PEM
 | 
				
			||||||
 * -in arg	- input file - default stdin
 | 
					 * -in arg	- input file - default stdin
 | 
				
			||||||
 * -out arg	- output file - default stdout
 | 
					 * -out arg	- output file - default stdout
 | 
				
			||||||
@@ -84,16 +82,13 @@
 | 
				
			|||||||
 * -C
 | 
					 * -C
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	DH *dh=NULL;
 | 
						DH *dh=NULL;
 | 
				
			||||||
	int i,badops=0,text=0;
 | 
						int i,badops=0,text=0;
 | 
				
			||||||
	BIO *in=NULL,*out=NULL;
 | 
						BIO *in=NULL,*out=NULL;
 | 
				
			||||||
	int informat,outformat,check=0,noout=0,C=0,ret=1;
 | 
						int informat,outformat,check=0,noout=0,C=0,ret=1;
 | 
				
			||||||
	char *infile,*outfile,*prog,*engine;
 | 
						char *infile,*outfile,*prog;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -101,7 +96,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
							if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
				
			||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	engine=NULL;
 | 
					 | 
				
			||||||
	infile=NULL;
 | 
						infile=NULL;
 | 
				
			||||||
	outfile=NULL;
 | 
						outfile=NULL;
 | 
				
			||||||
	informat=FORMAT_PEM;
 | 
						informat=FORMAT_PEM;
 | 
				
			||||||
@@ -132,11 +126,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-check") == 0)
 | 
							else if (strcmp(*argv,"-check") == 0)
 | 
				
			||||||
			check=1;
 | 
								check=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
							else if (strcmp(*argv,"-text") == 0)
 | 
				
			||||||
@@ -160,38 +149,19 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg   input format - one of DER PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg  output format - one of DER PEM\n");
 | 
							BIO_printf(bio_err," -outform arg  output format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg       input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg      output file\n");
 | 
							BIO_printf(bio_err," -out arg      output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -check        check the DH parameters\n");
 | 
							BIO_printf(bio_err," -check        check the DH parameters\n");
 | 
				
			||||||
		BIO_printf(bio_err," -text         print a text form of the DH parameters\n");
 | 
							BIO_printf(bio_err," -text         print a text form of the DH parameters\n");
 | 
				
			||||||
		BIO_printf(bio_err," -C            Output C code\n");
 | 
							BIO_printf(bio_err," -C            Output C code\n");
 | 
				
			||||||
		BIO_printf(bio_err," -noout        no output\n");
 | 
							BIO_printf(bio_err," -noout        no output\n");
 | 
				
			||||||
		BIO_printf(bio_err," -engine e     use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if ((in == NULL) || (out == NULL))
 | 
						if ((in == NULL) || (out == NULL))
 | 
				
			||||||
@@ -211,15 +181,7 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -232,7 +194,7 @@ bad:
 | 
				
			|||||||
	if	(informat == FORMAT_ASN1)
 | 
						if	(informat == FORMAT_ASN1)
 | 
				
			||||||
		dh=d2i_DHparams_bio(in,NULL);
 | 
							dh=d2i_DHparams_bio(in,NULL);
 | 
				
			||||||
	else if (informat == FORMAT_PEM)
 | 
						else if (informat == FORMAT_PEM)
 | 
				
			||||||
		dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL);
 | 
							dh=PEM_read_bio_DHparams(in,NULL,NULL);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified\n");
 | 
							BIO_printf(bio_err,"bad input format specified\n");
 | 
				
			||||||
@@ -257,7 +219,7 @@ bad:
 | 
				
			|||||||
		BN_print(stdout,dh->g);
 | 
							BN_print(stdout,dh->g);
 | 
				
			||||||
		printf("\n");
 | 
							printf("\n");
 | 
				
			||||||
		if (dh->length != 0)
 | 
							if (dh->length != 0)
 | 
				
			||||||
			printf("recommended private length=%ld\n",dh->length);
 | 
								printf("recomented private length=%ld\n",dh->length);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -270,8 +232,8 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		if (i & DH_CHECK_P_NOT_PRIME)
 | 
							if (i & DH_CHECK_P_NOT_PRIME)
 | 
				
			||||||
			printf("p value is not prime\n");
 | 
								printf("p value is not prime\n");
 | 
				
			||||||
		if (i & DH_CHECK_P_NOT_SAFE_PRIME)
 | 
							if (i & DH_CHECK_P_NOT_STRONG_PRIME)
 | 
				
			||||||
			printf("p value is not a safe prime\n");
 | 
								printf("p value is not a strong prime\n");
 | 
				
			||||||
		if (i & DH_UNABLE_TO_CHECK_GENERATOR)
 | 
							if (i & DH_UNABLE_TO_CHECK_GENERATOR)
 | 
				
			||||||
			printf("unable to check the generator value\n");
 | 
								printf("unable to check the generator value\n");
 | 
				
			||||||
		if (i & DH_NOT_SUITABLE_GENERATOR)
 | 
							if (i & DH_NOT_SUITABLE_GENERATOR)
 | 
				
			||||||
@@ -286,10 +248,10 @@ bad:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		len=BN_num_bytes(dh->p);
 | 
							len=BN_num_bytes(dh->p);
 | 
				
			||||||
		bits=BN_num_bits(dh->p);
 | 
							bits=BN_num_bits(dh->p);
 | 
				
			||||||
		data=(unsigned char *)OPENSSL_malloc(len);
 | 
							data=(unsigned char *)Malloc(len);
 | 
				
			||||||
		if (data == NULL)
 | 
							if (data == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			perror("OPENSSL_malloc");
 | 
								perror("Malloc");
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		l=BN_bn2bin(dh->p,data);
 | 
							l=BN_bn2bin(dh->p,data);
 | 
				
			||||||
@@ -320,7 +282,6 @@ bad:
 | 
				
			|||||||
		printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
 | 
							printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
 | 
				
			||||||
		printf("\t\treturn(NULL);\n");
 | 
							printf("\t\treturn(NULL);\n");
 | 
				
			||||||
		printf("\treturn(dh);\n\t}\n");
 | 
							printf("\treturn(dh);\n\t}\n");
 | 
				
			||||||
		OPENSSL_free(data);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -336,7 +297,7 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		if (!i)
 | 
							if (!i)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unable to write DH parameters\n");
 | 
								BIO_printf(bio_err,"unable to write DH paramaters\n");
 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
								ERR_print_errors(bio_err);
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -344,7 +305,7 @@ bad:
 | 
				
			|||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (dh != NULL) DH_free(dh);
 | 
						if (dh != NULL) DH_free(dh);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,5 @@
 | 
				
			|||||||
-----BEGIN DH PARAMETERS-----
 | 
					-----BEGIN DH PARAMETERS-----
 | 
				
			||||||
MIGHAoGBAPSI/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPwpVsY
 | 
					MIGHAoGBAJf2QmHKtQXdKCjhPx1ottPb0PMTBH9A6FbaWMsTuKG/K3g6TG1Z1fkq
 | 
				
			||||||
jY67VYy4XTjTNP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6
 | 
					/Gz/PWk/eLI9TzFgqVAuPvr3q14a1aZeVUMTgo2oO5/y2UHe6VaJ+trqCTat3xlx
 | 
				
			||||||
ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpL3jHAgEC
 | 
					/mNbIK9HA2RgPC3gWfVLZQrY+gz3ASHHR5nXWHEyvpuZm7m3h+irAgEC
 | 
				
			||||||
-----END DH PARAMETERS-----
 | 
					-----END DH PARAMETERS-----
 | 
				
			||||||
 | 
					 | 
				
			||||||
These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols"
 | 
					 | 
				
			||||||
(http://www.skip-vpn.org/spec/numbers.html).
 | 
					 | 
				
			||||||
See there for how they were generated.
 | 
					 | 
				
			||||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +0,0 @@
 | 
				
			|||||||
-----BEGIN DH PARAMETERS-----
 | 
					 | 
				
			||||||
MIIBCAKCAQEA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV
 | 
					 | 
				
			||||||
89AHxstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50
 | 
					 | 
				
			||||||
T8X8dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknb
 | 
					 | 
				
			||||||
zSC0neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdX
 | 
					 | 
				
			||||||
Q6MdGGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbT
 | 
					 | 
				
			||||||
CD1mpF1Bn5x8vYlLIhkmuquiXsNV6TILOwIBAg==
 | 
					 | 
				
			||||||
-----END DH PARAMETERS-----
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
These are the 2048 bit DH parameters from "Assigned Number for SKIP Protocols"
 | 
					 | 
				
			||||||
(http://www.skip-vpn.org/spec/numbers.html).
 | 
					 | 
				
			||||||
See there for how they were generated.
 | 
					 | 
				
			||||||
@@ -1,18 +0,0 @@
 | 
				
			|||||||
-----BEGIN DH PARAMETERS-----
 | 
					 | 
				
			||||||
MIICCAKCAgEA+hRyUsFN4VpJ1O8JLcCo/VWr19k3BCgJ4uk+d+KhehjdRqNDNyOQ
 | 
					 | 
				
			||||||
l/MOyQNQfWXPeGKmOmIig6Ev/nm6Nf9Z2B1h3R4hExf+zTiHnvVPeRBhjdQi81rt
 | 
					 | 
				
			||||||
Xeoh6TNrSBIKIHfUJWBh3va0TxxjQIs6IZOLeVNRLMqzeylWqMf49HsIXqbcokUS
 | 
					 | 
				
			||||||
Vt1BkvLdW48j8PPv5DsKRN3tloTxqDJGo9tKvj1Fuk74A+Xda1kNhB7KFlqMyN98
 | 
					 | 
				
			||||||
VETEJ6c7KpfOo30mnK30wqw3S8OtaIR/maYX72tGOno2ehFDkq3pnPtEbD2CScxc
 | 
					 | 
				
			||||||
alJC+EL7RPk5c/tgeTvCngvc1KZn92Y//EI7G9tPZtylj2b56sHtMftIoYJ9+ODM
 | 
					 | 
				
			||||||
sccD5Piz/rejE3Ome8EOOceUSCYAhXn8b3qvxVI1ddd1pED6FHRhFvLrZxFvBEM9
 | 
					 | 
				
			||||||
ERRMp5QqOaHJkM+Dxv8Cj6MqrCbfC4u+ZErxodzuusgDgvZiLF22uxMZbobFWyte
 | 
					 | 
				
			||||||
OvOzKGtwcTqO/1wV5gKkzu1ZVswVUQd5Gg8lJicwqRWyyNRczDDoG9jVDxmogKTH
 | 
					 | 
				
			||||||
AaqLulO7R8Ifa1SwF2DteSGVtgWEN8gDpN3RBmmPTDngyF2DHb5qmpnznwtFKdTL
 | 
					 | 
				
			||||||
KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI=
 | 
					 | 
				
			||||||
-----END DH PARAMETERS-----
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
These are the 4096 bit DH parameters from "Assigned Number for SKIP Protocols"
 | 
					 | 
				
			||||||
(http://www.skip-vpn.org/spec/numbers.html).
 | 
					 | 
				
			||||||
See there for how they were generated.
 | 
					 | 
				
			||||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
 | 
					 | 
				
			||||||
@@ -1,9 +0,0 @@
 | 
				
			|||||||
-----BEGIN DH PARAMETERS-----
 | 
					 | 
				
			||||||
MEYCQQD1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6ypUM2Zafq9AKUJsCRtMIPWak
 | 
					 | 
				
			||||||
XUGfnHy9iUsiGSa6q6Jew1XpKgVfAgEC
 | 
					 | 
				
			||||||
-----END DH PARAMETERS-----
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
These are the 512 bit DH parameters from "Assigned Number for SKIP Protocols"
 | 
					 | 
				
			||||||
(http://www.skip-vpn.org/spec/numbers.html).
 | 
					 | 
				
			||||||
See there for how they were generated.
 | 
					 | 
				
			||||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
 | 
					 | 
				
			||||||
							
								
								
									
										554
									
								
								apps/dhparam.c
									
									
									
									
									
								
							
							
						
						
									
										554
									
								
								apps/dhparam.c
									
									
									
									
									
								
							@@ -1,554 +0,0 @@
 | 
				
			|||||||
/* apps/dhparam.c */
 | 
					 | 
				
			||||||
/* 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 (c) 1998-2000 The OpenSSL Project.  All rights reserved.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 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 above 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 acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
					 | 
				
			||||||
 *    endorse or promote products derived from this software without
 | 
					 | 
				
			||||||
 *    prior written permission. For written permission, please contact
 | 
					 | 
				
			||||||
 *    openssl-core@openssl.org.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
					 | 
				
			||||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
					 | 
				
			||||||
 *    permission of the OpenSSL Project.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
					 | 
				
			||||||
 *    acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
					 | 
				
			||||||
 * EXPRESSED 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 OpenSSL PROJECT OR
 | 
					 | 
				
			||||||
 * ITS 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.
 | 
					 | 
				
			||||||
 * ====================================================================
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This product includes cryptographic software written by Eric Young
 | 
					 | 
				
			||||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
					 | 
				
			||||||
 * Hudson (tjh@cryptsoft.com).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DH
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <time.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
#include <openssl/bio.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/bn.h>
 | 
					 | 
				
			||||||
#include <openssl/dh.h>
 | 
					 | 
				
			||||||
#include <openssl/x509.h>
 | 
					 | 
				
			||||||
#include <openssl/pem.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
#include <openssl/dsa.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#undef PROG
 | 
					 | 
				
			||||||
#define PROG	dhparam_main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define DEFBITS	512
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* -inform arg	- input format - default PEM (DER or PEM)
 | 
					 | 
				
			||||||
 * -outform arg - output format - default PEM
 | 
					 | 
				
			||||||
 * -in arg	- input file - default stdin
 | 
					 | 
				
			||||||
 * -out arg	- output file - default stdout
 | 
					 | 
				
			||||||
 * -dsaparam  - read or generate DSA parameters, convert to DH
 | 
					 | 
				
			||||||
 * -check	- check the parameters are ok
 | 
					 | 
				
			||||||
 * -noout
 | 
					 | 
				
			||||||
 * -text
 | 
					 | 
				
			||||||
 * -C
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	DH *dh=NULL;
 | 
					 | 
				
			||||||
	int i,badops=0,text=0;
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
	int dsaparam=0;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	BIO *in=NULL,*out=NULL;
 | 
					 | 
				
			||||||
	int informat,outformat,check=0,noout=0,C=0,ret=1;
 | 
					 | 
				
			||||||
	char *infile,*outfile,*prog;
 | 
					 | 
				
			||||||
	char *inrand=NULL,*engine=NULL;
 | 
					 | 
				
			||||||
	int num = 0, g = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	apps_startup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_err == NULL)
 | 
					 | 
				
			||||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
					 | 
				
			||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	infile=NULL;
 | 
					 | 
				
			||||||
	outfile=NULL;
 | 
					 | 
				
			||||||
	informat=FORMAT_PEM;
 | 
					 | 
				
			||||||
	outformat=FORMAT_PEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	prog=argv[0];
 | 
					 | 
				
			||||||
	argc--;
 | 
					 | 
				
			||||||
	argv++;
 | 
					 | 
				
			||||||
	while (argc >= 1)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if 	(strcmp(*argv,"-inform") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			informat=str2fmt(*(++argv));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-outform") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			outformat=str2fmt(*(++argv));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-in") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			infile= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-out") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			outfile= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-check") == 0)
 | 
					 | 
				
			||||||
			check=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
					 | 
				
			||||||
			text=1;
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-dsaparam") == 0)
 | 
					 | 
				
			||||||
			dsaparam=1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-C") == 0)
 | 
					 | 
				
			||||||
			C=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
					 | 
				
			||||||
			noout=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-2") == 0)
 | 
					 | 
				
			||||||
			g=2;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-5") == 0)
 | 
					 | 
				
			||||||
			g=5;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			inrand= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (((sscanf(*argv,"%d",&num) == 0) || (num <= 0)))
 | 
					 | 
				
			||||||
			goto bad;
 | 
					 | 
				
			||||||
		argv++;
 | 
					 | 
				
			||||||
		argc--;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (badops)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
bad:
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] [numbits]\n",prog);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -inform arg   input format - one of DER PEM\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -outform arg  output format - one of DER PEM\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -in arg       input file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -out arg      output file\n");
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -dsaparam     read or generate DSA parameters, convert to DH\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -check        check the DH parameters\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -text         print a text form of the DH parameters\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -C            Output C code\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -2            generate parameters using  2 as the generator value\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -5            generate parameters using  5 as the generator value\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," numbits       number of bits in to generate (default 512)\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -engine e     use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"               - load the file (or the files in the directory) into\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"               the random number generator\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -noout        no output\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (g && !num)
 | 
					 | 
				
			||||||
		num = DEFBITS;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
	if (dsaparam)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (g)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		/* DH parameters */
 | 
					 | 
				
			||||||
		if (num && !g)
 | 
					 | 
				
			||||||
			g = 2;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(num) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (inrand != NULL)
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
				app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
		if (dsaparam)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			DSA *dsa;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
 | 
					 | 
				
			||||||
			dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
 | 
					 | 
				
			||||||
			if (dsa == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			dh = DSA_dup_DH(dsa);
 | 
					 | 
				
			||||||
			DSA_free(dsa);
 | 
					 | 
				
			||||||
			if (dh == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"This is going to take a long time\n");
 | 
					 | 
				
			||||||
			dh=DH_generate_parameters(num,g,dh_cb,bio_err);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (dh == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		app_RAND_write_file(NULL, bio_err);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		in=BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
		if (in == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (infile == NULL)
 | 
					 | 
				
			||||||
			BIO_set_fp(in,stdin,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (BIO_read_filename(in,infile) <= 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				perror(infile);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if	(informat != FORMAT_ASN1 && informat != FORMAT_PEM)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"bad input format specified\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					 | 
				
			||||||
		if (dsaparam)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			DSA *dsa;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (informat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
				dsa=d2i_DSAparams_bio(in,NULL);
 | 
					 | 
				
			||||||
			else /* informat == FORMAT_PEM */
 | 
					 | 
				
			||||||
				dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (dsa == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				BIO_printf(bio_err,"unable to load DSA parameters\n");
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			dh = DSA_dup_DH(dsa);
 | 
					 | 
				
			||||||
			DSA_free(dsa);
 | 
					 | 
				
			||||||
			if (dh == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (informat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
				dh=d2i_DHparams_bio(in,NULL);
 | 
					 | 
				
			||||||
			else /* informat == FORMAT_PEM */
 | 
					 | 
				
			||||||
				dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (dh == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				BIO_printf(bio_err,"unable to load DH parameters\n");
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		/* dh != NULL */
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
	if (out == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (outfile == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			perror(outfile);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (text)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		DHparams_print(out,dh);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (check)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (!DH_check(dh,&i))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (i & DH_CHECK_P_NOT_PRIME)
 | 
					 | 
				
			||||||
			printf("p value is not prime\n");
 | 
					 | 
				
			||||||
		if (i & DH_CHECK_P_NOT_SAFE_PRIME)
 | 
					 | 
				
			||||||
			printf("p value is not a safe prime\n");
 | 
					 | 
				
			||||||
		if (i & DH_UNABLE_TO_CHECK_GENERATOR)
 | 
					 | 
				
			||||||
			printf("unable to check the generator value\n");
 | 
					 | 
				
			||||||
		if (i & DH_NOT_SUITABLE_GENERATOR)
 | 
					 | 
				
			||||||
			printf("the g value is not a generator\n");
 | 
					 | 
				
			||||||
		if (i == 0)
 | 
					 | 
				
			||||||
			printf("DH parameters appear to be ok.\n");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (C)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		unsigned char *data;
 | 
					 | 
				
			||||||
		int len,l,bits;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		len=BN_num_bytes(dh->p);
 | 
					 | 
				
			||||||
		bits=BN_num_bits(dh->p);
 | 
					 | 
				
			||||||
		data=(unsigned char *)OPENSSL_malloc(len);
 | 
					 | 
				
			||||||
		if (data == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			perror("OPENSSL_malloc");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		printf("#ifndef HEADER_DH_H\n"
 | 
					 | 
				
			||||||
		       "#include <openssl/dh.h>\n"
 | 
					 | 
				
			||||||
		       "#endif\n");
 | 
					 | 
				
			||||||
		printf("DH *get_dh%d()\n\t{\n",bits);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		l=BN_bn2bin(dh->p,data);
 | 
					 | 
				
			||||||
		printf("\tstatic unsigned char dh%d_p[]={",bits);
 | 
					 | 
				
			||||||
		for (i=0; i<l; i++)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((i%12) == 0) printf("\n\t\t");
 | 
					 | 
				
			||||||
			printf("0x%02X,",data[i]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		printf("\n\t\t};\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		l=BN_bn2bin(dh->g,data);
 | 
					 | 
				
			||||||
		printf("\tstatic unsigned char dh%d_g[]={",bits);
 | 
					 | 
				
			||||||
		for (i=0; i<l; i++)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((i%12) == 0) printf("\n\t\t");
 | 
					 | 
				
			||||||
			printf("0x%02X,",data[i]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		printf("\n\t\t};\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		printf("\tDH *dh;\n\n");
 | 
					 | 
				
			||||||
		printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
 | 
					 | 
				
			||||||
		printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
 | 
					 | 
				
			||||||
			bits,bits);
 | 
					 | 
				
			||||||
		printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
 | 
					 | 
				
			||||||
			bits,bits);
 | 
					 | 
				
			||||||
		printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
 | 
					 | 
				
			||||||
		printf("\t\t{ DH_free(dh); return(NULL); }\n");
 | 
					 | 
				
			||||||
		if (dh->length)
 | 
					 | 
				
			||||||
			printf("\tdh->length = %d;\n", dh->length);
 | 
					 | 
				
			||||||
		printf("\treturn(dh);\n\t}\n");
 | 
					 | 
				
			||||||
		OPENSSL_free(data);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!noout)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if 	(outformat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
			i=i2d_DHparams_bio(out,dh);
 | 
					 | 
				
			||||||
		else if (outformat == FORMAT_PEM)
 | 
					 | 
				
			||||||
			i=PEM_write_bio_DHparams(out,dh);
 | 
					 | 
				
			||||||
		else	{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (!i)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"unable to write DH parameters\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	ret=0;
 | 
					 | 
				
			||||||
end:
 | 
					 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
					 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
					 | 
				
			||||||
	if (dh != NULL) DH_free(dh);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
 | 
					 | 
				
			||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	char c='*';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (p == 0) c='.';
 | 
					 | 
				
			||||||
	if (p == 1) c='+';
 | 
					 | 
				
			||||||
	if (p == 2) c='*';
 | 
					 | 
				
			||||||
	if (p == 3) c='\n';
 | 
					 | 
				
			||||||
	BIO_write((BIO *)arg,&c,1);
 | 
					 | 
				
			||||||
	(void)BIO_flush((BIO *)arg);
 | 
					 | 
				
			||||||
#ifdef LINT
 | 
					 | 
				
			||||||
	p=n;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
							
								
								
									
										123
									
								
								apps/dsa.c
									
									
									
									
									
								
							
							
						
						
									
										123
									
								
								apps/dsa.c
									
									
									
									
									
								
							@@ -68,7 +68,6 @@
 | 
				
			|||||||
#include <openssl/evp.h>
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	dsa_main
 | 
					#define PROG	dsa_main
 | 
				
			||||||
@@ -84,21 +83,15 @@
 | 
				
			|||||||
 * -modulus	- print the DSA public key
 | 
					 * -modulus	- print the DSA public key
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	int ret=1;
 | 
						int ret=1;
 | 
				
			||||||
	DSA *dsa=NULL;
 | 
						DSA *dsa=NULL;
 | 
				
			||||||
	int i,badops=0;
 | 
						int i,badops=0;
 | 
				
			||||||
	const EVP_CIPHER *enc=NULL;
 | 
						const EVP_CIPHER *enc=NULL;
 | 
				
			||||||
	BIO *in=NULL,*out=NULL;
 | 
						BIO *in=NULL,*out=NULL;
 | 
				
			||||||
	int informat,outformat,text=0,noout=0;
 | 
						int informat,outformat,text=0,noout=0;
 | 
				
			||||||
	int pubin = 0, pubout = 0;
 | 
						char *infile,*outfile,*prog;
 | 
				
			||||||
	char *infile,*outfile,*prog,*engine;
 | 
					 | 
				
			||||||
	char *passargin = NULL, *passargout = NULL;
 | 
					 | 
				
			||||||
	char *passin = NULL, *passout = NULL;
 | 
					 | 
				
			||||||
	int modulus=0;
 | 
						int modulus=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
@@ -107,7 +100,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
							if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
				
			||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	engine=NULL;
 | 
					 | 
				
			||||||
	infile=NULL;
 | 
						infile=NULL;
 | 
				
			||||||
	outfile=NULL;
 | 
						outfile=NULL;
 | 
				
			||||||
	informat=FORMAT_PEM;
 | 
						informat=FORMAT_PEM;
 | 
				
			||||||
@@ -138,31 +130,12 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-passin") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargin= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-passout") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargout= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
							else if (strcmp(*argv,"-noout") == 0)
 | 
				
			||||||
			noout=1;
 | 
								noout=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
							else if (strcmp(*argv,"-text") == 0)
 | 
				
			||||||
			text=1;
 | 
								text=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-modulus") == 0)
 | 
							else if (strcmp(*argv,"-modulus") == 0)
 | 
				
			||||||
			modulus=1;
 | 
								modulus=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-pubin") == 0)
 | 
					 | 
				
			||||||
			pubin=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-pubout") == 0)
 | 
					 | 
				
			||||||
			pubout=1;
 | 
					 | 
				
			||||||
		else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
 | 
							else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -178,49 +151,23 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg     input format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER NET PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg    output format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -outform arg  output format - one of DER NET PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg         input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -passin arg     input file pass phrase source\n");
 | 
							BIO_printf(bio_err," -out arg      output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg        output file\n");
 | 
							BIO_printf(bio_err," -des          encrypt PEM output with cbc des\n");
 | 
				
			||||||
		BIO_printf(bio_err," -passout arg    output file pass phrase source\n");
 | 
							BIO_printf(bio_err," -des3         encrypt PEM output with ede cbc des using 168 bit key\n");
 | 
				
			||||||
		BIO_printf(bio_err," -engine e       use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -des            encrypt PEM output with cbc des\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -des3           encrypt PEM output with ede cbc des using 168 bit key\n");
 | 
					 | 
				
			||||||
#ifndef NO_IDEA
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
		BIO_printf(bio_err," -idea           encrypt PEM output with cbc idea\n");
 | 
							BIO_printf(bio_err," -idea         encrypt PEM output with cbc idea\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		BIO_printf(bio_err," -text           print the key in text\n");
 | 
							BIO_printf(bio_err," -text         print the key in text\n");
 | 
				
			||||||
		BIO_printf(bio_err," -noout          don't print key out\n");
 | 
							BIO_printf(bio_err," -noout        don't print key out\n");
 | 
				
			||||||
		BIO_printf(bio_err," -modulus        print the DSA public value\n");
 | 
							BIO_printf(bio_err," -modulus      print the DSA public value\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting passwords\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if ((in == NULL) || (out == NULL))
 | 
						if ((in == NULL) || (out == NULL))
 | 
				
			||||||
@@ -240,35 +187,25 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_err,"read DSA key\n");
 | 
						BIO_printf(bio_err,"read DSA private key\n");
 | 
				
			||||||
	if	(informat == FORMAT_ASN1) {
 | 
						if	(informat == FORMAT_ASN1)
 | 
				
			||||||
		if(pubin) dsa=d2i_DSA_PUBKEY_bio(in,NULL);
 | 
							dsa=d2i_DSAPrivateKey_bio(in,NULL);
 | 
				
			||||||
		else dsa=d2i_DSAPrivateKey_bio(in,NULL);
 | 
						else if (informat == FORMAT_PEM)
 | 
				
			||||||
	} else if (informat == FORMAT_PEM) {
 | 
							dsa=PEM_read_bio_DSAPrivateKey(in,NULL,NULL);
 | 
				
			||||||
		if(pubin) dsa=PEM_read_bio_DSA_PUBKEY(in,NULL, NULL, NULL);
 | 
						else
 | 
				
			||||||
		else dsa=PEM_read_bio_DSAPrivateKey(in,NULL,NULL,passin);
 | 
					 | 
				
			||||||
	} else
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified for key\n");
 | 
							BIO_printf(bio_err,"bad input format specified for key\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (dsa == NULL)
 | 
						if (dsa == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unable to load Key\n");
 | 
							BIO_printf(bio_err,"unable to load Private Key\n");
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -294,16 +231,12 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (noout) goto end;
 | 
						if (noout) goto end;
 | 
				
			||||||
	BIO_printf(bio_err,"writing DSA key\n");
 | 
						BIO_printf(bio_err,"writing DSA private key\n");
 | 
				
			||||||
	if 	(outformat == FORMAT_ASN1) {
 | 
						if 	(outformat == FORMAT_ASN1)
 | 
				
			||||||
		if(pubin || pubout) i=i2d_DSA_PUBKEY_bio(out,dsa);
 | 
							i=i2d_DSAPrivateKey_bio(out,dsa);
 | 
				
			||||||
		else i=i2d_DSAPrivateKey_bio(out,dsa);
 | 
						else if (outformat == FORMAT_PEM)
 | 
				
			||||||
	} else if (outformat == FORMAT_PEM) {
 | 
							i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL);
 | 
				
			||||||
		if(pubin || pubout)
 | 
						else	{
 | 
				
			||||||
			i=PEM_write_bio_DSA_PUBKEY(out,dsa);
 | 
					 | 
				
			||||||
		else i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,
 | 
					 | 
				
			||||||
							NULL,0,NULL, passout);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
							BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -315,11 +248,9 @@ bad:
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
		ret=0;
 | 
							ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if(in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if(out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if(dsa != NULL) DSA_free(dsa);
 | 
						if (dsa != NULL) DSA_free(dsa);
 | 
				
			||||||
	if(passin) OPENSSL_free(passin);
 | 
					 | 
				
			||||||
	if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,6 @@
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_DSA
 | 
					#ifndef NO_DSA
 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
@@ -66,6 +65,7 @@
 | 
				
			|||||||
#include <openssl/bio.h>
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/bn.h>
 | 
					#include <openssl/bn.h>
 | 
				
			||||||
 | 
					#include <openssl/rand.h>
 | 
				
			||||||
#include <openssl/dsa.h>
 | 
					#include <openssl/dsa.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
@@ -73,7 +73,7 @@
 | 
				
			|||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	dsaparam_main
 | 
					#define PROG	dsaparam_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -inform arg	- input format - default PEM (DER or PEM)
 | 
					/* -inform arg	- input format - default PEM (one of DER, TXT or PEM)
 | 
				
			||||||
 * -outform arg - output format - default PEM
 | 
					 * -outform arg - output format - default PEM
 | 
				
			||||||
 * -in arg	- input file - default stdin
 | 
					 * -in arg	- input file - default stdin
 | 
				
			||||||
 * -out arg	- output file - default stdout
 | 
					 * -out arg	- output file - default stdout
 | 
				
			||||||
@@ -84,10 +84,7 @@
 | 
				
			|||||||
 * -genkey
 | 
					 * -genkey
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
 | 
					static void MS_CALLBACK dsa_cb(int p, int n, char *arg);
 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	DSA *dsa=NULL;
 | 
						DSA *dsa=NULL;
 | 
				
			||||||
@@ -96,7 +93,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	int informat,outformat,noout=0,C=0,ret=1;
 | 
						int informat,outformat,noout=0,C=0,ret=1;
 | 
				
			||||||
	char *infile,*outfile,*prog,*inrand=NULL;
 | 
						char *infile,*outfile,*prog,*inrand=NULL;
 | 
				
			||||||
	int numbits= -1,num,genkey=0;
 | 
						int numbits= -1,num,genkey=0;
 | 
				
			||||||
	int need_rand=0;
 | 
						char buffer[200],*randfile=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,15 +136,11 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (strcmp(*argv,"-C") == 0)
 | 
							else if (strcmp(*argv,"-C") == 0)
 | 
				
			||||||
			C=1;
 | 
								C=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-genkey") == 0)
 | 
							else if (strcmp(*argv,"-genkey") == 0)
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			genkey=1;
 | 
								genkey=1;
 | 
				
			||||||
			need_rand=1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
							else if (strcmp(*argv,"-rand") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			inrand= *(++argv);
 | 
								inrand= *(++argv);
 | 
				
			||||||
			need_rand=1;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
							else if (strcmp(*argv,"-noout") == 0)
 | 
				
			||||||
			noout=1;
 | 
								noout=1;
 | 
				
			||||||
@@ -155,7 +148,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
			/* generate a key */
 | 
								/* generate a key */
 | 
				
			||||||
			numbits=num;
 | 
								numbits=num;
 | 
				
			||||||
			need_rand=1;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -172,11 +164,11 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] [bits] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] [bits] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg   input format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg  output format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -outform arg  output format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg       input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg      output file\n");
 | 
							BIO_printf(bio_err," -out arg      output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -text         print the key in text\n");
 | 
							BIO_printf(bio_err," -text         check the DSA parameters\n");
 | 
				
			||||||
		BIO_printf(bio_err," -C            Output C code\n");
 | 
							BIO_printf(bio_err," -C            Output C code\n");
 | 
				
			||||||
		BIO_printf(bio_err," -noout        no output\n");
 | 
							BIO_printf(bio_err," -noout        no output\n");
 | 
				
			||||||
		BIO_printf(bio_err," -rand         files to use for random number input\n");
 | 
							BIO_printf(bio_err," -rand         files to use for random number input\n");
 | 
				
			||||||
@@ -205,15 +197,7 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -223,25 +207,20 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (need_rand)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		app_RAND_load_file(NULL, bio_err, (inrand != NULL));
 | 
					 | 
				
			||||||
		if (inrand != NULL)
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
				app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (numbits > 0)
 | 
						if (numbits > 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		assert(need_rand);
 | 
							randfile=RAND_file_name(buffer,200);
 | 
				
			||||||
 | 
							RAND_load_file(randfile,1024L*1024L);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
 | 
							BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
 | 
				
			||||||
	        BIO_printf(bio_err,"This could take some time\n");
 | 
						        BIO_printf(bio_err,"This could take some time\n");
 | 
				
			||||||
	        dsa=DSA_generate_parameters(num,NULL,0,NULL,NULL, dsa_cb,bio_err);
 | 
						        dsa=DSA_generate_parameters(num,NULL,0,NULL,NULL,
 | 
				
			||||||
 | 
								dsa_cb,(char *)bio_err);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	else if	(informat == FORMAT_ASN1)
 | 
						else if	(informat == FORMAT_ASN1)
 | 
				
			||||||
		dsa=d2i_DSAparams_bio(in,NULL);
 | 
							dsa=d2i_DSAparams_bio(in,NULL);
 | 
				
			||||||
	else if (informat == FORMAT_PEM)
 | 
						else if (informat == FORMAT_PEM)
 | 
				
			||||||
		dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL);
 | 
							dsa=PEM_read_bio_DSAparams(in,NULL,NULL);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified\n");
 | 
							BIO_printf(bio_err,"bad input format specified\n");
 | 
				
			||||||
@@ -268,10 +247,10 @@ bad:
 | 
				
			|||||||
		bits_p=BN_num_bits(dsa->p);
 | 
							bits_p=BN_num_bits(dsa->p);
 | 
				
			||||||
		bits_q=BN_num_bits(dsa->q);
 | 
							bits_q=BN_num_bits(dsa->q);
 | 
				
			||||||
		bits_g=BN_num_bits(dsa->g);
 | 
							bits_g=BN_num_bits(dsa->g);
 | 
				
			||||||
		data=(unsigned char *)OPENSSL_malloc(len+20);
 | 
							data=(unsigned char *)Malloc(len+20);
 | 
				
			||||||
		if (data == NULL)
 | 
							if (data == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			perror("OPENSSL_malloc");
 | 
								perror("Malloc");
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		l=BN_bn2bin(dsa->p,data);
 | 
							l=BN_bn2bin(dsa->p,data);
 | 
				
			||||||
@@ -311,7 +290,7 @@ bad:
 | 
				
			|||||||
		printf("\tdsa->g=BN_bin2bn(dsa%d_g,sizeof(dsa%d_g),NULL);\n",
 | 
							printf("\tdsa->g=BN_bin2bn(dsa%d_g,sizeof(dsa%d_g),NULL);\n",
 | 
				
			||||||
			bits_p,bits_p);
 | 
								bits_p,bits_p);
 | 
				
			||||||
		printf("\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n");
 | 
							printf("\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n");
 | 
				
			||||||
		printf("\t\t{ DSA_free(dsa); return(NULL); }\n");
 | 
							printf("\t\treturn(NULL);\n");
 | 
				
			||||||
		printf("\treturn(dsa);\n\t}\n");
 | 
							printf("\treturn(dsa);\n\t}\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -328,7 +307,7 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		if (!i)
 | 
							if (!i)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unable to write DSA parameters\n");
 | 
								BIO_printf(bio_err,"unable to write DSA paramaters\n");
 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
								ERR_print_errors(bio_err);
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -337,30 +316,27 @@ bad:
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
		DSA *dsakey;
 | 
							DSA *dsakey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assert(need_rand);
 | 
					 | 
				
			||||||
		if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end;
 | 
							if ((dsakey=DSAparams_dup(dsa)) == NULL) goto end;
 | 
				
			||||||
		if (!DSA_generate_key(dsakey)) goto end;
 | 
							if (!DSA_generate_key(dsakey)) goto end;
 | 
				
			||||||
		if 	(outformat == FORMAT_ASN1)
 | 
							if 	(outformat == FORMAT_ASN1)
 | 
				
			||||||
			i=i2d_DSAPrivateKey_bio(out,dsakey);
 | 
								i=i2d_DSAPrivateKey_bio(out,dsakey);
 | 
				
			||||||
		else if (outformat == FORMAT_PEM)
 | 
							else if (outformat == FORMAT_PEM)
 | 
				
			||||||
			i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL,NULL);
 | 
								i=PEM_write_bio_DSAPrivateKey(out,dsakey,NULL,NULL,0,NULL);
 | 
				
			||||||
		else	{
 | 
							else	{
 | 
				
			||||||
			BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
								BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		DSA_free(dsakey);
 | 
							DSA_free(dsakey);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (need_rand)
 | 
					 | 
				
			||||||
		app_RAND_write_file(NULL, bio_err);
 | 
					 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (dsa != NULL) DSA_free(dsa);
 | 
						if (dsa != NULL) DSA_free(dsa);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
 | 
					static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	char c='*';
 | 
						char c='*';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -368,8 +344,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
 | 
				
			|||||||
	if (p == 1) c='+';
 | 
						if (p == 1) c='+';
 | 
				
			||||||
	if (p == 2) c='*';
 | 
						if (p == 2) c='*';
 | 
				
			||||||
	if (p == 3) c='\n';
 | 
						if (p == 3) c='\n';
 | 
				
			||||||
	BIO_write(arg,&c,1);
 | 
						BIO_write((BIO *)arg,&c,1);
 | 
				
			||||||
	(void)BIO_flush(arg);
 | 
						BIO_flush((BIO *)arg);
 | 
				
			||||||
#ifdef LINT
 | 
					#ifdef LINT
 | 
				
			||||||
	p=n;
 | 
						p=n;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										130
									
								
								apps/eay.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								apps/eay.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,130 @@
 | 
				
			|||||||
 | 
					/* apps/eay.c */
 | 
				
			||||||
 | 
					/* 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.]
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MONOLITH
 | 
				
			||||||
 | 
					#define USE_SOCKETS
 | 
				
			||||||
 | 
					#include <openssl/e_os.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
 | 
					#include <openssl/stack.h>
 | 
				
			||||||
 | 
					#include <openssl/lhash.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/err.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/bn.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/rand.h>
 | 
				
			||||||
 | 
					#include <openssl/conf.h>
 | 
				
			||||||
 | 
					#include <openssl/txt_db.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/err.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
 | 
					#include <openssl/pkcs7.h>
 | 
				
			||||||
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
 | 
					#include <openssl/asn1.h>
 | 
				
			||||||
 | 
					#include <openssl/objects.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MONOLITH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "openssl.c"
 | 
				
			||||||
 | 
					#include "apps.c"
 | 
				
			||||||
 | 
					#include "asn1pars.c"
 | 
				
			||||||
 | 
					#ifndef NO_RSA
 | 
				
			||||||
 | 
					#include "ca.c"
 | 
				
			||||||
 | 
					#include "genrsa.c"
 | 
				
			||||||
 | 
					#include "req.c"
 | 
				
			||||||
 | 
					#include "rsa.c"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef NO_DH
 | 
				
			||||||
 | 
					#include "gendh.c"
 | 
				
			||||||
 | 
					#include "dh.c"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#include "crl.c"
 | 
				
			||||||
 | 
					#include "crl2p7.c"
 | 
				
			||||||
 | 
					#include "dgst.c"
 | 
				
			||||||
 | 
					#include "enc.c"
 | 
				
			||||||
 | 
					#include "errstr.c"
 | 
				
			||||||
 | 
					#if !defined(NO_SSL2) || !defined(NO_SSL3)
 | 
				
			||||||
 | 
					#ifndef NO_SOCK
 | 
				
			||||||
 | 
					#include "s_cb.c"
 | 
				
			||||||
 | 
					#include "s_client.c"
 | 
				
			||||||
 | 
					#include "s_server.c"
 | 
				
			||||||
 | 
					#include "s_socket.c"
 | 
				
			||||||
 | 
					#include "s_time.c"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#include "speed.c"
 | 
				
			||||||
 | 
					#include "verify.c"
 | 
				
			||||||
 | 
					#include "version.c"
 | 
				
			||||||
 | 
					#include "x509.c"
 | 
				
			||||||
 | 
					#include "ciphers.c"
 | 
				
			||||||
 | 
					#include "sess_id.c"
 | 
				
			||||||
 | 
					#include "pkcs7.c"
 | 
				
			||||||
 | 
					#ifndef NO_DSA
 | 
				
			||||||
 | 
					#include "dsaparam.c"
 | 
				
			||||||
 | 
					#include "dsa.c"
 | 
				
			||||||
 | 
					#include "gendsa.c"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										272
									
								
								apps/enc.c
									
									
									
									
									
								
							
							
						
						
									
										272
									
								
								apps/enc.c
									
									
									
									
									
								
							@@ -65,12 +65,10 @@
 | 
				
			|||||||
#include <openssl/evp.h>
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
#include <openssl/objects.h>
 | 
					#include <openssl/objects.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
#ifndef NO_MD5
 | 
					#ifndef NO_MD5
 | 
				
			||||||
#include <openssl/md5.h>
 | 
					#include <openssl/md5.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int set_hex(char *in,unsigned char *out,int size);
 | 
					int set_hex(char *in,unsigned char *out,int size);
 | 
				
			||||||
#undef SIZE
 | 
					#undef SIZE
 | 
				
			||||||
@@ -81,29 +79,22 @@ int set_hex(char *in,unsigned char *out,int size);
 | 
				
			|||||||
#define BSIZE	(8*1024)
 | 
					#define BSIZE	(8*1024)
 | 
				
			||||||
#define	PROG	enc_main
 | 
					#define	PROG	enc_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	static const char magic[]="Salted__";
 | 
					 | 
				
			||||||
	char mbuf[8];	/* should be 1 smaller than magic */
 | 
					 | 
				
			||||||
	char *strbuf=NULL;
 | 
						char *strbuf=NULL;
 | 
				
			||||||
	unsigned char *buff=NULL,*bufsize=NULL;
 | 
						unsigned char *buff=NULL,*bufsize=NULL;
 | 
				
			||||||
	int bsize=BSIZE,verbose=0;
 | 
						int bsize=BSIZE,verbose=0;
 | 
				
			||||||
	int ret=1,inl;
 | 
						int ret=1,inl;
 | 
				
			||||||
	unsigned char key[24],iv[MD5_DIGEST_LENGTH];
 | 
						unsigned char key[24],iv[MD5_DIGEST_LENGTH];
 | 
				
			||||||
	unsigned char salt[PKCS5_SALT_LEN];
 | 
						char *str=NULL;
 | 
				
			||||||
	char *str=NULL, *passarg = NULL, *pass = NULL;
 | 
						char *hkey=NULL,*hiv=NULL;
 | 
				
			||||||
	char *hkey=NULL,*hiv=NULL,*hsalt = NULL;
 | 
					 | 
				
			||||||
	int enc=1,printkey=0,i,base64=0;
 | 
						int enc=1,printkey=0,i,base64=0;
 | 
				
			||||||
	int debug=0,olb64=0,nosalt=0;
 | 
						int debug=0,olb64=0;
 | 
				
			||||||
	const EVP_CIPHER *cipher=NULL,*c;
 | 
						const EVP_CIPHER *cipher=NULL,*c;
 | 
				
			||||||
	char *inf=NULL,*outf=NULL;
 | 
						char *inf=NULL,*outf=NULL;
 | 
				
			||||||
	BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
 | 
						BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
 | 
				
			||||||
#define PROG_NAME_SIZE  39
 | 
					#define PROG_NAME_SIZE  16
 | 
				
			||||||
	char pname[PROG_NAME_SIZE+1];
 | 
					        char pname[PROG_NAME_SIZE];
 | 
				
			||||||
	char *engine = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -112,7 +103,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* first check the program name */
 | 
						/* first check the program name */
 | 
				
			||||||
	program_name(argv[0],pname,PROG_NAME_SIZE);
 | 
					        program_name(argv[0],pname,PROG_NAME_SIZE);
 | 
				
			||||||
	if (strcmp(pname,"base64") == 0)
 | 
						if (strcmp(pname,"base64") == 0)
 | 
				
			||||||
		base64=1;
 | 
							base64=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,27 +130,14 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outf= *(++argv);
 | 
								outf= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-pass") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passarg= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-d") == 0)
 | 
							else if	(strcmp(*argv,"-d") == 0)
 | 
				
			||||||
			enc=0;
 | 
								enc=0;
 | 
				
			||||||
		else if	(strcmp(*argv,"-p") == 0)
 | 
							else if	(strcmp(*argv,"-p") == 0)
 | 
				
			||||||
			printkey=1;
 | 
								printkey=1;
 | 
				
			||||||
		else if	(strcmp(*argv,"-v") == 0)
 | 
							else if	(strcmp(*argv,"-v") == 0)
 | 
				
			||||||
			verbose=1;
 | 
								verbose=1;
 | 
				
			||||||
		else if	(strcmp(*argv,"-salt") == 0)
 | 
							else if	((strcmp(*argv,"-debug") == 0) ||
 | 
				
			||||||
			nosalt=0;
 | 
								 (strcmp(*argv,"-d") == 0))
 | 
				
			||||||
		else if	(strcmp(*argv,"-nosalt") == 0)
 | 
					 | 
				
			||||||
			nosalt=1;
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-debug") == 0)
 | 
					 | 
				
			||||||
			debug=1;
 | 
								debug=1;
 | 
				
			||||||
		else if	(strcmp(*argv,"-P") == 0)
 | 
							else if	(strcmp(*argv,"-P") == 0)
 | 
				
			||||||
			printkey=2;
 | 
								printkey=2;
 | 
				
			||||||
@@ -216,11 +194,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			hkey= *(++argv);
 | 
								hkey= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-S") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			hsalt= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-iv") == 0)
 | 
							else if (strcmp(*argv,"-iv") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -239,8 +212,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
			BIO_printf(bio_err,"options are\n");
 | 
								BIO_printf(bio_err,"options are\n");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s input file\n","-in <file>");
 | 
								BIO_printf(bio_err,"%-14s input file\n","-in <file>");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s output file\n","-out <file>");
 | 
								BIO_printf(bio_err,"%-14s output fileencrypt\n","-out <file>");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s pass phrase source\n","-pass <arg>");
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"%-14s encrypt\n","-e");
 | 
								BIO_printf(bio_err,"%-14s encrypt\n","-e");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s decrypt\n","-d");
 | 
								BIO_printf(bio_err,"%-14s decrypt\n","-d");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s base64 encode/decode, depending on encryption flag\n","-a/-base64");
 | 
								BIO_printf(bio_err,"%-14s base64 encode/decode, depending on encryption flag\n","-a/-base64");
 | 
				
			||||||
@@ -249,7 +221,6 @@ bad:
 | 
				
			|||||||
			BIO_printf(bio_err,"%-14s key/iv in hex is the next argument\n","-K/-iv");
 | 
								BIO_printf(bio_err,"%-14s key/iv in hex is the next argument\n","-K/-iv");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s print the iv/key (then exit if -P)\n","-[pP]");
 | 
								BIO_printf(bio_err,"%-14s print the iv/key (then exit if -P)\n","-[pP]");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s buffer size\n","-bufsize <n>");
 | 
								BIO_printf(bio_err,"%-14s buffer size\n","-bufsize <n>");
 | 
				
			||||||
			BIO_printf(bio_err,"%-14s use engine e, possibly a hardware device.\n","-engine e");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			BIO_printf(bio_err,"Cipher Types\n");
 | 
								BIO_printf(bio_err,"Cipher Types\n");
 | 
				
			||||||
			BIO_printf(bio_err,"des     : 56 bit key DES encryption\n");
 | 
								BIO_printf(bio_err,"des     : 56 bit key DES encryption\n");
 | 
				
			||||||
@@ -262,7 +233,7 @@ bad:
 | 
				
			|||||||
			BIO_printf(bio_err,"rc2     :128 bit key RC2 encryption\n");
 | 
								BIO_printf(bio_err,"rc2     :128 bit key RC2 encryption\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef NO_BF
 | 
					#ifndef NO_BF
 | 
				
			||||||
			BIO_printf(bio_err,"bf      :128 bit key Blowfish encryption\n");
 | 
								BIO_printf(bio_err,"bf      :128 bit key BlowFish encryption\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef NO_RC4
 | 
					#ifndef NO_RC4
 | 
				
			||||||
			BIO_printf(bio_err," -%-5s :128 bit key RC4 encryption\n",
 | 
								BIO_printf(bio_err," -%-5s :128 bit key RC4 encryption\n",
 | 
				
			||||||
@@ -323,24 +294,6 @@ bad:
 | 
				
			|||||||
		argv++;
 | 
							argv++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bufsize != NULL)
 | 
						if (bufsize != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		unsigned long n;
 | 
							unsigned long n;
 | 
				
			||||||
@@ -370,11 +323,11 @@ bad:
 | 
				
			|||||||
		if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize);
 | 
							if (verbose) BIO_printf(bio_err,"bufsize=%d\n",bsize);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	strbuf=OPENSSL_malloc(SIZE);
 | 
						strbuf=Malloc(SIZE);
 | 
				
			||||||
	buff=(unsigned char *)OPENSSL_malloc(EVP_ENCODE_LENGTH(bsize));
 | 
						buff=(unsigned char *)Malloc(EVP_ENCODE_LENGTH(bsize));
 | 
				
			||||||
	if ((buff == NULL) || (strbuf == NULL))
 | 
						if ((buff == NULL) || (strbuf == NULL))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"OPENSSL_malloc failure %ld\n",(long)EVP_ENCODE_LENGTH(bsize));
 | 
							BIO_printf(bio_err,"Malloc failure %ld\n",(long)EVP_ENCODE_LENGTH(bsize));
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -404,14 +357,6 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!str && passarg) {
 | 
					 | 
				
			||||||
		if(!app_passwd(bio_err, passarg, NULL, &pass, NULL)) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error getting password\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		str = pass;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((str == NULL) && (cipher != NULL) && (hkey == NULL))
 | 
						if ((str == NULL) && (cipher != NULL) && (hkey == NULL))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		for (;;)
 | 
							for (;;)
 | 
				
			||||||
@@ -441,17 +386,69 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (cipher != NULL)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							if (str != NULL)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								EVP_BytesToKey(cipher,EVP_md5(),NULL,
 | 
				
			||||||
 | 
									(unsigned char *)str,
 | 
				
			||||||
 | 
									strlen(str),1,key,iv);
 | 
				
			||||||
 | 
								/* zero the complete buffer or the string
 | 
				
			||||||
 | 
								 * passed from the command line
 | 
				
			||||||
 | 
								 * bug picked up by
 | 
				
			||||||
 | 
								 * Larry J. Hughes Jr. <hughes@indiana.edu> */
 | 
				
			||||||
 | 
								if (str == strbuf)
 | 
				
			||||||
 | 
									memset(str,0,SIZE);
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									memset(str,0,strlen(str));
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							if ((hiv != NULL) && !set_hex(hiv,iv,8))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								BIO_printf(bio_err,"invalid hex iv value\n");
 | 
				
			||||||
 | 
								goto end;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							if ((hkey != NULL) && !set_hex(hkey,key,24))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								BIO_printf(bio_err,"invalid hex key value\n");
 | 
				
			||||||
 | 
								goto end;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if ((benc=BIO_new(BIO_f_cipher())) == NULL)
 | 
				
			||||||
 | 
								goto end;
 | 
				
			||||||
 | 
							BIO_set_cipher(benc,cipher,key,iv,enc);
 | 
				
			||||||
 | 
							if (debug)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								BIO_set_callback(benc,BIO_debug_callback);
 | 
				
			||||||
 | 
								BIO_set_callback_arg(benc,bio_err);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (printkey)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								if (cipher->key_len > 0)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
									printf("key=");
 | 
				
			||||||
 | 
									for (i=0; i<cipher->key_len; i++)
 | 
				
			||||||
 | 
										printf("%02X",key[i]);
 | 
				
			||||||
 | 
									printf("\n");
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								if (cipher->iv_len > 0)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
									printf("iv =");
 | 
				
			||||||
 | 
									for (i=0; i<cipher->iv_len; i++)
 | 
				
			||||||
 | 
										printf("%02X",iv[i]);
 | 
				
			||||||
 | 
									printf("\n");
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								if (printkey == 2)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
									ret=0;
 | 
				
			||||||
 | 
									goto end;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outf == NULL)
 | 
						if (outf == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outf) <= 0)
 | 
							if (BIO_write_filename(out,outf) <= 0)
 | 
				
			||||||
@@ -481,121 +478,6 @@ bad:
 | 
				
			|||||||
			rbio=BIO_push(b64,rbio);
 | 
								rbio=BIO_push(b64,rbio);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cipher != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (str != NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			/* Salt handling: if encrypting generate a salt and
 | 
					 | 
				
			||||||
			 * write to output BIO. If decrypting read salt from
 | 
					 | 
				
			||||||
			 * input BIO.
 | 
					 | 
				
			||||||
			 */
 | 
					 | 
				
			||||||
			unsigned char *sptr;
 | 
					 | 
				
			||||||
			if(nosalt) sptr = NULL;
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				if(enc) {
 | 
					 | 
				
			||||||
					if(hsalt) {
 | 
					 | 
				
			||||||
						if(!set_hex(hsalt,salt,PKCS5_SALT_LEN)) {
 | 
					 | 
				
			||||||
							BIO_printf(bio_err,
 | 
					 | 
				
			||||||
								"invalid hex salt value\n");
 | 
					 | 
				
			||||||
							goto end;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					} else if (RAND_pseudo_bytes(salt, PKCS5_SALT_LEN) < 0)
 | 
					 | 
				
			||||||
						goto end;
 | 
					 | 
				
			||||||
					/* If -P option then don't bother writing */
 | 
					 | 
				
			||||||
					if((printkey != 2)
 | 
					 | 
				
			||||||
					   && (BIO_write(wbio,magic,
 | 
					 | 
				
			||||||
							 sizeof magic-1) != sizeof magic-1
 | 
					 | 
				
			||||||
					       || BIO_write(wbio,
 | 
					 | 
				
			||||||
							    (char *)salt,
 | 
					 | 
				
			||||||
							    PKCS5_SALT_LEN) != PKCS5_SALT_LEN)) {
 | 
					 | 
				
			||||||
						BIO_printf(bio_err,"error writing output file\n");
 | 
					 | 
				
			||||||
						goto end;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				} else if(BIO_read(rbio,mbuf,sizeof mbuf) != sizeof mbuf
 | 
					 | 
				
			||||||
					  || BIO_read(rbio,
 | 
					 | 
				
			||||||
						      (unsigned char *)salt,
 | 
					 | 
				
			||||||
				    PKCS5_SALT_LEN) != PKCS5_SALT_LEN) {
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,"error reading input file\n");
 | 
					 | 
				
			||||||
					goto end;
 | 
					 | 
				
			||||||
				} else if(memcmp(mbuf,magic,sizeof magic-1)) {
 | 
					 | 
				
			||||||
				    BIO_printf(bio_err,"bad magic number\n");
 | 
					 | 
				
			||||||
				    goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				sptr = salt;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			EVP_BytesToKey(cipher,EVP_md5(),sptr,
 | 
					 | 
				
			||||||
				(unsigned char *)str,
 | 
					 | 
				
			||||||
				strlen(str),1,key,iv);
 | 
					 | 
				
			||||||
			/* zero the complete buffer or the string
 | 
					 | 
				
			||||||
			 * passed from the command line
 | 
					 | 
				
			||||||
			 * bug picked up by
 | 
					 | 
				
			||||||
			 * Larry J. Hughes Jr. <hughes@indiana.edu> */
 | 
					 | 
				
			||||||
			if (str == strbuf)
 | 
					 | 
				
			||||||
				memset(str,0,SIZE);
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				memset(str,0,strlen(str));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if ((hiv != NULL) && !set_hex(hiv,iv,8))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid hex iv value\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if ((hiv == NULL) && (str == NULL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			/* No IV was explicitly set and no IV was generated
 | 
					 | 
				
			||||||
			 * during EVP_BytesToKey. Hence the IV is undefined,
 | 
					 | 
				
			||||||
			 * making correct decryption impossible. */
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "iv undefined\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if ((hkey != NULL) && !set_hex(hkey,key,24))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid hex key value\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if ((benc=BIO_new(BIO_f_cipher())) == NULL)
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		BIO_set_cipher(benc,cipher,key,iv,enc);
 | 
					 | 
				
			||||||
		if (debug)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_set_callback(benc,BIO_debug_callback);
 | 
					 | 
				
			||||||
			BIO_set_callback_arg(benc,bio_err);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (printkey)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!nosalt)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				printf("salt=");
 | 
					 | 
				
			||||||
				for (i=0; i<PKCS5_SALT_LEN; i++)
 | 
					 | 
				
			||||||
					printf("%02X",salt[i]);
 | 
					 | 
				
			||||||
				printf("\n");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			if (cipher->key_len > 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				printf("key=");
 | 
					 | 
				
			||||||
				for (i=0; i<cipher->key_len; i++)
 | 
					 | 
				
			||||||
					printf("%02X",key[i]);
 | 
					 | 
				
			||||||
				printf("\n");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			if (cipher->iv_len > 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				printf("iv =");
 | 
					 | 
				
			||||||
				for (i=0; i<cipher->iv_len; i++)
 | 
					 | 
				
			||||||
					printf("%02X",iv[i]);
 | 
					 | 
				
			||||||
				printf("\n");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			if (printkey == 2)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				ret=0;
 | 
					 | 
				
			||||||
				goto end;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Only encrypt/decrypt as we write the file */
 | 
						/* Only encrypt/decrypt as we write the file */
 | 
				
			||||||
	if (benc != NULL)
 | 
						if (benc != NULL)
 | 
				
			||||||
		wbio=BIO_push(benc,wbio);
 | 
							wbio=BIO_push(benc,wbio);
 | 
				
			||||||
@@ -623,14 +505,12 @@ bad:
 | 
				
			|||||||
		BIO_printf(bio_err,"bytes written:%8ld\n",BIO_number_written(out));
 | 
							BIO_printf(bio_err,"bytes written:%8ld\n",BIO_number_written(out));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	ERR_print_errors(bio_err);
 | 
						if (strbuf != NULL) Free(strbuf);
 | 
				
			||||||
	if (strbuf != NULL) OPENSSL_free(strbuf);
 | 
						if (buff != NULL) Free(buff);
 | 
				
			||||||
	if (buff != NULL) OPENSSL_free(buff);
 | 
					 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (benc != NULL) BIO_free(benc);
 | 
						if (benc != NULL) BIO_free(benc);
 | 
				
			||||||
	if (b64 != NULL) BIO_free(b64);
 | 
						if (b64 != NULL) BIO_free(b64);
 | 
				
			||||||
	if(pass) OPENSSL_free(pass);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,8 +68,6 @@
 | 
				
			|||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	errstr_main
 | 
					#define PROG	errstr_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int i,ret=0;
 | 
						int i,ret=0;
 | 
				
			||||||
@@ -91,18 +89,12 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		out=BIO_new(BIO_s_file());
 | 
							out=BIO_new(BIO_s_file());
 | 
				
			||||||
		if ((out != NULL) && BIO_set_fp(out,stdout,BIO_NOCLOSE))
 | 
							if ((out != NULL) && BIO_set_fp(out,stdout,BIO_NOCLOSE))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
			out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			lh_node_stats_bio((LHASH *)ERR_get_string_table(),out);
 | 
								lh_node_stats_bio((LHASH *)ERR_get_string_table(),out);
 | 
				
			||||||
			lh_stats_bio((LHASH *)ERR_get_string_table(),out);
 | 
								lh_stats_bio((LHASH *)ERR_get_string_table(),out);
 | 
				
			||||||
			lh_node_usage_stats_bio((LHASH *)
 | 
								lh_node_usage_stats_bio((LHASH *)
 | 
				
			||||||
				ERR_get_string_table(),out);
 | 
									ERR_get_string_table(),out);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		if (out != NULL) BIO_free_all(out);
 | 
							if (out != NULL) BIO_free(out);
 | 
				
			||||||
		argc--;
 | 
							argc--;
 | 
				
			||||||
		argv++;
 | 
							argv++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -110,10 +102,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	for (i=1; i<argc; i++)
 | 
						for (i=1; i<argc; i++)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (sscanf(argv[i],"%lx",&l))
 | 
							if (sscanf(argv[i],"%lx",&l))
 | 
				
			||||||
			{
 | 
								printf("%s\n",ERR_error_string(l,buf));
 | 
				
			||||||
			ERR_error_string_n(l, buf, sizeof buf);
 | 
					 | 
				
			||||||
			printf("%s\n",buf);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			printf("%s: bad error code\n",argv[i]);
 | 
								printf("%s: bad error code\n",argv[i]);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										108
									
								
								apps/gendh.c
									
									
									
									
									
								
							
							
						
						
									
										108
									
								
								apps/gendh.c
									
									
									
									
									
								
							@@ -1,5 +1,4 @@
 | 
				
			|||||||
/* apps/gendh.c */
 | 
					/* apps/gendh.c */
 | 
				
			||||||
/* obsoleted by dhparam.c */
 | 
					 | 
				
			||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
					/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
				
			||||||
 * All rights reserved.
 | 
					 * All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -70,25 +69,21 @@
 | 
				
			|||||||
#include <openssl/dh.h>
 | 
					#include <openssl/dh.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DEFBITS	512
 | 
					#define DEFBITS	512
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG gendh_main
 | 
					#define PROG gendh_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg);
 | 
					static void MS_CALLBACK dh_cb(int p, int n, char *arg);
 | 
				
			||||||
 | 
					static long dh_load_rand(char *names);
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
						char buffer[200];
 | 
				
			||||||
	DH *dh=NULL;
 | 
						DH *dh=NULL;
 | 
				
			||||||
	int ret=1,num=DEFBITS;
 | 
						int ret=1,num=DEFBITS;
 | 
				
			||||||
	int g=2;
 | 
						int g=2;
 | 
				
			||||||
	char *outfile=NULL;
 | 
						char *outfile=NULL;
 | 
				
			||||||
	char *inrand=NULL;
 | 
						char *inrand=NULL,*randfile;
 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
	BIO *out=NULL;
 | 
						BIO *out=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
@@ -113,11 +108,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			g=3; */
 | 
								g=3; */
 | 
				
			||||||
		else if (strcmp(*argv,"-5") == 0)
 | 
							else if (strcmp(*argv,"-5") == 0)
 | 
				
			||||||
			g=5;
 | 
								g=5;
 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
							else if (strcmp(*argv,"-rand") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -133,34 +123,15 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"usage: gendh [args] [numbits]\n");
 | 
							BIO_printf(bio_err,"usage: gendh [args] [numbits]\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out file - output the key to 'file\n");
 | 
							BIO_printf(bio_err," -out file - output the key to 'file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -2        - use 2 as the generator value\n");
 | 
							BIO_printf(bio_err," -2    use 2 as the generator value\n");
 | 
				
			||||||
	/*	BIO_printf(bio_err," -3        - use 3 as the generator value\n"); */
 | 
						/*	BIO_printf(bio_err," -3    use 3 as the generator value\n"); */
 | 
				
			||||||
		BIO_printf(bio_err," -5        - use 5 as the generator value\n");
 | 
							BIO_printf(bio_err," -5    use 5 as the generator value\n");
 | 
				
			||||||
		BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
 | 
							BIO_printf(bio_err," -rand file:file:...\n");
 | 
				
			||||||
		BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"           - load the file (or the files in the directory) into\n");
 | 
							BIO_printf(bio_err,"           - load the file (or the files in the directory) into\n");
 | 
				
			||||||
		BIO_printf(bio_err,"             the random number generator\n");
 | 
							BIO_printf(bio_err,"             the random number generator\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if (out == NULL)
 | 
						if (out == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -169,15 +140,7 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -187,21 +150,28 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
 | 
						randfile=RAND_file_name(buffer,200);
 | 
				
			||||||
		{
 | 
						if ((randfile == NULL)|| !RAND_load_file(randfile,1024L*1024L))
 | 
				
			||||||
		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
							BIO_printf(bio_err,"unable to load 'random state'\n");
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (inrand != NULL)
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
 | 
						if (inrand == NULL)
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
				
			||||||
 | 
								dh_load_rand(inrand));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						BIO_printf(bio_err,"Generating DH parameters, %d bit long strong prime, generator of %d\n",num,g);
 | 
				
			||||||
	BIO_printf(bio_err,"This is going to take a long time\n");
 | 
						BIO_printf(bio_err,"This is going to take a long time\n");
 | 
				
			||||||
	dh=DH_generate_parameters(num,g,dh_cb,bio_err);
 | 
						dh=DH_generate_parameters(num,g,dh_cb,(char *)bio_err);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	if (dh == NULL) goto end;
 | 
						if (dh == NULL) goto end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app_RAND_write_file(NULL, bio_err);
 | 
						if (randfile == NULL)
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"unable to write 'random state'\n");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							RAND_write_file(randfile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!PEM_write_bio_DHparams(out,dh))
 | 
						if (!PEM_write_bio_DHparams(out,dh))
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
@@ -209,12 +179,12 @@ bad:
 | 
				
			|||||||
end:
 | 
					end:
 | 
				
			||||||
	if (ret != 0)
 | 
						if (ret != 0)
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (dh != NULL) DH_free(dh);
 | 
						if (dh != NULL) DH_free(dh);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
 | 
					static void MS_CALLBACK dh_cb(int p, int n, char *arg)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	char c='*';
 | 
						char c='*';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -223,9 +193,31 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
 | 
				
			|||||||
	if (p == 2) c='*';
 | 
						if (p == 2) c='*';
 | 
				
			||||||
	if (p == 3) c='\n';
 | 
						if (p == 3) c='\n';
 | 
				
			||||||
	BIO_write((BIO *)arg,&c,1);
 | 
						BIO_write((BIO *)arg,&c,1);
 | 
				
			||||||
	(void)BIO_flush((BIO *)arg);
 | 
						BIO_flush((BIO *)arg);
 | 
				
			||||||
#ifdef LINT
 | 
					#ifdef LINT
 | 
				
			||||||
	p=n;
 | 
						p=n;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static long dh_load_rand(char *name)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						char *p,*n;
 | 
				
			||||||
 | 
						int last;
 | 
				
			||||||
 | 
						long tot=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (;;)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							last=0;
 | 
				
			||||||
 | 
							for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
 | 
				
			||||||
 | 
							if (*p == '\0') last=1;
 | 
				
			||||||
 | 
							*p='\0';
 | 
				
			||||||
 | 
							n=name;
 | 
				
			||||||
 | 
							name=p+1;
 | 
				
			||||||
 | 
							if (*n == '\0') break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tot+=RAND_load_file(n,1);
 | 
				
			||||||
 | 
							if (last) break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						return(tot);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										114
									
								
								apps/gendsa.c
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								apps/gendsa.c
									
									
									
									
									
								
							@@ -63,30 +63,27 @@
 | 
				
			|||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
#include <openssl/bio.h>
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
 | 
					#include <openssl/rand.h>
 | 
				
			||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/bn.h>
 | 
					#include <openssl/bn.h>
 | 
				
			||||||
#include <openssl/dsa.h>
 | 
					#include <openssl/dsa.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DEFBITS	512
 | 
					#define DEFBITS	512
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG gendsa_main
 | 
					#define PROG gendsa_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					static long dsa_load_rand(char *names);
 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
						char buffer[200];
 | 
				
			||||||
	DSA *dsa=NULL;
 | 
						DSA *dsa=NULL;
 | 
				
			||||||
	int ret=1;
 | 
						int ret=1;
 | 
				
			||||||
	char *outfile=NULL;
 | 
						char *outfile=NULL;
 | 
				
			||||||
	char *inrand=NULL,*dsaparams=NULL;
 | 
						char *inrand=NULL,*randfile,*dsaparams=NULL;
 | 
				
			||||||
	char *passargout = NULL, *passout = NULL;
 | 
					 | 
				
			||||||
	BIO *out=NULL,*in=NULL;
 | 
						BIO *out=NULL,*in=NULL;
 | 
				
			||||||
	EVP_CIPHER *enc=NULL;
 | 
						EVP_CIPHER *enc=NULL;
 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -104,16 +101,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-passout") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargout= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
							else if (strcmp(*argv,"-rand") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -121,6 +108,10 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-") == 0)
 | 
							else if (strcmp(*argv,"-") == 0)
 | 
				
			||||||
			goto bad;
 | 
								goto bad;
 | 
				
			||||||
 | 
							else if (dsaparams == NULL)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								dsaparams= *argv;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
#ifndef NO_DES
 | 
					#ifndef NO_DES
 | 
				
			||||||
		else if (strcmp(*argv,"-des") == 0)
 | 
							else if (strcmp(*argv,"-des") == 0)
 | 
				
			||||||
			enc=EVP_des_cbc();
 | 
								enc=EVP_des_cbc();
 | 
				
			||||||
@@ -131,10 +122,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (strcmp(*argv,"-idea") == 0)
 | 
							else if (strcmp(*argv,"-idea") == 0)
 | 
				
			||||||
			enc=EVP_idea_cbc();
 | 
								enc=EVP_idea_cbc();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		else if (**argv != '-' && dsaparams == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			dsaparams = *argv;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			goto bad;
 | 
								goto bad;
 | 
				
			||||||
		argv++;
 | 
							argv++;
 | 
				
			||||||
@@ -153,8 +140,7 @@ bad:
 | 
				
			|||||||
#ifndef NO_IDEA
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
		BIO_printf(bio_err," -idea     - encrypt the generated key with IDEA in cbc mode\n");
 | 
							BIO_printf(bio_err," -idea     - encrypt the generated key with IDEA in cbc mode\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device.\n");
 | 
							BIO_printf(bio_err," -rand file:file:...\n");
 | 
				
			||||||
		BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"           - load the file (or the files in the directory) into\n");
 | 
							BIO_printf(bio_err,"           - load the file (or the files in the directory) into\n");
 | 
				
			||||||
		BIO_printf(bio_err,"             the random number generator\n");
 | 
							BIO_printf(bio_err,"             the random number generator\n");
 | 
				
			||||||
		BIO_printf(bio_err," dsaparam-file\n");
 | 
							BIO_printf(bio_err," dsaparam-file\n");
 | 
				
			||||||
@@ -162,30 +148,6 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting password\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	if (!(BIO_read_filename(in,dsaparams)))
 | 
						if (!(BIO_read_filename(in,dsaparams)))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -193,27 +155,18 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL)) == NULL)
 | 
						if ((dsa=PEM_read_bio_DSAparams(in,NULL,NULL)) == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unable to load DSA parameter file\n");
 | 
							BIO_printf(bio_err,"unable to load DSA parameter file\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	BIO_free(in);
 | 
						BIO_free(in);
 | 
				
			||||||
	in = NULL;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if (out == NULL) goto end;
 | 
						if (out == NULL) goto end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -223,30 +176,57 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
 | 
						randfile=RAND_file_name(buffer,200);
 | 
				
			||||||
		{
 | 
						if ((randfile == NULL)|| !RAND_load_file(randfile,1024L*1024L))
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"unable to load 'random state'\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (inrand == NULL)
 | 
				
			||||||
		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
							BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
				
			||||||
		}
 | 
						else
 | 
				
			||||||
	if (inrand != NULL)
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
							BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
								dsa_load_rand(inrand));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_err,"Generating DSA key, %d bits\n",
 | 
						BIO_printf(bio_err,"Generating DSA key, %d bits\n",
 | 
				
			||||||
							BN_num_bits(dsa->p));
 | 
												BN_num_bits(dsa->p));
 | 
				
			||||||
	if (!DSA_generate_key(dsa)) goto end;
 | 
						if (!DSA_generate_key(dsa)) goto end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app_RAND_write_file(NULL, bio_err);
 | 
						if (randfile == NULL)
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"unable to write 'random state'\n");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							RAND_write_file(randfile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout))
 | 
						if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL))
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (ret != 0)
 | 
						if (ret != 0)
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
					 | 
				
			||||||
	if (dsa != NULL) DSA_free(dsa);
 | 
						if (dsa != NULL) DSA_free(dsa);
 | 
				
			||||||
	if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static long dsa_load_rand(char *name)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						char *p,*n;
 | 
				
			||||||
 | 
						int last;
 | 
				
			||||||
 | 
						long tot=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (;;)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							last=0;
 | 
				
			||||||
 | 
							for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
 | 
				
			||||||
 | 
							if (*p == '\0') last=1;
 | 
				
			||||||
 | 
							*p='\0';
 | 
				
			||||||
 | 
							n=name;
 | 
				
			||||||
 | 
							name=p+1;
 | 
				
			||||||
 | 
							if (*n == '\0') break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tot+=RAND_load_file(n,1);
 | 
				
			||||||
 | 
							if (last) break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						return(tot);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										154
									
								
								apps/genrsa.c
									
									
									
									
									
								
							
							
						
						
									
										154
									
								
								apps/genrsa.c
									
									
									
									
									
								
							@@ -63,35 +63,31 @@
 | 
				
			|||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
#include <openssl/bio.h>
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
 | 
					#include <openssl/rand.h>
 | 
				
			||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/bn.h>
 | 
					#include <openssl/bn.h>
 | 
				
			||||||
#include <openssl/rsa.h>
 | 
					#include <openssl/rsa.h>
 | 
				
			||||||
#include <openssl/evp.h>
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DEFBITS	512
 | 
					#define DEFBITS	512
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG genrsa_main
 | 
					#define PROG genrsa_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK genrsa_cb(int p, int n, void *arg);
 | 
					static void MS_CALLBACK genrsa_cb(int p, int n, char *arg);
 | 
				
			||||||
 | 
					static long gr_load_rand(char *names);
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	int ret=1;
 | 
						int ret=1;
 | 
				
			||||||
 | 
						char buffer[200];
 | 
				
			||||||
	RSA *rsa=NULL;
 | 
						RSA *rsa=NULL;
 | 
				
			||||||
	int i,num=DEFBITS;
 | 
						int i,num=DEFBITS;
 | 
				
			||||||
	long l;
 | 
						long rnum=0,l;
 | 
				
			||||||
	EVP_CIPHER *enc=NULL;
 | 
						EVP_CIPHER *enc=NULL;
 | 
				
			||||||
	unsigned long f4=RSA_F4;
 | 
						unsigned long f4=RSA_F4;
 | 
				
			||||||
	char *outfile=NULL;
 | 
						char *outfile=NULL;
 | 
				
			||||||
	char *passargout = NULL, *passout = NULL;
 | 
						char *inrand=NULL,*randfile;
 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
	char *inrand=NULL;
 | 
					 | 
				
			||||||
	BIO *out=NULL;
 | 
						BIO *out=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
@@ -101,7 +97,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
	if ((out=BIO_new(BIO_s_file())) == NULL)
 | 
						if ((out=BIO_new(BIO_s_file())) == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unable to create BIO for output\n");
 | 
							BIO_printf(bio_err,"unable to creat BIO for output\n");
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -117,13 +113,8 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-3") == 0)
 | 
							else if (strcmp(*argv,"-3") == 0)
 | 
				
			||||||
			f4=3;
 | 
								f4=3;
 | 
				
			||||||
		else if (strcmp(*argv,"-F4") == 0 || strcmp(*argv,"-f4") == 0)
 | 
							else if (strcmp(*argv,"-F4") == 0)
 | 
				
			||||||
			f4=RSA_F4;
 | 
								f4=RSA_F4;
 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
							else if (strcmp(*argv,"-rand") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -139,11 +130,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (strcmp(*argv,"-idea") == 0)
 | 
							else if (strcmp(*argv,"-idea") == 0)
 | 
				
			||||||
			enc=EVP_idea_cbc();
 | 
								enc=EVP_idea_cbc();
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		else if (strcmp(*argv,"-passout") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargout= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		argv++;
 | 
							argv++;
 | 
				
			||||||
@@ -153,57 +139,23 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n");
 | 
							BIO_printf(bio_err,"usage: genrsa [args] [numbits]\n");
 | 
				
			||||||
		BIO_printf(bio_err," -des            encrypt the generated key with DES in cbc mode\n");
 | 
							BIO_printf(bio_err," -des      - encrypt the generated key with DES in cbc mode\n");
 | 
				
			||||||
		BIO_printf(bio_err," -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
 | 
							BIO_printf(bio_err," -des3     - encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
 | 
				
			||||||
#ifndef NO_IDEA
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
		BIO_printf(bio_err," -idea           encrypt the generated key with IDEA in cbc mode\n");
 | 
							BIO_printf(bio_err," -idea     - encrypt the generated key with IDEA in cbc mode\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		BIO_printf(bio_err," -out file       output the key to 'file\n");
 | 
							BIO_printf(bio_err," -out file - output the key to 'file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -passout arg    output file pass phrase source\n");
 | 
							BIO_printf(bio_err," -f4       - use F4 (0x10001) for the E value\n");
 | 
				
			||||||
		BIO_printf(bio_err," -f4             use F4 (0x10001) for the E value\n");
 | 
							BIO_printf(bio_err," -3        - use 3 for the E value\n");
 | 
				
			||||||
		BIO_printf(bio_err," -3              use 3 for the E value\n");
 | 
							BIO_printf(bio_err," -rand file:file:...\n");
 | 
				
			||||||
		BIO_printf(bio_err," -engine e       use engine e, possibly a hardware device.\n");
 | 
							BIO_printf(bio_err,"           - load the file (or the files in the directory) into\n");
 | 
				
			||||||
		BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
							BIO_printf(bio_err,"             the random number generator\n");
 | 
				
			||||||
		BIO_printf(bio_err,"                 load the file (or the files in the directory) into\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"                 the random number generator\n");
 | 
					 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting password\n");
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -213,24 +165,45 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
 | 
					#ifdef WINDOWS
 | 
				
			||||||
		&& !RAND_status())
 | 
						BIO_printf(bio_err,"Loading 'screen' into random state -");
 | 
				
			||||||
 | 
						BIO_flush(bio_err);
 | 
				
			||||||
 | 
						RAND_screen();
 | 
				
			||||||
 | 
						BIO_printf(bio_err," done\n");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						randfile=RAND_file_name(buffer,200);
 | 
				
			||||||
 | 
						if ((randfile == NULL) ||
 | 
				
			||||||
 | 
							 !(rnum=(long)RAND_load_file(randfile,1024L*1024L)))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
							BIO_printf(bio_err,"unable to load 'random state'\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (inrand != NULL)
 | 
					
 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
						if (inrand == NULL)
 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
							{
 | 
				
			||||||
 | 
							if (rnum == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							rnum+=gr_load_rand(inrand);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						if (rnum != 0)
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"%ld semi-random bytes loaded\n",rnum);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
 | 
						BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
 | 
				
			||||||
		num);
 | 
							num);
 | 
				
			||||||
	rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err);
 | 
						rsa=RSA_generate_key(num,f4,genrsa_cb,(char *)bio_err);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	app_RAND_write_file(NULL, bio_err);
 | 
						if (randfile == NULL)
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"unable to write 'random state'\n");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							RAND_write_file(randfile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (rsa == NULL) goto err;
 | 
						if (rsa == NULL) goto err;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* We need to do the following for when the base number size is <
 | 
						/* We need to do the folloing for when the base number size is <
 | 
				
			||||||
	 * long, esp windows 3.1 :-(. */
 | 
						 * long, esp windows 3.1 :-(. */
 | 
				
			||||||
	l=0L;
 | 
						l=0L;
 | 
				
			||||||
	for (i=0; i<rsa->e->top; i++)
 | 
						for (i=0; i<rsa->e->top; i++)
 | 
				
			||||||
@@ -242,20 +215,19 @@ bad:
 | 
				
			|||||||
		l+=rsa->e->d[i];
 | 
							l+=rsa->e->d[i];
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l);
 | 
						BIO_printf(bio_err,"e is %ld (0x%lX)\n",l,l);
 | 
				
			||||||
	if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL, passout))
 | 
						if (!PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL))
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
err:
 | 
					err:
 | 
				
			||||||
	if (rsa != NULL) RSA_free(rsa);
 | 
						if (rsa != NULL) RSA_free(rsa);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
	if (ret != 0)
 | 
						if (ret != 0)
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
 | 
					static void MS_CALLBACK genrsa_cb(int p, int n, char *arg)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	char c='*';
 | 
						char c='*';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -264,15 +236,31 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
 | 
				
			|||||||
	if (p == 2) c='*';
 | 
						if (p == 2) c='*';
 | 
				
			||||||
	if (p == 3) c='\n';
 | 
						if (p == 3) c='\n';
 | 
				
			||||||
	BIO_write((BIO *)arg,&c,1);
 | 
						BIO_write((BIO *)arg,&c,1);
 | 
				
			||||||
	(void)BIO_flush((BIO *)arg);
 | 
						BIO_flush((BIO *)arg);
 | 
				
			||||||
#ifdef LINT
 | 
					#ifdef LINT
 | 
				
			||||||
	p=n;
 | 
						p=n;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#else /* !NO_RSA */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# if PEDANTIC
 | 
					static long gr_load_rand(char *name)
 | 
				
			||||||
static void *dummy=&dummy;
 | 
						{
 | 
				
			||||||
# endif
 | 
						char *p,*n;
 | 
				
			||||||
 | 
						int last;
 | 
				
			||||||
 | 
						long tot=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (;;)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							last=0;
 | 
				
			||||||
 | 
							for (p=name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++);
 | 
				
			||||||
 | 
							if (*p == '\0') last=1;
 | 
				
			||||||
 | 
							*p='\0';
 | 
				
			||||||
 | 
							n=name;
 | 
				
			||||||
 | 
							name=p+1;
 | 
				
			||||||
 | 
							if (*n == '\0') break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tot+=RAND_load_file(n,1024L*1024L);
 | 
				
			||||||
 | 
							if (last) break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						return(tot);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ $!
 | 
				
			|||||||
$! Define what programs should be compiled
 | 
					$! Define what programs should be compiled
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ PROGRAMS := OPENSSL
 | 
					$ PROGRAMS := OPENSSL
 | 
				
			||||||
$!$ PROGRAMS := VERIFY,ASN1PARS,REQ,DGST,DH,ENC,PASSWD,GENDH,ERRSTR,CA,CRL,-
 | 
					$!$ PROGRAMS := VERIFY,ASN1PARS,REQ,DGST,DH,ENC,GENDH,ERRSTR,CA,CRL,-
 | 
				
			||||||
$!	      RSA,DSA,DSAPARAM,-
 | 
					$!	      RSA,DSA,DSAPARAM,-
 | 
				
			||||||
$!	      X509,GENRSA,GENDSA,S_SERVER,S_CLIENT,SPEED,-
 | 
					$!	      X509,GENRSA,GENDSA,S_SERVER,S_CLIENT,SPEED,-
 | 
				
			||||||
$!	      S_TIME,VERSION,PKCS7,CRL2P7,SESS_ID,CIPHERS,NSEQ,
 | 
					$!	      S_TIME,VERSION,PKCS7,CRL2P7,SESS_ID,CIPHERS,NSEQ,
 | 
				
			||||||
@@ -152,18 +152,20 @@ $ GOSUB CHECK_OPT_FILE
 | 
				
			|||||||
$!
 | 
					$!
 | 
				
			||||||
$! Define The Application Files.
 | 
					$! Define The Application Files.
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;DHPARAM;ENC;PASSWD;GENDH;ERRSTR;"+-
 | 
					$ LIB_FILES = "VERIFY;ASN1PARS;REQ;DGST;DH;ENC;GENDH;"+-
 | 
				
			||||||
	      "CA;PKCS7;CRL2P7;CRL;"+-
 | 
						      "ERRSTR;CA;"+-
 | 
				
			||||||
	      "RSA;RSAUTL;DSA;DSAPARAM;"+-
 | 
						      "PKCS7;CRL2P7;CRL;"+-
 | 
				
			||||||
 | 
						      "RSA;DSA;DSAPARAM;"+-
 | 
				
			||||||
	      "X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+-
 | 
						      "X509;GENRSA;GENDSA;S_SERVER;S_CLIENT;SPEED;"+-
 | 
				
			||||||
	      "S_TIME;APPS;S_CB;S_SOCKET;APP_RAND;VERSION;SESS_ID;"+-
 | 
						      "S_TIME;APPS;S_CB;S_SOCKET;VERSION;SESS_ID;"+-
 | 
				
			||||||
	      "CIPHERS;NSEQ;PKCS12;PKCS8;SPKAC;SMIME;RAND"
 | 
						      "CIPHERS;NSEQ;PKCS12"
 | 
				
			||||||
$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,DHPARAM.OBJ,ENC.OBJ,PASSWD.OBJ,GENDH.OBJ,ERRSTR.OBJ,-
 | 
					$ APP_FILES := OPENSSL,'OBJ_DIR'VERIFY.OBJ,ASN1PARS.OBJ,REQ.OBJ,DGST.OBJ,DH.OBJ,ENC.OBJ,GENDH.OBJ,-
 | 
				
			||||||
	       CA.OBJ,PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,-
 | 
						       ERRSTR.OBJ,CA.OBJ,-
 | 
				
			||||||
	       RSA.OBJ,RSAUTL.OBJ,DSA.OBJ,DSAPARAM.OBJ,-
 | 
						       PKCS7.OBJ,CRL2P7.OBJ,CRL.OBJ,-
 | 
				
			||||||
 | 
						       RSA.OBJ,DSA.OBJ,DSAPARAM.OBJ,-
 | 
				
			||||||
	       X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,-
 | 
						       X509.OBJ,GENRSA.OBJ,GENDSA.OBJ,S_SERVER.OBJ,S_CLIENT.OBJ,SPEED.OBJ,-
 | 
				
			||||||
	       S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,APP_RAND.OBJ,VERSION.OBJ,SESS_ID.OBJ,-
 | 
						       S_TIME.OBJ,APPS.OBJ,S_CB.OBJ,S_SOCKET.OBJ,VERSION.OBJ,SESS_ID.OBJ,-
 | 
				
			||||||
	       CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ,PKCS8.OBJ,SPKAC.OBJ,SMIME.OBJ,RAND.OBJ
 | 
						       CIPHERS.OBJ,NSEQ.OBJ,PKCS12.OBJ
 | 
				
			||||||
$ TCPIP_PROGRAMS = ",,"
 | 
					$ TCPIP_PROGRAMS = ",,"
 | 
				
			||||||
$ IF COMPILER .EQS. "VAXC" THEN -
 | 
					$ IF COMPILER .EQS. "VAXC" THEN -
 | 
				
			||||||
     TCPIP_PROGRAMS = ",OPENSSL,"
 | 
					     TCPIP_PROGRAMS = ",OPENSSL,"
 | 
				
			||||||
@@ -806,36 +808,12 @@ $!
 | 
				
			|||||||
$! Set Up Initial CC Definitions, Possibly With User Ones
 | 
					$! Set Up Initial CC Definitions, Possibly With User Ones
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ CCDEFS = "VMS=1,MONOLITH"
 | 
					$ CCDEFS = "VMS=1,MONOLITH"
 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_ASM") THEN CCDEFS = CCDEFS + ",NO_ASM"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_RSA") THEN CCDEFS = CCDEFS + ",NO_RSA"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_DSA") THEN CCDEFS = CCDEFS + ",NO_DSA"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_DH") THEN CCDEFS = CCDEFS + ",NO_DH"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_MD2") THEN CCDEFS = CCDEFS + ",NO_MD2"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_MD5") THEN CCDEFS = CCDEFS + ",NO_MD5"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_RIPEMD") THEN CCDEFS = CCDEFS + ",NO_RIPEMD"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_SHA") THEN CCDEFS = CCDEFS + ",NO_SHA"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_SHA0") THEN CCDEFS = CCDEFS + ",NO_SHA0"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_SHA1") THEN CCDEFS = CCDEFS + ",NO_SHA1"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_DES")
 | 
					 | 
				
			||||||
$ THEN
 | 
					 | 
				
			||||||
$   CCDEFS = CCDEFS + ",NO_DES,NO_MDC2"
 | 
					 | 
				
			||||||
$ ELSE
 | 
					 | 
				
			||||||
$   IF F$TRNLNM("OPENSSL_NO_MDC2") THEN CCDEFS = CCDEFS + ",NO_MDC2"
 | 
					 | 
				
			||||||
$ ENDIF
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_RC2") THEN CCDEFS = CCDEFS + ",NO_RC2"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_RC4") THEN CCDEFS = CCDEFS + ",NO_RC4"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_RC5") THEN CCDEFS = CCDEFS + ",NO_RC5"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_IDEA") THEN CCDEFS = CCDEFS + ",NO_IDEA"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_BF") THEN CCDEFS = CCDEFS + ",NO_BF"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_CAST") THEN CCDEFS = CCDEFS + ",NO_CAST"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_HMAC") THEN CCDEFS = CCDEFS + ",NO_HMAC"
 | 
					 | 
				
			||||||
$ IF F$TRNLNM("OPENSSL_NO_SSL2") THEN CCDEFS = CCDEFS + ",NO_SSL2"
 | 
					 | 
				
			||||||
$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
 | 
					$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
 | 
				
			||||||
$ CCEXTRAFLAGS = ""
 | 
					$ CCEXTRAFLAGS = ""
 | 
				
			||||||
$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
 | 
					$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
 | 
				
			||||||
$ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX"
 | 
					$ CCDISABLEWARNINGS = ""
 | 
				
			||||||
$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
 | 
					$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
 | 
				
			||||||
	CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
 | 
						CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$!  Check To See If The User Entered A Valid Paramter.
 | 
					$!  Check To See If The User Entered A Valid Paramter.
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
@@ -922,8 +900,7 @@ $     WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
 | 
				
			|||||||
$!
 | 
					$!
 | 
				
			||||||
$!    Use GNU C...
 | 
					$!    Use GNU C...
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$     IF F$TYPE(GCC) .EQS. "" THEN GCC := GCC
 | 
					$     CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
 | 
				
			||||||
$     CC = GCC+"/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
 | 
					 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$!    Define The Linker Options File Name.
 | 
					$!    Define The Linker Options File Name.
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
@@ -1133,7 +1110,6 @@ $!
 | 
				
			|||||||
$! Save directory information
 | 
					$! Save directory information
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
 | 
					$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
 | 
				
			||||||
$ __HERE = F$EDIT(__HERE,"UPCASE")
 | 
					 | 
				
			||||||
$ __TOP = __HERE - "APPS]"
 | 
					$ __TOP = __HERE - "APPS]"
 | 
				
			||||||
$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
 | 
					$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
 | 
				
			||||||
$!
 | 
					$!
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										49
									
								
								apps/nseq.c
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								apps/nseq.c
									
									
									
									
									
								
							@@ -65,7 +65,7 @@
 | 
				
			|||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG nseq_main
 | 
					#define PROG nseq_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					static int dump_cert_text(BIO *out, X509 *x);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -99,9 +99,9 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		BIO_printf (bio_err, "Netscape certificate sequence utility\n");
 | 
							BIO_printf (bio_err, "Netscape certificate sequence utility\n");
 | 
				
			||||||
		BIO_printf (bio_err, "Usage nseq [options]\n");
 | 
							BIO_printf (bio_err, "Usage nseq [options]\n");
 | 
				
			||||||
		BIO_printf (bio_err, "where options are\n");
 | 
							BIO_printf (bio_err, "where options are\n");
 | 
				
			||||||
		BIO_printf (bio_err, "-in file  input file\n");
 | 
					                BIO_printf (bio_err, "-in file  input file\n");
 | 
				
			||||||
		BIO_printf (bio_err, "-out file output file\n");
 | 
					                BIO_printf (bio_err, "-out file output file\n");
 | 
				
			||||||
		BIO_printf (bio_err, "-toseq    output NS Sequence file\n");
 | 
					                BIO_printf (bio_err, "-toseq    output NS Sequence file\n");
 | 
				
			||||||
		EXIT(1);
 | 
							EXIT(1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -119,22 +119,15 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
				 "Can't open output file %s\n", outfile);
 | 
									 "Can't open output file %s\n", outfile);
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else out = BIO_new_fp(stdout, BIO_NOCLOSE);
 | 
				
			||||||
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
 | 
					
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (toseq) {
 | 
						if (toseq) {
 | 
				
			||||||
		seq = NETSCAPE_CERT_SEQUENCE_new();
 | 
							seq = NETSCAPE_CERT_SEQUENCE_new();
 | 
				
			||||||
		seq->certs = sk_X509_new_null();
 | 
							seq->certs = sk_new(NULL);
 | 
				
			||||||
		while((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) 
 | 
							while((x509 = PEM_read_bio_X509(in, NULL, NULL))) 
 | 
				
			||||||
		    sk_X509_push(seq->certs,x509);
 | 
										sk_push(seq->certs, (char *)x509);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(!sk_X509_num(seq->certs))
 | 
							if(!sk_num(seq->certs))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			BIO_printf (bio_err, "Error reading certs file %s\n", infile);
 | 
								BIO_printf (bio_err, "Error reading certs file %s\n", infile);
 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
								ERR_print_errors(bio_err);
 | 
				
			||||||
@@ -145,23 +138,37 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) {
 | 
						if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL))) {
 | 
				
			||||||
		BIO_printf (bio_err, "Error reading sequence file %s\n", infile);
 | 
							BIO_printf (bio_err, "Error reading sequence file %s\n", infile);
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for(i = 0; i < sk_X509_num(seq->certs); i++) {
 | 
						for(i = 0; i < sk_num(seq->certs); i++) {
 | 
				
			||||||
		x509 = sk_X509_value(seq->certs, i);
 | 
							x509 = (X509 *) sk_value(seq->certs, i);
 | 
				
			||||||
		dump_cert_text(out, x509);
 | 
							dump_cert_text(out, x509);
 | 
				
			||||||
		PEM_write_bio_X509(out, x509);
 | 
							PEM_write_bio_X509(out, x509);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ret = 0;
 | 
						ret = 0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	BIO_free(in);
 | 
						BIO_free(in);
 | 
				
			||||||
	BIO_free_all(out);
 | 
						BIO_free(out);
 | 
				
			||||||
	NETSCAPE_CERT_SEQUENCE_free(seq);
 | 
						NETSCAPE_CERT_SEQUENCE_free(seq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int dump_cert_text(BIO *out, X509 *x)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        char buf[256];
 | 
				
			||||||
 | 
					        X509_NAME_oneline(X509_get_subject_name(x),buf,256);
 | 
				
			||||||
 | 
					        BIO_puts(out,"subject=");
 | 
				
			||||||
 | 
					        BIO_puts(out,buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
 | 
				
			||||||
 | 
					        BIO_puts(out,"\nissuer= ");
 | 
				
			||||||
 | 
					        BIO_puts(out,buf);
 | 
				
			||||||
 | 
					        BIO_puts(out,"\n");
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,17 +3,10 @@
 | 
				
			|||||||
# This is mostly being used for generation of certificate requests.
 | 
					# This is mostly being used for generation of certificate requests.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
RANDFILE		= $ENV::HOME/.rnd
 | 
					RANDFILE		= $ENV::HOME.rnd
 | 
				
			||||||
oid_file		= $ENV::HOME/.oid
 | 
					oid_file		= $ENV::HOME.oid
 | 
				
			||||||
oid_section		= new_oids
 | 
					oid_section		= new_oids
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# To use this configuration file with the "-extfile" option of the
 | 
					 | 
				
			||||||
# "openssl x509" utility, name here the section containing the
 | 
					 | 
				
			||||||
# X.509v3 extensions to use:
 | 
					 | 
				
			||||||
# extensions		= 
 | 
					 | 
				
			||||||
# (Alternatively, use a configuration file that has only
 | 
					 | 
				
			||||||
# X.509v3 extensions in its main [= default] section.)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[ new_oids ]
 | 
					[ new_oids ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# We can add new OIDs in here for use by 'ca' and 'req'.
 | 
					# We can add new OIDs in here for use by 'ca' and 'req'.
 | 
				
			||||||
@@ -42,11 +35,6 @@ private_key	= $dir.private]cakey.pem# The private key
 | 
				
			|||||||
RANDFILE	= $dir.private].rand	# private random number file
 | 
					RANDFILE	= $dir.private].rand	# private random number file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
x509_extensions	= usr_cert		# The extentions to add to the cert
 | 
					x509_extensions	= usr_cert		# The extentions to add to the cert
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
 | 
					 | 
				
			||||||
# so this is commented out by default to leave a V1 CRL.
 | 
					 | 
				
			||||||
# crl_extensions	= crl_ext
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
default_days	= 365			# how long to certify for
 | 
					default_days	= 365			# how long to certify for
 | 
				
			||||||
default_crl_days= 30			# how long before next CRL
 | 
					default_crl_days= 30			# how long before next CRL
 | 
				
			||||||
default_md	= md5			# which md to use.
 | 
					default_md	= md5			# which md to use.
 | 
				
			||||||
@@ -86,19 +74,6 @@ distinguished_name	= req_distinguished_name
 | 
				
			|||||||
attributes		= req_attributes
 | 
					attributes		= req_attributes
 | 
				
			||||||
x509_extensions	= v3_ca	# The extentions to add to the self signed cert
 | 
					x509_extensions	= v3_ca	# The extentions to add to the self signed cert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This sets the permitted types in a DirectoryString. There are several
 | 
					 | 
				
			||||||
# options. 
 | 
					 | 
				
			||||||
# default: PrintableString, T61String, BMPString.
 | 
					 | 
				
			||||||
# pkix	 : PrintableString, BMPString.
 | 
					 | 
				
			||||||
# utf8only: only UTF8Strings.
 | 
					 | 
				
			||||||
# nobmp : PrintableString, T61String (no BMPStrings).
 | 
					 | 
				
			||||||
# MASK:XXXX a literal mask value.
 | 
					 | 
				
			||||||
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
 | 
					 | 
				
			||||||
# so use this option with caution!
 | 
					 | 
				
			||||||
dirstring_type = nobmp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# req_extensions = v3_req # The extensions to add to a certificate request
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[ req_distinguished_name ]
 | 
					[ req_distinguished_name ]
 | 
				
			||||||
countryName			= Country Name (2 letter code)
 | 
					countryName			= Country Name (2 letter code)
 | 
				
			||||||
countryName_default		= AU
 | 
					countryName_default		= AU
 | 
				
			||||||
@@ -148,33 +123,31 @@ basicConstraints=CA:FALSE
 | 
				
			|||||||
# the certificate can be used for anything *except* object signing.
 | 
					# the certificate can be used for anything *except* object signing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is OK for an SSL server.
 | 
					# This is OK for an SSL server.
 | 
				
			||||||
# nsCertType			= server
 | 
					#nsCertType			= server
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# For an object signing certificate this would be used.
 | 
					# For an object signing certificate this would be used.
 | 
				
			||||||
# nsCertType = objsign
 | 
					#nsCertType = objsign
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# For normal client use this is typical
 | 
					# For normal client use this is typical
 | 
				
			||||||
# nsCertType = client, email
 | 
					#nsCertType = client, email
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# and for everything including object signing:
 | 
					# This is typical also
 | 
				
			||||||
# nsCertType = client, email, objsign
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is typical in keyUsage for a client certificate.
 | 
					keyUsage = nonRepudiation, digitalSignature, keyEncipherment
 | 
				
			||||||
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This will be displayed in Netscape's comment listbox.
 | 
					 | 
				
			||||||
nsComment			= "OpenSSL Generated Certificate"
 | 
					nsComment			= "OpenSSL Generated Certificate"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# PKIX recommendations harmless if included in all certificates.
 | 
					# PKIX recommendations
 | 
				
			||||||
subjectKeyIdentifier=hash
 | 
					subjectKeyIdentifier=hash
 | 
				
			||||||
authorityKeyIdentifier=keyid,issuer:always
 | 
					authorityKeyIdentifier=keyid,issuer:always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This stuff is for subjectAltName and issuerAltname.
 | 
					 | 
				
			||||||
# Import the email address.
 | 
					# Import the email address.
 | 
				
			||||||
# subjectAltName=email:copy
 | 
					
 | 
				
			||||||
 | 
					subjectAltName=email:copy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Copy subject details
 | 
					# Copy subject details
 | 
				
			||||||
# issuerAltName=issuer:copy
 | 
					
 | 
				
			||||||
 | 
					issuerAltName=issuer:copy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
 | 
					#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
 | 
				
			||||||
#nsBaseUrl
 | 
					#nsBaseUrl
 | 
				
			||||||
@@ -183,18 +156,12 @@ authorityKeyIdentifier=keyid,issuer:always
 | 
				
			|||||||
#nsCaPolicyUrl
 | 
					#nsCaPolicyUrl
 | 
				
			||||||
#nsSslServerName
 | 
					#nsSslServerName
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ v3_req ]
 | 
					[ v3_ca]
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Extensions to add to a certificate request
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
basicConstraints = CA:FALSE
 | 
					 | 
				
			||||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[ v3_ca ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Extensions for a typical CA
 | 
					# Extensions for a typical CA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# It's a CA certificate
 | 
				
			||||||
 | 
					basicConstraints = CA:true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# PKIX recommendation.
 | 
					# PKIX recommendation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -205,32 +172,19 @@ authorityKeyIdentifier=keyid:always,issuer:always
 | 
				
			|||||||
# This is what PKIX recommends but some broken software chokes on critical
 | 
					# This is what PKIX recommends but some broken software chokes on critical
 | 
				
			||||||
# extensions.
 | 
					# extensions.
 | 
				
			||||||
#basicConstraints = critical,CA:true
 | 
					#basicConstraints = critical,CA:true
 | 
				
			||||||
# So we do this instead.
 | 
					 | 
				
			||||||
basicConstraints = CA:true
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Key usage: this is typical for a CA certificate. However since it will
 | 
					# Key usage: again this should really be critical.
 | 
				
			||||||
# prevent it being used as an test self-signed certificate it is best
 | 
					keyUsage = cRLSign, keyCertSign
 | 
				
			||||||
# left out by default.
 | 
					 | 
				
			||||||
# keyUsage = cRLSign, keyCertSign
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Some might want this also
 | 
					# Some might want this also
 | 
				
			||||||
# nsCertType = sslCA, emailCA
 | 
					#nsCertType = sslCA, emailCA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Include email address in subject alt name: another PKIX recommendation
 | 
					# Include email address in subject alt name: another PKIX recommendation
 | 
				
			||||||
# subjectAltName=email:copy
 | 
					subjectAltName=email:copy
 | 
				
			||||||
# Copy issuer details
 | 
					# Copy issuer details
 | 
				
			||||||
# issuerAltName=issuer:copy
 | 
					issuerAltName=issuer:copy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# DER hex encoding of an extension: beware experts only!
 | 
					# RAW DER hex encoding of an extension: beware experts only!
 | 
				
			||||||
# obj=DER:02:03
 | 
					# 1.2.3.5=RAW:02:03
 | 
				
			||||||
# Where 'obj' is a standard or added object
 | 
					 | 
				
			||||||
# You can even override a supported extension:
 | 
					# You can even override a supported extension:
 | 
				
			||||||
# basicConstraints= critical, DER:30:03:01:01:FF
 | 
					# basicConstraints= critical, RAW:30:03:01:01:FF
 | 
				
			||||||
 | 
					 | 
				
			||||||
[ crl_ext ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# CRL extensions.
 | 
					 | 
				
			||||||
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# issuerAltName=issuer:copy
 | 
					 | 
				
			||||||
authorityKeyIdentifier=keyid:always,issuer:always
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,10 +56,13 @@
 | 
				
			|||||||
 * [including the GNU Public Licence.]
 | 
					 * [including the GNU Public Licence.]
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef DEBUG
 | 
				
			||||||
 | 
					#undef DEBUG
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#define OPENSSL_C /* tells apps.h to use complete apps_startup() */
 | 
					 | 
				
			||||||
#include <openssl/bio.h>
 | 
					#include <openssl/bio.h>
 | 
				
			||||||
#include <openssl/crypto.h>
 | 
					#include <openssl/crypto.h>
 | 
				
			||||||
#include <openssl/lhash.h>
 | 
					#include <openssl/lhash.h>
 | 
				
			||||||
@@ -67,12 +70,19 @@
 | 
				
			|||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					#include <openssl/ssl.h>
 | 
				
			||||||
 | 
					#define SSLEAY	/* turn off a few special case MONOLITH macros */
 | 
				
			||||||
#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
 | 
					#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
 | 
				
			||||||
 | 
					#define SSLEAY_SRC
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
#include "progs.h"
 | 
					 | 
				
			||||||
#include "s_apps.h"
 | 
					#include "s_apps.h"
 | 
				
			||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					#ifdef WINDOWS
 | 
				
			||||||
 | 
					#include "bss_file.c"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static unsigned long MS_CALLBACK hash(FUNCTION *a);
 | 
					static unsigned long MS_CALLBACK hash(FUNCTION *a);
 | 
				
			||||||
static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b);
 | 
					static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b);
 | 
				
			||||||
static LHASH *prog_init(void );
 | 
					static LHASH *prog_init(void );
 | 
				
			||||||
@@ -80,6 +90,15 @@ static int do_cmd(LHASH *prog,int argc,char *argv[]);
 | 
				
			|||||||
LHASH *config=NULL;
 | 
					LHASH *config=NULL;
 | 
				
			||||||
char *default_config_file=NULL;
 | 
					char *default_config_file=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					static void sig_stop(int i)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						char *a=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*a='\0';
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Make sure there is only one when MONOLITH is defined */
 | 
					/* Make sure there is only one when MONOLITH is defined */
 | 
				
			||||||
#ifdef MONOLITH
 | 
					#ifdef MONOLITH
 | 
				
			||||||
BIO *bio_err=NULL;
 | 
					BIO *bio_err=NULL;
 | 
				
			||||||
@@ -88,8 +107,8 @@ BIO *bio_err=NULL;
 | 
				
			|||||||
int main(int Argc, char *Argv[])
 | 
					int main(int Argc, char *Argv[])
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ARGS arg;
 | 
						ARGS arg;
 | 
				
			||||||
#define PROG_NAME_SIZE	39
 | 
					#define PROG_NAME_SIZE	16
 | 
				
			||||||
	char pname[PROG_NAME_SIZE+1];
 | 
						char pname[PROG_NAME_SIZE];
 | 
				
			||||||
	FUNCTION f,*fp;
 | 
						FUNCTION f,*fp;
 | 
				
			||||||
	MS_STATIC char *prompt,buf[1024],config_name[256];
 | 
						MS_STATIC char *prompt,buf[1024],config_name[256];
 | 
				
			||||||
	int n,i,ret=0;
 | 
						int n,i,ret=0;
 | 
				
			||||||
@@ -101,16 +120,24 @@ int main(int Argc, char *Argv[])
 | 
				
			|||||||
	arg.data=NULL;
 | 
						arg.data=NULL;
 | 
				
			||||||
	arg.count=0;
 | 
						arg.count=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (getenv("OPENSSL_DEBUG_MEMORY") != NULL)
 | 
						/* SSLeay_add_ssl_algorithms(); is called in apps_startup() */
 | 
				
			||||||
		CRYPTO_malloc_debug_init();
 | 
					 | 
				
			||||||
	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(DEBUG) && !defined(WINDOWS) && !defined(MSDOS)
 | 
				
			||||||
 | 
					#ifdef SIGBUS
 | 
				
			||||||
 | 
						signal(SIGBUS,sig_stop);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifdef SIGSEGV
 | 
				
			||||||
 | 
						signal(SIGSEGV,sig_stop);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bio_err == NULL)
 | 
						if (bio_err == NULL)
 | 
				
			||||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
							if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
				
			||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
								BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Lets load up our environment a little */
 | 
						/* Lets load up our environment a little */
 | 
				
			||||||
@@ -138,7 +165,7 @@ int main(int Argc, char *Argv[])
 | 
				
			|||||||
	program_name(Argv[0],pname,PROG_NAME_SIZE);
 | 
						program_name(Argv[0],pname,PROG_NAME_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	f.name=pname;
 | 
						f.name=pname;
 | 
				
			||||||
	fp=(FUNCTION *)lh_retrieve(prog,&f);
 | 
						fp=(FUNCTION *)lh_retrieve(prog,(char *)&f);
 | 
				
			||||||
	if (fp != NULL)
 | 
						if (fp != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		Argv[0]=pname;
 | 
							Argv[0]=pname;
 | 
				
			||||||
@@ -192,7 +219,7 @@ int main(int Argc, char *Argv[])
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		if (ret != 0)
 | 
							if (ret != 0)
 | 
				
			||||||
			BIO_printf(bio_err,"error in %s\n",argv[0]);
 | 
								BIO_printf(bio_err,"error in %s\n",argv[0]);
 | 
				
			||||||
		(void)BIO_flush(bio_err);
 | 
							BIO_flush(bio_err);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	BIO_printf(bio_err,"bad exit\n");
 | 
						BIO_printf(bio_err,"bad exit\n");
 | 
				
			||||||
	ret=1;
 | 
						ret=1;
 | 
				
			||||||
@@ -203,12 +230,12 @@ end:
 | 
				
			|||||||
		config=NULL;
 | 
							config=NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (prog != NULL) lh_free(prog);
 | 
						if (prog != NULL) lh_free(prog);
 | 
				
			||||||
	if (arg.data != NULL) OPENSSL_free(arg.data);
 | 
						if (arg.data != NULL) Free(arg.data);
 | 
				
			||||||
	ERR_remove_state(0);
 | 
						ERR_remove_state(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EVP_cleanup();
 | 
						EVP_cleanup();
 | 
				
			||||||
	ERR_free_strings();
 | 
						ERR_free_strings();
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	CRYPTO_mem_leaks(bio_err);
 | 
						CRYPTO_mem_leaks(bio_err);
 | 
				
			||||||
	if (bio_err != NULL)
 | 
						if (bio_err != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -230,29 +257,11 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
 | 
				
			|||||||
	if ((argc <= 0) || (argv[0] == NULL))
 | 
						if ((argc <= 0) || (argv[0] == NULL))
 | 
				
			||||||
		{ ret=0; goto end; }
 | 
							{ ret=0; goto end; }
 | 
				
			||||||
	f.name=argv[0];
 | 
						f.name=argv[0];
 | 
				
			||||||
	fp=(FUNCTION *)lh_retrieve(prog,&f);
 | 
						fp=(FUNCTION *)lh_retrieve(prog,(char *)&f);
 | 
				
			||||||
	if (fp != NULL)
 | 
						if (fp != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		ret=fp->func(argc,argv);
 | 
							ret=fp->func(argc,argv);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	else if ((strncmp(argv[0],"no-",3)) == 0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		bio_stdout = BIO_push(tmpbio, bio_stdout);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		f.name=argv[0]+3;
 | 
					 | 
				
			||||||
		ret = (lh_retrieve(prog,&f) != NULL);
 | 
					 | 
				
			||||||
		if (!ret)
 | 
					 | 
				
			||||||
			BIO_printf(bio_stdout, "%s\n", argv[0]);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			BIO_printf(bio_stdout, "%s\n", argv[0]+3);
 | 
					 | 
				
			||||||
		BIO_free_all(bio_stdout);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else if ((strcmp(argv[0],"quit") == 0) ||
 | 
						else if ((strcmp(argv[0],"quit") == 0) ||
 | 
				
			||||||
		(strcmp(argv[0],"q") == 0) ||
 | 
							(strcmp(argv[0],"q") == 0) ||
 | 
				
			||||||
		(strcmp(argv[0],"exit") == 0) ||
 | 
							(strcmp(argv[0],"exit") == 0) ||
 | 
				
			||||||
@@ -275,17 +284,11 @@ static int do_cmd(LHASH *prog, int argc, char *argv[])
 | 
				
			|||||||
		else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */
 | 
							else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */
 | 
				
			||||||
			list_type = FUNC_TYPE_CIPHER;
 | 
								list_type = FUNC_TYPE_CIPHER;
 | 
				
			||||||
		bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
 | 
							bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		bio_stdout = BIO_push(tmpbio, bio_stdout);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		for (fp=functions; fp->name != NULL; fp++)
 | 
							for (fp=functions; fp->name != NULL; fp++)
 | 
				
			||||||
			if (fp->type == list_type)
 | 
								if (fp->type == list_type)
 | 
				
			||||||
				BIO_printf(bio_stdout, "%s\n", fp->name);
 | 
									BIO_printf(bio_stdout, "%s\n", fp->name);
 | 
				
			||||||
		BIO_free_all(bio_stdout);
 | 
							BIO_free(bio_stdout);
 | 
				
			||||||
		ret=0;
 | 
							ret=0;
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -353,7 +356,7 @@ static LHASH *prog_init(void)
 | 
				
			|||||||
	if ((ret=lh_new(hash,cmp)) == NULL) return(NULL);
 | 
						if ((ret=lh_new(hash,cmp)) == NULL) return(NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (f=functions; f->name != NULL; f++)
 | 
						for (f=functions; f->name != NULL; f++)
 | 
				
			||||||
		lh_insert(ret,f);
 | 
							lh_insert(ret,(char *)f);
 | 
				
			||||||
	return(ret);
 | 
						return(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -366,3 +369,5 @@ static unsigned long MS_CALLBACK hash(FUNCTION *a)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
	return(lh_strhash(a->name));
 | 
						return(lh_strhash(a->name));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef SSLEAY
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,13 +3,8 @@
 | 
				
			|||||||
# This is mostly being used for generation of certificate requests.
 | 
					# This is mostly being used for generation of certificate requests.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This definition stops the following lines choking if HOME isn't
 | 
					 | 
				
			||||||
# defined.
 | 
					 | 
				
			||||||
HOME			= .
 | 
					 | 
				
			||||||
RANDFILE		= $ENV::HOME/.rnd
 | 
					RANDFILE		= $ENV::HOME/.rnd
 | 
				
			||||||
 | 
					oid_file		= $ENV::HOME/.oid
 | 
				
			||||||
# Extra OBJECT IDENTIFIER info:
 | 
					 | 
				
			||||||
#oid_file		= $ENV::HOME/.oid
 | 
					 | 
				
			||||||
oid_section		= new_oids
 | 
					oid_section		= new_oids
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# To use this configuration file with the "-extfile" option of the
 | 
					# To use this configuration file with the "-extfile" option of the
 | 
				
			||||||
@@ -91,22 +86,6 @@ distinguished_name	= req_distinguished_name
 | 
				
			|||||||
attributes		= req_attributes
 | 
					attributes		= req_attributes
 | 
				
			||||||
x509_extensions	= v3_ca	# The extentions to add to the self signed cert
 | 
					x509_extensions	= v3_ca	# The extentions to add to the self signed cert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Passwords for private keys if not present they will be prompted for
 | 
					 | 
				
			||||||
# input_password = secret
 | 
					 | 
				
			||||||
# output_password = secret
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# This sets a mask for permitted string types. There are several options. 
 | 
					 | 
				
			||||||
# default: PrintableString, T61String, BMPString.
 | 
					 | 
				
			||||||
# pkix	 : PrintableString, BMPString.
 | 
					 | 
				
			||||||
# utf8only: only UTF8Strings.
 | 
					 | 
				
			||||||
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
 | 
					 | 
				
			||||||
# MASK:XXXX a literal mask value.
 | 
					 | 
				
			||||||
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
 | 
					 | 
				
			||||||
# so use this option with caution!
 | 
					 | 
				
			||||||
string_mask = nombstr
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# req_extensions = v3_req # The extensions to add to a certificate request
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[ req_distinguished_name ]
 | 
					[ req_distinguished_name ]
 | 
				
			||||||
countryName			= Country Name (2 letter code)
 | 
					countryName			= Country Name (2 letter code)
 | 
				
			||||||
countryName_default		= AU
 | 
					countryName_default		= AU
 | 
				
			||||||
@@ -191,15 +170,7 @@ authorityKeyIdentifier=keyid,issuer:always
 | 
				
			|||||||
#nsCaPolicyUrl
 | 
					#nsCaPolicyUrl
 | 
				
			||||||
#nsSslServerName
 | 
					#nsSslServerName
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ v3_req ]
 | 
					[ v3_ca]
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Extensions to add to a certificate request
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
basicConstraints = CA:FALSE
 | 
					 | 
				
			||||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[ v3_ca ]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Extensions for a typical CA
 | 
					# Extensions for a typical CA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -229,11 +200,10 @@ basicConstraints = CA:true
 | 
				
			|||||||
# Copy issuer details
 | 
					# Copy issuer details
 | 
				
			||||||
# issuerAltName=issuer:copy
 | 
					# issuerAltName=issuer:copy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# DER hex encoding of an extension: beware experts only!
 | 
					# RAW DER hex encoding of an extension: beware experts only!
 | 
				
			||||||
# obj=DER:02:03
 | 
					# 1.2.3.5=RAW:02:03
 | 
				
			||||||
# Where 'obj' is a standard or added object
 | 
					 | 
				
			||||||
# You can even override a supported extension:
 | 
					# You can even override a supported extension:
 | 
				
			||||||
# basicConstraints= critical, DER:30:03:01:01:FF
 | 
					# basicConstraints= critical, RAW:30:03:01:01:FF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ crl_ext ]
 | 
					[ crl_ext ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										503
									
								
								apps/passwd.c
									
									
									
									
									
								
							
							
						
						
									
										503
									
								
								apps/passwd.c
									
									
									
									
									
								
							@@ -1,503 +0,0 @@
 | 
				
			|||||||
/* apps/passwd.c */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined NO_MD5 || defined CHARSET_EBCDIC
 | 
					 | 
				
			||||||
# define NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if !defined(NO_DES) || !defined(NO_MD5CRYPT_1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <openssl/bio.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/evp.h>
 | 
					 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_DES
 | 
					 | 
				
			||||||
# include <openssl/des.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
# include <openssl/md5.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#undef PROG
 | 
					 | 
				
			||||||
#define PROG passwd_main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static unsigned const char cov_2char[64]={
 | 
					 | 
				
			||||||
	/* from crypto/des/fcrypt.c */
 | 
					 | 
				
			||||||
	0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
 | 
					 | 
				
			||||||
	0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,
 | 
					 | 
				
			||||||
	0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,
 | 
					 | 
				
			||||||
	0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,
 | 
					 | 
				
			||||||
	0x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62,
 | 
					 | 
				
			||||||
	0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,
 | 
					 | 
				
			||||||
	0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,
 | 
					 | 
				
			||||||
	0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
 | 
					 | 
				
			||||||
	char *passwd, BIO *out, int quiet, int table, int reverse,
 | 
					 | 
				
			||||||
	size_t pw_maxlen, int usecrypt, int use1, int useapr1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* -crypt        - standard Unix password algorithm (default)
 | 
					 | 
				
			||||||
 * -1            - MD5-based password algorithm
 | 
					 | 
				
			||||||
 * -apr1         - MD5-based password algorithm, Apache variant
 | 
					 | 
				
			||||||
 * -salt string  - salt
 | 
					 | 
				
			||||||
 * -in file      - read passwords from file
 | 
					 | 
				
			||||||
 * -stdin        - read passwords from stdin
 | 
					 | 
				
			||||||
 * -quiet        - no warnings
 | 
					 | 
				
			||||||
 * -table        - format output as table
 | 
					 | 
				
			||||||
 * -reverse      - switch table columns
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	int ret = 1;
 | 
					 | 
				
			||||||
	char *infile = NULL;
 | 
					 | 
				
			||||||
	int in_stdin = 0;
 | 
					 | 
				
			||||||
	char *salt = NULL, *passwd = NULL, **passwds = NULL;
 | 
					 | 
				
			||||||
	char *salt_malloc = NULL, *passwd_malloc = NULL;
 | 
					 | 
				
			||||||
	size_t passwd_malloc_size = 0;
 | 
					 | 
				
			||||||
	int pw_source_defined = 0;
 | 
					 | 
				
			||||||
	BIO *in = NULL, *out = NULL;
 | 
					 | 
				
			||||||
	int i, badopt, opt_done;
 | 
					 | 
				
			||||||
	int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
 | 
					 | 
				
			||||||
	int usecrypt = 0, use1 = 0, useapr1 = 0;
 | 
					 | 
				
			||||||
	size_t pw_maxlen = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	apps_startup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_err == NULL)
 | 
					 | 
				
			||||||
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
 | 
					 | 
				
			||||||
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 | 
					 | 
				
			||||||
	out = BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
	if (out == NULL)
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
	BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
	out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	badopt = 0, opt_done = 0;
 | 
					 | 
				
			||||||
	i = 0;
 | 
					 | 
				
			||||||
	while (!badopt && !opt_done && argv[++i] != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (strcmp(argv[i], "-crypt") == 0)
 | 
					 | 
				
			||||||
			usecrypt = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-1") == 0)
 | 
					 | 
				
			||||||
			use1 = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-apr1") == 0)
 | 
					 | 
				
			||||||
			useapr1 = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-salt") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((argv[i+1] != NULL) && (salt == NULL))
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				passed_salt = 1;
 | 
					 | 
				
			||||||
				salt = argv[++i];
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-in") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((argv[i+1] != NULL) && !pw_source_defined)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				pw_source_defined = 1;
 | 
					 | 
				
			||||||
				infile = argv[++i];
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-stdin") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!pw_source_defined)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				pw_source_defined = 1;
 | 
					 | 
				
			||||||
				in_stdin = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-quiet") == 0)
 | 
					 | 
				
			||||||
			quiet = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-table") == 0)
 | 
					 | 
				
			||||||
			table = 1;
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-reverse") == 0)
 | 
					 | 
				
			||||||
			reverse = 1;
 | 
					 | 
				
			||||||
		else if (argv[i][0] == '-')
 | 
					 | 
				
			||||||
			badopt = 1;
 | 
					 | 
				
			||||||
		else if (!pw_source_defined)
 | 
					 | 
				
			||||||
			/* non-option arguments, use as passwords */
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			pw_source_defined = 1;
 | 
					 | 
				
			||||||
			passwds = &argv[i];
 | 
					 | 
				
			||||||
			opt_done = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			badopt = 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!usecrypt && !use1 && !useapr1) /* use default */
 | 
					 | 
				
			||||||
		usecrypt = 1;
 | 
					 | 
				
			||||||
	if (usecrypt + use1 + useapr1 > 1) /* conflict */
 | 
					 | 
				
			||||||
		badopt = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* reject unsupported algorithms */
 | 
					 | 
				
			||||||
#ifdef NO_DES
 | 
					 | 
				
			||||||
	if (usecrypt) badopt = 1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifdef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
	if (use1 || useapr1) badopt = 1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (badopt) 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Usage: passwd [options] [passwords]\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "where options are\n");
 | 
					 | 
				
			||||||
#ifndef NO_DES
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-crypt             standard Unix password algorithm (default)\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-1                 MD5-based password algorithm\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-apr1              MD5-based password algorithm, Apache variant\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-salt string       use provided salt\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-in file           read passwords from file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-stdin             read passwords from stdin\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-quiet             no warnings\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-table             format output as table\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-reverse           switch table columns\n");
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((infile != NULL) || in_stdin)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		in = BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
		if (in == NULL)
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
		if (infile != NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			assert(in_stdin == 0);
 | 
					 | 
				
			||||||
			if (BIO_read_filename(in, infile) <= 0)
 | 
					 | 
				
			||||||
				goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			assert(in_stdin);
 | 
					 | 
				
			||||||
			BIO_set_fp(in, stdin, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (usecrypt)
 | 
					 | 
				
			||||||
		pw_maxlen = 8;
 | 
					 | 
				
			||||||
	else if (use1 || useapr1)
 | 
					 | 
				
			||||||
		pw_maxlen = 256; /* arbitrary limit, should be enough for most passwords */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (passwds == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		/* no passwords on the command line */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		passwd_malloc_size = pw_maxlen + 2;
 | 
					 | 
				
			||||||
		/* longer than necessary so that we can warn about truncation */
 | 
					 | 
				
			||||||
		passwd = passwd_malloc = OPENSSL_malloc(passwd_malloc_size);
 | 
					 | 
				
			||||||
		if (passwd_malloc == NULL)
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((in == NULL) && (passwds == NULL))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		/* build a null-terminated list */
 | 
					 | 
				
			||||||
		static char *passwds_static[2] = {NULL, NULL};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		passwds = passwds_static;
 | 
					 | 
				
			||||||
		if (in == NULL)
 | 
					 | 
				
			||||||
			if (EVP_read_pw_string(passwd_malloc, passwd_malloc_size, "Password: ", 0) != 0)
 | 
					 | 
				
			||||||
				goto err;
 | 
					 | 
				
			||||||
		passwds[0] = passwd_malloc;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (in == NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		assert(passwds != NULL);
 | 
					 | 
				
			||||||
		assert(*passwds != NULL);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		do /* loop over list of passwords */
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			passwd = *passwds++;
 | 
					 | 
				
			||||||
			if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out,
 | 
					 | 
				
			||||||
				quiet, table, reverse, pw_maxlen, usecrypt, use1, useapr1))
 | 
					 | 
				
			||||||
				goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		while (*passwds != NULL);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		/* in != NULL */
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		int done;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		assert (passwd != NULL);
 | 
					 | 
				
			||||||
		do
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			int r = BIO_gets(in, passwd, pw_maxlen + 1);
 | 
					 | 
				
			||||||
			if (r > 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				char *c = (strchr(passwd, '\n')) ;
 | 
					 | 
				
			||||||
				if (c != NULL)
 | 
					 | 
				
			||||||
					*c = 0; /* truncate at newline */
 | 
					 | 
				
			||||||
				else
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
					/* ignore rest of line */
 | 
					 | 
				
			||||||
					char trash[BUFSIZ];
 | 
					 | 
				
			||||||
					do
 | 
					 | 
				
			||||||
						r = BIO_gets(in, trash, sizeof trash);
 | 
					 | 
				
			||||||
					while ((r > 0) && (!strchr(trash, '\n')));
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
				if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, out,
 | 
					 | 
				
			||||||
					quiet, table, reverse, pw_maxlen, usecrypt, use1, useapr1))
 | 
					 | 
				
			||||||
					goto err;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			done = (r <= 0);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		while (!done);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	ret = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
err:
 | 
					 | 
				
			||||||
	ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
	if (salt_malloc)
 | 
					 | 
				
			||||||
		OPENSSL_free(salt_malloc);
 | 
					 | 
				
			||||||
	if (passwd_malloc)
 | 
					 | 
				
			||||||
		OPENSSL_free(passwd_malloc);
 | 
					 | 
				
			||||||
	if (in)
 | 
					 | 
				
			||||||
		BIO_free(in);
 | 
					 | 
				
			||||||
	if (out)
 | 
					 | 
				
			||||||
		BIO_free_all(out);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
/* MD5-based password algorithm (should probably be available as a library
 | 
					 | 
				
			||||||
 * function; then the static buffer would not be acceptable).
 | 
					 | 
				
			||||||
 * For magic string "1", this should be compatible to the MD5-based BSD
 | 
					 | 
				
			||||||
 * password algorithm.
 | 
					 | 
				
			||||||
 * For 'magic' string "apr1", this is compatible to the MD5-based Apache
 | 
					 | 
				
			||||||
 * password algorithm.
 | 
					 | 
				
			||||||
 * (Apparently, the Apache password algorithm is identical except that the
 | 
					 | 
				
			||||||
 * 'magic' string was changed -- the laziest application of the NIH principle
 | 
					 | 
				
			||||||
 * I've ever encountered.)
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
static char *md5crypt(const char *passwd, const char *magic, const char *salt)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	static char out_buf[6 + 9 + 24 + 2]; /* "$apr1$..salt..$.......md5hash..........\0" */
 | 
					 | 
				
			||||||
	unsigned char buf[MD5_DIGEST_LENGTH];
 | 
					 | 
				
			||||||
	char *salt_out;
 | 
					 | 
				
			||||||
	int n, i;
 | 
					 | 
				
			||||||
	MD5_CTX md;
 | 
					 | 
				
			||||||
	size_t passwd_len, salt_len;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	passwd_len = strlen(passwd);
 | 
					 | 
				
			||||||
	out_buf[0] = '$';
 | 
					 | 
				
			||||||
	out_buf[1] = 0;
 | 
					 | 
				
			||||||
	assert(strlen(magic) <= 4); /* "1" or "apr1" */
 | 
					 | 
				
			||||||
	strncat(out_buf, magic, 4);
 | 
					 | 
				
			||||||
	strncat(out_buf, "$", 1);
 | 
					 | 
				
			||||||
	strncat(out_buf, salt, 8);
 | 
					 | 
				
			||||||
	assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */
 | 
					 | 
				
			||||||
	salt_out = out_buf + 2 + strlen(magic);
 | 
					 | 
				
			||||||
	salt_len = strlen(salt_out);
 | 
					 | 
				
			||||||
	assert(salt_len <= 8);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	MD5_Init(&md);
 | 
					 | 
				
			||||||
	MD5_Update(&md, passwd, passwd_len);
 | 
					 | 
				
			||||||
	MD5_Update(&md, "$", 1);
 | 
					 | 
				
			||||||
	MD5_Update(&md, magic, strlen(magic));
 | 
					 | 
				
			||||||
	MD5_Update(&md, "$", 1);
 | 
					 | 
				
			||||||
	MD5_Update(&md, salt_out, salt_len);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	 {
 | 
					 | 
				
			||||||
		MD5_CTX md2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		MD5_Init(&md2);
 | 
					 | 
				
			||||||
		MD5_Update(&md2, passwd, passwd_len);
 | 
					 | 
				
			||||||
		MD5_Update(&md2, salt_out, salt_len);
 | 
					 | 
				
			||||||
		MD5_Update(&md2, passwd, passwd_len);
 | 
					 | 
				
			||||||
		MD5_Final(buf, &md2);
 | 
					 | 
				
			||||||
	 }
 | 
					 | 
				
			||||||
	for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
 | 
					 | 
				
			||||||
		MD5_Update(&md, buf, sizeof buf);
 | 
					 | 
				
			||||||
	MD5_Update(&md, buf, i);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	n = passwd_len;
 | 
					 | 
				
			||||||
	while (n)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		MD5_Update(&md, (n & 1) ? "\0" : passwd, 1);
 | 
					 | 
				
			||||||
		n >>= 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	MD5_Final(buf, &md);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (i = 0; i < 1000; i++)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		MD5_CTX md2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		MD5_Init(&md2);
 | 
					 | 
				
			||||||
		MD5_Update(&md2, (i & 1) ? (unsigned char *) passwd : buf,
 | 
					 | 
				
			||||||
		                 (i & 1) ? passwd_len : sizeof buf);
 | 
					 | 
				
			||||||
		if (i % 3)
 | 
					 | 
				
			||||||
			MD5_Update(&md2, salt_out, salt_len);
 | 
					 | 
				
			||||||
		if (i % 7)
 | 
					 | 
				
			||||||
			MD5_Update(&md2, passwd, passwd_len);
 | 
					 | 
				
			||||||
		MD5_Update(&md2, (i & 1) ? buf : (unsigned char *) passwd,
 | 
					 | 
				
			||||||
		                 (i & 1) ? sizeof buf : passwd_len);
 | 
					 | 
				
			||||||
		MD5_Final(buf, &md2);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	 {
 | 
					 | 
				
			||||||
		/* transform buf into output string */
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		unsigned char buf_perm[sizeof buf];
 | 
					 | 
				
			||||||
		int dest, source;
 | 
					 | 
				
			||||||
		char *output;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* silly output permutation */
 | 
					 | 
				
			||||||
		for (dest = 0, source = 0; dest < 14; dest++, source = (source + 6) % 17)
 | 
					 | 
				
			||||||
			buf_perm[dest] = buf[source];
 | 
					 | 
				
			||||||
		buf_perm[14] = buf[5];
 | 
					 | 
				
			||||||
		buf_perm[15] = buf[11];
 | 
					 | 
				
			||||||
#ifndef PEDANTIC /* Unfortunately, this generates a "no effect" warning */
 | 
					 | 
				
			||||||
		assert(16 == sizeof buf_perm);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		output = salt_out + salt_len;
 | 
					 | 
				
			||||||
		assert(output == out_buf + strlen(out_buf));
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		*output++ = '$';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for (i = 0; i < 15; i += 3)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			*output++ = cov_2char[buf_perm[i+2] & 0x3f];
 | 
					 | 
				
			||||||
			*output++ = cov_2char[((buf_perm[i+1] & 0xf) << 2) |
 | 
					 | 
				
			||||||
				                  (buf_perm[i+2] >> 6)];
 | 
					 | 
				
			||||||
			*output++ = cov_2char[((buf_perm[i] & 3) << 4) |
 | 
					 | 
				
			||||||
				                  (buf_perm[i+1] >> 4)];
 | 
					 | 
				
			||||||
			*output++ = cov_2char[buf_perm[i] >> 2];
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		assert(i == 15);
 | 
					 | 
				
			||||||
		*output++ = cov_2char[buf_perm[i] & 0x3f];
 | 
					 | 
				
			||||||
		*output++ = cov_2char[buf_perm[i] >> 6];
 | 
					 | 
				
			||||||
		*output = 0;
 | 
					 | 
				
			||||||
		assert(strlen(out_buf) < sizeof(out_buf));
 | 
					 | 
				
			||||||
	 }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return out_buf;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
 | 
					 | 
				
			||||||
	char *passwd, BIO *out,	int quiet, int table, int reverse,
 | 
					 | 
				
			||||||
	size_t pw_maxlen, int usecrypt, int use1, int useapr1)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	char *hash = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	assert(salt_p != NULL);
 | 
					 | 
				
			||||||
	assert(salt_malloc_p != NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* first make sure we have a salt */
 | 
					 | 
				
			||||||
	if (!passed_salt)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
#ifndef NO_DES
 | 
					 | 
				
			||||||
		if (usecrypt)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (*salt_malloc_p == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				*salt_p = *salt_malloc_p = OPENSSL_malloc(3);
 | 
					 | 
				
			||||||
				if (*salt_malloc_p == NULL)
 | 
					 | 
				
			||||||
					goto err;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			if (RAND_pseudo_bytes((unsigned char *)*salt_p, 2) < 0)
 | 
					 | 
				
			||||||
				goto err;
 | 
					 | 
				
			||||||
			(*salt_p)[0] = cov_2char[(*salt_p)[0] & 0x3f]; /* 6 bits */
 | 
					 | 
				
			||||||
			(*salt_p)[1] = cov_2char[(*salt_p)[1] & 0x3f]; /* 6 bits */
 | 
					 | 
				
			||||||
			(*salt_p)[2] = 0;
 | 
					 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
			ascii2ebcdic(*salt_p, *salt_p, 2); /* des_crypt will convert
 | 
					 | 
				
			||||||
			                                    * back to ASCII */
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#endif /* !NO_DES */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
		if (use1 || useapr1)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			int i;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (*salt_malloc_p == NULL)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				*salt_p = *salt_malloc_p = OPENSSL_malloc(9);
 | 
					 | 
				
			||||||
				if (*salt_malloc_p == NULL)
 | 
					 | 
				
			||||||
					goto err;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			if (RAND_pseudo_bytes((unsigned char *)*salt_p, 8) < 0)
 | 
					 | 
				
			||||||
				goto err;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			for (i = 0; i < 8; i++)
 | 
					 | 
				
			||||||
				(*salt_p)[i] = cov_2char[(*salt_p)[i] & 0x3f]; /* 6 bits */
 | 
					 | 
				
			||||||
			(*salt_p)[8] = 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#endif /* !NO_MD5CRYPT_1 */
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	assert(*salt_p != NULL);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/* truncate password if necessary */
 | 
					 | 
				
			||||||
	if ((strlen(passwd) > pw_maxlen))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (!quiet)
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Warning: truncating password to %u characters\n", pw_maxlen);
 | 
					 | 
				
			||||||
		passwd[pw_maxlen] = 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	assert(strlen(passwd) <= pw_maxlen);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/* now compute password hash */
 | 
					 | 
				
			||||||
#ifndef NO_DES
 | 
					 | 
				
			||||||
	if (usecrypt)
 | 
					 | 
				
			||||||
		hash = des_crypt(passwd, *salt_p);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_MD5CRYPT_1
 | 
					 | 
				
			||||||
	if (use1 || useapr1)
 | 
					 | 
				
			||||||
		hash = md5crypt(passwd, (use1 ? "1" : "apr1"), *salt_p);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	assert(hash != NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (table && !reverse)
 | 
					 | 
				
			||||||
		BIO_printf(out, "%s\t%s\n", passwd, hash);
 | 
					 | 
				
			||||||
	else if (table && reverse)
 | 
					 | 
				
			||||||
		BIO_printf(out, "%s\t%s\n", hash, passwd);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		BIO_printf(out, "%s\n", hash);
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
err:
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	fputs("Program not available.\n", stderr)
 | 
					 | 
				
			||||||
	EXIT(1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
07
 | 
					01
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										170
									
								
								apps/pem_mail.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								apps/pem_mail.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,170 @@
 | 
				
			|||||||
 | 
					/* apps/pem_mail.c */
 | 
				
			||||||
 | 
					/* 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.]
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef NO_RSA
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <openssl/rsa.h>
 | 
				
			||||||
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
 | 
					#include <openssl/objects.h>
 | 
				
			||||||
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
 | 
					#include <openssl/err.h>
 | 
				
			||||||
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
 | 
					#include "apps.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#undef PROG
 | 
				
			||||||
 | 
					#define PROG	pem_mail_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static char *usage[]={
 | 
				
			||||||
 | 
					"usage: pem_mail args\n",
 | 
				
			||||||
 | 
					"\n",
 | 
				
			||||||
 | 
					" -in arg         - input file - default stdin\n",
 | 
				
			||||||
 | 
					" -out arg        - output file - default stdout\n",
 | 
				
			||||||
 | 
					" -cert arg       - the certificate to use\n",
 | 
				
			||||||
 | 
					" -key arg        - the private key to use\n",
 | 
				
			||||||
 | 
					" -MIC           - sign the message\n",
 | 
				
			||||||
 | 
					" -enc arg        - encrypt with one of cbc-des\n",
 | 
				
			||||||
 | 
					NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct lines_St
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						char *line;
 | 
				
			||||||
 | 
						struct lines_st *next;
 | 
				
			||||||
 | 
						} LINES;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(int argc, char **argv)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						FILE *in;
 | 
				
			||||||
 | 
						RSA *rsa=NULL;
 | 
				
			||||||
 | 
						EVP_MD_CTX ctx;
 | 
				
			||||||
 | 
						unsigned int mic=0,i,n;
 | 
				
			||||||
 | 
						unsigned char buf[1024*15];
 | 
				
			||||||
 | 
						char *prog,*infile=NULL,*outfile=NULL,*key=NULL;
 | 
				
			||||||
 | 
						int badops=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						prog=argv[0];
 | 
				
			||||||
 | 
						argc--;
 | 
				
			||||||
 | 
						argv++;
 | 
				
			||||||
 | 
						while (argc >= 1)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							if (strcmp(*argv,"-key") == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
 | 
								key= *(++argv);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							else if (strcmp(*argv,"-in") == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
 | 
								infile= *(++argv);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							else if (strcmp(*argv,"-out") == 0)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
 | 
								outfile= *(++argv);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							else if (strcmp(*argv,"-mic") == 0)
 | 
				
			||||||
 | 
								mic=1;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
 | 
								badops=1;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							argc--;
 | 
				
			||||||
 | 
							argv++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (badops)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
					bad:
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"where options  are\n");
 | 
				
			||||||
 | 
							EXIT(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (key == NULL)
 | 
				
			||||||
 | 
							{ BIO_printf(bio_err,"you need to specify a key\n"); EXIT(1); }
 | 
				
			||||||
 | 
						in=fopen(key,"r");
 | 
				
			||||||
 | 
						if (in == NULL) { perror(key); EXIT(1); }
 | 
				
			||||||
 | 
						rsa=PEM_read_RSAPrivateKey(in,NULL,NULL);
 | 
				
			||||||
 | 
						if (rsa == NULL)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							BIO_printf(bio_err,"unable to load Private Key\n");
 | 
				
			||||||
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
 | 
							EXIT(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						fclose(in);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PEM_SignInit(&ctx,EVP_md5());
 | 
				
			||||||
 | 
						for (;;)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							i=fread(buf,1,1024*10,stdin);
 | 
				
			||||||
 | 
							if (i <= 0) break;
 | 
				
			||||||
 | 
							PEM_SignUpdate(&ctx,buf,i);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						if (!PEM_SignFinal(&ctx,buf,&n,rsa)) goto err;
 | 
				
			||||||
 | 
						BIO_printf(bio_err,"%s\n",buf);
 | 
				
			||||||
 | 
						EXIT(0);
 | 
				
			||||||
 | 
					err:
 | 
				
			||||||
 | 
						ERR_print_errors(bio_err);
 | 
				
			||||||
 | 
						EXIT(1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										577
									
								
								apps/pkcs12.c
									
									
									
									
									
								
							
							
						
						
									
										577
									
								
								apps/pkcs12.c
									
									
									
									
									
								
							@@ -1,6 +1,4 @@
 | 
				
			|||||||
/* pkcs12.c */
 | 
					/* pkcs12.c */
 | 
				
			||||||
#if !defined(NO_DES) && !defined(NO_SHA1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
					/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
				
			||||||
 * project 1999.
 | 
					 * project 1999.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -61,13 +59,12 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include "apps.h"
 | 
					#include <openssl/des.h>
 | 
				
			||||||
#include <openssl/crypto.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/pkcs12.h>
 | 
					#include <openssl/pkcs12.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "apps.h"
 | 
				
			||||||
#define PROG pkcs12_main
 | 
					#define PROG pkcs12_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EVP_CIPHER *enc;
 | 
					EVP_CIPHER *enc;
 | 
				
			||||||
@@ -79,21 +76,17 @@ EVP_CIPHER *enc;
 | 
				
			|||||||
#define CLCERTS		0x8
 | 
					#define CLCERTS		0x8
 | 
				
			||||||
#define CACERTS		0x10
 | 
					#define CACERTS		0x10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain);
 | 
					int get_cert_chain(X509 *cert, STACK **chain);
 | 
				
			||||||
int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass, int passlen, int options, char *pempass);
 | 
					int dump_cert_text (BIO *out, X509 *x);
 | 
				
			||||||
int dump_certs_pkeys_bags(BIO *out, STACK_OF(PKCS12_SAFEBAG) *bags, char *pass,
 | 
					int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass, int passlen, int options);
 | 
				
			||||||
			  int passlen, int options, char *pempass);
 | 
					int dump_certs_pkeys_bags(BIO *out, STACK *bags, char *pass, int passlen, int options);
 | 
				
			||||||
int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bags, char *pass, int passlen, int options, char *pempass);
 | 
					int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bags, char *pass, int passlen, int options);
 | 
				
			||||||
int print_attribs(BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name);
 | 
					int print_attribs(BIO *out, STACK *attrlst, char *name);
 | 
				
			||||||
void hex_prin(BIO *out, unsigned char *buf, int len);
 | 
					void hex_prin(BIO *out, unsigned char *buf, int len);
 | 
				
			||||||
int alg_print(BIO *x, X509_ALGOR *alg);
 | 
					int alg_print(BIO *x, X509_ALGOR *alg);
 | 
				
			||||||
int cert_load(BIO *in, STACK_OF(X509) *sk);
 | 
					int cert_load(BIO *in, STACK *sk);
 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    ENGINE *e = NULL;
 | 
					 | 
				
			||||||
    char *infile=NULL, *outfile=NULL, *keyname = NULL;	
 | 
					    char *infile=NULL, *outfile=NULL, *keyname = NULL;	
 | 
				
			||||||
    char *certfile=NULL;
 | 
					    char *certfile=NULL;
 | 
				
			||||||
    BIO *in=NULL, *out = NULL, *inkey = NULL, *certsin = NULL;
 | 
					    BIO *in=NULL, *out = NULL, *inkey = NULL, *certsin = NULL;
 | 
				
			||||||
@@ -106,21 +99,15 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
    int chain = 0;
 | 
					    int chain = 0;
 | 
				
			||||||
    int badarg = 0;
 | 
					    int badarg = 0;
 | 
				
			||||||
    int iter = PKCS12_DEFAULT_ITER;
 | 
					    int iter = PKCS12_DEFAULT_ITER;
 | 
				
			||||||
    int maciter = PKCS12_DEFAULT_ITER;
 | 
					    int maciter = 1;
 | 
				
			||||||
    int twopass = 0;
 | 
					    int twopass = 0;
 | 
				
			||||||
    int keytype = 0;
 | 
					    int keytype = 0;
 | 
				
			||||||
    int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
 | 
					    int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;
 | 
				
			||||||
    int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;
 | 
					 | 
				
			||||||
    int ret = 1;
 | 
					    int ret = 1;
 | 
				
			||||||
    int macver = 1;
 | 
					    int macver = 1;
 | 
				
			||||||
    int noprompt = 0;
 | 
					    int noprompt = 0;
 | 
				
			||||||
    STACK *canames = NULL;
 | 
					    STACK *canames = NULL;
 | 
				
			||||||
    char *cpass = NULL, *mpass = NULL;
 | 
					    char *cpass = NULL, *mpass = NULL;
 | 
				
			||||||
    char *passargin = NULL, *passargout = NULL, *passarg = NULL;
 | 
					 | 
				
			||||||
    char *passin = NULL, *passout = NULL;
 | 
					 | 
				
			||||||
    char *inrand = NULL;
 | 
					 | 
				
			||||||
    char *CApath = NULL, *CAfile = NULL;
 | 
					 | 
				
			||||||
    char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    apps_startup();
 | 
					    apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -154,35 +141,8 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (!strcmp (*args, "-noiter")) iter = 1;
 | 
							else if (!strcmp (*args, "-noiter")) iter = 1;
 | 
				
			||||||
		else if (!strcmp (*args, "-maciter"))
 | 
							else if (!strcmp (*args, "-maciter"))
 | 
				
			||||||
					 maciter = PKCS12_DEFAULT_ITER;
 | 
										 maciter = PKCS12_DEFAULT_ITER;
 | 
				
			||||||
		else if (!strcmp (*args, "-nomaciter"))
 | 
					 | 
				
			||||||
					 maciter = 1;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-nodes")) enc=NULL;
 | 
							else if (!strcmp (*args, "-nodes")) enc=NULL;
 | 
				
			||||||
		else if (!strcmp (*args, "-certpbe")) {
 | 
							else if (!strcmp (*args, "-inkey")) {
 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				cert_pbe=OBJ_txt2nid(*args);
 | 
					 | 
				
			||||||
				if(cert_pbe == NID_undef) {
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,
 | 
					 | 
				
			||||||
						 "Unknown PBE algorithm %s\n", *args);
 | 
					 | 
				
			||||||
					badarg = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp (*args, "-keypbe")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				key_pbe=OBJ_txt2nid(*args);
 | 
					 | 
				
			||||||
				if(key_pbe == NID_undef) {
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,
 | 
					 | 
				
			||||||
						 "Unknown PBE algorithm %s\n", *args);
 | 
					 | 
				
			||||||
					badarg = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp (*args, "-rand")) {
 | 
					 | 
				
			||||||
		    if (args[1]) {
 | 
					 | 
				
			||||||
			args++;	
 | 
					 | 
				
			||||||
			inrand = *args;
 | 
					 | 
				
			||||||
		    } else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp (*args, "-inkey")) {
 | 
					 | 
				
			||||||
		    if (args[1]) {
 | 
							    if (args[1]) {
 | 
				
			||||||
			args++;	
 | 
								args++;	
 | 
				
			||||||
			keyname = *args;
 | 
								keyname = *args;
 | 
				
			||||||
@@ -200,7 +160,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		} else if (!strcmp (*args, "-caname")) {
 | 
							} else if (!strcmp (*args, "-caname")) {
 | 
				
			||||||
		    if (args[1]) {
 | 
							    if (args[1]) {
 | 
				
			||||||
			args++;	
 | 
								args++;	
 | 
				
			||||||
			if (!canames) canames = sk_new_null();
 | 
								if (!canames) canames = sk_new(NULL);
 | 
				
			||||||
			sk_push(canames, *args);
 | 
								sk_push(canames, *args);
 | 
				
			||||||
		    } else badarg = 1;
 | 
							    } else badarg = 1;
 | 
				
			||||||
		} else if (!strcmp (*args, "-in")) {
 | 
							} else if (!strcmp (*args, "-in")) {
 | 
				
			||||||
@@ -213,37 +173,22 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			args++;	
 | 
								args++;	
 | 
				
			||||||
			outfile = *args;
 | 
								outfile = *args;
 | 
				
			||||||
		    } else badarg = 1;
 | 
							    } else badarg = 1;
 | 
				
			||||||
		} else if (!strcmp(*args,"-passin")) {
 | 
							} else if (!strcmp (*args, "-envpass")) {
 | 
				
			||||||
		    if (args[1]) {
 | 
							    if (args[1]) {
 | 
				
			||||||
			args++;	
 | 
								args++;	
 | 
				
			||||||
			passargin = *args;
 | 
								if(!(cpass = getenv(*args))) {
 | 
				
			||||||
		    } else badarg = 1;
 | 
									BIO_printf(bio_err,
 | 
				
			||||||
		} else if (!strcmp(*args,"-passout")) {
 | 
									 "Can't read environment variable %s\n", *args);
 | 
				
			||||||
		    if (args[1]) {
 | 
									goto end;
 | 
				
			||||||
			args++;	
 | 
								}
 | 
				
			||||||
			passargout = *args;
 | 
								noprompt = 1;
 | 
				
			||||||
		    } else badarg = 1;
 | 
							    } else badarg = 1;
 | 
				
			||||||
		} else if (!strcmp (*args, "-password")) {
 | 
							} else if (!strcmp (*args, "-password")) {
 | 
				
			||||||
		    if (args[1]) {
 | 
							    if (args[1]) {
 | 
				
			||||||
			args++;	
 | 
								args++;	
 | 
				
			||||||
			passarg = *args;
 | 
								cpass = *args;
 | 
				
			||||||
		    	noprompt = 1;
 | 
							    	noprompt = 1;
 | 
				
			||||||
		    } else badarg = 1;
 | 
							    } else badarg = 1;
 | 
				
			||||||
		} else if (!strcmp(*args,"-CApath")) {
 | 
					 | 
				
			||||||
		    if (args[1]) {
 | 
					 | 
				
			||||||
			args++;	
 | 
					 | 
				
			||||||
			CApath = *args;
 | 
					 | 
				
			||||||
		    } else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp(*args,"-CAfile")) {
 | 
					 | 
				
			||||||
		    if (args[1]) {
 | 
					 | 
				
			||||||
			args++;	
 | 
					 | 
				
			||||||
			CAfile = *args;
 | 
					 | 
				
			||||||
		    } else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp(*args,"-engine")) {
 | 
					 | 
				
			||||||
		    if (args[1]) {
 | 
					 | 
				
			||||||
			args++;	
 | 
					 | 
				
			||||||
			engine = *args;
 | 
					 | 
				
			||||||
		    } else badarg = 1;
 | 
					 | 
				
			||||||
		} else badarg = 1;
 | 
							} else badarg = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	} else badarg = 1;
 | 
						} else badarg = 1;
 | 
				
			||||||
@@ -257,8 +202,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	BIO_printf (bio_err, "-chain        add certificate chain\n");
 | 
						BIO_printf (bio_err, "-chain        add certificate chain\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-inkey file   private key if not infile\n");
 | 
						BIO_printf (bio_err, "-inkey file   private key if not infile\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-certfile f   add all certs in f\n");
 | 
						BIO_printf (bio_err, "-certfile f   add all certs in f\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-CApath arg   - PEM format directory of CA's\n");
 | 
					 | 
				
			||||||
	BIO_printf (bio_err, "-CAfile arg   - PEM format file of CA's\n");
 | 
					 | 
				
			||||||
	BIO_printf (bio_err, "-name \"name\"  use name as friendly name\n");
 | 
						BIO_printf (bio_err, "-name \"name\"  use name as friendly name\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-caname \"nm\"  use nm as CA friendly name (can be used more than once).\n");
 | 
						BIO_printf (bio_err, "-caname \"nm\"  use nm as CA friendly name (can be used more than once).\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-in  infile   input filename\n");
 | 
						BIO_printf (bio_err, "-in  infile   input filename\n");
 | 
				
			||||||
@@ -280,352 +223,202 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	BIO_printf (bio_err, "-maciter      use MAC iteration\n");
 | 
						BIO_printf (bio_err, "-maciter      use MAC iteration\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-twopass      separate MAC, encryption passwords\n");
 | 
						BIO_printf (bio_err, "-twopass      separate MAC, encryption passwords\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-descert      encrypt PKCS#12 certificates with triple DES (default RC2-40)\n");
 | 
						BIO_printf (bio_err, "-descert      encrypt PKCS#12 certificates with triple DES (default RC2-40)\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-certpbe alg  specify certificate PBE algorithm (default RC2-40)\n");
 | 
					 | 
				
			||||||
	BIO_printf (bio_err, "-keypbe alg   specify private key PBE algorithm (default 3DES)\n");
 | 
					 | 
				
			||||||
	BIO_printf (bio_err, "-keyex        set MS key exchange type\n");
 | 
						BIO_printf (bio_err, "-keyex        set MS key exchange type\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-keysig       set MS key signature type\n");
 | 
						BIO_printf (bio_err, "-keysig       set MS key signature type\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-password p   set import/export password source\n");
 | 
						BIO_printf (bio_err, "-password p   set import/export password (NOT RECOMMENDED)\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-passin p     input file pass phrase source\n");
 | 
						BIO_printf (bio_err, "-envpass p    set import/export password from environment\n");
 | 
				
			||||||
	BIO_printf (bio_err, "-passout p    output file pass phrase source\n");
 | 
					 | 
				
			||||||
	BIO_printf (bio_err, "-engine e     use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,  "-rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,  "              load the file (or the files in the directory) into\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,  "              the random number generator\n");
 | 
					 | 
				
			||||||
    	goto end;
 | 
					    	goto end;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (engine != NULL) {
 | 
					    if(cpass) mpass = cpass;
 | 
				
			||||||
	if((e = ENGINE_by_id(engine)) == NULL) {
 | 
					    else {
 | 
				
			||||||
	    BIO_printf(bio_err,"invalid engine \"%s\"\n", engine);
 | 
					 | 
				
			||||||
	    goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
 | 
					 | 
				
			||||||
	    BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
	    goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
	/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
	ENGINE_free(e);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(passarg) {
 | 
					 | 
				
			||||||
	if(export_cert) passargout = passarg;
 | 
					 | 
				
			||||||
	else passargin = passarg;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "Error getting passwords\n");
 | 
					 | 
				
			||||||
	goto end;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(!cpass) {
 | 
					 | 
				
			||||||
    	if(export_cert) cpass = passout;
 | 
					 | 
				
			||||||
    	else cpass = passin;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if(cpass) {
 | 
					 | 
				
			||||||
	mpass = cpass;
 | 
					 | 
				
			||||||
	noprompt = 1;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
	cpass = pass;
 | 
						cpass = pass;
 | 
				
			||||||
	mpass = macpass;
 | 
						mpass = macpass;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(export_cert || inrand) {
 | 
					 | 
				
			||||||
    	app_RAND_load_file(NULL, bio_err, (inrand != NULL));
 | 
					 | 
				
			||||||
        if (inrand != NULL)
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    ERR_load_crypto_strings();
 | 
					    ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					    in = BIO_new (BIO_s_file());
 | 
				
			||||||
    CRYPTO_push_info("read files");
 | 
					    out = BIO_new (BIO_s_file());
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!infile) in = BIO_new_fp(stdin, BIO_NOCLOSE);
 | 
					    if (!infile) BIO_set_fp (in, stdin, BIO_NOCLOSE);
 | 
				
			||||||
    else in = BIO_new_file(infile, "rb");
 | 
					    else {
 | 
				
			||||||
    if (!in) {
 | 
					        if (BIO_read_filename (in, infile) <= 0) {
 | 
				
			||||||
	    BIO_printf(bio_err, "Error opening input file %s\n",
 | 
					 | 
				
			||||||
						infile ? infile : "<stdin>");
 | 
					 | 
				
			||||||
	    perror (infile);
 | 
						    perror (infile);
 | 
				
			||||||
	    goto end;
 | 
						    goto end;
 | 
				
			||||||
   }
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   if (certfile) {
 | 
					   if (certfile) {
 | 
				
			||||||
    	if(!(certsin = BIO_new_file(certfile, "r"))) {
 | 
					    	certsin = BIO_new (BIO_s_file());
 | 
				
			||||||
	    BIO_printf(bio_err, "Can't open certificate file %s\n", certfile);
 | 
					        if (BIO_read_filename (certsin, certfile) <= 0) {
 | 
				
			||||||
	    perror (certfile);
 | 
						    perror (certfile);
 | 
				
			||||||
	    goto end;
 | 
						    goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (keyname) {
 | 
					    if (keyname) {
 | 
				
			||||||
    	if(!(inkey = BIO_new_file(keyname, "r"))) {
 | 
					    	inkey = BIO_new (BIO_s_file());
 | 
				
			||||||
	    BIO_printf(bio_err, "Can't key certificate file %s\n", keyname);
 | 
					        if (BIO_read_filename (inkey, keyname) <= 0) {
 | 
				
			||||||
	    perror (keyname);
 | 
						    perror (keyname);
 | 
				
			||||||
	    goto end;
 | 
						    goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					    if (!outfile) BIO_set_fp (out, stdout, BIO_NOCLOSE);
 | 
				
			||||||
    CRYPTO_pop_info();
 | 
					    else {
 | 
				
			||||||
    CRYPTO_push_info("write files");
 | 
					        if (BIO_write_filename (out, outfile) <= 0) {
 | 
				
			||||||
#endif
 | 
						    perror (outfile);
 | 
				
			||||||
 | 
						    goto end;
 | 
				
			||||||
    if (!outfile) {
 | 
					 | 
				
			||||||
	out = BIO_new_fp(stdout, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	    BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
	    out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    } else out = BIO_new_file(outfile, "wb");
 | 
					 | 
				
			||||||
    if (!out) {
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "Error opening output file %s\n",
 | 
					 | 
				
			||||||
						outfile ? outfile : "<stdout>");
 | 
					 | 
				
			||||||
	perror (outfile);
 | 
					 | 
				
			||||||
	goto end;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (twopass) {
 | 
					    if (twopass) {
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert)) {
 | 
				
			||||||
    CRYPTO_push_info("read MAC password");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert))
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
    	    BIO_printf (bio_err, "Can't read Password\n");
 | 
					    	    BIO_printf (bio_err, "Can't read Password\n");
 | 
				
			||||||
    	    goto end;
 | 
					    	    goto end;
 | 
				
			||||||
       	}
 | 
					       	}
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
    CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (export_cert) {
 | 
					if (export_cert) {
 | 
				
			||||||
	EVP_PKEY *key = NULL;
 | 
						EVP_PKEY *key;
 | 
				
			||||||
	STACK_OF(PKCS12_SAFEBAG) *bags = NULL;
 | 
						STACK *bags, *safes;
 | 
				
			||||||
	STACK_OF(PKCS7) *safes = NULL;
 | 
						PKCS12_SAFEBAG *bag;
 | 
				
			||||||
	PKCS12_SAFEBAG *bag = NULL;
 | 
						PKCS8_PRIV_KEY_INFO *p8;
 | 
				
			||||||
	PKCS8_PRIV_KEY_INFO *p8 = NULL;
 | 
						PKCS7 *authsafe;
 | 
				
			||||||
	PKCS7 *authsafe = NULL;
 | 
						X509 *cert, *ucert = NULL;
 | 
				
			||||||
	X509 *ucert = NULL;
 | 
						STACK *certs;
 | 
				
			||||||
	STACK_OF(X509) *certs=NULL;
 | 
						char *catmp;
 | 
				
			||||||
	char *catmp = NULL;
 | 
						int i, pmatch = 0;
 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	unsigned char keyid[EVP_MAX_MD_SIZE];
 | 
						unsigned char keyid[EVP_MAX_MD_SIZE];
 | 
				
			||||||
	unsigned int keyidlen = 0;
 | 
						unsigned int keyidlen;
 | 
				
			||||||
 | 
						/* Get private key so we can match it to a certificate */
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						key = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL);
 | 
				
			||||||
	CRYPTO_push_info("process -export_cert");
 | 
						if (!inkey) BIO_reset(in);
 | 
				
			||||||
	CRYPTO_push_info("reading private key");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	key = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL, passin);
 | 
					 | 
				
			||||||
	if (!inkey) (void) BIO_reset(in);
 | 
					 | 
				
			||||||
	else BIO_free(inkey);
 | 
					 | 
				
			||||||
	if (!key) {
 | 
						if (!key) {
 | 
				
			||||||
		BIO_printf (bio_err, "Error loading private key\n");
 | 
							BIO_printf (bio_err, "Error loading private key\n");
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto export_end;
 | 
							goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						certs = sk_new(NULL);
 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("reading certs from input");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	certs = sk_X509_new_null();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Load in all certs in input file */
 | 
						/* Load in all certs in input file */
 | 
				
			||||||
	if(!cert_load(in, certs)) {
 | 
						if(!cert_load(in, certs)) {
 | 
				
			||||||
		BIO_printf(bio_err, "Error loading certificates from input\n");
 | 
							BIO_printf(bio_err, "Error loading certificates from input\n");
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto export_end;
 | 
							goto end;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("reading certs from input 2");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for(i = 0; i < sk_X509_num(certs); i++) {
 | 
					 | 
				
			||||||
		ucert = sk_X509_value(certs, i);
 | 
					 | 
				
			||||||
		if(X509_check_private_key(ucert, key)) {
 | 
					 | 
				
			||||||
			X509_digest(ucert, EVP_sha1(), keyid, &keyidlen);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(!keyidlen) {
 | 
					 | 
				
			||||||
		ucert = NULL;
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "No certificate matches private key\n");
 | 
					 | 
				
			||||||
		goto export_end;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						bags = sk_new (NULL);
 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("reading certs from certfile");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bags = sk_PKCS12_SAFEBAG_new_null ();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Add any more certificates asked for */
 | 
						/* Add any more certificates asked for */
 | 
				
			||||||
	if (certsin) {
 | 
						if (certsin) {
 | 
				
			||||||
		if(!cert_load(certsin, certs)) {
 | 
							if(!cert_load(certsin, certs)) {
 | 
				
			||||||
			BIO_printf(bio_err, "Error loading certificates from certfile\n");
 | 
								BIO_printf(bio_err, "Error loading certificates from certfile\n");
 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
								ERR_print_errors(bio_err);
 | 
				
			||||||
			goto export_end;
 | 
								goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    	BIO_free(certsin);
 | 
						    	BIO_free(certsin);
 | 
				
			||||||
 	}
 | 
					 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						/* Find certificate (if any) matching private key */
 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					
 | 
				
			||||||
	CRYPTO_push_info("building chain");
 | 
						for(i = 0; i < sk_num(certs); i++) {
 | 
				
			||||||
#endif
 | 
								cert = (X509 *)sk_value(certs, i);
 | 
				
			||||||
 | 
								if(X509_check_private_key(cert, key)) {
 | 
				
			||||||
 | 
									ucert = cert;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(!ucert) {
 | 
				
			||||||
 | 
							BIO_printf(bio_err, "No certificate matches private key\n");
 | 
				
			||||||
 | 
							goto end;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* If chaining get chain from user cert */
 | 
						/* If chaining get chain from user cert */
 | 
				
			||||||
	if (chain) {
 | 
						if (chain) {
 | 
				
			||||||
        	int vret;
 | 
					        	int vret;
 | 
				
			||||||
		STACK_OF(X509) *chain2;
 | 
							STACK *chain2;
 | 
				
			||||||
		X509_STORE *store = X509_STORE_new();
 | 
								
 | 
				
			||||||
		if (!store)
 | 
							vret = get_cert_chain (ucert, &chain2);
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf (bio_err, "Memory allocation error\n");
 | 
					 | 
				
			||||||
			goto export_end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (!X509_STORE_load_locations(store, CAfile, CApath))
 | 
					 | 
				
			||||||
			X509_STORE_set_default_paths (store);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		vret = get_cert_chain (ucert, store, &chain2);
 | 
					 | 
				
			||||||
		X509_STORE_free(store);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!vret) {
 | 
					 | 
				
			||||||
		    /* Exclude verified certificate */
 | 
					 | 
				
			||||||
		    for (i = 1; i < sk_X509_num (chain2) ; i++) 
 | 
					 | 
				
			||||||
			sk_X509_push(certs, sk_X509_value (chain2, i));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		sk_X509_free(chain2);
 | 
					 | 
				
			||||||
		if (vret) {
 | 
							if (vret) {
 | 
				
			||||||
			BIO_printf (bio_err, "Error %s getting chain.\n",
 | 
								BIO_printf (bio_err, "Error %s getting chain.\n",
 | 
				
			||||||
					X509_verify_cert_error_string(vret));
 | 
										X509_verify_cert_error_string(vret));
 | 
				
			||||||
			goto export_end;
 | 
								goto end;
 | 
				
			||||||
		}			
 | 
							}
 | 
				
			||||||
 | 
							/* Exclude verified certificate */
 | 
				
			||||||
 | 
							for (i = 1; i < sk_num (chain2) ; i++) 
 | 
				
			||||||
 | 
									 sk_push(certs, sk_value (chain2, i));
 | 
				
			||||||
 | 
							sk_free(chain2);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("building bags");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* We now have loads of certificates: include them all */
 | 
						/* We now have loads of certificates: include them all */
 | 
				
			||||||
	for(i = 0; i < sk_X509_num(certs); i++) {
 | 
						for(i = 0; i < sk_num(certs); i++) {
 | 
				
			||||||
		X509 *cert = NULL;
 | 
							cert = (X509 *)sk_value(certs, i);
 | 
				
			||||||
		cert = sk_X509_value(certs, i);
 | 
					 | 
				
			||||||
		bag = M_PKCS12_x5092certbag(cert);
 | 
							bag = M_PKCS12_x5092certbag(cert);
 | 
				
			||||||
		/* If it matches private key set id */
 | 
							/* If it matches private key mark it */
 | 
				
			||||||
		if(cert == ucert) {
 | 
							if(cert == ucert) {
 | 
				
			||||||
			if(name) PKCS12_add_friendlyname(bag, name, -1);
 | 
								if(name) PKCS12_add_friendlyname(bag, name, -1);
 | 
				
			||||||
 | 
								X509_digest(cert, EVP_sha1(), keyid, &keyidlen);
 | 
				
			||||||
			PKCS12_add_localkeyid(bag, keyid, keyidlen);
 | 
								PKCS12_add_localkeyid(bag, keyid, keyidlen);
 | 
				
			||||||
 | 
								pmatch = 1;
 | 
				
			||||||
		} else if((catmp = sk_shift(canames))) 
 | 
							} else if((catmp = sk_shift(canames))) 
 | 
				
			||||||
				PKCS12_add_friendlyname(bag, catmp, -1);
 | 
									PKCS12_add_friendlyname(bag, catmp, -1);
 | 
				
			||||||
		sk_PKCS12_SAFEBAG_push(bags, bag);
 | 
							sk_push(bags, (char *)bag);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sk_X509_pop_free(certs, X509_free);
 | 
					 | 
				
			||||||
	certs = NULL;
 | 
					 | 
				
			||||||
	/* ucert is part of certs so it is already freed */
 | 
					 | 
				
			||||||
	ucert = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						if (canames) sk_free(canames);
 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("encrypting bags");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!noprompt &&
 | 
						if(!noprompt &&
 | 
				
			||||||
		EVP_read_pw_string(pass, 50, "Enter Export Password:", 1)) {
 | 
							EVP_read_pw_string(pass, 50, "Enter Export Password:", 1)) {
 | 
				
			||||||
	    BIO_printf (bio_err, "Can't read Password\n");
 | 
						    BIO_printf (bio_err, "Can't read Password\n");
 | 
				
			||||||
	    goto export_end;
 | 
						    goto end;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
	if (!twopass) strcpy(macpass, pass);
 | 
						if (!twopass) strcpy(macpass, pass);
 | 
				
			||||||
	/* Turn certbags into encrypted authsafe */
 | 
						/* Turn certbags into encrypted authsafe */
 | 
				
			||||||
	authsafe = PKCS12_pack_p7encdata(cert_pbe, cpass, -1, NULL, 0,
 | 
						authsafe = PKCS12_pack_p7encdata (cert_pbe, cpass, -1, NULL, 0,
 | 
				
			||||||
								 iter, bags);
 | 
													 iter, bags);
 | 
				
			||||||
	sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
						sk_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
				
			||||||
	bags = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!authsafe) {
 | 
						if (!authsafe) {
 | 
				
			||||||
		ERR_print_errors (bio_err);
 | 
							ERR_print_errors (bio_err);
 | 
				
			||||||
		goto export_end;
 | 
							goto end;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	safes = sk_PKCS7_new_null ();
 | 
						safes = sk_new (NULL);
 | 
				
			||||||
	sk_PKCS7_push (safes, authsafe);
 | 
						sk_push (safes, (char *)authsafe);
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("building shrouded key bag");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Make a shrouded key bag */
 | 
						/* Make a shrouded key bag */
 | 
				
			||||||
	p8 = EVP_PKEY2PKCS8 (key);
 | 
						p8 = EVP_PKEY2PKCS8 (key);
 | 
				
			||||||
 | 
						EVP_PKEY_free(key);
 | 
				
			||||||
	if(keytype) PKCS8_add_keyusage(p8, keytype);
 | 
						if(keytype) PKCS8_add_keyusage(p8, keytype);
 | 
				
			||||||
	bag = PKCS12_MAKE_SHKEYBAG(key_pbe, cpass, -1, NULL, 0, iter, p8);
 | 
						bag = PKCS12_MAKE_SHKEYBAG (NID_pbe_WithSHA1And3_Key_TripleDES_CBC,
 | 
				
			||||||
 | 
								cpass, -1, NULL, 0, iter, p8);
 | 
				
			||||||
	PKCS8_PRIV_KEY_INFO_free(p8);
 | 
						PKCS8_PRIV_KEY_INFO_free(p8);
 | 
				
			||||||
	p8 = NULL;
 | 
					 | 
				
			||||||
        if (name) PKCS12_add_friendlyname (bag, name, -1);
 | 
					        if (name) PKCS12_add_friendlyname (bag, name, -1);
 | 
				
			||||||
	PKCS12_add_localkeyid (bag, keyid, keyidlen);
 | 
						if(pmatch) PKCS12_add_localkeyid (bag, keyid, keyidlen);
 | 
				
			||||||
	bags = sk_PKCS12_SAFEBAG_new_null();
 | 
						bags = sk_new(NULL);
 | 
				
			||||||
	sk_PKCS12_SAFEBAG_push (bags, bag);
 | 
						sk_push (bags, (char *)bag);
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("encrypting shrouded key bag");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Turn it into unencrypted safe bag */
 | 
						/* Turn it into unencrypted safe bag */
 | 
				
			||||||
	authsafe = PKCS12_pack_p7data (bags);
 | 
						authsafe = PKCS12_pack_p7data (bags);
 | 
				
			||||||
	sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
						sk_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
				
			||||||
	bags = NULL;
 | 
						sk_push (safes, (char *)authsafe);
 | 
				
			||||||
	sk_PKCS7_push (safes, authsafe);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("building pkcs12");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p12 = PKCS12_init (NID_pkcs7_data);
 | 
						p12 = PKCS12_init (NID_pkcs7_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	M_PKCS12_pack_authsafes (p12, safes);
 | 
						M_PKCS12_pack_authsafes (p12, safes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sk_PKCS7_pop_free(safes, PKCS7_free);
 | 
						sk_pop_free(safes, PKCS7_free);
 | 
				
			||||||
	safes = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PKCS12_set_mac (p12, mpass, -1, NULL, 0, maciter, NULL);
 | 
						PKCS12_set_mac (p12, mpass, -1, NULL, 0, maciter, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("writing pkcs12");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	i2d_PKCS12_bio (out, p12);
 | 
						i2d_PKCS12_bio (out, p12);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PKCS12_free(p12);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = 0;
 | 
						ret = 0;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    export_end:
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
	CRYPTO_push_info("process -export_cert: freeing");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (key) EVP_PKEY_free(key);
 | 
					 | 
				
			||||||
	if (certs) sk_X509_pop_free(certs, X509_free);
 | 
					 | 
				
			||||||
	if (safes) sk_PKCS7_pop_free(safes, PKCS7_free);
 | 
					 | 
				
			||||||
	if (bags) sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
 | 
					 | 
				
			||||||
	if (ucert) X509_free(ucert);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	goto end;
 | 
						goto end;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -635,76 +428,56 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	goto end;
 | 
						goto end;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
    CRYPTO_push_info("read import password");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    if(!noprompt && EVP_read_pw_string(pass, 50, "Enter Import Password:", 0)) {
 | 
					    if(!noprompt && EVP_read_pw_string(pass, 50, "Enter Import Password:", 0)) {
 | 
				
			||||||
	BIO_printf (bio_err, "Can't read Password\n");
 | 
						BIO_printf (bio_err, "Can't read Password\n");
 | 
				
			||||||
	goto end;
 | 
						goto end;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
    CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!twopass) strcpy(macpass, pass);
 | 
					    if (!twopass) strcpy(macpass, pass);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
 | 
					    if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);
 | 
				
			||||||
    if(macver) {
 | 
					    if(macver) {
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						if (!PKCS12_verify_mac (p12, mpass, -1)) {
 | 
				
			||||||
    CRYPTO_push_info("verify MAC");
 | 
						    BIO_printf (bio_err, "Mac verify errror: invalid password?\n");
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	/* If we enter empty password try no password first */
 | 
					 | 
				
			||||||
	if(!macpass[0] && PKCS12_verify_mac(p12, NULL, 0)) {
 | 
					 | 
				
			||||||
		/* If mac and crypto pass the same set it to NULL too */
 | 
					 | 
				
			||||||
		if(!twopass) cpass = NULL;
 | 
					 | 
				
			||||||
	} else if (!PKCS12_verify_mac(p12, mpass, -1)) {
 | 
					 | 
				
			||||||
	    BIO_printf (bio_err, "Mac verify error: invalid password?\n");
 | 
					 | 
				
			||||||
	    ERR_print_errors (bio_err);
 | 
						    ERR_print_errors (bio_err);
 | 
				
			||||||
	    goto end;
 | 
						    goto end;
 | 
				
			||||||
	}
 | 
						} else BIO_printf (bio_err, "MAC verified OK\n");
 | 
				
			||||||
	BIO_printf (bio_err, "MAC verified OK\n");
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
    CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					    if (!dump_certs_keys_p12 (out, p12, cpass, -1, options)) {
 | 
				
			||||||
    CRYPTO_push_info("output keys and certificates");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    if (!dump_certs_keys_p12 (out, p12, cpass, -1, options, passout)) {
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "Error outputting keys and certificates\n");
 | 
						BIO_printf(bio_err, "Error outputting keys and certificates\n");
 | 
				
			||||||
	ERR_print_errors (bio_err);
 | 
						ERR_print_errors (bio_err);
 | 
				
			||||||
	goto end;
 | 
						goto end;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					    PKCS12_free(p12);
 | 
				
			||||||
    CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    ret = 0;
 | 
					    ret = 0;
 | 
				
			||||||
 end:
 | 
					    end:
 | 
				
			||||||
    if (p12) PKCS12_free(p12);
 | 
					 | 
				
			||||||
    if(export_cert || inrand) app_RAND_write_file(NULL, bio_err);
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
    CRYPTO_remove_all_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    BIO_free(in);
 | 
					 | 
				
			||||||
    BIO_free_all(out);
 | 
					 | 
				
			||||||
    if (canames) sk_free(canames);
 | 
					 | 
				
			||||||
    if(passin) OPENSSL_free(passin);
 | 
					 | 
				
			||||||
    if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
    EXIT(ret);
 | 
					    EXIT(ret);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
 | 
					int dump_cert_text (BIO *out, X509 *x)
 | 
				
			||||||
	     int passlen, int options, char *pempass)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	STACK_OF(PKCS7) *asafes;
 | 
						char buf[256];
 | 
				
			||||||
	STACK_OF(PKCS12_SAFEBAG) *bags;
 | 
						X509_NAME_oneline(X509_get_subject_name(x),buf,256);
 | 
				
			||||||
 | 
						BIO_puts(out,"subject=");
 | 
				
			||||||
 | 
						BIO_puts(out,buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
 | 
				
			||||||
 | 
						BIO_puts(out,"\nissuer= ");
 | 
				
			||||||
 | 
						BIO_puts(out,buf);
 | 
				
			||||||
 | 
						BIO_puts(out,"\n");
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
 | 
				
			||||||
 | 
						     int passlen, int options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						STACK *asafes, *bags;
 | 
				
			||||||
	int i, bagnid;
 | 
						int i, bagnid;
 | 
				
			||||||
	PKCS7 *p7;
 | 
						PKCS7 *p7;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0;
 | 
						if (!( asafes = M_PKCS12_unpack_authsafes (p12))) return 0;
 | 
				
			||||||
	for (i = 0; i < sk_PKCS7_num (asafes); i++) {
 | 
						for (i = 0; i < sk_num (asafes); i++) {
 | 
				
			||||||
		p7 = sk_PKCS7_value (asafes, i);
 | 
							p7 = (PKCS7 *) sk_value (asafes, i);
 | 
				
			||||||
		bagnid = OBJ_obj2nid (p7->type);
 | 
							bagnid = OBJ_obj2nid (p7->type);
 | 
				
			||||||
		if (bagnid == NID_pkcs7_data) {
 | 
							if (bagnid == NID_pkcs7_data) {
 | 
				
			||||||
			bags = M_PKCS12_unpack_p7data (p7);
 | 
								bags = M_PKCS12_unpack_p7data (p7);
 | 
				
			||||||
@@ -719,32 +492,30 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass,
 | 
				
			|||||||
		} else continue;
 | 
							} else continue;
 | 
				
			||||||
		if (!bags) return 0;
 | 
							if (!bags) return 0;
 | 
				
			||||||
	    	if (!dump_certs_pkeys_bags (out, bags, pass, passlen, 
 | 
						    	if (!dump_certs_pkeys_bags (out, bags, pass, passlen, 
 | 
				
			||||||
						 options, pempass)) {
 | 
												 options)) {
 | 
				
			||||||
			sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free);
 | 
								sk_pop_free (bags, PKCS12_SAFEBAG_free);
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free);
 | 
							sk_pop_free (bags, PKCS12_SAFEBAG_free);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sk_PKCS7_pop_free (asafes, PKCS7_free);
 | 
						sk_pop_free (asafes, PKCS7_free);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dump_certs_pkeys_bags (BIO *out, STACK_OF(PKCS12_SAFEBAG) *bags,
 | 
					int dump_certs_pkeys_bags (BIO *out, STACK *bags, char *pass,
 | 
				
			||||||
			   char *pass, int passlen, int options, char *pempass)
 | 
						     int passlen, int options)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	for (i = 0; i < sk_PKCS12_SAFEBAG_num (bags); i++) {
 | 
						for (i = 0; i < sk_num (bags); i++) {
 | 
				
			||||||
		if (!dump_certs_pkeys_bag (out,
 | 
							if (!dump_certs_pkeys_bag (out,
 | 
				
			||||||
					   sk_PKCS12_SAFEBAG_value (bags, i),
 | 
								 (PKCS12_SAFEBAG *)sk_value (bags, i), pass, passlen,
 | 
				
			||||||
					   pass, passlen,
 | 
										 		options)) return 0;
 | 
				
			||||||
					   options, pempass))
 | 
					 | 
				
			||||||
		    return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
					int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
				
			||||||
	     int passlen, int options, char *pempass)
 | 
						     int passlen, int options)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	EVP_PKEY *pkey;
 | 
						EVP_PKEY *pkey;
 | 
				
			||||||
	PKCS8_PRIV_KEY_INFO *p8;
 | 
						PKCS8_PRIV_KEY_INFO *p8;
 | 
				
			||||||
@@ -759,7 +530,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
				
			|||||||
		p8 = bag->value.keybag;
 | 
							p8 = bag->value.keybag;
 | 
				
			||||||
		if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
 | 
							if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
 | 
				
			||||||
		print_attribs (out, p8->attributes, "Key Attributes");
 | 
							print_attribs (out, p8->attributes, "Key Attributes");
 | 
				
			||||||
		PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass);
 | 
							PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL);
 | 
				
			||||||
		EVP_PKEY_free(pkey);
 | 
							EVP_PKEY_free(pkey);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -775,7 +546,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
				
			|||||||
		if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
 | 
							if (!(pkey = EVP_PKCS82PKEY (p8))) return 0;
 | 
				
			||||||
		print_attribs (out, p8->attributes, "Key Attributes");
 | 
							print_attribs (out, p8->attributes, "Key Attributes");
 | 
				
			||||||
		PKCS8_PRIV_KEY_INFO_free(p8);
 | 
							PKCS8_PRIV_KEY_INFO_free(p8);
 | 
				
			||||||
		PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL, pempass);
 | 
							PEM_write_bio_PrivateKey (out, pkey, enc, NULL, 0, NULL);
 | 
				
			||||||
		EVP_PKEY_free(pkey);
 | 
							EVP_PKEY_free(pkey);
 | 
				
			||||||
	break;
 | 
						break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -798,7 +569,7 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
				
			|||||||
		if (options & INFO) BIO_printf (bio_err, "Safe Contents bag\n");
 | 
							if (options & INFO) BIO_printf (bio_err, "Safe Contents bag\n");
 | 
				
			||||||
		print_attribs (out, bag->attrib, "Bag Attributes");
 | 
							print_attribs (out, bag->attrib, "Bag Attributes");
 | 
				
			||||||
		return dump_certs_pkeys_bags (out, bag->value.safes, pass,
 | 
							return dump_certs_pkeys_bags (out, bag->value.safes, pass,
 | 
				
			||||||
							    passlen, options, pempass);
 | 
												    passlen, options);
 | 
				
			||||||
					
 | 
										
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		BIO_printf (bio_err, "Warning unsupported bag type: ");
 | 
							BIO_printf (bio_err, "Warning unsupported bag type: ");
 | 
				
			||||||
@@ -814,22 +585,30 @@ int dump_certs_pkeys_bag (BIO *out, PKCS12_SAFEBAG *bag, char *pass,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Hope this is OK .... */
 | 
					/* Hope this is OK .... */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int get_cert_chain (X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
 | 
					int get_cert_chain (X509 *cert, STACK **chain)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						X509_STORE *store;
 | 
				
			||||||
	X509_STORE_CTX store_ctx;
 | 
						X509_STORE_CTX store_ctx;
 | 
				
			||||||
	STACK_OF(X509) *chn;
 | 
						STACK *chn;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
						X509 *x;
 | 
				
			||||||
 | 
						store = X509_STORE_new ();
 | 
				
			||||||
 | 
						X509_STORE_set_default_paths (store);
 | 
				
			||||||
	X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
 | 
						X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
 | 
				
			||||||
	if (X509_verify_cert(&store_ctx) <= 0) {
 | 
						if (X509_verify_cert(&store_ctx) <= 0) {
 | 
				
			||||||
		i = X509_STORE_CTX_get_error (&store_ctx);
 | 
							i = X509_STORE_CTX_get_error (&store_ctx);
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	chn =  X509_STORE_CTX_get1_chain(&store_ctx);
 | 
						chn =  sk_dup(X509_STORE_CTX_get_chain (&store_ctx));
 | 
				
			||||||
 | 
						for (i = 0; i < sk_num(chn); i++) {
 | 
				
			||||||
 | 
							x = (X509 *)sk_value(chn, i);
 | 
				
			||||||
 | 
							CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	i = 0;
 | 
						i = 0;
 | 
				
			||||||
	*chain = chn;
 | 
						*chain = chn;
 | 
				
			||||||
err:
 | 
					err:
 | 
				
			||||||
	X509_STORE_CTX_cleanup(&store_ctx);
 | 
						X509_STORE_CTX_cleanup(&store_ctx);
 | 
				
			||||||
 | 
						X509_STORE_free(store);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
}	
 | 
					}	
 | 
				
			||||||
@@ -848,34 +627,22 @@ int alg_print (BIO *x, X509_ALGOR *alg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Load all certificates from a given file */
 | 
					/* Load all certificates from a given file */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cert_load(BIO *in, STACK_OF(X509) *sk)
 | 
					int cert_load(BIO *in, STACK *sk)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
	X509 *cert;
 | 
						X509 *cert;
 | 
				
			||||||
	ret = 0;
 | 
						ret = 0;
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
						while((cert = PEM_read_bio_X509(in, NULL, NULL))) {
 | 
				
			||||||
	CRYPTO_push_info("cert_load(): reading one cert");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	while((cert = PEM_read_bio_X509(in, NULL, NULL, NULL))) {
 | 
					 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
		CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		ret = 1;
 | 
							ret = 1;
 | 
				
			||||||
		sk_X509_push(sk, cert);
 | 
							sk_push(sk, (char *)cert);
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
		CRYPTO_push_info("cert_load(): reading one cert");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#ifdef CRYPTO_MDEBUG
 | 
					 | 
				
			||||||
	CRYPTO_pop_info();
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	if(ret) ERR_clear_error();
 | 
						if(ret) ERR_clear_error();
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Generalised attribute print: handle PKCS#8 and bag attributes */
 | 
					/* Generalised attribute print: handle PKCS#8 and bag attributes */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int print_attribs (BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name)
 | 
					int print_attribs (BIO *out, STACK *attrlst, char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	X509_ATTRIBUTE *attr;
 | 
						X509_ATTRIBUTE *attr;
 | 
				
			||||||
	ASN1_TYPE *av;
 | 
						ASN1_TYPE *av;
 | 
				
			||||||
@@ -885,13 +652,13 @@ int print_attribs (BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name)
 | 
				
			|||||||
		BIO_printf(out, "%s: <No Attributes>\n", name);
 | 
							BIO_printf(out, "%s: <No Attributes>\n", name);
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if(!sk_X509_ATTRIBUTE_num(attrlst)) {
 | 
						if(!sk_num(attrlst)) {
 | 
				
			||||||
		BIO_printf(out, "%s: <Empty Attributes>\n", name);
 | 
							BIO_printf(out, "%s: <Empty Attributes>\n", name);
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	BIO_printf(out, "%s\n", name);
 | 
						BIO_printf(out, "%s\n", name);
 | 
				
			||||||
	for(i = 0; i < sk_X509_ATTRIBUTE_num(attrlst); i++) {
 | 
						for(i = 0; i < sk_num(attrlst); i++) {
 | 
				
			||||||
		attr = sk_X509_ATTRIBUTE_value(attrlst, i);
 | 
							attr = (X509_ATTRIBUTE *) sk_value(attrlst, i);
 | 
				
			||||||
		attr_nid = OBJ_obj2nid(attr->object);
 | 
							attr_nid = OBJ_obj2nid(attr->object);
 | 
				
			||||||
		BIO_printf(out, "    ");
 | 
							BIO_printf(out, "    ");
 | 
				
			||||||
		if(attr_nid == NID_undef) {
 | 
							if(attr_nid == NID_undef) {
 | 
				
			||||||
@@ -906,18 +673,18 @@ int print_attribs (BIO *out, STACK_OF(X509_ATTRIBUTE) *attrlst, char *name)
 | 
				
			|||||||
        			value = uni2asc(av->value.bmpstring->data,
 | 
					        			value = uni2asc(av->value.bmpstring->data,
 | 
				
			||||||
                                	       av->value.bmpstring->length);
 | 
					                                	       av->value.bmpstring->length);
 | 
				
			||||||
				BIO_printf(out, "%s\n", value);
 | 
									BIO_printf(out, "%s\n", value);
 | 
				
			||||||
				OPENSSL_free(value);
 | 
									Free(value);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				case V_ASN1_OCTET_STRING:
 | 
									case V_ASN1_OCTET_STRING:
 | 
				
			||||||
				hex_prin(out, av->value.octet_string->data,
 | 
									hex_prin(out, av->value.bit_string->data,
 | 
				
			||||||
					av->value.octet_string->length);
 | 
										av->value.bit_string->length);
 | 
				
			||||||
				BIO_printf(out, "\n");	
 | 
									BIO_printf(out, "\n");	
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				case V_ASN1_BIT_STRING:
 | 
									case V_ASN1_BIT_STRING:
 | 
				
			||||||
				hex_prin(out, av->value.bit_string->data,
 | 
									hex_prin(out, av->value.octet_string->data,
 | 
				
			||||||
					av->value.bit_string->length);
 | 
										av->value.octet_string->length);
 | 
				
			||||||
				BIO_printf(out, "\n");	
 | 
									BIO_printf(out, "\n");	
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -935,5 +702,3 @@ void hex_prin(BIO *out, unsigned char *buf, int len)
 | 
				
			|||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	for (i = 0; i < len; i++) BIO_printf (out, "%02X ", buf[i]);
 | 
						for (i = 0; i < len; i++) BIO_printf (out, "%02X ", buf[i]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										141
									
								
								apps/pkcs7.c
									
									
									
									
									
								
							
							
						
						
									
										141
									
								
								apps/pkcs7.c
									
									
									
									
									
								
							@@ -67,31 +67,32 @@
 | 
				
			|||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pkcs7.h>
 | 
					#include <openssl/pkcs7.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	pkcs7_main
 | 
					#define PROG	pkcs7_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -inform arg	- input format - default PEM (DER or PEM)
 | 
					/* -inform arg	- input format - default PEM (one of DER, TXT or PEM)
 | 
				
			||||||
 * -outform arg - output format - default PEM
 | 
					 * -outform arg - output format - default PEM
 | 
				
			||||||
 * -in arg	- input file - default stdin
 | 
					 * -in arg	- input file - default stdin
 | 
				
			||||||
 * -out arg	- output file - default stdout
 | 
					 * -out arg	- output file - default stdout
 | 
				
			||||||
 | 
					 * -des		- encrypt output if PEM format with DES in cbc mode
 | 
				
			||||||
 | 
					 * -des3	- encrypt output if PEM format
 | 
				
			||||||
 | 
					 * -idea	- encrypt output if PEM format
 | 
				
			||||||
 * -print_certs
 | 
					 * -print_certs
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	PKCS7 *p7=NULL;
 | 
						PKCS7 *p7=NULL;
 | 
				
			||||||
	int i,badops=0;
 | 
						int i,badops=0;
 | 
				
			||||||
 | 
					#if !defined(NO_DES) || !defined(NO_IDEA)
 | 
				
			||||||
 | 
						EVP_CIPHER *enc=NULL;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
	BIO *in=NULL,*out=NULL;
 | 
						BIO *in=NULL,*out=NULL;
 | 
				
			||||||
	int informat,outformat;
 | 
						int informat,outformat;
 | 
				
			||||||
	char *infile,*outfile,*prog;
 | 
						char *infile,*outfile,*prog,buf[256];
 | 
				
			||||||
	int print_certs=0,text=0,noout=0;
 | 
						int print_certs=0;
 | 
				
			||||||
	int ret=0;
 | 
						int ret=0;
 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -129,17 +130,18 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
					 | 
				
			||||||
			noout=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
					 | 
				
			||||||
			text=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-print_certs") == 0)
 | 
							else if (strcmp(*argv,"-print_certs") == 0)
 | 
				
			||||||
			print_certs=1;
 | 
								print_certs=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					#ifndef NO_DES
 | 
				
			||||||
			{
 | 
							else if (strcmp(*argv,"-des") == 0)
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								enc=EVP_des_cbc();
 | 
				
			||||||
			engine= *(++argv);
 | 
							else if (strcmp(*argv,"-des3") == 0)
 | 
				
			||||||
			}
 | 
								enc=EVP_des_ede3_cbc();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
 | 
							else if (strcmp(*argv,"-idea") == 0)
 | 
				
			||||||
 | 
								enc=EVP_idea_cbc();
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -155,37 +157,21 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg   input format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg  output format - DER or PEM\n");
 | 
							BIO_printf(bio_err," -outform arg  output format - one of DER TXT PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg       input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg      output file\n");
 | 
							BIO_printf(bio_err," -out arg      output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -print_certs  print any certs or crl in the input\n");
 | 
							BIO_printf(bio_err," -print_certs  print any certs or crl in the input\n");
 | 
				
			||||||
		BIO_printf(bio_err," -text         print full details of certificates\n");
 | 
							BIO_printf(bio_err," -des          encrypt PEM output with cbc des\n");
 | 
				
			||||||
		BIO_printf(bio_err," -noout        don't output encoded data\n");
 | 
							BIO_printf(bio_err," -des3         encrypt PEM output with ede cbc des using 168 bit key\n");
 | 
				
			||||||
		BIO_printf(bio_err," -engine e     use engine e, possibly a hardware device.\n");
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
 | 
							BIO_printf(bio_err," -idea         encrypt PEM output with cbc idea\n");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		EXIT(1);
 | 
							EXIT(1);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if ((in == NULL) || (out == NULL))
 | 
						if ((in == NULL) || (out == NULL))
 | 
				
			||||||
@@ -209,7 +195,7 @@ bad:
 | 
				
			|||||||
	if	(informat == FORMAT_ASN1)
 | 
						if	(informat == FORMAT_ASN1)
 | 
				
			||||||
		p7=d2i_PKCS7_bio(in,NULL);
 | 
							p7=d2i_PKCS7_bio(in,NULL);
 | 
				
			||||||
	else if (informat == FORMAT_PEM)
 | 
						else if (informat == FORMAT_PEM)
 | 
				
			||||||
		p7=PEM_read_bio_PKCS7(in,NULL,NULL,NULL);
 | 
							p7=PEM_read_bio_PKCS7(in,NULL,NULL);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified for pkcs7 object\n");
 | 
							BIO_printf(bio_err,"bad input format specified for pkcs7 object\n");
 | 
				
			||||||
@@ -223,15 +209,7 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -244,7 +222,7 @@ bad:
 | 
				
			|||||||
	if (print_certs)
 | 
						if (print_certs)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		STACK_OF(X509) *certs=NULL;
 | 
							STACK_OF(X509) *certs=NULL;
 | 
				
			||||||
		STACK_OF(X509_CRL) *crls=NULL;
 | 
							STACK *crls=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		i=OBJ_obj2nid(p7->type);
 | 
							i=OBJ_obj2nid(p7->type);
 | 
				
			||||||
		switch (i)
 | 
							switch (i)
 | 
				
			||||||
@@ -268,10 +246,19 @@ bad:
 | 
				
			|||||||
			for (i=0; i<sk_X509_num(certs); i++)
 | 
								for (i=0; i<sk_X509_num(certs); i++)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				x=sk_X509_value(certs,i);
 | 
									x=sk_X509_value(certs,i);
 | 
				
			||||||
				if(text) X509_print(out, x);
 | 
					 | 
				
			||||||
				else dump_cert_text(out, x);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(!noout) PEM_write_bio_X509(out,x);
 | 
									X509_NAME_oneline(X509_get_subject_name(x),
 | 
				
			||||||
 | 
										buf,256);
 | 
				
			||||||
 | 
									BIO_puts(out,"subject=");
 | 
				
			||||||
 | 
									BIO_puts(out,buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									X509_NAME_oneline(X509_get_issuer_name(x),
 | 
				
			||||||
 | 
										buf,256);
 | 
				
			||||||
 | 
									BIO_puts(out,"\nissuer= ");
 | 
				
			||||||
 | 
									BIO_puts(out,buf);
 | 
				
			||||||
 | 
									BIO_puts(out,"\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									PEM_write_bio_X509(out,x);
 | 
				
			||||||
				BIO_puts(out,"\n");
 | 
									BIO_puts(out,"\n");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -279,13 +266,21 @@ bad:
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
			X509_CRL *crl;
 | 
								X509_CRL *crl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for (i=0; i<sk_X509_CRL_num(crls); i++)
 | 
								for (i=0; i<sk_num(crls); i++)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				crl=sk_X509_CRL_value(crls,i);
 | 
									crl=(X509_CRL *)sk_value(crls,i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				X509_CRL_print(out, crl);
 | 
									X509_NAME_oneline(crl->crl->issuer,buf,256);
 | 
				
			||||||
 | 
									BIO_puts(out,"issuer= ");
 | 
				
			||||||
 | 
									BIO_puts(out,buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(!noout)PEM_write_bio_X509_CRL(out,crl);
 | 
									BIO_puts(out,"\nlast update=");
 | 
				
			||||||
 | 
									ASN1_TIME_print(out,crl->crl->lastUpdate);
 | 
				
			||||||
 | 
									BIO_puts(out,"\nnext update=");
 | 
				
			||||||
 | 
									ASN1_TIME_print(out,crl->crl->nextUpdate);
 | 
				
			||||||
 | 
									BIO_puts(out,"\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									PEM_write_bio_X509_CRL(out,crl);
 | 
				
			||||||
				BIO_puts(out,"\n");
 | 
									BIO_puts(out,"\n");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -294,27 +289,25 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!noout) {
 | 
						if 	(outformat == FORMAT_ASN1)
 | 
				
			||||||
		if 	(outformat == FORMAT_ASN1)
 | 
							i=i2d_PKCS7_bio(out,p7);
 | 
				
			||||||
			i=i2d_PKCS7_bio(out,p7);
 | 
						else if (outformat == FORMAT_PEM)
 | 
				
			||||||
		else if (outformat == FORMAT_PEM)
 | 
							i=PEM_write_bio_PKCS7(out,p7);
 | 
				
			||||||
			i=PEM_write_bio_PKCS7(out,p7);
 | 
						else	{
 | 
				
			||||||
		else	{
 | 
							BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
				
			||||||
			BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
							goto end;
 | 
				
			||||||
			goto end;
 | 
							}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!i)
 | 
						if (!i)
 | 
				
			||||||
			{
 | 
							{
 | 
				
			||||||
			BIO_printf(bio_err,"unable to write pkcs7 object\n");
 | 
							BIO_printf(bio_err,"unable to write pkcs7 object\n");
 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
			goto end;
 | 
							goto end;
 | 
				
			||||||
			}
 | 
							}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if (p7 != NULL) PKCS7_free(p7);
 | 
						if (p7 != NULL) PKCS7_free(p7);
 | 
				
			||||||
	if (in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if (out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										382
									
								
								apps/pkcs8.c
									
									
									
									
									
								
							
							
						
						
									
										382
									
								
								apps/pkcs8.c
									
									
									
									
									
								
							@@ -1,382 +0,0 @@
 | 
				
			|||||||
/* pkcs8.c */
 | 
					 | 
				
			||||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
					 | 
				
			||||||
 * project 1999.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* ====================================================================
 | 
					 | 
				
			||||||
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 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 above 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 acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
					 | 
				
			||||||
 *    endorse or promote products derived from this software without
 | 
					 | 
				
			||||||
 *    prior written permission. For written permission, please contact
 | 
					 | 
				
			||||||
 *    licensing@OpenSSL.org.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
					 | 
				
			||||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
					 | 
				
			||||||
 *    permission of the OpenSSL Project.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
					 | 
				
			||||||
 *    acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
					 | 
				
			||||||
 * EXPRESSED 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 OpenSSL PROJECT OR
 | 
					 | 
				
			||||||
 * ITS 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.
 | 
					 | 
				
			||||||
 * ====================================================================
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This product includes cryptographic software written by Eric Young
 | 
					 | 
				
			||||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
					 | 
				
			||||||
 * Hudson (tjh@cryptsoft.com).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
#include <openssl/pem.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/evp.h>
 | 
					 | 
				
			||||||
#include <openssl/pkcs12.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
#define PROG pkcs8_main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	char **args, *infile = NULL, *outfile = NULL;
 | 
					 | 
				
			||||||
	char *passargin = NULL, *passargout = NULL;
 | 
					 | 
				
			||||||
	BIO *in = NULL, *out = NULL;
 | 
					 | 
				
			||||||
	int topk8 = 0;
 | 
					 | 
				
			||||||
	int pbe_nid = -1;
 | 
					 | 
				
			||||||
	const EVP_CIPHER *cipher = NULL;
 | 
					 | 
				
			||||||
	int iter = PKCS12_DEFAULT_ITER;
 | 
					 | 
				
			||||||
	int informat, outformat;
 | 
					 | 
				
			||||||
	int p8_broken = PKCS8_OK;
 | 
					 | 
				
			||||||
	int nocrypt = 0;
 | 
					 | 
				
			||||||
	X509_SIG *p8;
 | 
					 | 
				
			||||||
	PKCS8_PRIV_KEY_INFO *p8inf;
 | 
					 | 
				
			||||||
	EVP_PKEY *pkey;
 | 
					 | 
				
			||||||
	char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
 | 
					 | 
				
			||||||
	int badarg = 0;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	informat=FORMAT_PEM;
 | 
					 | 
				
			||||||
	outformat=FORMAT_PEM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
					 | 
				
			||||||
	OpenSSL_add_all_algorithms();
 | 
					 | 
				
			||||||
	args = argv + 1;
 | 
					 | 
				
			||||||
	while (!badarg && *args && *args[0] == '-') {
 | 
					 | 
				
			||||||
		if (!strcmp(*args,"-v2")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				cipher=EVP_get_cipherbyname(*args);
 | 
					 | 
				
			||||||
				if(!cipher) {
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,
 | 
					 | 
				
			||||||
						 "Unknown cipher %s\n", *args);
 | 
					 | 
				
			||||||
					badarg = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp(*args,"-v1")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				pbe_nid=OBJ_txt2nid(*args);
 | 
					 | 
				
			||||||
				if(pbe_nid == NID_undef) {
 | 
					 | 
				
			||||||
					BIO_printf(bio_err,
 | 
					 | 
				
			||||||
						 "Unknown PBE algorithm %s\n", *args);
 | 
					 | 
				
			||||||
					badarg = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp(*args,"-inform")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				informat=str2fmt(*args);
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp(*args,"-outform")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				outformat=str2fmt(*args);
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp (*args, "-topk8")) topk8 = 1;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-noiter")) iter = 1;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-nocrypt")) nocrypt = 1;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-nooct")) p8_broken = PKCS8_NO_OCTET;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-nsdb")) p8_broken = PKCS8_NS_DB;
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-embed")) p8_broken = PKCS8_EMBEDDED_PARAM;
 | 
					 | 
				
			||||||
		else if (!strcmp(*args,"-passin"))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!args[1]) goto bad;
 | 
					 | 
				
			||||||
			passargin= *(++args);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (!strcmp(*args,"-passout"))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!args[1]) goto bad;
 | 
					 | 
				
			||||||
			passargout= *(++args);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*args,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!args[1]) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++args);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (!strcmp (*args, "-in")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				infile = *args;
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else if (!strcmp (*args, "-out")) {
 | 
					 | 
				
			||||||
			if (args[1]) {
 | 
					 | 
				
			||||||
				args++;
 | 
					 | 
				
			||||||
				outfile = *args;
 | 
					 | 
				
			||||||
			} else badarg = 1;
 | 
					 | 
				
			||||||
		} else badarg = 1;
 | 
					 | 
				
			||||||
		args++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (badarg) {
 | 
					 | 
				
			||||||
		bad:
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Usage pkcs8 [options]\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "where options are\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-in file        input file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-inform X       input format (DER or PEM)\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-passin arg     input file pass phrase source\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-outform X      output format (DER or PEM)\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-out file       output file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-passout arg    output file pass phrase source\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-topk8          output PKCS8 file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-nooct          use (nonstandard) no octet format\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-embed          use (nonstandard) embedded DSA parameters format\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-nsdb           use (nonstandard) DSA Netscape DB format\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-noiter         use 1 as iteration count\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-nocrypt        use or expect unencrypted private key\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-v2 alg         use PKCS#5 v2.0 and cipher \"alg\"\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-v1 obj         use PKCS#5 v1.5 and cipher \"alg\"\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -engine e       use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		return (1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting passwords\n");
 | 
					 | 
				
			||||||
		return (1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((pbe_nid == -1) && !cipher) pbe_nid = NID_pbeWithMD5AndDES_CBC;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (infile) {
 | 
					 | 
				
			||||||
		if (!(in = BIO_new_file(infile, "rb"))) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,
 | 
					 | 
				
			||||||
				 "Can't open input file %s\n", infile);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else in = BIO_new_fp (stdin, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (outfile) {
 | 
					 | 
				
			||||||
		if (!(out = BIO_new_file (outfile, "wb"))) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,
 | 
					 | 
				
			||||||
				 "Can't open output file %s\n", outfile);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		out = BIO_new_fp (stdout, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
			out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (topk8) {
 | 
					 | 
				
			||||||
		if(informat == FORMAT_PEM)
 | 
					 | 
				
			||||||
			pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, passin);
 | 
					 | 
				
			||||||
		else if(informat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
			pkey = d2i_PrivateKey_bio(in, NULL);
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (!pkey) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error reading key\n", outfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		BIO_free(in);
 | 
					 | 
				
			||||||
		if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error converting key\n", outfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if(nocrypt) {
 | 
					 | 
				
			||||||
			if(outformat == FORMAT_PEM) 
 | 
					 | 
				
			||||||
				PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf);
 | 
					 | 
				
			||||||
			else if(outformat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
				i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8inf);
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
				return (1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			if(passout) p8pass = passout;
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				p8pass = pass;
 | 
					 | 
				
			||||||
				EVP_read_pw_string(pass, 50, "Enter Encryption Password:", 1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			app_RAND_load_file(NULL, bio_err, 0);
 | 
					 | 
				
			||||||
			if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
 | 
					 | 
				
			||||||
					p8pass, strlen(p8pass),
 | 
					 | 
				
			||||||
					NULL, 0, iter, p8inf))) {
 | 
					 | 
				
			||||||
				BIO_printf(bio_err, "Error encrypting key\n",
 | 
					 | 
				
			||||||
								 outfile);
 | 
					 | 
				
			||||||
				ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
				return (1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			app_RAND_write_file(NULL, bio_err);
 | 
					 | 
				
			||||||
			if(outformat == FORMAT_PEM) 
 | 
					 | 
				
			||||||
				PEM_write_bio_PKCS8(out, p8);
 | 
					 | 
				
			||||||
			else if(outformat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
				i2d_PKCS8_bio(out, p8);
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
				return (1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			X509_SIG_free(p8);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		PKCS8_PRIV_KEY_INFO_free (p8inf);
 | 
					 | 
				
			||||||
		EVP_PKEY_free(pkey);
 | 
					 | 
				
			||||||
		BIO_free_all(out);
 | 
					 | 
				
			||||||
		if(passin) OPENSSL_free(passin);
 | 
					 | 
				
			||||||
		if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
		return (0);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(nocrypt) {
 | 
					 | 
				
			||||||
		if(informat == FORMAT_PEM) 
 | 
					 | 
				
			||||||
			p8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in,NULL,NULL, NULL);
 | 
					 | 
				
			||||||
		else if(informat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
			p8inf = d2i_PKCS8_PRIV_KEY_INFO_bio(in, NULL);
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if(informat == FORMAT_PEM) 
 | 
					 | 
				
			||||||
			p8 = PEM_read_bio_PKCS8(in, NULL, NULL, NULL);
 | 
					 | 
				
			||||||
		else if(informat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
			p8 = d2i_PKCS8_bio(in, NULL);
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!p8) {
 | 
					 | 
				
			||||||
			BIO_printf (bio_err, "Error reading key\n", outfile);
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if(passin) p8pass = passin;
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			p8pass = pass;
 | 
					 | 
				
			||||||
			EVP_read_pw_string(pass, 50, "Enter Password:", 0);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		p8inf = M_PKCS8_decrypt(p8, p8pass, strlen(p8pass));
 | 
					 | 
				
			||||||
		X509_SIG_free(p8);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!p8inf) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error decrypting key\n", outfile);
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		return (1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!(pkey = EVP_PKCS82PKEY(p8inf))) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error converting key\n", outfile);
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		return (1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (p8inf->broken) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Warning: broken key encoding: ");
 | 
					 | 
				
			||||||
		switch (p8inf->broken) {
 | 
					 | 
				
			||||||
			case PKCS8_NO_OCTET:
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "No Octet String in PrivateKey\n");
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			case PKCS8_EMBEDDED_PARAM:
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "DSA parameters included in PrivateKey\n");
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			case PKCS8_NS_DB:
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "DSA public key include in PrivateKey\n");
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Unknown broken type\n");
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	PKCS8_PRIV_KEY_INFO_free(p8inf);
 | 
					 | 
				
			||||||
	if(outformat == FORMAT_PEM) 
 | 
					 | 
				
			||||||
		PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, passout);
 | 
					 | 
				
			||||||
	else if(outformat == FORMAT_ASN1)
 | 
					 | 
				
			||||||
		i2d_PrivateKey_bio(out, pkey);
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Bad format specified for key\n");
 | 
					 | 
				
			||||||
			return (1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	EVP_PKEY_free(pkey);
 | 
					 | 
				
			||||||
	BIO_free_all(out);
 | 
					 | 
				
			||||||
	BIO_free(in);
 | 
					 | 
				
			||||||
	if(passin) OPENSSL_free(passin);
 | 
					 | 
				
			||||||
	if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return (0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										45
									
								
								apps/progs.h
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								apps/progs.h
									
									
									
									
									
								
							@@ -1,20 +1,16 @@
 | 
				
			|||||||
/* apps/progs.h */
 | 
					/* This file was generated by progs.pl. */
 | 
				
			||||||
/* automatically generated by progs.pl for openssl.c */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int verify_main(int argc,char *argv[]);
 | 
					extern int verify_main(int argc,char *argv[]);
 | 
				
			||||||
extern int asn1parse_main(int argc,char *argv[]);
 | 
					extern int asn1parse_main(int argc,char *argv[]);
 | 
				
			||||||
extern int req_main(int argc,char *argv[]);
 | 
					extern int req_main(int argc,char *argv[]);
 | 
				
			||||||
extern int dgst_main(int argc,char *argv[]);
 | 
					extern int dgst_main(int argc,char *argv[]);
 | 
				
			||||||
extern int dh_main(int argc,char *argv[]);
 | 
					extern int dh_main(int argc,char *argv[]);
 | 
				
			||||||
extern int dhparam_main(int argc,char *argv[]);
 | 
					 | 
				
			||||||
extern int enc_main(int argc,char *argv[]);
 | 
					extern int enc_main(int argc,char *argv[]);
 | 
				
			||||||
extern int passwd_main(int argc,char *argv[]);
 | 
					 | 
				
			||||||
extern int gendh_main(int argc,char *argv[]);
 | 
					extern int gendh_main(int argc,char *argv[]);
 | 
				
			||||||
extern int errstr_main(int argc,char *argv[]);
 | 
					extern int errstr_main(int argc,char *argv[]);
 | 
				
			||||||
extern int ca_main(int argc,char *argv[]);
 | 
					extern int ca_main(int argc,char *argv[]);
 | 
				
			||||||
extern int crl_main(int argc,char *argv[]);
 | 
					extern int crl_main(int argc,char *argv[]);
 | 
				
			||||||
extern int rsa_main(int argc,char *argv[]);
 | 
					extern int rsa_main(int argc,char *argv[]);
 | 
				
			||||||
extern int rsautl_main(int argc,char *argv[]);
 | 
					 | 
				
			||||||
extern int dsa_main(int argc,char *argv[]);
 | 
					extern int dsa_main(int argc,char *argv[]);
 | 
				
			||||||
extern int dsaparam_main(int argc,char *argv[]);
 | 
					extern int dsaparam_main(int argc,char *argv[]);
 | 
				
			||||||
extern int x509_main(int argc,char *argv[]);
 | 
					extern int x509_main(int argc,char *argv[]);
 | 
				
			||||||
@@ -31,10 +27,8 @@ extern int sess_id_main(int argc,char *argv[]);
 | 
				
			|||||||
extern int ciphers_main(int argc,char *argv[]);
 | 
					extern int ciphers_main(int argc,char *argv[]);
 | 
				
			||||||
extern int nseq_main(int argc,char *argv[]);
 | 
					extern int nseq_main(int argc,char *argv[]);
 | 
				
			||||||
extern int pkcs12_main(int argc,char *argv[]);
 | 
					extern int pkcs12_main(int argc,char *argv[]);
 | 
				
			||||||
extern int pkcs8_main(int argc,char *argv[]);
 | 
					
 | 
				
			||||||
extern int spkac_main(int argc,char *argv[]);
 | 
					#ifdef SSLEAY_SRC  /* Defined only in openssl.c. */
 | 
				
			||||||
extern int smime_main(int argc,char *argv[]);
 | 
					 | 
				
			||||||
extern int rand_main(int argc,char *argv[]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FUNC_TYPE_GENERAL	1
 | 
					#define FUNC_TYPE_GENERAL	1
 | 
				
			||||||
#define FUNC_TYPE_MD		2
 | 
					#define FUNC_TYPE_MD		2
 | 
				
			||||||
@@ -53,12 +47,8 @@ FUNCTION functions[] = {
 | 
				
			|||||||
	{FUNC_TYPE_GENERAL,"dgst",dgst_main},
 | 
						{FUNC_TYPE_GENERAL,"dgst",dgst_main},
 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"dh",dh_main},
 | 
						{FUNC_TYPE_GENERAL,"dh",dh_main},
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_DH
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"dhparam",dhparam_main},
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"enc",enc_main},
 | 
						{FUNC_TYPE_GENERAL,"enc",enc_main},
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"passwd",passwd_main},
 | 
					 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"gendh",gendh_main},
 | 
						{FUNC_TYPE_GENERAL,"gendh",gendh_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -68,9 +58,6 @@ FUNCTION functions[] = {
 | 
				
			|||||||
#ifndef NO_RSA
 | 
					#ifndef NO_RSA
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"rsa",rsa_main},
 | 
						{FUNC_TYPE_GENERAL,"rsa",rsa_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef NO_RSA
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"rsautl",rsautl_main},
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_DSA
 | 
					#ifndef NO_DSA
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"dsa",dsa_main},
 | 
						{FUNC_TYPE_GENERAL,"dsa",dsa_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -84,33 +71,26 @@ FUNCTION functions[] = {
 | 
				
			|||||||
#ifndef NO_DSA
 | 
					#ifndef NO_DSA
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
 | 
						{FUNC_TYPE_GENERAL,"gendsa",gendsa_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
 | 
					#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"s_server",s_server_main},
 | 
						{FUNC_TYPE_GENERAL,"s_server",s_server_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
 | 
					#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"s_client",s_client_main},
 | 
						{FUNC_TYPE_GENERAL,"s_client",s_client_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"speed",speed_main},
 | 
						{FUNC_TYPE_GENERAL,"speed",speed_main},
 | 
				
			||||||
#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
 | 
					#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"s_time",s_time_main},
 | 
						{FUNC_TYPE_GENERAL,"s_time",s_time_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"version",version_main},
 | 
						{FUNC_TYPE_GENERAL,"version",version_main},
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"pkcs7",pkcs7_main},
 | 
						{FUNC_TYPE_GENERAL,"pkcs7",pkcs7_main},
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main},
 | 
						{FUNC_TYPE_GENERAL,"crl2pkcs7",crl2pkcs7_main},
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"sess_id",sess_id_main},
 | 
						{FUNC_TYPE_GENERAL,"sess_id",sess_id_main},
 | 
				
			||||||
#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))
 | 
					#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"ciphers",ciphers_main},
 | 
						{FUNC_TYPE_GENERAL,"ciphers",ciphers_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"nseq",nseq_main},
 | 
						{FUNC_TYPE_GENERAL,"nseq",nseq_main},
 | 
				
			||||||
#if !defined(NO_DES) && !defined(NO_SHA1)
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main},
 | 
						{FUNC_TYPE_GENERAL,"pkcs12",pkcs12_main},
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"pkcs8",pkcs8_main},
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"spkac",spkac_main},
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"smime",smime_main},
 | 
					 | 
				
			||||||
	{FUNC_TYPE_GENERAL,"rand",rand_main},
 | 
					 | 
				
			||||||
	{FUNC_TYPE_MD,"md2",dgst_main},
 | 
						{FUNC_TYPE_MD,"md2",dgst_main},
 | 
				
			||||||
	{FUNC_TYPE_MD,"md4",dgst_main},
 | 
					 | 
				
			||||||
	{FUNC_TYPE_MD,"md5",dgst_main},
 | 
						{FUNC_TYPE_MD,"md5",dgst_main},
 | 
				
			||||||
	{FUNC_TYPE_MD,"sha",dgst_main},
 | 
						{FUNC_TYPE_MD,"sha",dgst_main},
 | 
				
			||||||
	{FUNC_TYPE_MD,"sha1",dgst_main},
 | 
						{FUNC_TYPE_MD,"sha1",dgst_main},
 | 
				
			||||||
@@ -132,9 +112,6 @@ FUNCTION functions[] = {
 | 
				
			|||||||
#ifndef NO_RC4
 | 
					#ifndef NO_RC4
 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc4",enc_main},
 | 
						{FUNC_TYPE_CIPHER,"rc4",enc_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef NO_RC4
 | 
					 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc4-40",enc_main},
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_RC2
 | 
					#ifndef NO_RC2
 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc2",enc_main},
 | 
						{FUNC_TYPE_CIPHER,"rc2",enc_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -207,12 +184,6 @@ FUNCTION functions[] = {
 | 
				
			|||||||
#ifndef NO_RC2
 | 
					#ifndef NO_RC2
 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc2-ofb",enc_main},
 | 
						{FUNC_TYPE_CIPHER,"rc2-ofb",enc_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifndef NO_RC2
 | 
					 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc2-64-cbc",enc_main},
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_RC2
 | 
					 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"rc2-40-cbc",enc_main},
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#ifndef NO_BF
 | 
					#ifndef NO_BF
 | 
				
			||||||
	{FUNC_TYPE_CIPHER,"bf-cbc",enc_main},
 | 
						{FUNC_TYPE_CIPHER,"bf-cbc",enc_main},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -254,3 +225,5 @@ FUNCTION functions[] = {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
	{0,NULL,NULL}
 | 
						{0,NULL,NULL}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
#!/usr/local/bin/perl
 | 
					#!/usr/local/bin/perl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print "/* apps/progs.h */\n";
 | 
					print "/* This file was generated by progs.pl. */\n\n";
 | 
				
			||||||
print "/* automatically generated by progs.pl for openssl.c */\n\n";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
grep(s/^asn1pars$/asn1parse/,@ARGV);
 | 
					grep(s/^asn1pars$/asn1parse/,@ARGV);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,6 +9,8 @@ foreach (@ARGV)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
print <<'EOF';
 | 
					print <<'EOF';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef SSLEAY_SRC  /* Defined only in openssl.c. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FUNC_TYPE_GENERAL	1
 | 
					#define FUNC_TYPE_GENERAL	1
 | 
				
			||||||
#define FUNC_TYPE_MD		2
 | 
					#define FUNC_TYPE_MD		2
 | 
				
			||||||
#define FUNC_TYPE_CIPHER	3
 | 
					#define FUNC_TYPE_CIPHER	3
 | 
				
			||||||
@@ -28,20 +29,18 @@ foreach (@ARGV)
 | 
				
			|||||||
	push(@files,$_);
 | 
						push(@files,$_);
 | 
				
			||||||
	$str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
 | 
						$str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
 | 
				
			||||||
	if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
 | 
						if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
 | 
				
			||||||
		{ print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(NO_SSL3))\n${str}#endif\n"; } 
 | 
							{ print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; } 
 | 
				
			||||||
	elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) || ($_ =~ /^rsautl$/)) 
 | 
						elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) ) 
 | 
				
			||||||
		{ print "#ifndef NO_RSA\n${str}#endif\n";  }
 | 
							{ print "#ifndef NO_RSA\n${str}#endif\n";  }
 | 
				
			||||||
	elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
 | 
						elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
 | 
				
			||||||
		{ print "#ifndef NO_DSA\n${str}#endif\n"; }
 | 
							{ print "#ifndef NO_DSA\n${str}#endif\n"; }
 | 
				
			||||||
	elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/) || ($_ =~ /^dhparam$/))
 | 
						elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/))
 | 
				
			||||||
		{ print "#ifndef NO_DH\n${str}#endif\n"; }
 | 
							{ print "#ifndef NO_DH\n${str}#endif\n"; }
 | 
				
			||||||
	elsif ( ($_ =~ /^pkcs12$/))
 | 
					 | 
				
			||||||
		{ print "#if !defined(NO_DES) && !defined(NO_SHA1)\n${str}#endif\n"; }
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{ print $str; }
 | 
							{ print $str; }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
 | 
					foreach ("md2","md5","sha","sha1","mdc2","rmd160")
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	push(@files,$_);
 | 
						push(@files,$_);
 | 
				
			||||||
	printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_;
 | 
						printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_;
 | 
				
			||||||
@@ -49,14 +48,13 @@ foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
foreach (
 | 
					foreach (
 | 
				
			||||||
	"base64",
 | 
						"base64",
 | 
				
			||||||
	"des", "des3", "desx", "idea", "rc4", "rc4-40",
 | 
						"des", "des3", "desx", "idea", "rc4", "rc2","bf","cast","rc5",
 | 
				
			||||||
	"rc2", "bf", "cast", "rc5",
 | 
					 | 
				
			||||||
	"des-ecb", "des-ede",    "des-ede3",
 | 
						"des-ecb", "des-ede",    "des-ede3",
 | 
				
			||||||
	"des-cbc", "des-ede-cbc","des-ede3-cbc",
 | 
						"des-cbc", "des-ede-cbc","des-ede3-cbc",
 | 
				
			||||||
	"des-cfb", "des-ede-cfb","des-ede3-cfb",
 | 
						"des-cfb", "des-ede-cfb","des-ede3-cfb",
 | 
				
			||||||
	"des-ofb", "des-ede-ofb","des-ede3-ofb",
 | 
						"des-ofb", "des-ede-ofb","des-ede3-ofb",
 | 
				
			||||||
	"idea-cbc","idea-ecb",   "idea-cfb", "idea-ofb",
 | 
						"idea-cbc","idea-ecb",   "idea-cfb", "idea-ofb",
 | 
				
			||||||
	"rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
 | 
						"rc2-cbc", "rc2-ecb",    "rc2-cfb",  "rc2-ofb",
 | 
				
			||||||
	"bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb",
 | 
						"bf-cbc",  "bf-ecb",     "bf-cfb",   "bf-ofb",
 | 
				
			||||||
	"cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
 | 
						"cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
 | 
				
			||||||
	"cast-cbc", "rc5-cbc",   "rc5-ecb",  "rc5-cfb",  "rc5-ofb")
 | 
						"cast-cbc", "rc5-cbc",   "rc5-ecb",  "rc5-cfb",  "rc5-ofb")
 | 
				
			||||||
@@ -75,3 +73,5 @@ foreach (
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print "\t{0,NULL,NULL}\n\t};\n";
 | 
					print "\t{0,NULL,NULL}\n\t};\n";
 | 
				
			||||||
 | 
					print "#endif\n\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										177
									
								
								apps/rand.c
									
									
									
									
									
								
							
							
						
						
									
										177
									
								
								apps/rand.c
									
									
									
									
									
								
							@@ -1,177 +0,0 @@
 | 
				
			|||||||
/* apps/rand.c */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <ctype.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <openssl/bio.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#undef PROG
 | 
					 | 
				
			||||||
#define PROG rand_main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* -out file         - write to file
 | 
					 | 
				
			||||||
 * -rand file:file   - PRNG seed files
 | 
					 | 
				
			||||||
 * -base64           - encode output
 | 
					 | 
				
			||||||
 * num               - write 'num' bytes
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	int i, r, ret = 1;
 | 
					 | 
				
			||||||
	int badopt;
 | 
					 | 
				
			||||||
	char *outfile = NULL;
 | 
					 | 
				
			||||||
	char *inrand = NULL;
 | 
					 | 
				
			||||||
	int base64 = 0;
 | 
					 | 
				
			||||||
	BIO *out = NULL;
 | 
					 | 
				
			||||||
	int num = -1;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	apps_startup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_err == NULL)
 | 
					 | 
				
			||||||
		if ((bio_err = BIO_new(BIO_s_file())) != NULL)
 | 
					 | 
				
			||||||
			BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	badopt = 0;
 | 
					 | 
				
			||||||
	i = 0;
 | 
					 | 
				
			||||||
	while (!badopt && argv[++i] != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if (strcmp(argv[i], "-out") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((argv[i+1] != NULL) && (outfile == NULL))
 | 
					 | 
				
			||||||
				outfile = argv[++i];
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (strcmp(argv[i], "-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((argv[i+1] != NULL) && (engine == NULL))
 | 
					 | 
				
			||||||
				engine = argv[++i];
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-rand") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if ((argv[i+1] != NULL) && (inrand == NULL))
 | 
					 | 
				
			||||||
				inrand = argv[++i];
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(argv[i], "-base64") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (!base64)
 | 
					 | 
				
			||||||
				base64 = 1;
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (isdigit((unsigned char)argv[i][0]))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (num < 0)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				r = sscanf(argv[i], "%d", &num);
 | 
					 | 
				
			||||||
				if (r == 0 || num < 0)
 | 
					 | 
				
			||||||
					badopt = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				badopt = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			badopt = 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (num < 0)
 | 
					 | 
				
			||||||
		badopt = 1;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (badopt) 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Usage: rand [options] num\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "where options are\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-out file             - write to file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -engine e             - use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "-base64               - encode output\n");
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	app_RAND_load_file(NULL, bio_err, (inrand != NULL));
 | 
					 | 
				
			||||||
	if (inrand != NULL)
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	out = BIO_new(BIO_s_file());
 | 
					 | 
				
			||||||
	if (out == NULL)
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
	if (outfile != NULL)
 | 
					 | 
				
			||||||
		r = BIO_write_filename(out, outfile);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (r <= 0)
 | 
					 | 
				
			||||||
		goto err;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (base64)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *b64 = BIO_new(BIO_f_base64());
 | 
					 | 
				
			||||||
		if (b64 == NULL)
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
		out = BIO_push(b64, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	while (num > 0) 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		unsigned char buf[4096];
 | 
					 | 
				
			||||||
		int chunk;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		chunk = num;
 | 
					 | 
				
			||||||
		if (chunk > sizeof buf)
 | 
					 | 
				
			||||||
			chunk = sizeof buf;
 | 
					 | 
				
			||||||
		r = RAND_bytes(buf, chunk);
 | 
					 | 
				
			||||||
		if (r <= 0)
 | 
					 | 
				
			||||||
			goto err;
 | 
					 | 
				
			||||||
		BIO_write(out, buf, chunk);
 | 
					 | 
				
			||||||
		num -= chunk;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	BIO_flush(out);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	app_RAND_write_file(NULL, bio_err);
 | 
					 | 
				
			||||||
	ret = 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
err:
 | 
					 | 
				
			||||||
	ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
	if (out)
 | 
					 | 
				
			||||||
		BIO_free_all(out);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
							
								
								
									
										659
									
								
								apps/req.c
									
									
									
									
									
								
							
							
						
						
									
										659
									
								
								apps/req.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										199
									
								
								apps/rsa.c
									
									
									
									
									
								
							
							
						
						
									
										199
									
								
								apps/rsa.c
									
									
									
									
									
								
							@@ -68,7 +68,6 @@
 | 
				
			|||||||
#include <openssl/evp.h>
 | 
					#include <openssl/evp.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	rsa_main
 | 
					#define PROG	rsa_main
 | 
				
			||||||
@@ -82,27 +81,17 @@
 | 
				
			|||||||
 * -idea	- encrypt output if PEM format
 | 
					 * -idea	- encrypt output if PEM format
 | 
				
			||||||
 * -text	- print a text version
 | 
					 * -text	- print a text version
 | 
				
			||||||
 * -modulus	- print the RSA key modulus
 | 
					 * -modulus	- print the RSA key modulus
 | 
				
			||||||
 * -check	- verify key consistency
 | 
					 | 
				
			||||||
 * -pubin	- Expect a public key in input file.
 | 
					 | 
				
			||||||
 * -pubout	- Output a public key.
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	ENGINE *eng = NULL;
 | 
					 | 
				
			||||||
	int ret=1;
 | 
						int ret=1;
 | 
				
			||||||
	RSA *rsa=NULL;
 | 
						RSA *rsa=NULL;
 | 
				
			||||||
	int i,badops=0, sgckey=0;
 | 
						int i,badops=0;
 | 
				
			||||||
	const EVP_CIPHER *enc=NULL;
 | 
						const EVP_CIPHER *enc=NULL;
 | 
				
			||||||
	BIO *in=NULL,*out=NULL;
 | 
						BIO *in=NULL,*out=NULL;
 | 
				
			||||||
	int informat,outformat,text=0,check=0,noout=0;
 | 
						int informat,outformat,text=0,noout=0;
 | 
				
			||||||
	int pubin = 0, pubout = 0;
 | 
					 | 
				
			||||||
	char *infile,*outfile,*prog;
 | 
						char *infile,*outfile,*prog;
 | 
				
			||||||
	char *passargin = NULL, *passargout = NULL;
 | 
					 | 
				
			||||||
	char *passin = NULL, *passout = NULL;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
	int modulus=0;
 | 
						int modulus=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
@@ -141,35 +130,12 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			outfile= *(++argv);
 | 
								outfile= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if (strcmp(*argv,"-passin") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargin= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-passout") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			passargout= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-sgckey") == 0)
 | 
					 | 
				
			||||||
			sgckey=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-pubin") == 0)
 | 
					 | 
				
			||||||
			pubin=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-pubout") == 0)
 | 
					 | 
				
			||||||
			pubout=1;
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-noout") == 0)
 | 
							else if (strcmp(*argv,"-noout") == 0)
 | 
				
			||||||
			noout=1;
 | 
								noout=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-text") == 0)
 | 
							else if (strcmp(*argv,"-text") == 0)
 | 
				
			||||||
			text=1;
 | 
								text=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-modulus") == 0)
 | 
							else if (strcmp(*argv,"-modulus") == 0)
 | 
				
			||||||
			modulus=1;
 | 
								modulus=1;
 | 
				
			||||||
		else if (strcmp(*argv,"-check") == 0)
 | 
					 | 
				
			||||||
			check=1;
 | 
					 | 
				
			||||||
		else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
 | 
							else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -185,58 +151,23 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
bad:
 | 
					bad:
 | 
				
			||||||
		BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
							BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
 | 
				
			||||||
		BIO_printf(bio_err,"where options are\n");
 | 
							BIO_printf(bio_err,"where options are\n");
 | 
				
			||||||
		BIO_printf(bio_err," -inform arg     input format - one of DER NET PEM\n");
 | 
							BIO_printf(bio_err," -inform arg   input format - one of DER NET PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -outform arg    output format - one of DER NET PEM\n");
 | 
							BIO_printf(bio_err," -outform arg  output format - one of DER NET PEM\n");
 | 
				
			||||||
		BIO_printf(bio_err," -in arg         input file\n");
 | 
							BIO_printf(bio_err," -in arg       input file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -sgckey         Use IIS SGC key format\n");
 | 
							BIO_printf(bio_err," -out arg      output file\n");
 | 
				
			||||||
		BIO_printf(bio_err," -passin arg     input file pass phrase source\n");
 | 
							BIO_printf(bio_err," -des          encrypt PEM output with cbc des\n");
 | 
				
			||||||
		BIO_printf(bio_err," -out arg        output file\n");
 | 
							BIO_printf(bio_err," -des3         encrypt PEM output with ede cbc des using 168 bit key\n");
 | 
				
			||||||
		BIO_printf(bio_err," -passout arg    output file pass phrase source\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -des            encrypt PEM output with cbc des\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -des3           encrypt PEM output with ede cbc des using 168 bit key\n");
 | 
					 | 
				
			||||||
#ifndef NO_IDEA
 | 
					#ifndef NO_IDEA
 | 
				
			||||||
		BIO_printf(bio_err," -idea           encrypt PEM output with cbc idea\n");
 | 
							BIO_printf(bio_err," -idea         encrypt PEM output with cbc idea\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		BIO_printf(bio_err," -text           print the key in text\n");
 | 
							BIO_printf(bio_err," -text         print the key in text\n");
 | 
				
			||||||
		BIO_printf(bio_err," -noout          don't print key out\n");
 | 
							BIO_printf(bio_err," -noout        don't print key out\n");
 | 
				
			||||||
		BIO_printf(bio_err," -modulus        print the RSA key modulus\n");
 | 
							BIO_printf(bio_err," -modulus      print the RSA key modulus\n");
 | 
				
			||||||
		BIO_printf(bio_err," -check          verify key consistency\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -pubin          expect a public key in input file\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -pubout         output a public key\n");
 | 
					 | 
				
			||||||
		BIO_printf(bio_err," -engine e       use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
						ERR_load_crypto_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((eng = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(eng, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(eng);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting passwords\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(check && pubin) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Only private keys can be checked\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	in=BIO_new(BIO_s_file());
 | 
						in=BIO_new(BIO_s_file());
 | 
				
			||||||
	out=BIO_new(BIO_s_file());
 | 
						out=BIO_new(BIO_s_file());
 | 
				
			||||||
	if ((in == NULL) || (out == NULL))
 | 
						if ((in == NULL) || (out == NULL))
 | 
				
			||||||
@@ -256,11 +187,9 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_err,"read RSA key\n");
 | 
						BIO_printf(bio_err,"read RSA private key\n");
 | 
				
			||||||
	if	(informat == FORMAT_ASN1) {
 | 
						if	(informat == FORMAT_ASN1)
 | 
				
			||||||
		if (pubin) rsa=d2i_RSA_PUBKEY_bio(in,NULL);
 | 
							rsa=d2i_RSAPrivateKey_bio(in,NULL);
 | 
				
			||||||
		else rsa=d2i_RSAPrivateKey_bio(in,NULL);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#ifndef NO_RC4
 | 
					#ifndef NO_RC4
 | 
				
			||||||
	else if (informat == FORMAT_NETSCAPE)
 | 
						else if (informat == FORMAT_NETSCAPE)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -284,14 +213,12 @@ bad:
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		p=(unsigned char *)buf->data;
 | 
							p=(unsigned char *)buf->data;
 | 
				
			||||||
		rsa=d2i_RSA_NET(NULL,&p,(long)size,NULL, sgckey);
 | 
							rsa=(RSA *)d2i_Netscape_RSA(NULL,&p,(long)size,NULL);
 | 
				
			||||||
		BUF_MEM_free(buf);
 | 
							BUF_MEM_free(buf);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	else if (informat == FORMAT_PEM) {
 | 
						else if (informat == FORMAT_PEM)
 | 
				
			||||||
		if(pubin) rsa=PEM_read_bio_RSA_PUBKEY(in,NULL,NULL,NULL);
 | 
							rsa=PEM_read_bio_RSAPrivateKey(in,NULL,NULL);
 | 
				
			||||||
		else rsa=PEM_read_bio_RSAPrivateKey(in,NULL, NULL,passin);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"bad input format specified for key\n");
 | 
							BIO_printf(bio_err,"bad input format specified for key\n");
 | 
				
			||||||
@@ -299,21 +226,13 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	if (rsa == NULL)
 | 
						if (rsa == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unable to load key\n");
 | 
							BIO_printf(bio_err,"unable to load Private Key\n");
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (outfile == NULL)
 | 
						if (outfile == NULL)
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
							BIO_set_fp(out,stdout,BIO_NOCLOSE);
 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (BIO_write_filename(out,outfile) <= 0)
 | 
							if (BIO_write_filename(out,outfile) <= 0)
 | 
				
			||||||
@@ -333,48 +252,15 @@ bad:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (modulus)
 | 
						if (modulus)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(out,"Modulus=");
 | 
							fprintf(stdout,"Modulus=");
 | 
				
			||||||
		BN_print(out,rsa->n);
 | 
							BN_print(out,rsa->n);
 | 
				
			||||||
		BIO_printf(out,"\n");
 | 
							fprintf(stdout,"\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (check)
 | 
						if (noout) goto end;
 | 
				
			||||||
		{
 | 
						BIO_printf(bio_err,"writing RSA private key\n");
 | 
				
			||||||
		int r = RSA_check_key(rsa);
 | 
						if 	(outformat == FORMAT_ASN1)
 | 
				
			||||||
 | 
							i=i2d_RSAPrivateKey_bio(out,rsa);
 | 
				
			||||||
		if (r == 1)
 | 
					 | 
				
			||||||
			BIO_printf(out,"RSA key ok\n");
 | 
					 | 
				
			||||||
		else if (r == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			long e;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			while ((e = ERR_peek_error()) != 0 &&
 | 
					 | 
				
			||||||
				ERR_GET_LIB(e) == ERR_LIB_RSA &&
 | 
					 | 
				
			||||||
				ERR_GET_FUNC(e) == RSA_F_RSA_CHECK_KEY &&
 | 
					 | 
				
			||||||
				ERR_GET_REASON(e) != ERR_R_MALLOC_FAILURE)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				BIO_printf(out, "RSA key error: %s\n", ERR_reason_error_string(e));
 | 
					 | 
				
			||||||
				ERR_get_error(); /* remove e from error stack */
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (r == -1 || ERR_peek_error() != 0) /* should happen only if r == -1 */
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	if (noout)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		ret = 0;
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,"writing RSA key\n");
 | 
					 | 
				
			||||||
	if 	(outformat == FORMAT_ASN1) {
 | 
					 | 
				
			||||||
		if(pubout || pubin) i=i2d_RSA_PUBKEY_bio(out,rsa);
 | 
					 | 
				
			||||||
		else i=i2d_RSAPrivateKey_bio(out,rsa);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#ifndef NO_RC4
 | 
					#ifndef NO_RC4
 | 
				
			||||||
	else if (outformat == FORMAT_NETSCAPE)
 | 
						else if (outformat == FORMAT_NETSCAPE)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -382,46 +268,35 @@ bad:
 | 
				
			|||||||
		int size;
 | 
							int size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		i=1;
 | 
							i=1;
 | 
				
			||||||
		size=i2d_RSA_NET(rsa,NULL,NULL, sgckey);
 | 
							size=i2d_Netscape_RSA(rsa,NULL,NULL);
 | 
				
			||||||
		if ((p=(unsigned char *)OPENSSL_malloc(size)) == NULL)
 | 
							if ((p=(unsigned char *)Malloc(size)) == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"Memory allocation failure\n");
 | 
								BIO_printf(bio_err,"Malloc failure\n");
 | 
				
			||||||
			goto end;
 | 
								goto end;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		pp=p;
 | 
							pp=p;
 | 
				
			||||||
		i2d_RSA_NET(rsa,&p,NULL, sgckey);
 | 
							i2d_Netscape_RSA(rsa,&p,NULL);
 | 
				
			||||||
		BIO_write(out,(char *)pp,size);
 | 
							BIO_write(out,(char *)pp,size);
 | 
				
			||||||
		OPENSSL_free(pp);
 | 
							Free(pp);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	else if (outformat == FORMAT_PEM) {
 | 
						else if (outformat == FORMAT_PEM)
 | 
				
			||||||
		if(pubout || pubin)
 | 
							i=PEM_write_bio_RSAPrivateKey(out,rsa,enc,NULL,0,NULL);
 | 
				
			||||||
		    i=PEM_write_bio_RSA_PUBKEY(out,rsa);
 | 
						else	{
 | 
				
			||||||
		else i=PEM_write_bio_RSAPrivateKey(out,rsa,
 | 
					 | 
				
			||||||
						enc,NULL,0,NULL,passout);
 | 
					 | 
				
			||||||
	} else	{
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
							BIO_printf(bio_err,"bad output format specified for outfile\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (!i)
 | 
						if (!i)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"unable to write key\n");
 | 
							BIO_printf(bio_err,"unable to write private key\n");
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		ret=0;
 | 
							ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if(in != NULL) BIO_free(in);
 | 
						if (in != NULL) BIO_free(in);
 | 
				
			||||||
	if(out != NULL) BIO_free_all(out);
 | 
						if (out != NULL) BIO_free(out);
 | 
				
			||||||
	if(rsa != NULL) RSA_free(rsa);
 | 
						if (rsa != NULL) RSA_free(rsa);
 | 
				
			||||||
	if(passin) OPENSSL_free(passin);
 | 
					 | 
				
			||||||
	if(passout) OPENSSL_free(passout);
 | 
					 | 
				
			||||||
	EXIT(ret);
 | 
						EXIT(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#else /* !NO_RSA */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# if PEDANTIC
 | 
					 | 
				
			||||||
static void *dummy=&dummy;
 | 
					 | 
				
			||||||
# endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								apps/rsa/01.pem
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								apps/rsa/01.pem
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					-----BEGIN CERTIFICATE-----
 | 
				
			||||||
 | 
					MIICTjCCAbsCEGiuFKTJn6nzmiPPLxUZs1owDQYJKoZIhvcNAQEEBQAwXzELMAkG
 | 
				
			||||||
 | 
					A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD
 | 
				
			||||||
 | 
					VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk4
 | 
				
			||||||
 | 
					MDUxODAwMDAwMFoXDTk5MDUxODIzNTk1OVowdTELMAkGA1UEBhMCVVMxETAPBgNV
 | 
				
			||||||
 | 
					BAgTCE5ldyBZb3JrMREwDwYDVQQHFAhOZXcgWW9yazEeMBwGA1UEChQVSW5kdXN0
 | 
				
			||||||
 | 
					cmlhbCBQcmVzcyBJbmMuMSAwHgYDVQQDFBd3d3cuaW5kdXN0cmlhbHByZXNzLmNv
 | 
				
			||||||
 | 
					bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqiH9xUJNHvqCmaDon27ValJb
 | 
				
			||||||
 | 
					qTLymF3yKKWBxbODLWjX7yKjewoqWhotaEARI6jXPqomU87gFU1tH4r/bgwh3FmU
 | 
				
			||||||
 | 
					MK3qo92XOsvwNAHzXzWRXQNJmm54g2F1RUt00pgYiOximDse1t9RL5POCDEbfX8D
 | 
				
			||||||
 | 
					gugrE/WwkS2FrSoc5/cCAwEAATANBgkqhkiG9w0BAQQFAAN+AIw7fvF0EtEvrNS/
 | 
				
			||||||
 | 
					LYuqAgUw/tH0FLgCkqKLmYYm/yR+Z0hD2eP/UhF+jAwmV8rHtBnaTM7oN23RVW2k
 | 
				
			||||||
 | 
					Cf8soiGfr2PYtfufpXtd7azUFa+WJCWnp0N29EG0BR1JOFC0Q/4dh/X9qulM8luq
 | 
				
			||||||
 | 
					Pjrmw2eSgbdmmdumWAcNPVbV
 | 
				
			||||||
 | 
					-----END CERTIFICATE-----
 | 
				
			||||||
							
								
								
									
										50
									
								
								apps/rsa/1.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								apps/rsa/1.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					subject=/C=US/ST=New York/L=New York/O=Industrial Press Inc./CN=www.industrialpress.com
 | 
				
			||||||
 | 
					Certificate:
 | 
				
			||||||
 | 
					    Data:
 | 
				
			||||||
 | 
					        Version: 1 (0x0)
 | 
				
			||||||
 | 
					        Serial Number:
 | 
				
			||||||
 | 
					            68:ae:14:a4:c9:9f:a9:f3:9a:23:cf:2f:15:19:b3:5a
 | 
				
			||||||
 | 
					        Signature Algorithm: md5WithRSAEncryption
 | 
				
			||||||
 | 
					        Issuer: C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					        Validity
 | 
				
			||||||
 | 
					            Not Before: May 18 00:00:00 1998 GMT
 | 
				
			||||||
 | 
					            Not After : May 18 23:59:59 1999 GMT
 | 
				
			||||||
 | 
					        Subject: C=US, ST=New York, L=New York, O=Industrial Press Inc., CN=www.industrialpress.com
 | 
				
			||||||
 | 
					        Subject Public Key Info:
 | 
				
			||||||
 | 
					            Public Key Algorithm: rsaEncryption
 | 
				
			||||||
 | 
					            RSA Public Key: (1024 bit)
 | 
				
			||||||
 | 
					                Modulus (1024 bit):
 | 
				
			||||||
 | 
					                    00:aa:21:fd:c5:42:4d:1e:fa:82:99:a0:e8:9f:6e:
 | 
				
			||||||
 | 
					                    d5:6a:52:5b:a9:32:f2:98:5d:f2:28:a5:81:c5:b3:
 | 
				
			||||||
 | 
					                    83:2d:68:d7:ef:22:a3:7b:0a:2a:5a:1a:2d:68:40:
 | 
				
			||||||
 | 
					                    11:23:a8:d7:3e:aa:26:53:ce:e0:15:4d:6d:1f:8a:
 | 
				
			||||||
 | 
					                    ff:6e:0c:21:dc:59:94:30:ad:ea:a3:dd:97:3a:cb:
 | 
				
			||||||
 | 
					                    f0:34:01:f3:5f:35:91:5d:03:49:9a:6e:78:83:61:
 | 
				
			||||||
 | 
					                    75:45:4b:74:d2:98:18:88:ec:62:98:3b:1e:d6:df:
 | 
				
			||||||
 | 
					                    51:2f:93:ce:08:31:1b:7d:7f:03:82:e8:2b:13:f5:
 | 
				
			||||||
 | 
					                    b0:91:2d:85:ad:2a:1c:e7:f7
 | 
				
			||||||
 | 
					                Exponent: 65537 (0x10001)
 | 
				
			||||||
 | 
					    Signature Algorithm: md5WithRSAEncryption
 | 
				
			||||||
 | 
					        8c:3b:7e:f1:74:12:d1:2f:ac:d4:bf:2d:8b:aa:02:05:30:fe:
 | 
				
			||||||
 | 
					        d1:f4:14:b8:02:92:a2:8b:99:86:26:ff:24:7e:67:48:43:d9:
 | 
				
			||||||
 | 
					        e3:ff:52:11:7e:8c:0c:26:57:ca:c7:b4:19:da:4c:ce:e8:37:
 | 
				
			||||||
 | 
					        6d:d1:55:6d:a4:09:ff:2c:a2:21:9f:af:63:d8:b5:fb:9f:a5:
 | 
				
			||||||
 | 
					        7b:5d:ed:ac:d4:15:af:96:24:25:a7:a7:43:76:f4:41:b4:05:
 | 
				
			||||||
 | 
					        1d:49:38:50:b4:43:fe:1d:87:f5:fd:aa:e9:4c:f2:5b:aa:3e:
 | 
				
			||||||
 | 
					        3a:e6:c3:67:92:81:b7:66:99:db:a6:58:07:0d:3d:56:d5
 | 
				
			||||||
 | 
					-----BEGIN CERTIFICATE-----
 | 
				
			||||||
 | 
					MIICTjCCAbsCEGiuFKTJn6nzmiPPLxUZs1owDQYJKoZIhvcNAQEEBQAwXzELMAkG
 | 
				
			||||||
 | 
					A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD
 | 
				
			||||||
 | 
					VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk4
 | 
				
			||||||
 | 
					MDUxODAwMDAwMFoXDTk5MDUxODIzNTk1OVowdTELMAkGA1UEBhMCVVMxETAPBgNV
 | 
				
			||||||
 | 
					BAgTCE5ldyBZb3JrMREwDwYDVQQHFAhOZXcgWW9yazEeMBwGA1UEChQVSW5kdXN0
 | 
				
			||||||
 | 
					cmlhbCBQcmVzcyBJbmMuMSAwHgYDVQQDFBd3d3cuaW5kdXN0cmlhbHByZXNzLmNv
 | 
				
			||||||
 | 
					bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAqiH9xUJNHvqCmaDon27ValJb
 | 
				
			||||||
 | 
					qTLymF3yKKWBxbODLWjX7yKjewoqWhotaEARI6jXPqomU87gFU1tH4r/bgwh3FmU
 | 
				
			||||||
 | 
					MK3qo92XOsvwNAHzXzWRXQNJmm54g2F1RUt00pgYiOximDse1t9RL5POCDEbfX8D
 | 
				
			||||||
 | 
					gugrE/WwkS2FrSoc5/cCAwEAATANBgkqhkiG9w0BAQQFAAN+AIw7fvF0EtEvrNS/
 | 
				
			||||||
 | 
					LYuqAgUw/tH0FLgCkqKLmYYm/yR+Z0hD2eP/UhF+jAwmV8rHtBnaTM7oN23RVW2k
 | 
				
			||||||
 | 
					Cf8soiGfr2PYtfufpXtd7azUFa+WJCWnp0N29EG0BR1JOFC0Q/4dh/X9qulM8luq
 | 
				
			||||||
 | 
					Pjrmw2eSgbdmmdumWAcNPVbV
 | 
				
			||||||
 | 
					-----END CERTIFICATE-----
 | 
				
			||||||
							
								
								
									
										47
									
								
								apps/rsa/SecureServer.pem
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								apps/rsa/SecureServer.pem
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					Certificate:
 | 
				
			||||||
 | 
					    Data:
 | 
				
			||||||
 | 
					        Version: 1 (0x0)
 | 
				
			||||||
 | 
					        Serial Number:
 | 
				
			||||||
 | 
					            02:ad:66:7e:4e:45:fe:5e:57:6f:3c:98:19:5e:dd:c0
 | 
				
			||||||
 | 
					        Signature Algorithm: md2WithRSAEncryption
 | 
				
			||||||
 | 
					        Issuer: C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					        Validity
 | 
				
			||||||
 | 
					            Not Before: Nov  9 00:00:00 1994 GMT
 | 
				
			||||||
 | 
					            Not After : Jan  7 23:59:59 2010 GMT
 | 
				
			||||||
 | 
					        Subject: C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					        Subject Public Key Info:
 | 
				
			||||||
 | 
					            Public Key Algorithm: rsaEncryption
 | 
				
			||||||
 | 
					            RSA Public Key: (1000 bit)
 | 
				
			||||||
 | 
					                Modulus (1000 bit):
 | 
				
			||||||
 | 
					                    00:92:ce:7a:c1:ae:83:3e:5a:aa:89:83:57:ac:25:
 | 
				
			||||||
 | 
					                    01:76:0c:ad:ae:8e:2c:37:ce:eb:35:78:64:54:03:
 | 
				
			||||||
 | 
					                    e5:84:40:51:c9:bf:8f:08:e2:8a:82:08:d2:16:86:
 | 
				
			||||||
 | 
					                    37:55:e9:b1:21:02:ad:76:68:81:9a:05:a2:4b:c9:
 | 
				
			||||||
 | 
					                    4b:25:66:22:56:6c:88:07:8f:f7:81:59:6d:84:07:
 | 
				
			||||||
 | 
					                    65:70:13:71:76:3e:9b:77:4c:e3:50:89:56:98:48:
 | 
				
			||||||
 | 
					                    b9:1d:a7:29:1a:13:2e:4a:11:59:9c:1e:15:d5:49:
 | 
				
			||||||
 | 
					                    54:2c:73:3a:69:82:b1:97:39:9c:6d:70:67:48:e5:
 | 
				
			||||||
 | 
					                    dd:2d:d6:c8:1e:7b
 | 
				
			||||||
 | 
					                Exponent: 65537 (0x10001)
 | 
				
			||||||
 | 
					    Signature Algorithm: md2WithRSAEncryption
 | 
				
			||||||
 | 
					        65:dd:7e:e1:b2:ec:b0:e2:3a:e0:ec:71:46:9a:19:11:b8:d3:
 | 
				
			||||||
 | 
					        c7:a0:b4:03:40:26:02:3e:09:9c:e1:12:b3:d1:5a:f6:37:a5:
 | 
				
			||||||
 | 
					        b7:61:03:b6:5b:16:69:3b:c6:44:08:0c:88:53:0c:6b:97:49:
 | 
				
			||||||
 | 
					        c7:3e:35:dc:6c:b9:bb:aa:df:5c:bb:3a:2f:93:60:b6:a9:4b:
 | 
				
			||||||
 | 
					        4d:f2:20:f7:cd:5f:7f:64:7b:8e:dc:00:5c:d7:fa:77:ca:39:
 | 
				
			||||||
 | 
					        16:59:6f:0e:ea:d3:b5:83:7f:4d:4d:42:56:76:b4:c9:5f:04:
 | 
				
			||||||
 | 
					        f8:38:f8:eb:d2:5f:75:5f:cd:7b:fc:e5:8e:80:7c:fc:50
 | 
				
			||||||
 | 
					-----BEGIN CERTIFICATE-----
 | 
				
			||||||
 | 
					MIICNDCCAaECEAKtZn5ORf5eV288mBle3cAwDQYJKoZIhvcNAQECBQAwXzELMAkG
 | 
				
			||||||
 | 
					A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD
 | 
				
			||||||
 | 
					VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk0
 | 
				
			||||||
 | 
					MTEwOTAwMDAwMFoXDTEwMDEwNzIzNTk1OVowXzELMAkGA1UEBhMCVVMxIDAeBgNV
 | 
				
			||||||
 | 
					BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUgU2Vy
 | 
				
			||||||
 | 
					dmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGbMA0GCSqGSIb3DQEBAQUAA4GJ
 | 
				
			||||||
 | 
					ADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwjiioII
 | 
				
			||||||
 | 
					0haGN1XpsSECrXZogZoFokvJSyVmIlZsiAeP94FZbYQHZXATcXY+m3dM41CJVphI
 | 
				
			||||||
 | 
					uR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJKoZI
 | 
				
			||||||
 | 
					hvcNAQECBQADfgBl3X7hsuyw4jrg7HFGmhkRuNPHoLQDQCYCPgmc4RKz0Vr2N6W3
 | 
				
			||||||
 | 
					YQO2WxZpO8ZECAyIUwxrl0nHPjXcbLm7qt9cuzovk2C2qUtN8iD3zV9/ZHuO3ABc
 | 
				
			||||||
 | 
					1/p3yjkWWW8O6tO1g39NTUJWdrTJXwT4OPjr0l91X817/OWOgHz8UA==
 | 
				
			||||||
 | 
					-----END CERTIFICATE-----
 | 
				
			||||||
							
								
								
									
										49
									
								
								apps/rsa/s.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								apps/rsa/s.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					Certificate:
 | 
				
			||||||
 | 
					    Data:
 | 
				
			||||||
 | 
					        Version: 1 (0x0)
 | 
				
			||||||
 | 
					        Serial Number:
 | 
				
			||||||
 | 
					            02:ad:66:7e:4e:45:fe:5e:57:6f:3c:98:19:5e:dd:c0
 | 
				
			||||||
 | 
					        Signature Algorithm: md2WithRSAEncryption
 | 
				
			||||||
 | 
					        Issuer: C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					        Validity
 | 
				
			||||||
 | 
					            Not Before: Nov  9 00:00:00 1994 GMT
 | 
				
			||||||
 | 
					            Not After : Jan  7 23:59:59 2010 GMT
 | 
				
			||||||
 | 
					        Subject: C=US, O=RSA Data Security, Inc., OU=Secure Server Certification Authority
 | 
				
			||||||
 | 
					        Subject Public Key Info:
 | 
				
			||||||
 | 
					            Public Key Algorithm: rsaEncryption
 | 
				
			||||||
 | 
					            RSA Public Key: (1000 bit)
 | 
				
			||||||
 | 
					                Modulus (1000 bit):
 | 
				
			||||||
 | 
					                    00:92:ce:7a:c1:ae:83:3e:5a:aa:89:83:57:ac:25:
 | 
				
			||||||
 | 
					                    01:76:0c:ad:ae:8e:2c:37:ce:eb:35:78:64:54:03:
 | 
				
			||||||
 | 
					                    e5:84:40:51:c9:bf:8f:08:e2:8a:82:08:d2:16:86:
 | 
				
			||||||
 | 
					                    37:55:e9:b1:21:02:ad:76:68:81:9a:05:a2:4b:c9:
 | 
				
			||||||
 | 
					                    4b:25:66:22:56:6c:88:07:8f:f7:81:59:6d:84:07:
 | 
				
			||||||
 | 
					                    65:70:13:71:76:3e:9b:77:4c:e3:50:89:56:98:48:
 | 
				
			||||||
 | 
					                    b9:1d:a7:29:1a:13:2e:4a:11:59:9c:1e:15:d5:49:
 | 
				
			||||||
 | 
					                    54:2c:73:3a:69:82:b1:97:39:9c:6d:70:67:48:e5:
 | 
				
			||||||
 | 
					                    dd:2d:d6:c8:1e:7b
 | 
				
			||||||
 | 
					                Exponent: 65537 (0x10001)
 | 
				
			||||||
 | 
					    Signature Algorithm: md2WithRSAEncryption
 | 
				
			||||||
 | 
					        65:dd:7e:e1:b2:ec:b0:e2:3a:e0:ec:71:46:9a:19:11:b8:d3:
 | 
				
			||||||
 | 
					        c7:a0:b4:03:40:26:02:3e:09:9c:e1:12:b3:d1:5a:f6:37:a5:
 | 
				
			||||||
 | 
					        b7:61:03:b6:5b:16:69:3b:c6:44:08:0c:88:53:0c:6b:97:49:
 | 
				
			||||||
 | 
					        c7:3e:35:dc:6c:b9:bb:aa:df:5c:bb:3a:2f:93:60:b6:a9:4b:
 | 
				
			||||||
 | 
					        4d:f2:20:f7:cd:5f:7f:64:7b:8e:dc:00:5c:d7:fa:77:ca:39:
 | 
				
			||||||
 | 
					        16:59:6f:0e:ea:d3:b5:83:7f:4d:4d:42:56:76:b4:c9:5f:04:
 | 
				
			||||||
 | 
					        f8:38:f8:eb:d2:5f:75:5f:cd:7b:fc:e5:8e:80:7c:fc:50
 | 
				
			||||||
 | 
					-----BEGIN CERTIFICATE-----
 | 
				
			||||||
 | 
					MIICNDCCAaECEAKtZn5ORf5eV288mBle3cAwDQYJKoZIhvcNAQECBQAwXzELMAkG
 | 
				
			||||||
 | 
					A1UEBhMCVVMxIDAeBgNVBAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYD
 | 
				
			||||||
 | 
					VQQLEyVTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk0
 | 
				
			||||||
 | 
					MTEwOTAwMDAwMFoXDTEwMDEwNzIzNTk1OVowXzELMAkGA1UEBhMCVVMxIDAeBgNV
 | 
				
			||||||
 | 
					BAoTF1JTQSBEYXRhIFNlY3VyaXR5LCBJbmMuMS4wLAYDVQQLEyVTZWN1cmUgU2Vy
 | 
				
			||||||
 | 
					dmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGbMA0GCSqGSIb3DQEBAQUAA4GJ
 | 
				
			||||||
 | 
					ADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwjiioII
 | 
				
			||||||
 | 
					0haGN1XpsSECrXZogZoFokvJSyVmIlZsiAeP94FZbYQHZXATcXY+m3dM41CJVphI
 | 
				
			||||||
 | 
					uR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJKoZI
 | 
				
			||||||
 | 
					hvcNAQECBQADfgBl3X7hsuyw4jrg7HFGmhkRuNPHoLQDQCYCPgmc4RKz0Vr2N6W3
 | 
				
			||||||
 | 
					YQO2WxZpO8ZECAyIUwxrl0nHPjXcbLm7qt9cuzovk2C2qUtN8iD3zV9/ZHuO3ABc
 | 
				
			||||||
 | 
					1/p3yjkWWW8O6tO1g39NTUJWdrTJXwT4OPjr0l91X817/OWOgHz8UA==
 | 
				
			||||||
 | 
					-----END CERTIFICATE-----
 | 
				
			||||||
							
								
								
									
										319
									
								
								apps/rsautl.c
									
									
									
									
									
								
							
							
						
						
									
										319
									
								
								apps/rsautl.c
									
									
									
									
									
								
							@@ -1,319 +0,0 @@
 | 
				
			|||||||
/* rsautl.c */
 | 
					 | 
				
			||||||
/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
 | 
					 | 
				
			||||||
 * project 2000.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* ====================================================================
 | 
					 | 
				
			||||||
 * Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 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 above 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 acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
 | 
					 | 
				
			||||||
 *    endorse or promote products derived from this software without
 | 
					 | 
				
			||||||
 *    prior written permission. For written permission, please contact
 | 
					 | 
				
			||||||
 *    licensing@OpenSSL.org.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 5. Products derived from this software may not be called "OpenSSL"
 | 
					 | 
				
			||||||
 *    nor may "OpenSSL" appear in their names without prior written
 | 
					 | 
				
			||||||
 *    permission of the OpenSSL Project.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * 6. Redistributions of any form whatsoever must retain the following
 | 
					 | 
				
			||||||
 *    acknowledgment:
 | 
					 | 
				
			||||||
 *    "This product includes software developed by the OpenSSL Project
 | 
					 | 
				
			||||||
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
 | 
					 | 
				
			||||||
 * EXPRESSED 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 OpenSSL PROJECT OR
 | 
					 | 
				
			||||||
 * ITS 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.
 | 
					 | 
				
			||||||
 * ====================================================================
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * This product includes cryptographic software written by Eric Young
 | 
					 | 
				
			||||||
 * (eay@cryptsoft.com).  This product includes software written by Tim
 | 
					 | 
				
			||||||
 * Hudson (tjh@cryptsoft.com).
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef NO_RSA
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "apps.h"
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include <openssl/err.h>
 | 
					 | 
				
			||||||
#include <openssl/pem.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define RSA_SIGN 	1
 | 
					 | 
				
			||||||
#define RSA_VERIFY 	2
 | 
					 | 
				
			||||||
#define RSA_ENCRYPT 	3
 | 
					 | 
				
			||||||
#define RSA_DECRYPT 	4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define KEY_PRIVKEY	1
 | 
					 | 
				
			||||||
#define KEY_PUBKEY	2
 | 
					 | 
				
			||||||
#define KEY_CERT	3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void usage(void);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#undef PROG
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define PROG rsautl_main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	ENGINE *e = NULL;
 | 
					 | 
				
			||||||
	BIO *in = NULL, *out = NULL;
 | 
					 | 
				
			||||||
	char *infile = NULL, *outfile = NULL;
 | 
					 | 
				
			||||||
	char *keyfile = NULL;
 | 
					 | 
				
			||||||
	char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY;
 | 
					 | 
				
			||||||
	int keyform = FORMAT_PEM;
 | 
					 | 
				
			||||||
	char need_priv = 0, badarg = 0, rev = 0;
 | 
					 | 
				
			||||||
	char hexdump = 0, asn1parse = 0;
 | 
					 | 
				
			||||||
	X509 *x;
 | 
					 | 
				
			||||||
	EVP_PKEY *pkey = NULL;
 | 
					 | 
				
			||||||
	RSA *rsa = NULL;
 | 
					 | 
				
			||||||
	unsigned char *rsa_in = NULL, *rsa_out = NULL, pad;
 | 
					 | 
				
			||||||
	int rsa_inlen, rsa_outlen = 0;
 | 
					 | 
				
			||||||
	int keysize;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int ret = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	argc--;
 | 
					 | 
				
			||||||
	argv++;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!bio_err) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
	ERR_load_crypto_strings();
 | 
					 | 
				
			||||||
	OpenSSL_add_all_algorithms();
 | 
					 | 
				
			||||||
	pad = RSA_PKCS1_PADDING;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	while(argc >= 1)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		if (!strcmp(*argv,"-in")) {
 | 
					 | 
				
			||||||
			if (--argc < 1) badarg = 1;
 | 
					 | 
				
			||||||
                        infile= *(++argv);
 | 
					 | 
				
			||||||
		} else if (!strcmp(*argv,"-out")) {
 | 
					 | 
				
			||||||
			if (--argc < 1) badarg = 1;
 | 
					 | 
				
			||||||
			outfile= *(++argv);
 | 
					 | 
				
			||||||
		} else if(!strcmp(*argv, "-inkey")) {
 | 
					 | 
				
			||||||
			if (--argc < 1) badarg = 1;
 | 
					 | 
				
			||||||
			keyfile = *(++argv);
 | 
					 | 
				
			||||||
		} else if(!strcmp(*argv, "-engine")) {
 | 
					 | 
				
			||||||
			if (--argc < 1) badarg = 1;
 | 
					 | 
				
			||||||
			engine = *(++argv);
 | 
					 | 
				
			||||||
		} else if(!strcmp(*argv, "-pubin")) {
 | 
					 | 
				
			||||||
			key_type = KEY_PUBKEY;
 | 
					 | 
				
			||||||
		} else if(!strcmp(*argv, "-certin")) {
 | 
					 | 
				
			||||||
			key_type = KEY_CERT;
 | 
					 | 
				
			||||||
		} 
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-asn1parse")) asn1parse = 1;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-hexdump")) hexdump = 1;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-raw")) pad = RSA_NO_PADDING;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-oaep")) pad = RSA_PKCS1_OAEP_PADDING;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-ssl")) pad = RSA_SSLV23_PADDING;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-pkcs")) pad = RSA_PKCS1_PADDING;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-sign")) {
 | 
					 | 
				
			||||||
			rsa_mode = RSA_SIGN;
 | 
					 | 
				
			||||||
			need_priv = 1;
 | 
					 | 
				
			||||||
		} else if(!strcmp(*argv, "-verify")) rsa_mode = RSA_VERIFY;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-rev")) rev = 1;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-encrypt")) rsa_mode = RSA_ENCRYPT;
 | 
					 | 
				
			||||||
		else if(!strcmp(*argv, "-decrypt")) {
 | 
					 | 
				
			||||||
			rsa_mode = RSA_DECRYPT;
 | 
					 | 
				
			||||||
			need_priv = 1;
 | 
					 | 
				
			||||||
		} else badarg = 1;
 | 
					 | 
				
			||||||
		if(badarg) {
 | 
					 | 
				
			||||||
			usage();
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		argc--;
 | 
					 | 
				
			||||||
		argv++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(need_priv && (key_type != KEY_PRIVKEY)) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "A private key is needed for this operation\n");
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine \"%s\"\n",
 | 
					 | 
				
			||||||
				engine);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		/* Free our "structural" reference. */
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* FIXME: seed PRNG only if needed */
 | 
					 | 
				
			||||||
	app_RAND_load_file(NULL, bio_err, 0);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	switch(key_type) {
 | 
					 | 
				
			||||||
		case KEY_PRIVKEY:
 | 
					 | 
				
			||||||
		pkey = load_key(bio_err, keyfile, keyform, NULL);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case KEY_PUBKEY:
 | 
					 | 
				
			||||||
		pkey = load_pubkey(bio_err, keyfile, keyform);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case KEY_CERT:
 | 
					 | 
				
			||||||
		x = load_cert(bio_err, keyfile, keyform);
 | 
					 | 
				
			||||||
		if(x) {
 | 
					 | 
				
			||||||
			pkey = X509_get_pubkey(x);
 | 
					 | 
				
			||||||
			X509_free(x);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!pkey) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error loading key\n");
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rsa = EVP_PKEY_get1_RSA(pkey);
 | 
					 | 
				
			||||||
	EVP_PKEY_free(pkey);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!rsa) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error getting RSA key\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(infile) {
 | 
					 | 
				
			||||||
		if(!(in = BIO_new_file(infile, "rb"))) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error Reading Input File\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);	
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else in = BIO_new_fp(stdin, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(outfile) {
 | 
					 | 
				
			||||||
		if(!(out = BIO_new_file(outfile, "wb"))) {
 | 
					 | 
				
			||||||
			BIO_printf(bio_err, "Error Reading Output File\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);	
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		out = BIO_new_fp(stdout, BIO_NOCLOSE);
 | 
					 | 
				
			||||||
#ifdef VMS
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		    BIO *tmpbio = BIO_new(BIO_f_linebuffer());
 | 
					 | 
				
			||||||
		    out = BIO_push(tmpbio, out);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	keysize = RSA_size(rsa);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rsa_in = OPENSSL_malloc(keysize * 2);
 | 
					 | 
				
			||||||
	rsa_out = OPENSSL_malloc(keysize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Read the input data */
 | 
					 | 
				
			||||||
	rsa_inlen = BIO_read(in, rsa_in, keysize * 2);
 | 
					 | 
				
			||||||
	if(rsa_inlen <= 0) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "Error reading input Data\n");
 | 
					 | 
				
			||||||
		exit(1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(rev) {
 | 
					 | 
				
			||||||
		int i;
 | 
					 | 
				
			||||||
		unsigned char ctmp;
 | 
					 | 
				
			||||||
		for(i = 0; i < rsa_inlen/2; i++) {
 | 
					 | 
				
			||||||
			ctmp = rsa_in[i];
 | 
					 | 
				
			||||||
			rsa_in[i] = rsa_in[rsa_inlen - 1 - i];
 | 
					 | 
				
			||||||
			rsa_in[rsa_inlen - 1 - i] = ctmp;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	switch(rsa_mode) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case RSA_VERIFY:
 | 
					 | 
				
			||||||
			rsa_outlen  = RSA_public_decrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case RSA_SIGN:
 | 
					 | 
				
			||||||
			rsa_outlen  = RSA_private_encrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case RSA_ENCRYPT:
 | 
					 | 
				
			||||||
			rsa_outlen  = RSA_public_encrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case RSA_DECRYPT:
 | 
					 | 
				
			||||||
			rsa_outlen  = RSA_private_decrypt(rsa_inlen, rsa_in, rsa_out, rsa, pad);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(rsa_outlen <= 0) {
 | 
					 | 
				
			||||||
		BIO_printf(bio_err, "RSA operation error\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	ret = 0;
 | 
					 | 
				
			||||||
	if(asn1parse) {
 | 
					 | 
				
			||||||
		if(!ASN1_parse_dump(out, rsa_out, rsa_outlen, 1, -1)) {
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else if(hexdump) BIO_dump(out, (char *)rsa_out, rsa_outlen);
 | 
					 | 
				
			||||||
	else BIO_write(out, rsa_out, rsa_outlen);
 | 
					 | 
				
			||||||
	end:
 | 
					 | 
				
			||||||
	RSA_free(rsa);
 | 
					 | 
				
			||||||
	BIO_free(in);
 | 
					 | 
				
			||||||
	BIO_free_all(out);
 | 
					 | 
				
			||||||
	if(rsa_in) OPENSSL_free(rsa_in);
 | 
					 | 
				
			||||||
	if(rsa_out) OPENSSL_free(rsa_out);
 | 
					 | 
				
			||||||
	return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void usage()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "Usage: rsautl [options]\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-in file        input file\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-out file       output file\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-inkey file     input key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-pubin          input is an RSA public\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-certin         input is a certificate carrying an RSA public key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-engine e       use engine e, possibly a hardware device.\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-ssl            use SSL v2 padding\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-raw            use no padding\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-pkcs           use PKCS#1 v1.5 padding (default)\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-oaep           use PKCS#1 OAEP\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-sign           sign with private key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-verify         verify with public key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-encrypt        encrypt with public key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-decrypt        decrypt with private key\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err, "-hexdump        hex dump output\n");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@@ -84,6 +84,7 @@ typedef fd_mask fd_set;
 | 
				
			|||||||
#define PORT_STR        "4433"
 | 
					#define PORT_STR        "4433"
 | 
				
			||||||
#define PROTOCOL        "tcp"
 | 
					#define PROTOCOL        "tcp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int do_accept(int acc_sock, int *sock, char **host);
 | 
				
			||||||
int do_server(int port, int *ret, int (*cb) (), char *context);
 | 
					int do_server(int port, int *ret, int (*cb) (), char *context);
 | 
				
			||||||
#ifdef HEADER_X509_H
 | 
					#ifdef HEADER_X509_H
 | 
				
			||||||
int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 | 
					int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 | 
				
			||||||
@@ -96,9 +97,17 @@ int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
 | 
				
			|||||||
int set_cert_stuff(char *ctx, char *cert_file, char *key_file);
 | 
					int set_cert_stuff(char *ctx, char *cert_file, char *key_file);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
int init_client(int *sock, char *server, int port);
 | 
					int init_client(int *sock, char *server, int port);
 | 
				
			||||||
 | 
					int init_client_ip(int *sock,unsigned char ip[4], int port);
 | 
				
			||||||
 | 
					int nbio_init_client_ip(int *sock,unsigned char ip[4], int port);
 | 
				
			||||||
 | 
					int nbio_sock_error(int sock);
 | 
				
			||||||
 | 
					int spawn(int argc, char **argv, int *in, int *out);
 | 
				
			||||||
 | 
					int init_server(int *sock, int port);
 | 
				
			||||||
 | 
					int init_server_long(int *sock, int port,char *ip);
 | 
				
			||||||
int should_retry(int i);
 | 
					int should_retry(int i);
 | 
				
			||||||
 | 
					void sock_cleanup(void );
 | 
				
			||||||
int extract_port(char *str, short *port_ptr);
 | 
					int extract_port(char *str, short *port_ptr);
 | 
				
			||||||
int extract_host_port(char *str,char **host_ptr,unsigned char *ip,short *p);
 | 
					int extract_host_port(char *str,char **host_ptr,unsigned char *ip,short *p);
 | 
				
			||||||
 | 
					int host_ip(char *str, unsigned char ip[4]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp,
 | 
					long MS_CALLBACK bio_dump_cb(BIO *bio, int cmd, const char *argp,
 | 
				
			||||||
	int argi, long argl, long ret);
 | 
						int argi, long argl, long ret);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* apps/s_cb.c - callback functions used by s_client, s_server, and s_time */
 | 
					/* apps/s_cb.c */
 | 
				
			||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
					/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
				
			||||||
 * All rights reserved.
 | 
					 * All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										203
									
								
								apps/s_client.c
									
									
									
									
									
								
							
							
						
						
									
										203
									
								
								apps/s_client.c
									
									
									
									
									
								
							@@ -56,43 +56,38 @@
 | 
				
			|||||||
 * [including the GNU Public Licence.]
 | 
					 * [including the GNU Public Licence.]
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#ifdef NO_STDIO
 | 
					 | 
				
			||||||
#define APPS_WIN16
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
					/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
				
			||||||
   recursive header file inclusion, resulting in the compiler complaining
 | 
					   recursive header file inclusion, resulting in the compiler complaining
 | 
				
			||||||
   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
					   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
				
			||||||
   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
					   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
				
			||||||
#if defined(VMS) && defined(__DECC) && !defined(__U_INT)
 | 
					#if defined(__DECC) && !defined(__U_INT)
 | 
				
			||||||
#define __U_INT
 | 
					#define __U_INT
 | 
				
			||||||
typedef unsigned int u_int;
 | 
					typedef unsigned int u_int;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
#define USE_SOCKETS
 | 
					#define USE_SOCKETS
 | 
				
			||||||
 | 
					#ifdef NO_STDIO
 | 
				
			||||||
 | 
					#define APPS_WIN16
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					#include <openssl/ssl.h>
 | 
				
			||||||
#include <openssl/err.h>
 | 
					#include <openssl/err.h>
 | 
				
			||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
#include "s_apps.h"
 | 
					#include "s_apps.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
#include <conio.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if (defined(VMS) && __VMS_VER < 70000000)
 | 
					#if (defined(VMS) && __VMS_VER < 70000000)
 | 
				
			||||||
/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 | 
					/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 | 
				
			||||||
#undef FIONBIO
 | 
					#undef FIONBIO
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(NO_RSA) && !defined(NO_SSL2)
 | 
				
			||||||
 | 
					#define NO_SSL2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG	s_client_main
 | 
					#define PROG	s_client_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -119,7 +114,6 @@ static void sc_usage(void);
 | 
				
			|||||||
static void print_stuff(BIO *berr,SSL *con,int full);
 | 
					static void print_stuff(BIO *berr,SSL *con,int full);
 | 
				
			||||||
static BIO *bio_c_out=NULL;
 | 
					static BIO *bio_c_out=NULL;
 | 
				
			||||||
static int c_quiet=0;
 | 
					static int c_quiet=0;
 | 
				
			||||||
static int c_ign_eof=0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sc_usage(void)
 | 
					static void sc_usage(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -144,21 +138,16 @@ static void sc_usage(void)
 | 
				
			|||||||
#ifdef FIONBIO
 | 
					#ifdef FIONBIO
 | 
				
			||||||
	BIO_printf(bio_err," -nbio         - Run with non-blocking IO\n");
 | 
						BIO_printf(bio_err," -nbio         - Run with non-blocking IO\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	BIO_printf(bio_err," -crlf         - convert LF from terminal into CRLF\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -quiet        - no s_client output\n");
 | 
						BIO_printf(bio_err," -quiet        - no s_client output\n");
 | 
				
			||||||
	BIO_printf(bio_err," -ign_eof      - ignore input eof (default when -quiet)\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -ssl2         - just use SSLv2\n");
 | 
						BIO_printf(bio_err," -ssl2         - just use SSLv2\n");
 | 
				
			||||||
	BIO_printf(bio_err," -ssl3         - just use SSLv3\n");
 | 
						BIO_printf(bio_err," -ssl3         - just use SSLv3\n");
 | 
				
			||||||
	BIO_printf(bio_err," -tls1         - just use TLSv1\n");
 | 
						BIO_printf(bio_err," -tls1         - just use TLSv1\n");
 | 
				
			||||||
	BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
 | 
						BIO_printf(bio_err," -no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
 | 
				
			||||||
	BIO_printf(bio_err," -bugs         - Switch on all SSL implementation bug workarounds\n");
 | 
						BIO_printf(bio_err," -bugs         - Switch on all SSL implementation bug workarounds\n");
 | 
				
			||||||
	BIO_printf(bio_err," -cipher       - preferred cipher to use, use the 'openssl ciphers'\n");
 | 
						BIO_printf(bio_err," -cipher       - prefered cipher to use, use the 'openssl ciphers'\n");
 | 
				
			||||||
	BIO_printf(bio_err,"                 command to see what is available\n");
 | 
						BIO_printf(bio_err,"                 command to see what is available\n");
 | 
				
			||||||
	BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -engine id    - Initialise and use the specified engine\n");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int, char **);
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -175,19 +164,12 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	char *cert_file=NULL,*key_file=NULL;
 | 
						char *cert_file=NULL,*key_file=NULL;
 | 
				
			||||||
	char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
 | 
						char *CApath=NULL,*CAfile=NULL,*cipher=NULL;
 | 
				
			||||||
	int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
 | 
						int reconnect=0,badop=0,verify=SSL_VERIFY_NONE,bugs=0;
 | 
				
			||||||
	int crlf=0;
 | 
					 | 
				
			||||||
	int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
 | 
						int write_tty,read_tty,write_ssl,read_ssl,tty_on,ssl_pending;
 | 
				
			||||||
	SSL_CTX *ctx=NULL;
 | 
						SSL_CTX *ctx=NULL;
 | 
				
			||||||
	int ret=1,in_init=1,i,nbio_test=0;
 | 
						int ret=1,in_init=1,i,nbio_test=0;
 | 
				
			||||||
	int prexit = 0;
 | 
					 | 
				
			||||||
	SSL_METHOD *meth=NULL;
 | 
						SSL_METHOD *meth=NULL;
 | 
				
			||||||
	BIO *sbio;
 | 
						BIO *sbio;
 | 
				
			||||||
	char *inrand=NULL;
 | 
						/*static struct timeval timeout={10,0};*/
 | 
				
			||||||
	char *engine_id=NULL;
 | 
					 | 
				
			||||||
	ENGINE *e=NULL;
 | 
					 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
	struct timeval tv;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(NO_SSL2) && !defined(NO_SSL3)
 | 
					#if !defined(NO_SSL2) && !defined(NO_SSL3)
 | 
				
			||||||
	meth=SSLv23_client_method();
 | 
						meth=SSLv23_client_method();
 | 
				
			||||||
@@ -200,15 +182,14 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
	c_Pause=0;
 | 
						c_Pause=0;
 | 
				
			||||||
	c_quiet=0;
 | 
						c_quiet=0;
 | 
				
			||||||
	c_ign_eof=0;
 | 
					 | 
				
			||||||
	c_debug=0;
 | 
						c_debug=0;
 | 
				
			||||||
	c_showcerts=0;
 | 
						c_showcerts=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bio_err == NULL)
 | 
						if (bio_err == NULL)
 | 
				
			||||||
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
							bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (	((cbuf=OPENSSL_malloc(BUFSIZZ)) == NULL) ||
 | 
						if (	((cbuf=Malloc(BUFSIZZ)) == NULL) ||
 | 
				
			||||||
		((sbuf=OPENSSL_malloc(BUFSIZZ)) == NULL))
 | 
							((sbuf=Malloc(BUFSIZZ)) == NULL))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"out of memory\n");
 | 
							BIO_printf(bio_err,"out of memory\n");
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
@@ -253,17 +234,8 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			cert_file= *(++argv);
 | 
								cert_file= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if	(strcmp(*argv,"-prexit") == 0)
 | 
					 | 
				
			||||||
			prexit=1;
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-crlf") == 0)
 | 
					 | 
				
			||||||
			crlf=1;
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-quiet") == 0)
 | 
							else if	(strcmp(*argv,"-quiet") == 0)
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			c_quiet=1;
 | 
								c_quiet=1;
 | 
				
			||||||
			c_ign_eof=1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-ign_eof") == 0)
 | 
					 | 
				
			||||||
			c_ign_eof=1;
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-pause") == 0)
 | 
							else if	(strcmp(*argv,"-pause") == 0)
 | 
				
			||||||
			c_Pause=1;
 | 
								c_Pause=1;
 | 
				
			||||||
		else if	(strcmp(*argv,"-debug") == 0)
 | 
							else if	(strcmp(*argv,"-debug") == 0)
 | 
				
			||||||
@@ -322,16 +294,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
		else if (strcmp(*argv,"-nbio") == 0)
 | 
							else if (strcmp(*argv,"-nbio") == 0)
 | 
				
			||||||
			{ c_nbio=1; }
 | 
								{ c_nbio=1; }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			inrand= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine_id = *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -348,15 +310,6 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
 | 
					 | 
				
			||||||
		&& !RAND_status())
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (inrand != NULL)
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_c_out == NULL)
 | 
						if (bio_c_out == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (c_quiet)
 | 
							if (c_quiet)
 | 
				
			||||||
@@ -370,32 +323,7 @@ bad:
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	OpenSSL_add_ssl_algorithms();
 | 
						SSLeay_add_ssl_algorithms();
 | 
				
			||||||
	SSL_load_error_strings();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine_id != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine_id)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (c_debug)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
 | 
					 | 
				
			||||||
				0, bio_err, 0);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine_id);
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ctx=SSL_CTX_new(meth);
 | 
						ctx=SSL_CTX_new(meth);
 | 
				
			||||||
	if (ctx == NULL)
 | 
						if (ctx == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -410,11 +338,7 @@ bad:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
 | 
						if (state) SSL_CTX_set_info_callback(ctx,apps_ssl_info_callback);
 | 
				
			||||||
	if (cipher != NULL)
 | 
						if (cipher != NULL)
 | 
				
			||||||
		if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
 | 
							SSL_CTX_set_cipher_list(ctx,cipher);
 | 
				
			||||||
		BIO_printf(bio_err,"error setting cipher list\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
 | 
							SSL_CTX_set_cipher_list(ctx,getenv("SSL_CIPHER"));
 | 
				
			||||||
@@ -427,13 +351,14 @@ bad:
 | 
				
			|||||||
	if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
 | 
						if ((!SSL_CTX_load_verify_locations(ctx,CAfile,CApath)) ||
 | 
				
			||||||
		(!SSL_CTX_set_default_verify_paths(ctx)))
 | 
							(!SSL_CTX_set_default_verify_paths(ctx)))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		/* BIO_printf(bio_err,"error setting default verify locations\n"); */
 | 
							/* BIO_printf(bio_err,"error seting default verify locations\n"); */
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		/* goto end; */
 | 
							/* goto end; */
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SSL_load_error_strings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	con=SSL_new(ctx);
 | 
						con=(SSL *)SSL_new(ctx);
 | 
				
			||||||
/*	SSL_set_cipher_list(con,"RC4-MD5"); */
 | 
					/*	SSL_set_cipher_list(con,"RC4-MD5"); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
re_start:
 | 
					re_start:
 | 
				
			||||||
@@ -534,18 +459,12 @@ re_start:
 | 
				
			|||||||
				if (read_tty)  FD_SET(fileno(stdin),&readfds);
 | 
									if (read_tty)  FD_SET(fileno(stdin),&readfds);
 | 
				
			||||||
				if (write_tty) FD_SET(fileno(stdout),&writefds);
 | 
									if (write_tty) FD_SET(fileno(stdout),&writefds);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
			if (read_ssl)
 | 
								if (read_ssl)
 | 
				
			||||||
				FD_SET(SSL_get_fd(con),&readfds);
 | 
									FD_SET(SSL_get_fd(con),&readfds);
 | 
				
			||||||
			if (write_ssl)
 | 
								if (write_ssl)
 | 
				
			||||||
				FD_SET(SSL_get_fd(con),&writefds);
 | 
									FD_SET(SSL_get_fd(con),&writefds);
 | 
				
			||||||
#else
 | 
					
 | 
				
			||||||
			if(!tty_on || !write_tty) {
 | 
					 | 
				
			||||||
				if (read_ssl)
 | 
					 | 
				
			||||||
					FD_SET(SSL_get_fd(con),&readfds);
 | 
					 | 
				
			||||||
				if (write_ssl)
 | 
					 | 
				
			||||||
					FD_SET(SSL_get_fd(con),&writefds);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
/*			printf("mode tty(%d %d%d) ssl(%d%d)\n",
 | 
					/*			printf("mode tty(%d %d%d) ssl(%d%d)\n",
 | 
				
			||||||
				tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
 | 
									tty_on,read_tty,write_tty,read_ssl,write_ssl);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -555,29 +474,8 @@ re_start:
 | 
				
			|||||||
			 * will choke the compiler: if you do have a cast then
 | 
								 * will choke the compiler: if you do have a cast then
 | 
				
			||||||
			 * you can either go for (int *) or (void *).
 | 
								 * you can either go for (int *) or (void *).
 | 
				
			||||||
			 */
 | 
								 */
 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
			/* Under Windows we make the assumption that we can
 | 
					 | 
				
			||||||
			 * always write to the tty: therefore if we need to
 | 
					 | 
				
			||||||
			 * write to the tty we just fall through. Otherwise
 | 
					 | 
				
			||||||
			 * we timeout the select every second and see if there
 | 
					 | 
				
			||||||
			 * are any keypresses. Note: this is a hack, in a proper
 | 
					 | 
				
			||||||
			 * Windows application we wouldn't do this.
 | 
					 | 
				
			||||||
			 */
 | 
					 | 
				
			||||||
			i=0;
 | 
					 | 
				
			||||||
			if(!write_tty) {
 | 
					 | 
				
			||||||
				if(read_tty) {
 | 
					 | 
				
			||||||
					tv.tv_sec = 1;
 | 
					 | 
				
			||||||
					tv.tv_usec = 0;
 | 
					 | 
				
			||||||
					i=select(width,(void *)&readfds,(void *)&writefds,
 | 
					 | 
				
			||||||
						 NULL,&tv);
 | 
					 | 
				
			||||||
					if(!i && (!((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) || !read_tty) ) continue;
 | 
					 | 
				
			||||||
				} else 	i=select(width,(void *)&readfds,(void *)&writefds,
 | 
					 | 
				
			||||||
					 NULL,NULL);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
			i=select(width,(void *)&readfds,(void *)&writefds,
 | 
								i=select(width,(void *)&readfds,(void *)&writefds,
 | 
				
			||||||
				 NULL,NULL);
 | 
									 NULL,NULL);
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			if ( i < 0)
 | 
								if ( i < 0)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_err,"bad select %d\n",
 | 
									BIO_printf(bio_err,"bad select %d\n",
 | 
				
			||||||
@@ -654,16 +552,9 @@ re_start:
 | 
				
			|||||||
				goto shut;
 | 
									goto shut;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
#ifdef WINDOWS
 | 
					#ifndef WINDOWS
 | 
				
			||||||
		/* Assume Windows can always write */
 | 
					 | 
				
			||||||
		else if (!ssl_pending && write_tty)
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
		else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
 | 
							else if (!ssl_pending && FD_ISSET(fileno(stdout),&writefds))
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
			ascii2ebcdic(&(sbuf[sbuf_off]),&(sbuf[sbuf_off]),sbuf_len);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			i=write(fileno(stdout),&(sbuf[sbuf_off]),sbuf_len);
 | 
								i=write(fileno(stdout),&(sbuf[sbuf_off]),sbuf_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (i <= 0)
 | 
								if (i <= 0)
 | 
				
			||||||
@@ -681,6 +572,7 @@ re_start:
 | 
				
			|||||||
				write_tty=0;
 | 
									write_tty=0;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		else if (ssl_pending || FD_ISSET(SSL_get_fd(con),&readfds))
 | 
							else if (ssl_pending || FD_ISSET(SSL_get_fd(con),&readfds))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
#ifdef RENEG
 | 
					#ifdef RENEG
 | 
				
			||||||
@@ -735,44 +627,18 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WINDOWS
 | 
					#ifndef WINDOWS
 | 
				
			||||||
		else if ((_kbhit()) || (WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
		else if (FD_ISSET(fileno(stdin),&readfds))
 | 
							else if (FD_ISSET(fileno(stdin),&readfds))
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (crlf)
 | 
								i=read(fileno(stdin),cbuf,BUFSIZZ);
 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				int j, lf_num;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				i=read(fileno(stdin),cbuf,BUFSIZZ/2);
 | 
								if ((!c_quiet) && ((i <= 0) || (cbuf[0] == 'Q')))
 | 
				
			||||||
				lf_num = 0;
 | 
					 | 
				
			||||||
				/* both loops are skipped when i <= 0 */
 | 
					 | 
				
			||||||
				for (j = 0; j < i; j++)
 | 
					 | 
				
			||||||
					if (cbuf[j] == '\n')
 | 
					 | 
				
			||||||
						lf_num++;
 | 
					 | 
				
			||||||
				for (j = i-1; j >= 0; j--)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
					cbuf[j+lf_num] = cbuf[j];
 | 
					 | 
				
			||||||
					if (cbuf[j] == '\n')
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
						lf_num--;
 | 
					 | 
				
			||||||
						i++;
 | 
					 | 
				
			||||||
						cbuf[j+lf_num] = '\r';
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				assert(lf_num == 0);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				i=read(fileno(stdin),cbuf,BUFSIZZ);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q')))
 | 
					 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_err,"DONE\n");
 | 
									BIO_printf(bio_err,"DONE\n");
 | 
				
			||||||
				goto shut;
 | 
									goto shut;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ((!c_ign_eof) && (cbuf[0] == 'R'))
 | 
								if ((!c_quiet) && (cbuf[0] == 'R'))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				BIO_printf(bio_err,"RENEGOTIATING\n");
 | 
									BIO_printf(bio_err,"RENEGOTIATING\n");
 | 
				
			||||||
				SSL_renegotiate(con);
 | 
									SSL_renegotiate(con);
 | 
				
			||||||
@@ -782,26 +648,23 @@ printf("read=%d pending=%d peek=%d\n",k,SSL_pending(con),SSL_peek(con,zbuf,10240
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
				cbuf_len=i;
 | 
									cbuf_len=i;
 | 
				
			||||||
				cbuf_off=0;
 | 
									cbuf_off=0;
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
				ebcdic2ascii(cbuf, cbuf, i);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			write_ssl=1;
 | 
								write_ssl=1;
 | 
				
			||||||
			read_tty=0;
 | 
								read_tty=0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
shut:
 | 
					shut:
 | 
				
			||||||
	SSL_shutdown(con);
 | 
						SSL_shutdown(con);
 | 
				
			||||||
	SHUTDOWN(SSL_get_fd(con));
 | 
						SHUTDOWN(SSL_get_fd(con));
 | 
				
			||||||
	ret=0;
 | 
						ret=0;
 | 
				
			||||||
end:
 | 
					end:
 | 
				
			||||||
	if(prexit) print_stuff(bio_c_out,con,1);
 | 
					 | 
				
			||||||
	if (con != NULL) SSL_free(con);
 | 
						if (con != NULL) SSL_free(con);
 | 
				
			||||||
	if (con2 != NULL) SSL_free(con2);
 | 
						if (con2 != NULL) SSL_free(con2);
 | 
				
			||||||
	if (ctx != NULL) SSL_CTX_free(ctx);
 | 
						if (ctx != NULL) SSL_CTX_free(ctx);
 | 
				
			||||||
	if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); OPENSSL_free(cbuf); }
 | 
						if (cbuf != NULL) { memset(cbuf,0,BUFSIZZ); Free(cbuf); }
 | 
				
			||||||
	if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); OPENSSL_free(sbuf); }
 | 
						if (sbuf != NULL) { memset(sbuf,0,BUFSIZZ); Free(sbuf); }
 | 
				
			||||||
	if (bio_c_out != NULL)
 | 
						if (bio_c_out != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_free(bio_c_out);
 | 
							BIO_free(bio_c_out);
 | 
				
			||||||
@@ -928,7 +791,5 @@ static void print_stuff(BIO *bio, SSL *s, int full)
 | 
				
			|||||||
	BIO_printf(bio,"---\n");
 | 
						BIO_printf(bio,"---\n");
 | 
				
			||||||
	if (peer != NULL)
 | 
						if (peer != NULL)
 | 
				
			||||||
		X509_free(peer);
 | 
							X509_free(peer);
 | 
				
			||||||
	/* flush, or debugging output gets mixed with http response */
 | 
					 | 
				
			||||||
	BIO_flush(bio);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										484
									
								
								apps/s_server.c
									
									
									
									
									
								
							
							
						
						
									
										484
									
								
								apps/s_server.c
									
									
									
									
									
								
							@@ -56,7 +56,15 @@
 | 
				
			|||||||
 * [including the GNU Public Licence.]
 | 
					 * [including the GNU Public Licence.]
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <assert.h>
 | 
					/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
				
			||||||
 | 
					   recursive header file inclusion, resulting in the compiler complaining
 | 
				
			||||||
 | 
					   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
				
			||||||
 | 
					   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
				
			||||||
 | 
					#if defined(__DECC) && !defined(__U_INT)
 | 
				
			||||||
 | 
					#define __U_INT
 | 
				
			||||||
 | 
					typedef unsigned int u_int;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
@@ -65,16 +73,6 @@
 | 
				
			|||||||
#ifdef NO_STDIO
 | 
					#ifdef NO_STDIO
 | 
				
			||||||
#define APPS_WIN16
 | 
					#define APPS_WIN16
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
					 | 
				
			||||||
   recursive header file inclusion, resulting in the compiler complaining
 | 
					 | 
				
			||||||
   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
					 | 
				
			||||||
   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
					 | 
				
			||||||
#if defined(VMS) && defined(__DECC) && !defined(__U_INT)
 | 
					 | 
				
			||||||
#define __U_INT
 | 
					 | 
				
			||||||
typedef unsigned int u_int;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <openssl/lhash.h>
 | 
					#include <openssl/lhash.h>
 | 
				
			||||||
#include <openssl/bn.h>
 | 
					#include <openssl/bn.h>
 | 
				
			||||||
#define USE_SOCKETS
 | 
					#define USE_SOCKETS
 | 
				
			||||||
@@ -83,21 +81,19 @@ typedef unsigned int u_int;
 | 
				
			|||||||
#include <openssl/pem.h>
 | 
					#include <openssl/pem.h>
 | 
				
			||||||
#include <openssl/x509.h>
 | 
					#include <openssl/x509.h>
 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					#include <openssl/ssl.h>
 | 
				
			||||||
#include <openssl/rand.h>
 | 
					 | 
				
			||||||
#include <openssl/engine.h>
 | 
					 | 
				
			||||||
#include "s_apps.h"
 | 
					#include "s_apps.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
#include <conio.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if (defined(VMS) && __VMS_VER < 70000000)
 | 
					#if (defined(VMS) && __VMS_VER < 70000000)
 | 
				
			||||||
/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 | 
					/* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */
 | 
				
			||||||
#undef FIONBIO
 | 
					#undef FIONBIO
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(NO_RSA) && !defined(NO_SSL2)
 | 
				
			||||||
 | 
					#define NO_SSL2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_RSA
 | 
					#ifndef NO_RSA
 | 
				
			||||||
static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength);
 | 
					static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int export,int keylength);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
static int sv_body(char *hostname, int s, unsigned char *context);
 | 
					static int sv_body(char *hostname, int s, unsigned char *context);
 | 
				
			||||||
static int www_body(char *hostname, int s, unsigned char *context);
 | 
					static int www_body(char *hostname, int s, unsigned char *context);
 | 
				
			||||||
@@ -106,19 +102,17 @@ static void sv_usage(void);
 | 
				
			|||||||
static int init_ssl_connection(SSL *s);
 | 
					static int init_ssl_connection(SSL *s);
 | 
				
			||||||
static void print_stats(BIO *bp,SSL_CTX *ctx);
 | 
					static void print_stats(BIO *bp,SSL_CTX *ctx);
 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
static DH *load_dh_param(char *dhfile);
 | 
					static DH *load_dh_param(void );
 | 
				
			||||||
static DH *get_dh512(void);
 | 
					static DH *get_dh512(void);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
#ifdef MONOLITH
 | 
					/* static void s_server_init(void);*/
 | 
				
			||||||
static void s_server_init(void);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef S_ISDIR
 | 
					#ifndef S_ISDIR
 | 
				
			||||||
# if defined(_S_IFMT) && defined(_S_IFDIR)
 | 
					#if defined(VMS) && !defined(__DECC)
 | 
				
			||||||
#  define S_ISDIR(a)	(((a) & _S_IFMT) == _S_IFDIR)
 | 
					#define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
 | 
				
			||||||
# else
 | 
					#else
 | 
				
			||||||
#  define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
 | 
					#define S_ISDIR(a)	(((a) & _S_IFMT) == _S_IFDIR)
 | 
				
			||||||
# endif
 | 
					#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
@@ -151,13 +145,15 @@ static DH *get_dh512(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#undef BUFSIZZ
 | 
					#undef BUFSIZZ
 | 
				
			||||||
#define BUFSIZZ	16*1024
 | 
					#define BUFSIZZ	16*1024
 | 
				
			||||||
static int bufsize=BUFSIZZ;
 | 
					static int bufsize=32;
 | 
				
			||||||
static int accept_socket= -1;
 | 
					static int accept_socket= -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TEST_CERT	"server.pem"
 | 
					#define TEST_CERT	"server.pem"
 | 
				
			||||||
#undef PROG
 | 
					#undef PROG
 | 
				
			||||||
#define PROG		s_server_main
 | 
					#define PROG		s_server_main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DH_PARAM	"server.pem"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int verify_depth;
 | 
					extern int verify_depth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char *cipher=NULL;
 | 
					static char *cipher=NULL;
 | 
				
			||||||
@@ -169,7 +165,6 @@ static char *s_dcert_file=NULL,*s_dkey_file=NULL;
 | 
				
			|||||||
static int s_nbio=0;
 | 
					static int s_nbio=0;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
static int s_nbio_test=0;
 | 
					static int s_nbio_test=0;
 | 
				
			||||||
int s_crlf=0;
 | 
					 | 
				
			||||||
static SSL_CTX *ctx=NULL;
 | 
					static SSL_CTX *ctx=NULL;
 | 
				
			||||||
static int www=0;
 | 
					static int www=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -177,13 +172,9 @@ static BIO *bio_s_out=NULL;
 | 
				
			|||||||
static int s_debug=0;
 | 
					static int s_debug=0;
 | 
				
			||||||
static int s_quiet=0;
 | 
					static int s_quiet=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int hack=0;
 | 
					#if 0
 | 
				
			||||||
static char *engine_id=NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef MONOLITH
 | 
					 | 
				
			||||||
static void s_server_init(void)
 | 
					static void s_server_init(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	accept_socket=-1;
 | 
					 | 
				
			||||||
	cipher=NULL;
 | 
						cipher=NULL;
 | 
				
			||||||
	s_server_verify=SSL_VERIFY_NONE;
 | 
						s_server_verify=SSL_VERIFY_NONE;
 | 
				
			||||||
	s_dcert_file=NULL;
 | 
						s_dcert_file=NULL;
 | 
				
			||||||
@@ -200,8 +191,6 @@ static void s_server_init(void)
 | 
				
			|||||||
	bio_s_out=NULL;
 | 
						bio_s_out=NULL;
 | 
				
			||||||
	s_debug=0;
 | 
						s_debug=0;
 | 
				
			||||||
	s_quiet=0;
 | 
						s_quiet=0;
 | 
				
			||||||
	hack=0;
 | 
					 | 
				
			||||||
	engine_id=NULL;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -215,17 +204,14 @@ static void sv_usage(void)
 | 
				
			|||||||
	BIO_printf(bio_err," -Verify arg   - turn on peer certificate verification, must have a cert.\n");
 | 
						BIO_printf(bio_err," -Verify arg   - turn on peer certificate verification, must have a cert.\n");
 | 
				
			||||||
	BIO_printf(bio_err," -cert arg     - certificate file to use, PEM format assumed\n");
 | 
						BIO_printf(bio_err," -cert arg     - certificate file to use, PEM format assumed\n");
 | 
				
			||||||
	BIO_printf(bio_err,"                 (default is %s)\n",TEST_CERT);
 | 
						BIO_printf(bio_err,"                 (default is %s)\n",TEST_CERT);
 | 
				
			||||||
	BIO_printf(bio_err," -key arg      - Private Key file to use, PEM format assumed, in cert file if\n");
 | 
						BIO_printf(bio_err," -key arg      - RSA file to use, PEM format assumed, in cert file if\n");
 | 
				
			||||||
	BIO_printf(bio_err,"                 not specified (default is %s)\n",TEST_CERT);
 | 
						BIO_printf(bio_err,"                 not specified (default is %s)\n",TEST_CERT);
 | 
				
			||||||
	BIO_printf(bio_err," -dcert arg    - second certificate file to use (usually for DSA)\n");
 | 
						BIO_printf(bio_err," -dcert arg    - second certificate file to use (usually for DSA)\n");
 | 
				
			||||||
	BIO_printf(bio_err," -dkey arg     - second private key file to use (usually for DSA)\n");
 | 
						BIO_printf(bio_err," -dkey arg     - second private key file to use (usually for DSA)\n");
 | 
				
			||||||
	BIO_printf(bio_err," -dhparam arg  - DH parameter file to use, in cert file if not specified\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err,"                 or a default set of parameters is used\n");
 | 
					 | 
				
			||||||
#ifdef FIONBIO
 | 
					#ifdef FIONBIO
 | 
				
			||||||
	BIO_printf(bio_err," -nbio         - Run with non-blocking IO\n");
 | 
						BIO_printf(bio_err," -nbio         - Run with non-blocking IO\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	BIO_printf(bio_err," -nbio_test    - test with the non-blocking test bio\n");
 | 
						BIO_printf(bio_err," -nbio_test    - test with the non-blocking test bio\n");
 | 
				
			||||||
	BIO_printf(bio_err," -crlf         - convert LF from terminal into CRLF\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -debug        - Print more output\n");
 | 
						BIO_printf(bio_err," -debug        - Print more output\n");
 | 
				
			||||||
	BIO_printf(bio_err," -state        - Print the SSL states\n");
 | 
						BIO_printf(bio_err," -state        - Print the SSL states\n");
 | 
				
			||||||
	BIO_printf(bio_err," -CApath arg   - PEM format directory of CA's\n");
 | 
						BIO_printf(bio_err," -CApath arg   - PEM format directory of CA's\n");
 | 
				
			||||||
@@ -240,186 +226,26 @@ static void sv_usage(void)
 | 
				
			|||||||
	BIO_printf(bio_err," -no_ssl2      - Just disable SSLv2\n");
 | 
						BIO_printf(bio_err," -no_ssl2      - Just disable SSLv2\n");
 | 
				
			||||||
	BIO_printf(bio_err," -no_ssl3      - Just disable SSLv3\n");
 | 
						BIO_printf(bio_err," -no_ssl3      - Just disable SSLv3\n");
 | 
				
			||||||
	BIO_printf(bio_err," -no_tls1      - Just disable TLSv1\n");
 | 
						BIO_printf(bio_err," -no_tls1      - Just disable TLSv1\n");
 | 
				
			||||||
#ifndef NO_DH
 | 
						BIO_printf(bio_err," -bugs         - Turn on SSL bug compatability\n");
 | 
				
			||||||
	BIO_printf(bio_err," -no_dhe       - Disable ephemeral DH\n");
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -bugs         - Turn on SSL bug compatibility\n");
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -www          - Respond to a 'GET /' with a status page\n");
 | 
						BIO_printf(bio_err," -www          - Respond to a 'GET /' with a status page\n");
 | 
				
			||||||
	BIO_printf(bio_err," -WWW          - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
 | 
						BIO_printf(bio_err," -WWW          - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n");
 | 
				
			||||||
	BIO_printf(bio_err," -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);
 | 
					 | 
				
			||||||
	BIO_printf(bio_err," -engine id    - Initialise and use the specified engine\n");
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int local_argc=0;
 | 
					static int local_argc=0;
 | 
				
			||||||
static char **local_argv;
 | 
					static char **local_argv;
 | 
				
			||||||
 | 
					static int hack=0;
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
static int ebcdic_new(BIO *bi);
 | 
					 | 
				
			||||||
static int ebcdic_free(BIO *a);
 | 
					 | 
				
			||||||
static int ebcdic_read(BIO *b, char *out, int outl);
 | 
					 | 
				
			||||||
static int ebcdic_write(BIO *b, char *in, int inl);
 | 
					 | 
				
			||||||
static long ebcdic_ctrl(BIO *b, int cmd, long num, char *ptr);
 | 
					 | 
				
			||||||
static int ebcdic_gets(BIO *bp, char *buf, int size);
 | 
					 | 
				
			||||||
static int ebcdic_puts(BIO *bp, char *str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BIO_TYPE_EBCDIC_FILTER	(18|0x0200)
 | 
					 | 
				
			||||||
static BIO_METHOD methods_ebcdic=
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	BIO_TYPE_EBCDIC_FILTER,
 | 
					 | 
				
			||||||
	"EBCDIC/ASCII filter",
 | 
					 | 
				
			||||||
	ebcdic_write,
 | 
					 | 
				
			||||||
	ebcdic_read,
 | 
					 | 
				
			||||||
	ebcdic_puts,
 | 
					 | 
				
			||||||
	ebcdic_gets,
 | 
					 | 
				
			||||||
	ebcdic_ctrl,
 | 
					 | 
				
			||||||
	ebcdic_new,
 | 
					 | 
				
			||||||
	ebcdic_free,
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef struct
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	size_t	alloced;
 | 
					 | 
				
			||||||
	char	buff[1];
 | 
					 | 
				
			||||||
} EBCDIC_OUTBUFF;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
BIO_METHOD *BIO_f_ebcdic_filter()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return(&methods_ebcdic);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int ebcdic_new(BIO *bi)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	EBCDIC_OUTBUFF *wbuf;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	wbuf = (EBCDIC_OUTBUFF *)OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024);
 | 
					 | 
				
			||||||
	wbuf->alloced = 1024;
 | 
					 | 
				
			||||||
	wbuf->buff[0] = '\0';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bi->ptr=(char *)wbuf;
 | 
					 | 
				
			||||||
	bi->init=1;
 | 
					 | 
				
			||||||
	bi->flags=0;
 | 
					 | 
				
			||||||
	return(1);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int ebcdic_free(BIO *a)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (a == NULL) return(0);
 | 
					 | 
				
			||||||
	if (a->ptr != NULL)
 | 
					 | 
				
			||||||
		OPENSSL_free(a->ptr);
 | 
					 | 
				
			||||||
	a->ptr=NULL;
 | 
					 | 
				
			||||||
	a->init=0;
 | 
					 | 
				
			||||||
	a->flags=0;
 | 
					 | 
				
			||||||
	return(1);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
static int ebcdic_read(BIO *b, char *out, int outl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int ret=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (out == NULL || outl == 0) return(0);
 | 
					 | 
				
			||||||
	if (b->next_bio == NULL) return(0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret=BIO_read(b->next_bio,out,outl);
 | 
					 | 
				
			||||||
	if (ret > 0)
 | 
					 | 
				
			||||||
		ascii2ebcdic(out,out,ret);
 | 
					 | 
				
			||||||
	return(ret);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int ebcdic_write(BIO *b, char *in, int inl)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	EBCDIC_OUTBUFF *wbuf;
 | 
					 | 
				
			||||||
	int ret=0;
 | 
					 | 
				
			||||||
	int num;
 | 
					 | 
				
			||||||
	unsigned char n;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((in == NULL) || (inl <= 0)) return(0);
 | 
					 | 
				
			||||||
	if (b->next_bio == NULL) return(0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	wbuf=(EBCDIC_OUTBUFF *)b->ptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (inl > (num = wbuf->alloced))
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		num = num + num;  /* double the size */
 | 
					 | 
				
			||||||
		if (num < inl)
 | 
					 | 
				
			||||||
			num = inl;
 | 
					 | 
				
			||||||
		OPENSSL_free(wbuf);
 | 
					 | 
				
			||||||
		wbuf=(EBCDIC_OUTBUFF *)OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		wbuf->alloced = num;
 | 
					 | 
				
			||||||
		wbuf->buff[0] = '\0';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		b->ptr=(char *)wbuf;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ebcdic2ascii(wbuf->buff, in, inl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ret=BIO_write(b->next_bio, wbuf->buff, inl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return(ret);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static long ebcdic_ctrl(BIO *b, int cmd, long num, char *ptr)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	long ret;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (b->next_bio == NULL) return(0);
 | 
					 | 
				
			||||||
	switch (cmd)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	case BIO_CTRL_DUP:
 | 
					 | 
				
			||||||
		ret=0L;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return(ret);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int ebcdic_gets(BIO *bp, char *buf, int size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int i, ret;
 | 
					 | 
				
			||||||
	if (bp->next_bio == NULL) return(0);
 | 
					 | 
				
			||||||
/*	return(BIO_gets(bp->next_bio,buf,size));*/
 | 
					 | 
				
			||||||
	for (i=0; i<size-1; ++i)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		ret = ebcdic_read(bp,&buf[i],1);
 | 
					 | 
				
			||||||
		if (ret <= 0)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		else if (buf[i] == '\n')
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			++i;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (i < size)
 | 
					 | 
				
			||||||
		buf[i] = '\0';
 | 
					 | 
				
			||||||
	return (ret < 0 && i == 0) ? ret : i;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int ebcdic_puts(BIO *bp, char *str)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (bp->next_bio == NULL) return(0);
 | 
					 | 
				
			||||||
	return ebcdic_write(bp, str, strlen(str));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
int MAIN(int argc, char *argv[])
 | 
					int MAIN(int argc, char *argv[])
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	short port=PORT;
 | 
						short port=PORT;
 | 
				
			||||||
	char *CApath=NULL,*CAfile=NULL;
 | 
						char *CApath=NULL,*CAfile=NULL;
 | 
				
			||||||
	char *context = NULL;
 | 
						char *context = NULL;
 | 
				
			||||||
	char *dhfile = NULL;
 | 
					 | 
				
			||||||
	int badop=0,bugs=0;
 | 
						int badop=0,bugs=0;
 | 
				
			||||||
	int ret=1;
 | 
						int ret=1;
 | 
				
			||||||
	int off=0;
 | 
						int off=0;
 | 
				
			||||||
	int no_tmp_rsa=0,no_dhe=0,nocert=0;
 | 
						int no_tmp_rsa=0,nocert=0;
 | 
				
			||||||
	int state=0;
 | 
						int state=0;
 | 
				
			||||||
	SSL_METHOD *meth=NULL;
 | 
						SSL_METHOD *meth=NULL;
 | 
				
			||||||
	char *inrand=NULL;
 | 
					 | 
				
			||||||
	char *engine=NULL;
 | 
					 | 
				
			||||||
	ENGINE *e=NULL;
 | 
					 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
	DH *dh=NULL;
 | 
						DH *dh=NULL;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -436,9 +262,8 @@ int MAIN(int argc, char *argv[])
 | 
				
			|||||||
	local_argv=argv;
 | 
						local_argv=argv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
						apps_startup();
 | 
				
			||||||
#ifdef MONOLITH
 | 
						s_quiet=0;
 | 
				
			||||||
	s_server_init();
 | 
						s_debug=0;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (bio_err == NULL)
 | 
						if (bio_err == NULL)
 | 
				
			||||||
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
							bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
				
			||||||
@@ -491,11 +316,6 @@ int MAIN(int argc, char *argv[])
 | 
				
			|||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
			s_key_file= *(++argv);
 | 
								s_key_file= *(++argv);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if	(strcmp(*argv,"-dhparam") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			dhfile = *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-dcert") == 0)
 | 
							else if	(strcmp(*argv,"-dcert") == 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
								if (--argc < 1) goto bad;
 | 
				
			||||||
@@ -542,16 +362,12 @@ int MAIN(int argc, char *argv[])
 | 
				
			|||||||
			{ hack=1; }
 | 
								{ hack=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-state") == 0)
 | 
							else if	(strcmp(*argv,"-state") == 0)
 | 
				
			||||||
			{ state=1; }
 | 
								{ state=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-crlf") == 0)
 | 
					 | 
				
			||||||
			{ s_crlf=1; }
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-quiet") == 0)
 | 
							else if	(strcmp(*argv,"-quiet") == 0)
 | 
				
			||||||
			{ s_quiet=1; }
 | 
								{ s_quiet=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-bugs") == 0)
 | 
							else if	(strcmp(*argv,"-bugs") == 0)
 | 
				
			||||||
			{ bugs=1; }
 | 
								{ bugs=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-no_tmp_rsa") == 0)
 | 
							else if	(strcmp(*argv,"-no_tmp_rsa") == 0)
 | 
				
			||||||
			{ no_tmp_rsa=1; }
 | 
								{ no_tmp_rsa=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-no_dhe") == 0)
 | 
					 | 
				
			||||||
			{ no_dhe=1; }
 | 
					 | 
				
			||||||
		else if	(strcmp(*argv,"-www") == 0)
 | 
							else if	(strcmp(*argv,"-www") == 0)
 | 
				
			||||||
			{ www=1; }
 | 
								{ www=1; }
 | 
				
			||||||
		else if	(strcmp(*argv,"-WWW") == 0)
 | 
							else if	(strcmp(*argv,"-WWW") == 0)
 | 
				
			||||||
@@ -574,16 +390,6 @@ int MAIN(int argc, char *argv[])
 | 
				
			|||||||
		else if	(strcmp(*argv,"-tls1") == 0)
 | 
							else if	(strcmp(*argv,"-tls1") == 0)
 | 
				
			||||||
			{ meth=TLSv1_server_method(); }
 | 
								{ meth=TLSv1_server_method(); }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		else if (strcmp(*argv,"-rand") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			inrand= *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else if (strcmp(*argv,"-engine") == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			if (--argc < 1) goto bad;
 | 
					 | 
				
			||||||
			engine = *(++argv);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
								BIO_printf(bio_err,"unknown option %s\n",*argv);
 | 
				
			||||||
@@ -600,15 +406,6 @@ bad:
 | 
				
			|||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
 | 
					 | 
				
			||||||
		&& !RAND_status())
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	if (inrand != NULL)
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"%ld semi-random bytes loaded\n",
 | 
					 | 
				
			||||||
			app_RAND_load_files(inrand));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_s_out == NULL)
 | 
						if (bio_s_out == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if (s_quiet && !s_debug)
 | 
							if (s_quiet && !s_debug)
 | 
				
			||||||
@@ -633,30 +430,7 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SSL_load_error_strings();
 | 
						SSL_load_error_strings();
 | 
				
			||||||
	OpenSSL_add_ssl_algorithms();
 | 
						SSLeay_add_ssl_algorithms();
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (engine != NULL)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		if((e = ENGINE_by_id(engine)) == NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"invalid engine\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (s_debug)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
 | 
					 | 
				
			||||||
				0, bio_err, 0);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_err,"can't use that engine\n");
 | 
					 | 
				
			||||||
			ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
			goto end;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
 | 
					 | 
				
			||||||
		ENGINE_free(e);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx=SSL_CTX_new(meth);
 | 
						ctx=SSL_CTX_new(meth);
 | 
				
			||||||
	if (ctx == NULL)
 | 
						if (ctx == NULL)
 | 
				
			||||||
@@ -696,23 +470,21 @@ bad:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
	if (!no_dhe)
 | 
						/* EAY EAY EAY evil hack */
 | 
				
			||||||
 | 
						dh=load_dh_param();
 | 
				
			||||||
 | 
						if (dh != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		dh=load_dh_param(dhfile ? dhfile : s_cert_file);
 | 
							BIO_printf(bio_s_out,"Setting temp DH parameters\n");
 | 
				
			||||||
		if (dh != NULL)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_s_out,"Setting temp DH parameters\n");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			BIO_printf(bio_s_out,"Using default temp DH parameters\n");
 | 
					 | 
				
			||||||
			dh=get_dh512();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		(void)BIO_flush(bio_s_out);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		SSL_CTX_set_tmp_dh(ctx,dh);
 | 
					 | 
				
			||||||
		DH_free(dh);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							BIO_printf(bio_s_out,"Using default temp DH parameters\n");
 | 
				
			||||||
 | 
							dh=get_dh512();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						BIO_flush(bio_s_out);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SSL_CTX_set_tmp_dh(ctx,dh);
 | 
				
			||||||
 | 
						DH_free(dh);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!set_cert_stuff(ctx,s_cert_file,s_key_file))
 | 
						if (!set_cert_stuff(ctx,s_cert_file,s_key_file))
 | 
				
			||||||
@@ -725,8 +497,7 @@ bad:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifndef NO_RSA
 | 
					#ifndef NO_RSA
 | 
				
			||||||
#if 1
 | 
					#if 1
 | 
				
			||||||
	if (!no_tmp_rsa)
 | 
						SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb);
 | 
				
			||||||
		SSL_CTX_set_tmp_rsa_callback(ctx,tmp_rsa_cb);
 | 
					 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx))
 | 
						if (!no_tmp_rsa && SSL_CTX_need_tmp_RSA(ctx))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -749,17 +520,12 @@ bad:
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (cipher != NULL)
 | 
						if (cipher != NULL)
 | 
				
			||||||
		if(!SSL_CTX_set_cipher_list(ctx,cipher)) {
 | 
							SSL_CTX_set_cipher_list(ctx,cipher);
 | 
				
			||||||
		BIO_printf(bio_err,"error setting cipher list\n");
 | 
					 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
					 | 
				
			||||||
		goto end;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	SSL_CTX_set_verify(ctx,s_server_verify,verify_callback);
 | 
						SSL_CTX_set_verify(ctx,s_server_verify,verify_callback);
 | 
				
			||||||
	SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context,
 | 
						SSL_CTX_set_session_id_context(ctx,(void*)&s_server_session_id_context,
 | 
				
			||||||
		sizeof s_server_session_id_context);
 | 
							sizeof s_server_session_id_context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (CAfile != NULL)
 | 
						SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
 | 
				
			||||||
	    SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	BIO_printf(bio_s_out,"ACCEPT\n");
 | 
						BIO_printf(bio_s_out,"ACCEPT\n");
 | 
				
			||||||
	if (www)
 | 
						if (www)
 | 
				
			||||||
@@ -812,11 +578,8 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
	unsigned long l;
 | 
						unsigned long l;
 | 
				
			||||||
	SSL *con=NULL;
 | 
						SSL *con=NULL;
 | 
				
			||||||
	BIO *sbio;
 | 
						BIO *sbio;
 | 
				
			||||||
#ifdef WINDOWS
 | 
					 | 
				
			||||||
	struct timeval tv;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((buf=OPENSSL_malloc(bufsize)) == NULL)
 | 
						if ((buf=Malloc(bufsize)) == NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		BIO_printf(bio_err,"out of memory\n");
 | 
							BIO_printf(bio_err,"out of memory\n");
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
@@ -834,7 +597,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (con == NULL) {
 | 
						if (con == NULL) {
 | 
				
			||||||
		con=SSL_new(ctx);
 | 
							con=(SSL *)SSL_new(ctx);
 | 
				
			||||||
		if(context)
 | 
							if(context)
 | 
				
			||||||
		      SSL_set_session_id_context(con, context,
 | 
							      SSL_set_session_id_context(con, context,
 | 
				
			||||||
						 strlen((char *)context));
 | 
											 strlen((char *)context));
 | 
				
			||||||
@@ -863,72 +626,22 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
	width=s+1;
 | 
						width=s+1;
 | 
				
			||||||
	for (;;)
 | 
						for (;;)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		int read_from_terminal;
 | 
							FD_ZERO(&readfds);
 | 
				
			||||||
		int read_from_sslcon;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		read_from_terminal = 0;
 | 
					 | 
				
			||||||
		read_from_sslcon = SSL_pending(con);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!read_from_sslcon)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
			FD_ZERO(&readfds);
 | 
					 | 
				
			||||||
#ifndef WINDOWS
 | 
					#ifndef WINDOWS
 | 
				
			||||||
			FD_SET(fileno(stdin),&readfds);
 | 
							FD_SET(fileno(stdin),&readfds);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
			FD_SET(s,&readfds);
 | 
							FD_SET(s,&readfds);
 | 
				
			||||||
			/* Note: under VMS with SOCKETSHR the second parameter is
 | 
							/* Note: under VMS with SOCKETSHR the second parameter is
 | 
				
			||||||
			 * currently of type (int *) whereas under other systems
 | 
							 * currently of type (int *) whereas under other systems
 | 
				
			||||||
			 * it is (void *) if you don't have a cast it will choke
 | 
							 * it is (void *) if you don't have a cast it will choke
 | 
				
			||||||
			 * the compiler: if you do have a cast then you can either
 | 
							 * the compiler: if you do have a cast then you can either
 | 
				
			||||||
			 * go for (int *) or (void *).
 | 
							 * go for (int *) or (void *).
 | 
				
			||||||
			 */
 | 
							 */
 | 
				
			||||||
#ifdef WINDOWS
 | 
							i=select(width,(void *)&readfds,NULL,NULL,NULL);
 | 
				
			||||||
			/* Under Windows we can't select on stdin: only
 | 
							if (i <= 0) continue;
 | 
				
			||||||
			 * on sockets. As a workaround we timeout the select every
 | 
							if (FD_ISSET(fileno(stdin),&readfds))
 | 
				
			||||||
			 * second and check for any keypress. In a proper Windows
 | 
					 | 
				
			||||||
			 * application we wouldn't do this because it is inefficient.
 | 
					 | 
				
			||||||
			 */
 | 
					 | 
				
			||||||
			tv.tv_sec = 1;
 | 
					 | 
				
			||||||
			tv.tv_usec = 0;
 | 
					 | 
				
			||||||
			i=select(width,(void *)&readfds,NULL,NULL,&tv);
 | 
					 | 
				
			||||||
			if((i < 0) || (!i && !_kbhit() ) )continue;
 | 
					 | 
				
			||||||
			if(_kbhit())
 | 
					 | 
				
			||||||
				read_from_terminal = 1;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
			i=select(width,(void *)&readfds,NULL,NULL,NULL);
 | 
					 | 
				
			||||||
			if (i <= 0) continue;
 | 
					 | 
				
			||||||
			if (FD_ISSET(fileno(stdin),&readfds))
 | 
					 | 
				
			||||||
				read_from_terminal = 1;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			if (FD_ISSET(s,&readfds))
 | 
					 | 
				
			||||||
				read_from_sslcon = 1;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		if (read_from_terminal)
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (s_crlf)
 | 
								i=read(fileno(stdin),buf,bufsize);
 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
				int j, lf_num;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				i=read(fileno(stdin), buf, bufsize/2);
 | 
					 | 
				
			||||||
				lf_num = 0;
 | 
					 | 
				
			||||||
				/* both loops are skipped when i <= 0 */
 | 
					 | 
				
			||||||
				for (j = 0; j < i; j++)
 | 
					 | 
				
			||||||
					if (buf[j] == '\n')
 | 
					 | 
				
			||||||
						lf_num++;
 | 
					 | 
				
			||||||
				for (j = i-1; j >= 0; j--)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
					buf[j+lf_num] = buf[j];
 | 
					 | 
				
			||||||
					if (buf[j] == '\n')
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
						lf_num--;
 | 
					 | 
				
			||||||
						i++;
 | 
					 | 
				
			||||||
						buf[j+lf_num] = '\r';
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				assert(lf_num == 0);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				i=read(fileno(stdin),buf,bufsize);
 | 
					 | 
				
			||||||
			if (!s_quiet)
 | 
								if (!s_quiet)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				if ((i <= 0) || (buf[0] == 'Q'))
 | 
									if ((i <= 0) || (buf[0] == 'Q'))
 | 
				
			||||||
@@ -979,9 +692,6 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
					print_stats(bio_s_out,SSL_get_SSL_CTX(con));
 | 
										print_stats(bio_s_out,SSL_get_SSL_CTX(con));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
			ebcdic2ascii(buf,buf,i);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			l=k=0;
 | 
								l=k=0;
 | 
				
			||||||
			for (;;)
 | 
								for (;;)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@@ -1016,7 +726,7 @@ static int sv_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
				if (i <= 0) break;
 | 
									if (i <= 0) break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		if (read_from_sslcon)
 | 
							if (FD_ISSET(s,&readfds))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if (!SSL_is_init_finished(con))
 | 
								if (!SSL_is_init_finished(con))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@@ -1040,9 +750,6 @@ again:
 | 
				
			|||||||
				switch (SSL_get_error(con,i))
 | 
									switch (SSL_get_error(con,i))
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
				case SSL_ERROR_NONE:
 | 
									case SSL_ERROR_NONE:
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
					ascii2ebcdic(buf,buf,i);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
					write(fileno(stdout),buf,
 | 
										write(fileno(stdout),buf,
 | 
				
			||||||
						(unsigned int)i);
 | 
											(unsigned int)i);
 | 
				
			||||||
					if (SSL_pending(con)) goto again;
 | 
										if (SSL_pending(con)) goto again;
 | 
				
			||||||
@@ -1078,7 +785,7 @@ err:
 | 
				
			|||||||
	if (buf != NULL)
 | 
						if (buf != NULL)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		memset(buf,0,bufsize);
 | 
							memset(buf,0,bufsize);
 | 
				
			||||||
		OPENSSL_free(buf);
 | 
							Free(buf);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	if (ret >= 0)
 | 
						if (ret >= 0)
 | 
				
			||||||
		BIO_printf(bio_s_out,"ACCEPT\n");
 | 
							BIO_printf(bio_s_out,"ACCEPT\n");
 | 
				
			||||||
@@ -1149,14 +856,14 @@ static int init_ssl_connection(SSL *con)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_DH
 | 
					#ifndef NO_DH
 | 
				
			||||||
static DH *load_dh_param(char *dhfile)
 | 
					static DH *load_dh_param(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	DH *ret=NULL;
 | 
						DH *ret=NULL;
 | 
				
			||||||
	BIO *bio;
 | 
						BIO *bio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((bio=BIO_new_file(dhfile,"r")) == NULL)
 | 
						if ((bio=BIO_new_file(DH_PARAM,"r")) == NULL)
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
	ret=PEM_read_bio_DHparams(bio,NULL,NULL,NULL);
 | 
						ret=PEM_read_bio_DHparams(bio,NULL,NULL);
 | 
				
			||||||
err:
 | 
					err:
 | 
				
			||||||
	if (bio != NULL) BIO_free(bio);
 | 
						if (bio != NULL) BIO_free(bio);
 | 
				
			||||||
	return(ret);
 | 
						return(ret);
 | 
				
			||||||
@@ -1195,7 +902,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
	BIO *io,*ssl_bio,*sbio;
 | 
						BIO *io,*ssl_bio,*sbio;
 | 
				
			||||||
	long total_bytes;
 | 
						long total_bytes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buf=OPENSSL_malloc(bufsize);
 | 
						buf=Malloc(bufsize);
 | 
				
			||||||
	if (buf == NULL) return(0);
 | 
						if (buf == NULL) return(0);
 | 
				
			||||||
	io=BIO_new(BIO_f_buffer());
 | 
						io=BIO_new(BIO_f_buffer());
 | 
				
			||||||
	ssl_bio=BIO_new(BIO_f_ssl());
 | 
						ssl_bio=BIO_new(BIO_f_ssl());
 | 
				
			||||||
@@ -1216,7 +923,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
	/* lets make the output buffer a reasonable size */
 | 
						/* lets make the output buffer a reasonable size */
 | 
				
			||||||
	if (!BIO_set_write_buffer_size(io,bufsize)) goto err;
 | 
						if (!BIO_set_write_buffer_size(io,bufsize)) goto err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((con=SSL_new(ctx)) == NULL) goto err;
 | 
						if ((con=(SSL *)SSL_new(ctx)) == NULL) goto err;
 | 
				
			||||||
	if(context) SSL_set_session_id_context(con, context,
 | 
						if(context) SSL_set_session_id_context(con, context,
 | 
				
			||||||
					       strlen((char *)context));
 | 
										       strlen((char *)context));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1234,9 +941,6 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
	/* SSL_set_fd(con,s); */
 | 
						/* SSL_set_fd(con,s); */
 | 
				
			||||||
	BIO_set_ssl(ssl_bio,con,BIO_CLOSE);
 | 
						BIO_set_ssl(ssl_bio,con,BIO_CLOSE);
 | 
				
			||||||
	BIO_push(io,ssl_bio);
 | 
						BIO_push(io,ssl_bio);
 | 
				
			||||||
#ifdef CHARSET_EBCDIC
 | 
					 | 
				
			||||||
	io = BIO_push(BIO_new(BIO_f_ebcdic_filter()),io);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (s_debug)
 | 
						if (s_debug)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -1306,7 +1010,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
			static char *space="                          ";
 | 
								static char *space="                          ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n");
 | 
								BIO_puts(io,"HTTP/1.0 200 ok\r\nContent-type: text/html\r\n\r\n");
 | 
				
			||||||
			BIO_puts(io,"<HTML><BODY BGCOLOR=\"#ffffff\">\n");
 | 
								BIO_puts(io,"<HTML><BODY BGCOLOR=ffffff>\n");
 | 
				
			||||||
			BIO_puts(io,"<pre>\n");
 | 
								BIO_puts(io,"<pre>\n");
 | 
				
			||||||
/*			BIO_puts(io,SSLeay_version(SSLEAY_VERSION));*/
 | 
					/*			BIO_puts(io,SSLeay_version(SSLEAY_VERSION));*/
 | 
				
			||||||
			BIO_puts(io,"\n");
 | 
								BIO_puts(io,"\n");
 | 
				
			||||||
@@ -1378,7 +1082,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
			BIO_puts(io,"</BODY></HTML>\r\n\r\n");
 | 
								BIO_puts(io,"</BODY></HTML>\r\n\r\n");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		else if ((www == 2) && (strncmp("GET /",buf,5) == 0))
 | 
							else if ((www == 2) && (strncmp("GET ",buf,4) == 0))
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO *file;
 | 
								BIO *file;
 | 
				
			||||||
			char *p,*e;
 | 
								char *p,*e;
 | 
				
			||||||
@@ -1386,29 +1090,15 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			/* skip the '/' */
 | 
								/* skip the '/' */
 | 
				
			||||||
			p= &(buf[5]);
 | 
								p= &(buf[5]);
 | 
				
			||||||
 | 
								dot=0;
 | 
				
			||||||
			dot = 1;
 | 
					 | 
				
			||||||
			for (e=p; *e != '\0'; e++)
 | 
								for (e=p; *e != '\0'; e++)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
				if (e[0] == ' ')
 | 
									if (e[0] == ' ') break;
 | 
				
			||||||
					break;
 | 
									if (	(e[0] == '.') &&
 | 
				
			||||||
 | 
										(strncmp(&(e[-1]),"/../",4) == 0))
 | 
				
			||||||
				switch (dot)
 | 
										dot=1;
 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
				case 1:
 | 
					 | 
				
			||||||
					dot = (e[0] == '.') ? 2 : 0;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				case 2:
 | 
					 | 
				
			||||||
					dot = (e[0] == '.') ? 3 : 0;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				case 3:
 | 
					 | 
				
			||||||
					dot = (e[0] == '/') ? -1 : 0;
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				if (dot == 0)
 | 
					 | 
				
			||||||
					dot = (e[0] == '/') ? 1 : 0;
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			dot = (dot == 3) || (dot == -1); /* filename contains ".." component */
 | 
								
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (*e == '\0')
 | 
								if (*e == '\0')
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@@ -1432,11 +1122,9 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
				break;
 | 
									break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
			/* append if a directory lookup */
 | 
								/* append if a directory lookup */
 | 
				
			||||||
			if (e[-1] == '/')
 | 
								if (e[-1] == '/')
 | 
				
			||||||
				strcat(p,"index.html");
 | 
									strcat(p,"index.html");
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			/* if a directory, do the index thang */
 | 
								/* if a directory, do the index thang */
 | 
				
			||||||
			if (stat(p,&st_buf) < 0)
 | 
								if (stat(p,&st_buf) < 0)
 | 
				
			||||||
@@ -1448,13 +1136,7 @@ static int www_body(char *hostname, int s, unsigned char *context)
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			if (S_ISDIR(st_buf.st_mode))
 | 
								if (S_ISDIR(st_buf.st_mode))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
#if 0 /* must check buffer size */
 | 
					 | 
				
			||||||
				strcat(p,"/index.html");
 | 
									strcat(p,"/index.html");
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
				BIO_puts(io,text);
 | 
					 | 
				
			||||||
				BIO_printf(io,"'%s' is a directory\r\n",p);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ((file=BIO_new_file(p,"r")) == NULL)
 | 
								if ((file=BIO_new_file(p,"r")) == NULL)
 | 
				
			||||||
@@ -1536,7 +1218,7 @@ end:
 | 
				
			|||||||
	/* make sure we re-use sessions */
 | 
						/* make sure we re-use sessions */
 | 
				
			||||||
	SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
 | 
						SSL_set_shutdown(con,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	/* This kills performance */
 | 
						/* This kills performace */
 | 
				
			||||||
/*	SSL_shutdown(con); A shutdown gets sent in the
 | 
					/*	SSL_shutdown(con); A shutdown gets sent in the
 | 
				
			||||||
 *	BIO_free_all(io) procession */
 | 
					 *	BIO_free_all(io) procession */
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -1546,14 +1228,14 @@ err:
 | 
				
			|||||||
	if (ret >= 0)
 | 
						if (ret >= 0)
 | 
				
			||||||
		BIO_printf(bio_s_out,"ACCEPT\n");
 | 
							BIO_printf(bio_s_out,"ACCEPT\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (buf != NULL) OPENSSL_free(buf);
 | 
						if (buf != NULL) Free(buf);
 | 
				
			||||||
	if (io != NULL) BIO_free_all(io);
 | 
						if (io != NULL) BIO_free_all(io);
 | 
				
			||||||
/*	if (ssl_bio != NULL) BIO_free(ssl_bio);*/
 | 
					/*	if (ssl_bio != NULL) BIO_free(ssl_bio);*/
 | 
				
			||||||
	return(ret);
 | 
						return(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef NO_RSA
 | 
					#ifndef NO_RSA
 | 
				
			||||||
static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
 | 
					static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int export, int keylength)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	static RSA *rsa_tmp=NULL;
 | 
						static RSA *rsa_tmp=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1562,13 +1244,13 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
 | 
				
			|||||||
		if (!s_quiet)
 | 
							if (!s_quiet)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
 | 
								BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
 | 
				
			||||||
			(void)BIO_flush(bio_err);
 | 
								BIO_flush(bio_err);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		rsa_tmp=RSA_generate_key(keylength,RSA_F4,NULL,NULL);
 | 
							rsa_tmp=RSA_generate_key(keylength,RSA_F4,NULL,NULL);
 | 
				
			||||||
		if (!s_quiet)
 | 
							if (!s_quiet)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			BIO_printf(bio_err,"\n");
 | 
								BIO_printf(bio_err,"\n");
 | 
				
			||||||
			(void)BIO_flush(bio_err);
 | 
								BIO_flush(bio_err);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	return(rsa_tmp);
 | 
						return(rsa_tmp);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										201
									
								
								apps/s_socket.c
									
									
									
									
									
								
							
							
						
						
									
										201
									
								
								apps/s_socket.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* apps/s_socket.c -  socket-related functions used by s_client and s_server */
 | 
					/* apps/s_socket.c */
 | 
				
			||||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
					/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 | 
				
			||||||
 * All rights reserved.
 | 
					 * All rights reserved.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -56,21 +56,20 @@
 | 
				
			|||||||
 * [including the GNU Public Licence.]
 | 
					 * [including the GNU Public Licence.]
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
				
			||||||
 | 
					   recursive header file inclusion, resulting in the compiler complaining
 | 
				
			||||||
 | 
					   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
				
			||||||
 | 
					   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
				
			||||||
 | 
					#if defined(__DECC) && !defined(__U_INT)
 | 
				
			||||||
 | 
					#define __U_INT
 | 
				
			||||||
 | 
					typedef unsigned int u_int;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* With IPv6, it looks like Digital has mixed up the proper order of
 | 
					 | 
				
			||||||
   recursive header file inclusion, resulting in the compiler complaining
 | 
					 | 
				
			||||||
   that u_int isn't defined, but only if _POSIX_C_SOURCE is defined, which
 | 
					 | 
				
			||||||
   is needed to have fileno() declared correctly...  So let's define u_int */
 | 
					 | 
				
			||||||
#if defined(VMS) && defined(__DECC) && !defined(__U_INT)
 | 
					 | 
				
			||||||
#define __U_INT
 | 
					 | 
				
			||||||
typedef unsigned int u_int;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define USE_SOCKETS
 | 
					#define USE_SOCKETS
 | 
				
			||||||
#define NON_MAIN
 | 
					#define NON_MAIN
 | 
				
			||||||
#include "apps.h"
 | 
					#include "apps.h"
 | 
				
			||||||
@@ -79,17 +78,16 @@ typedef unsigned int u_int;
 | 
				
			|||||||
#include "s_apps.h"
 | 
					#include "s_apps.h"
 | 
				
			||||||
#include <openssl/ssl.h>
 | 
					#include <openssl/ssl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct hostent *GetHostByName(char *name);
 | 
					#ifdef VMS
 | 
				
			||||||
#ifdef WINDOWS
 | 
					#if (__VMS_VER < 70000000) /* FIONBIO used as a switch to enable ioctl,
 | 
				
			||||||
static void sock_cleanup(void);
 | 
								      and that isn't in VMS < 7.0 */
 | 
				
			||||||
 | 
					#undef FIONBIO
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#include <processes.h> /* for vfork() */
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
static int sock_init(void);
 | 
					 | 
				
			||||||
static int init_client_ip(int *sock,unsigned char ip[4], int port);
 | 
					 | 
				
			||||||
static int init_server(int *sock, int port);
 | 
					 | 
				
			||||||
static int init_server_long(int *sock, int port,char *ip);
 | 
					 | 
				
			||||||
static int do_accept(int acc_sock, int *sock, char **host);
 | 
					 | 
				
			||||||
static int host_ip(char *str, unsigned char ip[4]);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct hostent *GetHostByName(char *name);
 | 
				
			||||||
 | 
					int sock_init(void );
 | 
				
			||||||
#ifdef WIN16
 | 
					#ifdef WIN16
 | 
				
			||||||
#define SOCKET_PROTOCOL	0 /* more microsoft stupidity */
 | 
					#define SOCKET_PROTOCOL	0 /* more microsoft stupidity */
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
@@ -132,19 +130,19 @@ static BOOL CALLBACK enumproc(HWND hwnd,LPARAM lParam)
 | 
				
			|||||||
#endif /* WIN32 */
 | 
					#endif /* WIN32 */
 | 
				
			||||||
#endif /* WINDOWS */
 | 
					#endif /* WINDOWS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WINDOWS
 | 
					void sock_cleanup(void)
 | 
				
			||||||
static void sock_cleanup(void)
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
					#ifdef WINDOWS
 | 
				
			||||||
	if (wsa_init_done)
 | 
						if (wsa_init_done)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		wsa_init_done=0;
 | 
							wsa_init_done=0;
 | 
				
			||||||
		WSACancelBlockingCall();
 | 
							WSACancelBlockingCall();
 | 
				
			||||||
		WSACleanup();
 | 
							WSACleanup();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int sock_init(void)
 | 
					int sock_init(void)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
#ifdef WINDOWS
 | 
					#ifdef WINDOWS
 | 
				
			||||||
	if (!wsa_init_done)
 | 
						if (!wsa_init_done)
 | 
				
			||||||
@@ -188,7 +186,7 @@ int init_client(int *sock, char *host, int port)
 | 
				
			|||||||
	return(init_client_ip(sock,ip,port));
 | 
						return(init_client_ip(sock,ip,port));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int init_client_ip(int *sock, unsigned char ip[4], int port)
 | 
					int init_client_ip(int *sock, unsigned char ip[4], int port)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	unsigned long addr;
 | 
						unsigned long addr;
 | 
				
			||||||
	struct sockaddr_in them;
 | 
						struct sockaddr_in them;
 | 
				
			||||||
@@ -209,11 +207,9 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port)
 | 
				
			|||||||
	s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
 | 
						s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
 | 
				
			||||||
	if (s == INVALID_SOCKET) { perror("socket"); return(0); }
 | 
						if (s == INVALID_SOCKET) { perror("socket"); return(0); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef MPE
 | 
					 | 
				
			||||||
	i=0;
 | 
						i=0;
 | 
				
			||||||
	i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
 | 
						i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
 | 
				
			||||||
	if (i < 0) { perror("keepalive"); return(0); }
 | 
						if (i < 0) { perror("keepalive"); return(0); }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (connect(s,(struct sockaddr *)&them,sizeof(them)) == -1)
 | 
						if (connect(s,(struct sockaddr *)&them,sizeof(them)) == -1)
 | 
				
			||||||
		{ close(s); perror("connect"); return(0); }
 | 
							{ close(s); perror("connect"); return(0); }
 | 
				
			||||||
@@ -221,6 +217,75 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port)
 | 
				
			|||||||
	return(1);
 | 
						return(1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int nbio_sock_error(int sock)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						int j,i;
 | 
				
			||||||
 | 
						int size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size=sizeof(int);
 | 
				
			||||||
 | 
						/* Note: under VMS with SOCKETSHR the third parameter is currently
 | 
				
			||||||
 | 
						 * of type (int *) whereas under other systems it is (void *) if
 | 
				
			||||||
 | 
						 * you don't have a cast it will choke the compiler: if you do
 | 
				
			||||||
 | 
						 * have a cast then you can either go for (int *) or (void *).
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						i=getsockopt(sock,SOL_SOCKET,SO_ERROR,(char *)&j,(void *)&size);
 | 
				
			||||||
 | 
						if (i < 0)
 | 
				
			||||||
 | 
							return(1);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return(j);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int nbio_init_client_ip(int *sock, unsigned char ip[4], int port)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						unsigned long addr;
 | 
				
			||||||
 | 
						struct sockaddr_in them;
 | 
				
			||||||
 | 
						int s,i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!sock_init()) return(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset((char *)&them,0,sizeof(them));
 | 
				
			||||||
 | 
						them.sin_family=AF_INET;
 | 
				
			||||||
 | 
						them.sin_port=htons((unsigned short)port);
 | 
				
			||||||
 | 
						addr=	(unsigned long)
 | 
				
			||||||
 | 
							((unsigned long)ip[0]<<24L)|
 | 
				
			||||||
 | 
							((unsigned long)ip[1]<<16L)|
 | 
				
			||||||
 | 
							((unsigned long)ip[2]<< 8L)|
 | 
				
			||||||
 | 
							((unsigned long)ip[3]);
 | 
				
			||||||
 | 
						them.sin_addr.s_addr=htonl(addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (*sock <= 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
					#ifdef FIONBIO
 | 
				
			||||||
 | 
							unsigned long l=1;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
 | 
				
			||||||
 | 
							if (s == INVALID_SOCKET) { perror("socket"); return(0); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							i=0;
 | 
				
			||||||
 | 
							i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
 | 
				
			||||||
 | 
							if (i < 0) { perror("keepalive"); return(0); }
 | 
				
			||||||
 | 
							*sock=s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef FIONBIO
 | 
				
			||||||
 | 
							BIO_socket_ioctl(s,FIONBIO,&l);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							s= *sock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						i=connect(s,(struct sockaddr *)&them,sizeof(them));
 | 
				
			||||||
 | 
						if (i == INVALID_SOCKET)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							if (BIO_sock_should_retry(i))
 | 
				
			||||||
 | 
								return(-1);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								return(0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return(1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int do_server(int port, int *ret, int (*cb)(), char *context)
 | 
					int do_server(int port, int *ret, int (*cb)(), char *context)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int sock;
 | 
						int sock;
 | 
				
			||||||
@@ -243,7 +308,7 @@ int do_server(int port, int *ret, int (*cb)(), char *context)
 | 
				
			|||||||
			return(0);
 | 
								return(0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		i=(*cb)(name,sock, context);
 | 
							i=(*cb)(name,sock, context);
 | 
				
			||||||
		if (name != NULL) OPENSSL_free(name);
 | 
							if (name != NULL) Free(name);
 | 
				
			||||||
		SHUTDOWN2(sock);
 | 
							SHUTDOWN2(sock);
 | 
				
			||||||
		if (i < 0)
 | 
							if (i < 0)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -253,7 +318,7 @@ int do_server(int port, int *ret, int (*cb)(), char *context)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int init_server_long(int *sock, int port, char *ip)
 | 
					int init_server_long(int *sock, int port, char *ip)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int ret=0;
 | 
						int ret=0;
 | 
				
			||||||
	struct sockaddr_in server;
 | 
						struct sockaddr_in server;
 | 
				
			||||||
@@ -303,12 +368,12 @@ err:
 | 
				
			|||||||
	return(ret);
 | 
						return(ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int init_server(int *sock, int port)
 | 
					int init_server(int *sock, int port)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	return(init_server_long(sock, port, NULL));
 | 
						return(init_server_long(sock, port, NULL));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int do_accept(int acc_sock, int *sock, char **host)
 | 
					int do_accept(int acc_sock, int *sock, char **host)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	int ret,i;
 | 
						int ret,i;
 | 
				
			||||||
	struct hostent *h1,*h2;
 | 
						struct hostent *h1,*h2;
 | 
				
			||||||
@@ -374,9 +439,9 @@ redoit:
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
 | 
							if ((*host=(char *)Malloc(strlen(h1->h_name)+1)) == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			perror("OPENSSL_malloc");
 | 
								perror("Malloc");
 | 
				
			||||||
			return(0);
 | 
								return(0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		strcpy(*host,h1->h_name);
 | 
							strcpy(*host,h1->h_name);
 | 
				
			||||||
@@ -424,12 +489,12 @@ err:
 | 
				
			|||||||
	return(0);
 | 
						return(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int host_ip(char *str, unsigned char ip[4])
 | 
					int host_ip(char *str, unsigned char ip[4])
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	unsigned int in[4]; 
 | 
						unsigned int in[4]; 
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sscanf(str,"%u.%u.%u.%u",&(in[0]),&(in[1]),&(in[2]),&(in[3])) == 4)
 | 
						if (sscanf(str,"%d.%d.%d.%d",&(in[0]),&(in[1]),&(in[2]),&(in[3])) == 4)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		for (i=0; i<4; i++)
 | 
							for (i=0; i<4; i++)
 | 
				
			||||||
			if (in[i] > 255)
 | 
								if (in[i] > 255)
 | 
				
			||||||
@@ -540,3 +605,69 @@ static struct hostent *GetHostByName(char *name)
 | 
				
			|||||||
		return(ret);
 | 
							return(ret);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef MSDOS
 | 
				
			||||||
 | 
					int spawn(int argc, char **argv, int *in, int *out)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						int pid;
 | 
				
			||||||
 | 
					#define CHILD_READ	p1[0]
 | 
				
			||||||
 | 
					#define CHILD_WRITE	p2[1]
 | 
				
			||||||
 | 
					#define PARENT_READ	p2[0]
 | 
				
			||||||
 | 
					#define PARENT_WRITE	p1[1]
 | 
				
			||||||
 | 
						int p1[2],p2[2];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((pipe(p1) < 0) || (pipe(p2) < 0)) return(-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef VMS
 | 
				
			||||||
 | 
						if ((pid=vfork()) == 0)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						if ((pid=fork()) == 0)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							{ /* child */
 | 
				
			||||||
 | 
							if (dup2(CHILD_WRITE,fileno(stdout)) < 0)
 | 
				
			||||||
 | 
								perror("dup2");
 | 
				
			||||||
 | 
							if (dup2(CHILD_WRITE,fileno(stderr)) < 0)
 | 
				
			||||||
 | 
								perror("dup2");
 | 
				
			||||||
 | 
							if (dup2(CHILD_READ,fileno(stdin)) < 0)
 | 
				
			||||||
 | 
								perror("dup2");
 | 
				
			||||||
 | 
							close(CHILD_READ); 
 | 
				
			||||||
 | 
							close(CHILD_WRITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							close(PARENT_READ);
 | 
				
			||||||
 | 
							close(PARENT_WRITE);
 | 
				
			||||||
 | 
							execvp(argv[0],argv);
 | 
				
			||||||
 | 
							perror("child");
 | 
				
			||||||
 | 
							exit(1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* parent */
 | 
				
			||||||
 | 
						*in= PARENT_READ;
 | 
				
			||||||
 | 
						*out=PARENT_WRITE;
 | 
				
			||||||
 | 
						close(CHILD_READ);
 | 
				
			||||||
 | 
						close(CHILD_WRITE);
 | 
				
			||||||
 | 
						return(pid);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif /* MSDOS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef undef
 | 
				
			||||||
 | 
						/* Turn on synchronous sockets so that we can do a WaitForMultipleObjects
 | 
				
			||||||
 | 
						 * on sockets */
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						SOCKET s;
 | 
				
			||||||
 | 
						int optionValue = SO_SYNCHRONOUS_NONALERT;
 | 
				
			||||||
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						err = setsockopt( 
 | 
				
			||||||
 | 
						    INVALID_SOCKET, 
 | 
				
			||||||
 | 
						    SOL_SOCKET, 
 | 
				
			||||||
 | 
						    SO_OPENTYPE, 
 | 
				
			||||||
 | 
						    (char *)&optionValue, 
 | 
				
			||||||
 | 
						    sizeof(optionValue));
 | 
				
			||||||
 | 
						if (err != NO_ERROR) {
 | 
				
			||||||
 | 
						/* failed for some reason... */
 | 
				
			||||||
 | 
							BIO_printf(bio_err, "failed to setsockopt(SO_OPENTYPE, SO_SYNCHRONOUS_ALERT) - %d\n",
 | 
				
			||||||
 | 
								WSAGetLastError());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,6 +67,10 @@
 | 
				
			|||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(NO_RSA) && !defined(NO_SSL2)
 | 
				
			||||||
 | 
					#define NO_SSL2
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef NO_STDIO
 | 
					#ifdef NO_STDIO
 | 
				
			||||||
#define APPS_WIN16
 | 
					#define APPS_WIN16
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -82,7 +86,7 @@
 | 
				
			|||||||
#include "wintext.h"
 | 
					#include "wintext.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(MSDOS) && !defined(VXWORKS) && (!defined(VMS) || defined(__DECC)) || defined (_DARWIN)
 | 
					#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
 | 
				
			||||||
#define TIMES
 | 
					#define TIMES
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -102,7 +106,7 @@
 | 
				
			|||||||
#undef TIMES
 | 
					#undef TIMES
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(TIMES) && !defined(VXWORKS)
 | 
					#ifndef TIMES
 | 
				
			||||||
#include <sys/timeb.h>
 | 
					#include <sys/timeb.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,8 +143,6 @@
 | 
				
			|||||||
#undef BUFSIZZ
 | 
					#undef BUFSIZZ
 | 
				
			||||||
#define BUFSIZZ 1024*10
 | 
					#define BUFSIZZ 1024*10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef min
 | 
					 | 
				
			||||||
#undef max
 | 
					 | 
				
			||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
 | 
					#define min(a,b) (((a) < (b)) ? (a) : (b))
 | 
				
			||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
 | 
					#define max(a,b) (((a) > (b)) ? (a) : (b))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -218,7 +220,7 @@ static void s_time_usage(void)
 | 
				
			|||||||
                file if not specified by this option\n\
 | 
					                file if not specified by this option\n\
 | 
				
			||||||
-CApath arg   - PEM format directory of CA's\n\
 | 
					-CApath arg   - PEM format directory of CA's\n\
 | 
				
			||||||
-CAfile arg   - PEM format file of CA's\n\
 | 
					-CAfile arg   - PEM format file of CA's\n\
 | 
				
			||||||
-cipher       - preferred cipher to use, play with 'openssl ciphers'\n\n";
 | 
					-cipher       - prefered cipher to use, play with 'openssl ciphers'\n\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	printf( "usage: s_time <args>\n\n" );
 | 
						printf( "usage: s_time <args>\n\n" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -227,7 +229,7 @@ static void s_time_usage(void)
 | 
				
			|||||||
	printf("-nbio         - Run with non-blocking IO\n");
 | 
						printf("-nbio         - Run with non-blocking IO\n");
 | 
				
			||||||
	printf("-ssl2         - Just use SSLv2\n");
 | 
						printf("-ssl2         - Just use SSLv2\n");
 | 
				
			||||||
	printf("-ssl3         - Just use SSLv3\n");
 | 
						printf("-ssl3         - Just use SSLv3\n");
 | 
				
			||||||
	printf("-bugs         - Turn on SSL bug compatibility\n");
 | 
						printf("-bugs         - Turn on SSL bug compatability\n");
 | 
				
			||||||
	printf("-new          - Just time new connections\n");
 | 
						printf("-new          - Just time new connections\n");
 | 
				
			||||||
	printf("-reuse        - Just time connection reuse\n");
 | 
						printf("-reuse        - Just time connection reuse\n");
 | 
				
			||||||
	printf("-www page     - Retrieve 'page' from the site\n");
 | 
						printf("-www page     - Retrieve 'page' from the site\n");
 | 
				
			||||||
@@ -246,6 +248,15 @@ static int parseArgs(int argc, char **argv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    verify_depth=0;
 | 
					    verify_depth=0;
 | 
				
			||||||
    verify_error=X509_V_OK;
 | 
					    verify_error=X509_V_OK;
 | 
				
			||||||
 | 
					#ifdef FIONBIO
 | 
				
			||||||
 | 
					    t_nbio=0;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						apps_startup();
 | 
				
			||||||
 | 
						s_time_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (bio_err == NULL)
 | 
				
			||||||
 | 
							bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    argc--;
 | 
					    argc--;
 | 
				
			||||||
    argv++;
 | 
					    argv++;
 | 
				
			||||||
@@ -370,22 +381,6 @@ static double tm_Time_F(int s)
 | 
				
			|||||||
		ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
 | 
							ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
 | 
				
			||||||
		return((ret == 0.0)?1e-6:ret);
 | 
							return((ret == 0.0)?1e-6:ret);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#elif defined(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.0)?1e-6:ret);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
#else /* !times() */
 | 
					#else /* !times() */
 | 
				
			||||||
	static struct timeb tstart,tend;
 | 
						static struct timeb tstart,tend;
 | 
				
			||||||
	long i;
 | 
						long i;
 | 
				
			||||||
@@ -406,8 +401,6 @@ static double tm_Time_F(int s)
 | 
				
			|||||||
 * MAIN - main processing area for client
 | 
					 * MAIN - main processing area for client
 | 
				
			||||||
 *			real name depends on MONOLITH
 | 
					 *			real name depends on MONOLITH
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int MAIN(int, char **);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int MAIN(int argc, char **argv)
 | 
					int MAIN(int argc, char **argv)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	double totalTime = 0.0;
 | 
						double totalTime = 0.0;
 | 
				
			||||||
@@ -418,12 +411,6 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	MS_STATIC char buf[1024*8];
 | 
						MS_STATIC char buf[1024*8];
 | 
				
			||||||
	int ver;
 | 
						int ver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	apps_startup();
 | 
					 | 
				
			||||||
	s_time_init();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (bio_err == NULL)
 | 
					 | 
				
			||||||
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if !defined(NO_SSL2) && !defined(NO_SSL3)
 | 
					#if !defined(NO_SSL2) && !defined(NO_SSL3)
 | 
				
			||||||
	s_time_meth=SSLv23_client_method();
 | 
						s_time_meth=SSLv23_client_method();
 | 
				
			||||||
#elif !defined(NO_SSL3)
 | 
					#elif !defined(NO_SSL3)
 | 
				
			||||||
@@ -436,7 +423,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	if( parseArgs( argc, argv ) < 0 )
 | 
						if( parseArgs( argc, argv ) < 0 )
 | 
				
			||||||
		goto end;
 | 
							goto end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	OpenSSL_add_ssl_algorithms();
 | 
						SSLeay_add_ssl_algorithms();
 | 
				
			||||||
	if ((tm_ctx=SSL_CTX_new(s_time_meth)) == NULL) return(1);
 | 
						if ((tm_ctx=SSL_CTX_new(s_time_meth)) == NULL) return(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SSL_CTX_set_quiet_shutdown(tm_ctx,1);
 | 
						SSL_CTX_set_quiet_shutdown(tm_ctx,1);
 | 
				
			||||||
@@ -451,7 +438,7 @@ int MAIN(int argc, char **argv)
 | 
				
			|||||||
	if ((!SSL_CTX_load_verify_locations(tm_ctx,CAfile,CApath)) ||
 | 
						if ((!SSL_CTX_load_verify_locations(tm_ctx,CAfile,CApath)) ||
 | 
				
			||||||
		(!SSL_CTX_set_default_verify_paths(tm_ctx)))
 | 
							(!SSL_CTX_set_default_verify_paths(tm_ctx)))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		/* BIO_printf(bio_err,"error setting default verify locations\n"); */
 | 
							/* BIO_printf(bio_err,"error seting default verify locations\n"); */
 | 
				
			||||||
		ERR_print_errors(bio_err);
 | 
							ERR_print_errors(bio_err);
 | 
				
			||||||
		/* goto end; */
 | 
							/* goto end; */
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -652,7 +639,7 @@ static SSL *doConnection(SSL *scon)
 | 
				
			|||||||
	BIO_set_conn_hostname(conn,host);
 | 
						BIO_set_conn_hostname(conn,host);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (scon == NULL)
 | 
						if (scon == NULL)
 | 
				
			||||||
		serverCon=SSL_new(tm_ctx);
 | 
							serverCon=(SSL *)SSL_new(tm_ctx);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		serverCon=scon;
 | 
							serverCon=scon;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,17 @@
 | 
				
			|||||||
issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
 | 
					issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
 | 
				
			||||||
subject= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Server test cert (512 bit)
 | 
					subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Server test cert (512 bit)
 | 
				
			||||||
-----BEGIN CERTIFICATE-----
 | 
					-----BEGIN CERTIFICATE-----
 | 
				
			||||||
MIIB6TCCAVICAQYwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV
 | 
					MIIB6TCCAVICAQQwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV
 | 
				
			||||||
BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD
 | 
					BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD
 | 
				
			||||||
VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNMDAxMDE2MjIzMTAzWhcNMDMwMTE0
 | 
					VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNOTgwNjI5MjM1MjQwWhcNMDAwNjI4
 | 
				
			||||||
MjIzMTAzWjBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEaMBgG
 | 
					MjM1MjQwWjBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEaMBgG
 | 
				
			||||||
A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGlNlcnZlciB0ZXN0IGNl
 | 
					A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGlNlcnZlciB0ZXN0IGNl
 | 
				
			||||||
cnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+zw4Qnlf8SMVIP
 | 
					cnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+zw4Qnlf8SMVIP
 | 
				
			||||||
Fe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/7tdkuD8Ey2//
 | 
					Fe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/7tdkuD8Ey2//
 | 
				
			||||||
Kv7+ue0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQCT0grFQeZaqYb5EYfk20XixZV4
 | 
					Kv7+ue0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQCVvvfkGSe2GHgDFfmOua4Isjb9
 | 
				
			||||||
GmyAbXMftG1Eo7qGiMhYzRwGNWxEYojf5PZkYZXvSqZ/ZXHXa4g59jK/rJNnaVGM
 | 
					JVhImWMASiOClkZlMESDJjsszg/6+d/W+8TrbObhazpl95FivXBVucbj9dudh7AO
 | 
				
			||||||
k+xIX8mxQvlV0n5O9PIha5BX5teZnkHKgL8aKKLKW1BK7YTngsfSzzaeame5iKfz
 | 
					IZu1h1MAPlyknc9Ud816vz3FejB4qqUoaXjnlkrIgEbr/un7jSS86WOe0hRhwHkJ
 | 
				
			||||||
itAE+OjGF+PFKbwX8Q==
 | 
					FUGcPZf9ND22Etc+AQ==
 | 
				
			||||||
-----END CERTIFICATE-----
 | 
					-----END CERTIFICATE-----
 | 
				
			||||||
-----BEGIN RSA PRIVATE KEY-----
 | 
					-----BEGIN RSA PRIVATE KEY-----
 | 
				
			||||||
MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD
 | 
					MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD
 | 
				
			||||||
 
 | 
				
			|||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user